import{s as i}from"./ForgotPassword.module.51f61226.js";import{u as C,a as P}from"./index.ab3d776b.js";/* empty css              *//* empty css               */import{C as v}from"./Cover.fc91526c.js";import{f as b}from"./antd.5e666edb.js";import{r as m,i as y,j as o,d as n}from"./react.6693569e.js";import{F as c,m as u,I as f,a as N,C as h,B as p}from"./antd.e57bc55d.js";const g=e=>{let r=[1,2,3,4,5,6,7,8,9,"a","b","c","d","e","f","g","h","i","j","k","m","n","o","p","q","r","s","t","u","v","w","x","y","z","A","B","C","D","E","F","G","H","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"],s="";for(;e>0;){const t=Math.floor(Math.random()*r.length);s+=r[t],e--}return s};function I(e=4){const[r,s]=m.exports.useState(g(e)),t=m.exports.useCallback(()=>{s(g(e))},[e]);return[r,t]}const{layout:w}=b,T=()=>{const{T:e}=C(),r=y(),[s,t]=I();return o(v,{children:n("div",{className:i.forgotPassword,children:[o("div",{className:i.header,children:e("forgotPassword.header")}),n(c,{className:i.form,...w,onFinish:async l=>{try{await P.authApi.forgotPassword({email:l.email}),u.success(e("forgotPassword.submit.success")),setTimeout(()=>r.push("/login"),1e3)}catch(a){console.error(a);let d=e("forgotPassword.submit.error.basic");switch(a==null?void 0:a.message){case"user not found":d=e("forgotPassword.submit.error.userNotFound");break}u.error(d)}},children:[o(c.Item,{label:e("forgotPassword.label.email"),name:"email",rules:[{required:!0,message:e("forgotPassword.rules.email.required")},{type:"email",message:e("forgotPassword.rules.email.type")}],children:o(f,{})}),o(c.Item,{label:e("forgotPassword.label.verificationCode"),...w,children:n(N,{gutter:8,children:[o(h,{span:16,children:o(c.Item,{noStyle:!0,name:"verificationCode",rules:[{required:!0,message:e("forgotPassword.rules.verificationCode.required")},{validator:(l,a)=>a&&a.toLocaleLowerCase()===s.toLocaleLowerCase()?Promise.resolve():Promise.reject(e("forgotPassword.rules.verificationCode.validator"))}],children:o(f,{})})}),o(h,{span:8,children:o("div",{className:i.verificationCode,onClick:t,children:s})})]})}),o(c.Item,{wrapperCol:{span:24},children:n("div",{className:i.btnGroup,children:[o(p,{type:"primary",htmlType:"submit",children:e("forgotPassword.submit.button")}),o(p,{onClick:()=>r.go(-1),children:e("forgotPassword.goBackButton")})]})})]})]})})};export{T as default};
