1import{u as S,r as a,a as C,j as e,V as F,B as P,C as D,A as L,b as B,L as I,k as T,I as $,c as g,D as A,d as R}from"./index-DTlGp7Od.js";import{a as U}from"./authApi-CAwSzJa9.js";function O(){const l=S(),[p,b]=a.useState(!0),[j,w]=a.useState(!1),[o,m]=a.useState(""),[i,x]=a.useState(""),[c,u]=a.useState(!1),[h,n]=a.useState(""),[d]=C(),v=`${F}/login.svg`,f=s=>s?/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(s)?"":"Please enter a valid email":"Email is required",y=s=>{const{value:t}=s.target;m(t);const r=f(t);x(r)},N=()=>{l("/login")},k=async()=>{const s=f(o);if(x(s),n(""),o&&!s){u(!0);try{await U.forgotPassword(o),m(""),b(!1),w(!0)}catch(t){const r=t?.message;r?.includes("NOT FOUND")?n("No account found with this email address"):r?.includes("Unverified Email")?n("This email has not been verified yet"):n(r||"Failed to send reset email")}finally{u(!1)}}},E=()=>{l("/login")};return a.useEffect(()=>{const s=d.get("u"),t=d.get("t");s&&t&&l(`/verify-forgot-password?u=${s}&t=${t}`)},[d,l]),e.jsxs("div",{className:"min-h-screen w-full relative flex flex-col justify-between overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 bg-cover bg-center bg-no-repeat",style:{backgroundImage:`url(${v})`,backgroundSize:"cover",backgroundPosition:"center",backgroundColor:"black"}}),e.jsxs("div",{className:"relative z-10 flex-grow flex items-center justify-center px-4 sm:px-6",children:[e.jsx("div",{className:"w-full fixed top-6 left-6",children:e.jsx("button",{className:"text-sm font-semibold",onClick:N,"aria-label":"Back to login",children:e.jsx(P,{})})}),e.jsx("div",{className:"w-full max-w-[527px] flex flex-col items-center",children:e.jsxs("div",{className:"w-full bg-card rounded-3xl flex items-center justify-center px-6 pt-9 pb-8 shadow-lg",children:[p&&e.jsxs("div",{className:"w-full max-w-[364px] flex flex-col items-center text-center",children:[e.jsxs("div",{className:"mb-8",children:[e.jsx("div",{className:"mb-4 flex justify-center fill-black dark:fill-white",children:e.jsx(D,{})}),e.jsx("h4",{className:"text-xl text-gray-900 dark:text-white font-bold mb-4",children:"Change your password"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Please enter your email address to receive ",e.jsx("br",{}),"instructions to reset your password"]})]}),h&&e.jsx(L,{variant:"destructive",className:"mb-4 w-full",children:e.jsx(B,{children:h})}),e.jsxs("div",{className:"w-full space-y-2 mb-8",children:[e.jsx(I,{htmlFor:"email",className:"text-left block text-card-foreground",children:"Email"}),e.jsxs("div",{className:"relative",children:[e.jsx(T,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-5 w-5 text-gray-400"}),e.jsx($,{id:"email",type:"email",placeholder:"Enter your email",value:o,onChange:y,disabled:c,className:`pl-10 rounded-xl h-12 ${i?"border-2 border-red-500":"border-2 border-transparent bg-gray-100 dark:bg-gray-800"}`})]}),i&&e.jsx("p",{className:"text-sm text-red-500 text-left",children:i})]}),e.jsx("div",{className:"w-full mb-4",children:e.jsx(g,{type:"button",onClick:k,className:"h-12 w-full bg-primary hover:bg-primary-600 text-white rounded-xl",disabled:c,children:c?e.jsxs(e.Fragment,{children:[e.jsx(A,{className:"mr-2 h-4 w-4 animate-spin"}),"Sending..."]}):"Request password reset"})}),e.jsx("div",{className:"text-center",children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Don't have an account?"," ",e.jsx(R,{to:"/signup",className:"text-primary hover:underline font-medium",children:"Sign Up"})]})})]}),j&&e.jsxs("div",{className:"w-full flex flex-col items-center text-center py-6",children:[e.jsx("h4",{className:"text-2xl font-semibold text-gray-900 dark:text-white mb-4",children:"Check your email"}),e.jsxs("p",{className:"text-sm text-muted-foreground mb-6",children:["If the email you entered is associated with a ",e.jsx("br",{}),"Commander account, you should receive a link to ",e.jsx("br",{}),"create a new password shortly."]}),e.jsxs("p",{className:"text-sm text-muted-foreground mb-6",children:["Didn't receive a link?"," ",e.jsx("button",{type:"button",className:"text-primary font-bold hover:underline",onClick:()=>{console.log("Contact support clicked")},children:"Contact support"})]}),e.jsx(g,{type:"button",onClick:E,className:"h-12 w-full max-w-[364px] bg-primary hover:bg-primary-600 text-white rounded-xl",children:"Done"})]})]})})]})]})}export{O as default}; 2//# sourceMappingURL=ForgotPassword-pzj0E41t.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.