UNPKG

@particle-network/auth-core-modal

Version:

Auth Core provides MPC (Multi-Party Computation)-based threshold signatures.

94 lines (90 loc) 4.03 kB
"use client"; import { ParticleKeywords_default } from "./chunk-WSUHUJ3D.js"; import "./chunk-WVDARMME.js"; import "./chunk-Q77XRZTS.js"; import { particle_drawer_default, useAuthCoreModal, useParticleAuth } from "./chunk-BJTDO4LQ.js"; import "./chunk-LQ53OFQ3.js"; // src/pages/account/paymentVerifyModal/index.tsx import { ApiError, verifyPaymentPassword } from "@particle-network/auth-core"; import { useRequest } from "ahooks"; import React, { useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; // src/pages/account/paymentVerifyModal/index.less var paymentVerifyModal_default = ".payment-password-drawer {\n width: 100%;\n height: 100%;\n overflow: hidden;\n}\n.payment-password-drawer .ant-drawer-body {\n padding-right: 0;\n padding-left: 0;\n overflow: hidden;\n}\n.payment-password-drawer .ant-drawer-content-wrapper {\n width: 100% !important;\n}\n.payment-password-drawer .ant-drawer-content .ant-drawer-wrapper-body .ant-drawer-header {\n display: none;\n}\n.payment-password-drawer .particle-pc-drawer .payment-verify-content {\n margin-top: 38px;\n}\n.payment-password-drawer .payment-verify-content {\n display: flex;\n flex-direction: column;\n align-items: center;\n height: 100%;\n margin-top: 22px;\n}\n.payment-password-drawer .payment-verify-content .particle-keywords-map {\n position: absolute;\n}\n@media (min-width: 600px) {\n .payment-password-drawer {\n position: absolute;\n }\n}\n"; // src/pages/account/paymentVerifyModal/index.tsx var PaymentVerifyModal = ({ props }) => { const { setPaymentVerify, setWrongPassword } = useParticleAuth(); const { t } = useTranslation(); const [pwd, setPwd] = useState(""); const { authCoreModal } = useAuthCoreModal(); useEffect(() => { if (props.visible) { setPwd(""); } }, [props.visible]); const { loading: verifyLoading, run: runVerify } = useRequest(verifyPaymentPassword, { manual: true, onSuccess: (result, params) => { var _a; setPaymentVerify({ visible: false }); (_a = props.onVerifyCompleted) == null ? void 0 : _a.call(props, pwd); }, onError: (error) => { console.log("verify password error", error); setPwd(""); if ((error == null ? void 0 : error.error_code) === ApiError.WrongPaymentPassword) { setWrongPassword({ visible: true }); } else if ((error == null ? void 0 : error.error_code) === ApiError.SecurityAccountFrozen) { const seconds = error.extra.seconds || 0; setWrongPassword({ visible: true, accountFrozen: { seconds } }); } } }); const closeVerify = () => { var _a; if (verifyLoading) return false; setPaymentVerify({ visible: false }); (_a = props.onVerifyFailed) == null ? void 0 : _a.call(props, t("common.cancel")); }; const checkInputPwd = (value) => { setPwd(value); if (value.length === 6) { runVerify(value); } }; return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("style", null, paymentVerifyModal_default), /* @__PURE__ */ React.createElement( particle_drawer_default, { visible: props.visible, placement: "bottom", height: 421, closable: false, maskClosable: false, onClose: closeVerify, className: "payment-password-drawer", title: props.type === "close" ? t("account.close_payment_password") : t("account.payment_password"), forceRender: true, getContainer: () => { return authCoreModal.rootBody; } }, /* @__PURE__ */ React.createElement("div", { className: "content payment-verify-content" }, /* @__PURE__ */ React.createElement(ParticleKeywords_default, { onChange: checkInputPwd, value: pwd, keyboardInvisible: verifyLoading })) )); }; var paymentVerifyModal_default2 = PaymentVerifyModal; export { paymentVerifyModal_default2 as default }; //# sourceMappingURL=paymentVerifyModal-67UXIGBU.js.map