1import{d as A,r as b,T as I,U as _,j as s,o as F,W as y,Y as D,M as K,L as S,B as L,X as O,Z as P,_ as N,b as R,cn as Y,co as z,cl as B,cp as M,N as H}from"./index-BiwlBLjf.js";import{C as U}from"./card-BPqi3BI-.js";const V=P({email:N().email("Invalid email address"),password:N().min(6,"Password must be at least 6 characters")}),X=()=>{var r,c;const n=A(),[t,E]=b.useState(!1);b.useEffect(()=>{sessionStorage.clear()},[]);const{register:o,handleSubmit:v,formState:{errors:a,isSubmitting:i},setError:C}=I({resolver:_(V),mode:"onChange"}),T=async l=>{var d,m,x,g,h,p,u,f,j,w;try{const e=await R.post("/subsidiary/dashboard/login",l);if((m=(d=e==null?void 0:e.data)==null?void 0:d.token)!=null&&m.accessToken){sessionStorage.setItem(Y,(g=(x=e==null?void 0:e.data)==null?void 0:x.token)==null?void 0:g.accessToken),sessionStorage.setItem(z,((p=(h=e==null?void 0:e.data)==null?void 0:h.token)==null?void 0:p.refreshToken)??""),n("/dashboard");return}const k={...e==null?void 0:e.data,email:l==null?void 0:l.email};sessionStorage.setItem(B,M(JSON.stringify(k))),n("2fa")}catch(e){C("root",{type:"deps",message:((f=(u=e==null?void 0:e.response)==null?void 0:u.data)==null?void 0:f.message)??(e==null?void 0:e.message)??"An error occurred"}),H(((w=(j=e==null?void 0:e.response)==null?void 0:j.data)==null?void 0:w.message)??(e==null?void 0:e.message)??"An error occurred")}};return s.jsx(s.Fragment,{children:s.jsx(F,{className:"max-w-[600px] py-12",children:s.jsxs(U,{className:"flex items-center gap-y-6 p-12",children:[s.jsx("img",{src:"/assets/icons/transactpay-logo.svg",alt:"logo",className:"h-6 lg:h-7"}),s.jsx("div",{className:"w-full p-1 text-left",children:s.jsx("h6",{className:"mx-auto",children:"Sign in to your Account"})}),s.jsxs("form",{className:"flex w-full flex-col gap-y-6",onSubmit:v(T),children:[s.jsx(y,{label:"Email address",placeholder:"[email protected]",maxLength:48,...o("email"),error:(r=a==null?void 0:a.email)==null?void 0:r.message,disabled:i}),s.jsxs("div",{className:"relative flex w-full flex-col",children:[s.jsx(y,{label:"Password",placeholder:"Enter password",...o("password"),error:(c=a==null?void 0:a.password)==null?void 0:c.message,disabled:i,type:t?"text":"password",rightIcon:s.jsx("button",{onClick:()=>E(!t),type:"button","aria-label":t?"Hide password":"Show password",children:t?s.jsx(D,{size:20}):s.jsx(K,{size:20})})}),s.jsx("div",{className:"flex justify-end",children:s.jsx(S,{to:"/reset-password",className:"text-primary text-sm underline-offset-2 hover:underline",children:"Forgot password?"})})]}),s.jsx("div",{className:"flex w-full items-center justify-between gap-3 lg:justify-end",children:s.jsx(L,{disabled:i,type:"submit",className:"border-primary w-full min-w-[150px] max-w-none disabled:bg-[#DADBDC] disabled:text-[#505053] lg:py-3",children:i?s.jsxs(s.Fragment,{children:[s.jsx(O,{size:12,color:"white"})," Sign in"]}):s.jsx(s.Fragment,{children:"Sign in"})})})]}),s.jsx("div",{className:"w-full p-1 text-left",children:s.jsxs("p",{children:["Don't have an account?",s.jsxs(S,{to:"/sign-up",className:"text-primary",children:[" ","Sign up here"]})]})})]})})})};export{X as default};
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.