var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/components/ecocup/components/CustomerAndCupModal/hooks.ts
var hooks_exports = {};
__export(hooks_exports, {
  useBatchRentCups: () => useBatchRentCups,
  useCustomerDetail: () => useCustomerDetail
});
module.exports = __toCommonJS(hooks_exports);
var import_react = require("react");
var import_ahooks = require("ahooks");
var import_hooks = require("../../hooks");
var useCustomerDetail = () => {
  const { get } = (0, import_hooks.useRequest)();
  const [loading, setLoading] = (0, import_react.useState)(false);
  const { goalShopId } = (0, import_hooks.useGetGoalShopInfo)();
  const run = (0, import_ahooks.useMemoizedFn)(async (id) => {
    try {
      setLoading(true);
      const res = await get(`/shop/wallet/eco/customer/${id}`, {
        with_rent_cups_flag: 1,
        goal_shop_id: goalShopId,
        with: ["tags"]
      });
      if ((res == null ? void 0 : res.code) == 200) {
        return res == null ? void 0 : res.data;
      }
      return null;
    } catch (error) {
      console.error(error);
      return null;
    } finally {
      setLoading(false);
    }
  });
  return {
    run,
    loading
  };
};
var useBatchRentCups = () => {
  const { post } = (0, import_hooks.useRequest)();
  const [loading, setLoading] = (0, import_react.useState)(false);
  const { goalShopId } = (0, import_hooks.useGetGoalShopInfo)();
  const run = (0, import_ahooks.useMemoizedFn)(async (id, cupIds) => {
    try {
      setLoading(true);
      const res = await post("/shop/wallet/eco/cups-rent", {
        customer_id: id,
        eco_cup_ids: cupIds,
        goal_shop_id: goalShopId
      });
      if ((res == null ? void 0 : res.code) == 200) {
        return true;
      }
      return false;
    } catch (error) {
      console.error(error);
      return false;
    } finally {
      setLoading(false);
    }
  });
  return {
    run,
    loading
  };
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  useBatchRentCups,
  useCustomerDetail
});
