import { updateComponent, updateNextStep, useContextData, useDispatch } from "../../store/index.js";
import payLog from "../../utils/payLog.js";
import header_default from "../header/index.js";
import React, { useState } from "react";
import { Button } from "antd";
import { locales } from "@pisell/utils";
//#region src/components/eftposPay/component/signature/index.tsx
/**
* @title: 取消签名确认页
* @Author: hongbing.wang
* @Date: 2024-08-20 11:49
*/
var signature_default = ({ api, className = "" }) => {
	const dispatch = useDispatch();
	const { number, mode } = useContextData();
	const [disabled, setDisabled] = useState(false);
	/**
	* @title: 返回流程页
	* @Author: hongbing.wang
	* @Date: 2024-08-20 11:51
	*/
	const onBack = () => {
		payLog.log("取消签名确认页：点击返回");
		dispatch(updateComponent(""));
	};
	/**
	* @title: 取消签名确认页
	* @Author: hongbing.wang
	* @Date: 2024-08-20 11:51
	*/
	const onConfirm = () => {
		payLog.log("取消签名确认页：点击确认");
		setDisabled(true);
		api.update({
			type: "NO",
			number
		}).then(() => {
			setDisabled(false);
			dispatch(updateComponent(""));
			dispatch(updateNextStep());
		}).catch((res) => {
			setDisabled(false);
			console.log(res);
		});
	};
	return /* @__PURE__ */ React.createElement("div", { className: `pisell-lowcode__eft-pay-box ${className}` }, /* @__PURE__ */ React.createElement(header_default, { status: "warn" }), /* @__PURE__ */ React.createElement("div", { className: "pisell-lowcode__eft-pay-fail-title" }, locales.getText("page.eftpos-pay.text.signature.title")), /* @__PURE__ */ React.createElement("div", { className: "pisell-lowcode__eft-pay-warn-text pisell-lowcode__eft-pay-body" }, locales.getText("page.eftpos-pay.text.signature.text")(mode)), /* @__PURE__ */ React.createElement("div", { className: "pisell-lowcode__eft-pay-step-item-btns" }, /* @__PURE__ */ React.createElement(Button, {
		block: true,
		className: "pisell-lowcode__eft-pay-step-item-btn",
		onClick: onBack
	}, locales.getText("page.eftpos-pay.text.back")), /* @__PURE__ */ React.createElement(Button, {
		block: true,
		className: "pisell-lowcode__eft-pay-step-item-btn",
		type: "primary",
		onClick: onConfirm,
		disabled
	}, locales.getText("page.eftpos-pay.text.confirm.decline"))));
};
//#endregion
export { signature_default as default };
