import { _asyncToGenerator } from "../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js";
import { useGetGoalShopInfo, useRequest as useRequest$1 } from "../../hooks.js";
import { useState } from "react";
import { useMemoizedFn } from "ahooks";
//#region src/components/ecocup/components/CupActionModal/hooks.ts
const useCupAction = () => {
	const { put } = useRequest$1();
	const [loading, setLoading] = useState(false);
	const { goalShopId } = useGetGoalShopInfo();
	return {
		run: useMemoizedFn(function() {
			var _ref = _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
export { useCupAction };
