const require_runtime = require("../../../../../../_virtual/_rolldown/runtime.js");
const require_asyncToGenerator = require("../../../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js");
const require_usePrefix = require("../../../../../../hooks/usePrefix.js");
const require_serve = require("../../../serve.js");
let react = require("react");
react = require_runtime.__toESM(react);
let _pisell_utils = require("@pisell/utils");
let _pisell_materials = require("@pisell/materials");
let ahooks = require("ahooks");
require("./index.less");
//#region src/components/pay/toC/PaymentMethods/components/PaymentReturnContent/index.tsx
/**
* 支付返回后展示的内容组件
* 当用户从外部支付页面返回时展示此组件
*/
const PaymentReturnContent = ({ orderId, unique_payment_number, state, handleReturn, pay_number }) => {
	const prefix = require_usePrefix.default();
	const getPaymentIsPaid = (0, ahooks.useMemoizedFn)(require_asyncToGenerator._asyncToGenerator(function* () {
		if (!unique_payment_number && !pay_number) return true;
		const { data } = yield require_serve.getPaymentResult({
			order_id: orderId,
			pay_number,
			unique_payment_number: pay_number ? void 0 : unique_payment_number
		});
		return (data === null || data === void 0 ? void 0 : data.payment_status) === "paid";
	}));
	/**
	* 查看订单
	* @returns 
	*/
	const handleViewOrder = function() {
		var _ref = require_asyncToGenerator._asyncToGenerator(function* () {
			var _state$payCallback;
			if (!(yield getPaymentIsPaid())) {
				(0, _pisell_materials.PisellToast)({ content: _pisell_utils.locales.getText("tocPay.text.paymentFailed") });
				return;
			}
			(_state$payCallback = state.payCallback) === null || _state$payCallback === void 0 || _state$payCallback.call(state, { key: "success" });
		});
		return function handleViewOrder() {
			return _ref.apply(this, arguments);
		};
	}();
	/**
	* 返回并选择其他支付方式
	* @returns 
	*/
	const handleGoBack = function() {
		var _ref2 = require_asyncToGenerator._asyncToGenerator(function* () {
			if (!(yield getPaymentIsPaid())) {
				handleReturn === null || handleReturn === void 0 || handleReturn();
				return;
			} else {
				var _state$payCallback2;
				(_state$payCallback2 = state.payCallback) === null || _state$payCallback2 === void 0 || _state$payCallback2.call(state, { key: "success" });
			}
		});
		return function handleGoBack() {
			return _ref2.apply(this, arguments);
		};
	}();
	return /* @__PURE__ */ react.default.createElement("div", { className: "payment-return-content" }, /* @__PURE__ */ react.default.createElement("div", { className: "payment-return-content-img" }, /* @__PURE__ */ react.default.createElement("img", {
		src: `${prefix}/payment-content.png`,
		alt: "success"
	})), /* @__PURE__ */ react.default.createElement("div", { className: "payment-return-content-text" }, _pisell_utils.locales.getText("tocPay.text.weAreVerifyingYourPaymentPleaseCheckYourOrderStatusLater")), /* @__PURE__ */ react.default.createElement("div", { className: "payment-return-content-buttons" }, /* @__PURE__ */ react.default.createElement(_pisell_materials.Button, {
		block: true,
		className: "payment-return-content-order-button",
		onClick: handleViewOrder
	}, _pisell_utils.locales.getText("tocPay.text.paymentCompletedAndViewOrder")), /* @__PURE__ */ react.default.createElement(_pisell_materials.Button, {
		block: true,
		onClick: handleGoBack
	}, _pisell_utils.locales.getText("tocPay.text.returnAndSelectOtherPaymentMethod"))));
};
//#endregion
exports.default = PaymentReturnContent;
