import{N as w,x as E,r as t,eT as R,aD as b,u as C,eV as I,e,M as P,S as c,f1 as S,T as o,eX as L,B as A,d1 as D,k,ad as B}from"./index-_6SmYgWK.js";import{A as d,I as m}from"./IconExclamationCircle-kP-S1YaN.js";const V=()=>{const u=w();E();const h={label:"Username",name:"username",type:"email",placeholder:"user@company.com"},[i,f]=t.useState(""),{isEnterpriseLicensed:y}=R(),[g,n]=t.useState(!1),[s,p]=t.useState(void 0),{authRateLimitError:x,setAuthRateLimitError:l}=b(),r=C(I.forgotPassword),j=async a=>{a.preventDefault(),l(null);const v={user:{email:i}};n(!0),await r.request(v)};return t.useEffect(()=>{l(null)},[l]),t.useEffect(()=>{if(r.error){const a=typeof r.error.response.data=="object"?r.error.response.data.message:r.error.response.data;p({type:"error",msg:a??"Failed to send instructions, please contact your administrator."}),n(!1)}},[r.error]),t.useEffect(()=>{r.data&&(p({type:"success",msg:"Password reset instructions sent to the email."}),n(!1))},[r.data]),e.jsx(e.Fragment,{children:e.jsx(P,{children:e.jsxs(c,{flexDirection:"column",sx:{width:"480px",gap:3},children:[s&&(s==null?void 0:s.type)==="error"&&e.jsx(d,{icon:e.jsx(m,{}),variant:"filled",severity:"error",children:s.msg}),x&&e.jsx(d,{icon:e.jsx(m,{}),variant:"filled",severity:"error",children:x}),s&&(s==null?void 0:s.type)!=="error"&&e.jsx(d,{icon:e.jsx(S,{}),variant:"filled",severity:"success",children:s.msg}),e.jsxs(c,{sx:{gap:1},children:[e.jsx(o,{variant:"h1",children:"Forgot Password?"}),e.jsxs(o,{variant:"body2",sx:{color:u.palette.grey[600]},children:["Have a reset password code?"," ",e.jsx(L,{style:{color:u.palette.primary.main},to:"/reset-password",children:"Change your password here"}),"."]})]}),e.jsx("form",{onSubmit:j,children:e.jsxs(c,{sx:{width:"100%",flexDirection:"column",alignItems:"left",justifyContent:"center",gap:2},children:[e.jsxs(A,{children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row"},children:[e.jsxs(o,{children:["Email",e.jsx("span",{style:{color:"red"},children:" *"})]}),e.jsx(o,{align:"left"}),e.jsx("div",{style:{flexGrow:1}})]}),e.jsx(D,{inputParam:h,onChange:a=>f(a),value:i,showDialog:!1}),y&&e.jsx(o,{variant:"caption",children:e.jsx("i",{children:"If you forgot the email you used for signing up, please contact your administrator."})})]}),e.jsx(k,{variant:"contained",style:{borderRadius:12,height:40,marginRight:5},disabled:!i,type:"submit",children:"Send Reset Password Instructions"})]})}),e.jsx(B,{open:g})]})})})};export{V as default};
