import{o as u,p as x,v as h,j as e,L as g,H as p,$ as f,I as b,K as j,t as v,V as r,a0 as w,M as N,O as y}from"./index-CWMEhb0Z.js";const S=N({email:y().email("Please enter a valid email address").required("Email is required")});function P(){const[t,i]=u.useState(!1),c=x(),s=h({initialValues:{email:""},validationSchema:S,onSubmit:async o=>{var l;i(!0);try{const a=await v.resetPasswordRequest({email:o.email});a.data.success?(r.success(a.data.message),c("/auth/confirm-otp",{state:{email:o.email}})):r.error(a.data.message)}catch(a){w.isAxiosError(a)?((l=a.response)==null?void 0:l.status)==422?Object.entries(a.response.data.errors).forEach(([d,m])=>{m.forEach(n=>{console.log(`${d}: ${n}`),r.error(n)})}):r.error("An error occurred: "+a.message):(console.error("Unexpected error:",a),r.error("An unexpected error occurred."))}finally{i(!1)}}});return e.jsx("div",{className:"flex justify-center items-center   min-h-screen",children:e.jsxs("div",{className:" bg-main-300/15 rounded-xl py-12 px-8 max-w-6xl md:w-3xl m-auto",children:[e.jsx("img",{className:"mx-auto md:w-34 w-44 h-auto",src:"/logo.svg",alt:"dr. marco logo"}),e.jsx("h5",{className:"font-bold text-2xl text-center mt-8",children:"Reset Password"}),e.jsx("p",{className:"text-center",children:"Please enter your email address to receive a reset OTP"}),e.jsxs("form",{onSubmit:s.handleSubmit,className:"mt-8 grid grid-cols-1 gap-5",children:[e.jsxs("div",{children:[e.jsx(g,{className:"mb-2 font-light text-lg",children:"Email"}),e.jsxs("div",{className:"bg-white border border-transparent focus-within:border focus-within:border-main-400 focus-within:text-main-400 focus-within:bg-main-400/20 transition-all duration-200 flex items-center gap-2 px-3 rounded-lg",children:[e.jsx(p,{size:30,icon:f}),e.jsx(b,{type:"email",name:"email",placeholder:"Your email",value:s.values.email,onChange:s.handleChange,onBlur:s.handleBlur,className:"h-auto py-3 border-transparent !text-lg text-main-400"})]}),s.touched.email&&s.errors.email&&e.jsx("p",{className:"text-red-400 text-sm mt-1",children:s.errors.email})]}),e.jsx(j,{type:"submit",disabled:t||!s.isValid,className:"text-white bg-main-400 hover:bg-main-300 font-bold py-3 h-auto text-xl disabled:opacity-50 disabled:cursor-not-allowed",children:t?"Sending...":"Send Reset OTP"})]})]})})}export{P as default};
