import{s as t}from"./ForgotPassword.module.12f0c682.js";import{i as y,r as u,j as e,d as i}from"./react.6693569e.js";import{u as C,a as f}from"./index.b5b1089a.js";/* empty css              *//* empty css               */import{C as P}from"./Cover.fc91526c.js";import{f as v}from"./antd.5e666edb.js";import{F as o,m as g,I as d,a as I,C as h,B as p}from"./antd.ef9542dc.js";const{layout:F}=v,_=()=>{const{T:r}=C(),[m]=o.useForm(),l=y(),[w,b]=u.exports.useState("");u.exports.useEffect(()=>{c()},[]);const c=async()=>{try{const{code:s,signature:a}=await f.authApi.getVerificationCode();b(s),m.setFieldsValue({signature:a})}catch{}};return e(P,{children:i("div",{className:t.forgotPassword,children:[e("div",{className:t.header,children:r("forgotPassword.header")}),i(o,{form:m,className:t.form,...F,onFinish:async s=>{try{await f.authApi.forgotPassword({email:s.email,signature:s.signature,verification_code:s.verification_code}),g.success(r("forgotPassword.submit.success")),setTimeout(()=>l.push("/login"),1e3)}catch(a){console.error(a),c();let n=r("forgotPassword.submit.error.basic");switch(a==null?void 0:a.message){case"user not found":n=r("forgotPassword.submit.error.userNotFound");break;case"email or verification code not match":n=r("forgotPassword.submit.error.notMatch");break}g.error(n)}},children:[e(o.Item,{label:r("forgotPassword.label.email"),name:"email",rules:[{required:!0,message:r("forgotPassword.rules.email.required")},{type:"email",message:r("forgotPassword.rules.email.type")}],children:e(d,{})}),e(o.Item,{label:r("forgotPassword.label.verificationCode"),required:!0,children:i(I,{gutter:8,children:[i(h,{span:16,children:[e(o.Item,{noStyle:!0,name:"verification_code",rules:[{required:!0,message:r("forgotPassword.rules.verificationCode.required")}],children:e(d,{})}),e(o.Item,{name:"signature",hidden:!0,children:e(d,{})})]}),e(h,{span:8,children:e("div",{className:t.verificationCode,onClick:c,children:e("img",{src:w,alt:r("login.database.verificationCode")})})})]})}),e(o.Item,{wrapperCol:{span:24},children:i("div",{className:t.btnGroup,children:[e(p,{type:"primary",htmlType:"submit",children:r("forgotPassword.submit.button")}),e(p,{onClick:()=>l.go(-1),children:r("forgotPassword.goBackButton")})]})})]})]})})};export{_ as default};
