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/CupActionModal/hooks.ts
const useCupAction = () => {
	const { put } = 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* (cupId, action) {
				try {
					setLoading(true);
					const res = yield put(`/shop/wallet/eco/cup/action/${cupId}`, {
						action,
						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(_x, _x2) {
				return _ref.apply(this, arguments);
			};
		}()),
		loading
	};
};
//#endregion
exports.useCupAction = useCupAction;
