reset-password-95003483.js 2.6 KB

1
  1. import{u as S,Z as v,r as l,cV as E,j as o,a as e,F as P,B as j}from"./index-0d8158eb.js";import{l as k}from"./index-c0b93546.js";import{u as F,M}from"./index.esm-07f1e6d3.js";import{d as R}from"./index.modern-c903a5d6.js";import{L as _,S as n}from"./login-layout-d129ef85.js";import{S as C}from"./index-845e4de2.js";import{g as L}from"./error-messages-d2d0bb30.js";import"./index-9af9f9f3.js";const Y=()=>{const p=S(),f=v(),s=k.parse(f.search.substring(1));let r=null;if(s!=null&&s.token)try{r=R(s.token)}catch{r=null}const[w,i]=l.useState(!1),[g,d]=l.useState(null),[h,m]=l.useState(!1),c=(r==null?void 0:r.email)||(s==null?void 0:s.email)||"",{register:u,handleSubmit:x,formState:a}=F({defaultValues:{password:"",repeat_password:""}}),y=E(),b=t=>{if(i(!1),d(null),t.password!==t.repeat_password){i(!0);return}y.mutate({token:s.token,password:t.password,email:c},{onSuccess:()=>{p("/login")},onError:N=>{d(L(N))}})};return l.useEffect(()=>{a.dirtyFields.password&&a.dirtyFields.repeat_password?m(!0):m(!1)},[a]),o(_,{children:[e(C,{title:"Reset Password"}),e("div",{className:"flex h-full w-full items-center justify-center",children:e("div",{className:"bg-grey-0 rounded-rounded flex min-h-[540px] justify-center",children:o("form",{className:"flex w-full flex-col items-center py-12 px-[120px]",onSubmit:x(b),children:[e(M,{}),r?o(P,{children:[e("span",{className:"inter-2xlarge-semibold text-grey-90 mt-4",children:"Reset your password"}),e("span",{className:"inter-base-regular text-grey-50 mb-xlarge mt-2",children:"Choose a new password below 👇🏼"}),e(n,{placeholder:"Email",name:"first_name",value:c,readOnly:!0}),e(n,{placeholder:"Password",type:"password",...u("password",{required:!0}),autoComplete:"new-password"}),e(n,{placeholder:"Confirm password",type:"password",...u("repeat_password",{required:!0}),autoComplete:"new-password",className:"mb-0"}),g&&e("span",{className:"mt-xsmall inter-small-regular w-full text-rose-50",children:"The two passwords are not the same"}),w&&e("span",{className:"mt-xsmall inter-small-regular w-full text-rose-50",children:"The two passwords are not the same"}),e(j,{variant:"primary",size:"large",type:"submit",className:"mt-base rounded-rounded w-full",loading:a.isSubmitting,disabled:!h,children:"Reset Password"})]}):o("div",{className:"flex h-full flex-col items-center justify-center gap-y-2 text-center",children:[e("span",{className:"inter-large-semibold text-grey-90",children:"You reset link is invalid"}),e("span",{className:"inter-base-regular text-grey-50 mt-2",children:"Please try resetting your password again"})]})]})})})]})};export{Y as default};