1var j=(o,m,r)=>new Promise((u,n)=>{var i=s=>{try{a(r.next(s))}catch(t){n(t)}},x=s=>{try{a(r.throw(s))}catch(t){n(t)}},a=s=>s.done?u(s.value):Promise.resolve(s.value).then(i,x);a((r=r.apply(o,m)).next())});import{r as c,u as w,p as N,j as e,L as h,aQ as y,an as v,B as S,bS as C,t as d}from"./index-DSvlrhyY.js";import{C as b,a as L,b as k,d as E,c as F,e as I}from"./card-BLRVTA-L.js";import{C as B}from"./chevron-left-DzyuVRBq.js";function H(){const[o,m]=c.useState(""),[r,u]=c.useState(""),[n,i]=c.useState(!1),x=w(),a=N();c.useEffect(()=>{window.location.href="https://new-online.jkshahclasses.com/"},[]);const s=t=>j(null,null,function*(){var f;t.preventDefault(),i(!0);try{const{ok:p,data:l}=yield C.login({email:o,password:r});if(p){if(l.role!=="student"){d.error("Access denied. Admin accounts cannot log in here.");return}localStorage.setItem("token",l.token),localStorage.setItem("user",JSON.stringify(l)),d.success("Logged in successfully!");let g="/";(f=a.state)!=null&&f.from&&(g=typeof a.state.from=="string"?a.state.from:a.state.from.pathname||"/"),x(g,{replace:!0})}else d.error(l.message||"Invalid credentials")}catch(p){d.error("Failed to connect to the server.")}finally{i(!1)}});return e.jsxs("div",{className:"min-h-screen bg-muted flex items-center justify-center p-4",children:[e.jsxs(h,{to:"/",className:"absolute top-4 left-4 flex items-center text-sm text-foreground hover:text-primary transition-colors",children:[e.jsx(B,{className:"mr-1 h-4 w-4"}),"Back to Home"]}),e.jsxs(b,{className:"w-full max-w-md",children:[e.jsxs(L,{children:[e.jsx(k,{className:"text-2xl text-center",children:"Welcome Back"}),e.jsx(E,{className:"text-center",children:"Sign in to your student account"})]}),e.jsx(F,{children:e.jsxs("form",{onSubmit:s,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(y,{htmlFor:"email",children:"Email"}),e.jsx(v,{id:"email",type:"email",placeholder:"[email protected]",value:o,onChange:t=>m(t.target.value),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(y,{htmlFor:"password",children:"Password"}),e.jsx(h,{to:"/forgot-password",className:"text-sm text-primary hover:underline",children:"Forgot password?"})]}),e.jsx(v,{id:"password",type:"password",value:r,onChange:t=>u(t.target.value),required:!0})]}),e.jsx(S,{type:"submit",className:"w-full",disabled:n,children:n?"Signing in...":"Sign In"})]})}),e.jsx(I,{className:"flex justify-center",children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Don't have an account?"," ",e.jsx(h,{to:"/signup",className:"text-primary hover:underline font-medium",children:"Sign up"})]})})]})]})}export{H as LoginPage};
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.