require("../../../../_virtual/_rolldown/runtime.js");
const require_asyncToGenerator = require("../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js");
const require_hooks = require("../../hooks.js");
let react = require("react");
let ahooks = require("ahooks");
//#region src/components/ecocup/components/CustomerAndCupModal/hooks.ts
/**
* 获取客户详情
*/
const useCustomerDetail = () => {
	const { get } = require_hooks.useRequest();
	const [loading, setLoading] = (0, react.useState)(false);
	const { goalShopId } = require_hooks.useGetGoalShopInfo();
	return {
		run: (0, ahooks.useMemoizedFn)(function() {
			var _ref = require_asyncToGenerator._asyncToGenerator(function* (id) {
				try {
					setLoading(true);
					const res = yield get(`/shop/wallet/eco/customer/${id}`, {
						with_rent_cups_flag: 1,
						goal_shop_id: goalShopId,
						with: ["tags"]
					});
					if ((res === null || res === void 0 ? void 0 : res.code) == 200) return res === null || res === void 0 ? void 0 : res.data;
					return null;
				} catch (error) {
					console.error(error);
					return null;
				} finally {
					setLoading(false);
				}
			});
			return function(_x) {
				return _ref.apply(this, arguments);
			};
		}()),
		loading
	};
};
/**
* 批量租用杯子
*/
const useBatchRentCups = () => {
	const { post } = require_hooks.useRequest();
	const [loading, setLoading] = (0, react.useState)(false);
	const { goalShopId } = require_hooks.useGetGoalShopInfo();
	return {
		run: (0, ahooks.useMemoizedFn)(function() {
			var _ref2 = require_asyncToGenerator._asyncToGenerator(function* (id, cupIds) {
				try {
					setLoading(true);
					const res = yield post("/shop/wallet/eco/cups-rent", {
						customer_id: id,
						eco_cup_ids: cupIds,
						goal_shop_id: goalShopId
					});
					if ((res === null || res === void 0 ? void 0 : res.code) == 200) return true;
					return false;
				} catch (error) {
					console.error(error);
					return false;
				} finally {
					setLoading(false);
				}
			});
			return function(_x2, _x3) {
				return _ref2.apply(this, arguments);
			};
		}()),
		loading
	};
};
//#endregion
exports.useBatchRentCups = useBatchRentCups;
exports.useCustomerDetail = useCustomerDetail;
