const require_runtime = require("../../../../_virtual/_rolldown/runtime.js");
const require_hooks = require("../../hooks.js");
const require_types = require("../../types.js");
const require_index = require("../CupActionModal/index.js");
const require_index$1 = require("../MoreDropdown/index.js");
let dayjs = require("dayjs");
dayjs = require_runtime.__toESM(dayjs);
let react = require("react");
react = require_runtime.__toESM(react);
let _pisell_utils = require("@pisell/utils");
let _pisell_materials = require("@pisell/materials");
require("./index.less");
//#region src/components/ecocup/components/CupActionList/index.tsx
const CupActionList = (props) => {
	const { maxNum, currentNum, cups, customerData, onClearAll, onRemove, onAction } = props;
	const cupActionModal = require_hooks.useModal("ecocup-cup-action-modal");
	const isOverMax = (0, react.useMemo)(() => {
		return currentNum > maxNum;
	}, [currentNum, maxNum]);
	const handleAction = (type, cup) => {
		cupActionModal.open({
			data: {
				type,
				cupData: cup,
				customerData
			},
			onOk: () => {
				onAction(type, cup);
			}
		});
	};
	return /* @__PURE__ */ react.default.createElement("div", { className: "pisell2-ecocup-cup-action-list" }, isOverMax && /* @__PURE__ */ react.default.createElement("div", { className: "pisell2-ecocup-cup-action-list-over-max" }, /* @__PURE__ */ react.default.createElement("span", null, _pisell_utils.locales.getText("pisell2.text.ecocup.customer-first-modal.over-max").replace("{{num}}", (currentNum - maxNum).toString())), /* @__PURE__ */ react.default.createElement("span", { onClick: onClearAll }, _pisell_utils.locales.getText("pisell2.text.ecocup.button.clear-all"))), /* @__PURE__ */ react.default.createElement("div", { className: "pisell2-ecocup-cup-action-list-cup-list" }, cups.map((cup) => {
		var _cup$rent_shop;
		const isInStock = (cup === null || cup === void 0 ? void 0 : cup.status) === require_types.ECupStatus.IN_STOCK;
		return /* @__PURE__ */ react.default.createElement("div", {
			key: cup.code,
			className: "pisell2-ecocup-cup-action-list-cup",
			style: isInStock ? {
				backgroundColor: "#F6F2FF",
				border: "1px solid #F6F2FF"
			} : { border: "1px solid #D0D5DD" }
		}, /* @__PURE__ */ react.default.createElement(_pisell_materials.Icon, {
			type: "RestOutlined",
			size: 24,
			color: "#7F56DA"
		}), /* @__PURE__ */ react.default.createElement("div", { className: "pisell2-ecocup-cup-action-list-cup-info" }, /* @__PURE__ */ react.default.createElement("div", { className: "pisell2-ecocup-cup-action-list-cup-info-top" }, /* @__PURE__ */ react.default.createElement("span", null, _pisell_utils.locales.getText("pisell2.text.ecocup.cup-id")), /* @__PURE__ */ react.default.createElement("span", null, (cup === null || cup === void 0 ? void 0 : cup.eco_cup_code) || (cup === null || cup === void 0 ? void 0 : cup.code) || "-")), !isInStock && /* @__PURE__ */ react.default.createElement("div", { className: "pisell2-ecocup-cup-action-list-cup-info-bottom" }, /* @__PURE__ */ react.default.createElement("span", null, (cup === null || cup === void 0 || (_cup$rent_shop = cup.rent_shop) === null || _cup$rent_shop === void 0 ? void 0 : _cup$rent_shop.name) || "-"), /* @__PURE__ */ react.default.createElement("span", null, (cup === null || cup === void 0 ? void 0 : cup.rent_time) ? (0, dayjs.default)(cup === null || cup === void 0 ? void 0 : cup.rent_time).format("DD/MM/YYYY") : "-"))), isInStock ? /* @__PURE__ */ react.default.createElement(_pisell_materials.Button, {
			type: "primary",
			icon: /* @__PURE__ */ react.default.createElement(_pisell_materials.Icon, {
				type: "pisell2-trash-01",
				size: 24,
				color: "#7F56DA"
			}),
			onClick: () => onRemove(cup),
			className: "pisell2-ecocup-cup-action-list-cup-info-remove"
		}, _pisell_utils.locales.getText("pisell2.text.ecocup.button.remove")) : /* @__PURE__ */ react.default.createElement("div", { className: "pisell2-ecocup-cup-action-list-cup-info-actions" }, /* @__PURE__ */ react.default.createElement(_pisell_materials.Button, {
			type: "primary",
			onClick: () => handleAction(require_types.ECupActionType.RETURN, cup)
		}, "Return"), /* @__PURE__ */ react.default.createElement(require_index$1.default, {
			locales: _pisell_utils.locales,
			onClick: (key) => handleAction(key, cup),
			buttonText: _pisell_utils.locales.getText("pisell2.text.ecocup.button.others")
		})));
	})), (cupActionModal === null || cupActionModal === void 0 ? void 0 : cupActionModal.visible) && /* @__PURE__ */ react.default.createElement(require_index.default, cupActionModal === null || cupActionModal === void 0 ? void 0 : cupActionModal.modalProps));
};
//#endregion
exports.default = CupActionList;
