VirtualPR/frontend/dist/assets/forgot-password-EBF6TcjY.js

2 lines
2.0 KiB
JavaScript

import{r as e,j as s,C as x,R as p,l as j,ag as g,B as b,ah as f,m as y,ai as N,d as v}from"./index-DGCPJq4z.js";import{C as w}from"./Card-D1j94NWu.js";import{A as c,F as S}from"./Form-CyFJVGAu.js";import{F as C}from"./FormLabel-DoSLr8ng.js";import{F}from"./FormControl-DGdX8GC2.js";import"./FormCheck-tmQhdIFS.js";import"./FormContext-DDFZ16IF.js";function q(){const[r,u]=e.useState(""),[i,n]=e.useState(""),[l,o]=e.useState(""),[m,d]=e.useState(!1),h=async a=>{a.preventDefault(),n(""),o(""),d(!0);try{const t=await v("/api/auth/forgot-password",{method:"POST",body:{email:r}});o(t.message||"If that account exists, we sent a password reset link.")}catch(t){n(t.message||"Could not send the reset email.")}finally{d(!1)}};return s.jsxs("div",{className:"auth-pr-login",children:[s.jsx("div",{className:"auth-pr-bg","aria-hidden":"true"}),s.jsx(x,{children:s.jsx(p,{className:"justify-content-center",children:s.jsxs(j,{xxl:4,md:6,sm:8,children:[s.jsxs(w,{className:"auth-pr-card p-4",children:[s.jsxs("div",{className:"auth-brand text-center mb-4",children:[s.jsx("img",{src:g,alt:"Pulmonary Rehabilitation Program",height:140}),s.jsx("p",{className:"mt-3 mb-0",children:"Enter your email and we will send a link to reset your password."})]}),i?s.jsx(c,{variant:"danger",children:i}):null,l?s.jsx(c,{variant:"success",children:l}):null,s.jsxs(S,{onSubmit:h,children:[s.jsxs("div",{className:"mb-3 form-group",children:[s.jsxs(C,{children:["Email address ",s.jsx("span",{className:"text-danger",children:"*"})]}),s.jsx(F,{type:"email",value:r,onChange:a=>u(a.target.value),placeholder:"you@example.com",required:!0})]}),s.jsx("div",{className:"d-grid",children:s.jsx(b,{type:"submit",className:"btn-primary fw-semibold py-2",disabled:m,children:m?s.jsx(f,{size:"sm"}):"Send reset link"})})]}),s.jsxs("p",{className:"text-center mt-4 mb-0",children:["Return to ",s.jsx(y,{to:"/auth-1/sign-in",children:"Sign in"})]})]}),s.jsx("p",{className:"text-center auth-pr-footer mt-4 mb-0",children:s.jsx(N,{})})]})})})]})}export{q as default};