PageSourceSearch

https://app.onlinereadingtutor.com/assets/index-N2vKhAM2.js

js onlinereadingtutor.com collected 2026-10-02 15:56:54 UTC 6,177 bytes, 1 lines download raw bytes

1import{u as P,r as p,a as L,b as q,s as U,c as F,d as O,e as R,f as M,g as d,j as s,B as N,C as W,P as D,h as l,A as V,T as u,G as a,F as w,I as j,S as G,i as y,k as A,O as _,l as $,m as z,V as H,n as J,L as K,o as v,p as Q,q as c,t as h,v as I,w as X,x as Y,y as Z}from"./index-BAWMNNp6.js";import{M as S}from"./MenuItem-YLWD0Xvp.js";const ee=()=>{try{return P()}catch(n){return console.error("useNavigate can only be used inside a Router",n),()=>{}}},oe=/^(?=[a-f\d]{24}$)(\d+[a-f]|[a-f]+\d)/i,b="The username or password you entered is incorrect. Check both and try again.",se=new Set([400,401,403,404,409]),re=n=>n instanceof I&&n.status&&se.has(n.status)?b:Z(n),ae=()=>{const[n,B]=p.useState(!1),i=ee(),C=L(),x=q(e=>U(e)),T=()=>{const e=document.getElementById("outlined-adornment-password"),t=e?.selectionStart||0;B(o=>!o),setTimeout(()=>{e&&(e.focus(),e.selectionStart=t,e.selectionEnd=t)},0)},k=e=>{e.preventDefault()},m=e=>{const{name:t,value:o}=e.target,E=o.replace(/\s+/g,"");r.setFieldValue(t,E)},g=F({mutationFn:e=>Y(e),onSuccess:e=>{if(!e.isSuccess){c.error(b),h.error("User login attempt failed",{source:"login-mutation"});return}e&&e?.data?(h.info(`User login attempt - ${JSON.stringify(e?.data)}`,{source:"login-mutation"}),X(e.data),c.success("Login successful"),f(e.data)):(h.error(`Errorn on User login attempt - ${e?.data} `,{source:"login-mutation"}),c.error(e.message||"Something went wrong"))},onError:e=>{c.error(re(e)),h.error("User login attempt failed",{source:"login-mutation",status:e instanceof I?e.status:void 0})}});p.useEffect(()=>{(async()=>f(x))()},[x,C]),p.useEffect(()=>{const e=localStorage.getItem("token");(!e||e=="undefined")&&(localStorage.clear(),O(),i("/auth/login"))},[]);const f=e=>{e?.userType==="admin"?window.location.replace("/admin/dashboard"):e?.userType==="superAdmin"?window.location.replace("/superAdmin/dashboard"):e?.userType==="teacher"?window.location.replace("/teacher/dashboard"):e?.userType==="student"&&(e?.isPaymentCompleted?e?.isPlaced?i("/classroom-page",{state:{playAudio:!0}}):i("/test-level-page"):i("/payment-page"))},r=R({initialValues:{loginAs:"student",email:"",studentId:"",password:""},validationSchema:M({loginAs:d().required("Password is required."),email:d().when("loginAs",([e],t)=>["admin"].indexOf(e)>-1?t.trim().email("Please use a valid email address.").required("Email address is required."):t.notRequired()),studentId:d().when("loginAs",([e],t)=>["student"].indexOf(e)>-1?t.trim().required("Student id is required."):t.notRequired()),password:d().required("Password is required.")}),onSubmit:async(e,{setSubmitting:t})=>{try{const o={password:e.password};e.loginAs==="student"?o.username=e.studentId:o.email=e.email,g.mutate(o)}catch(o){console.error("Authentication failed:",o)}finally{t(!1)}}});return s.jsx(N,{children:s.jsx(W,{component:"main",maxWidth:"xs",children:s.jsx(D,{elevation:3,children:s.jsxs(l,{p:3,children:[s.jsxs(l,{display:"flex",alignItems:"center",children:[s.jsx(l,{flex:"0 0 auto",children:s.jsx(V,{color:"primary",onClick:()=>i("/auth/signup"),style:{marginRight:"8px",cursor:"pointer"}})}),s.jsx(l,{flex:"1",textAlign:"center",children:s.jsx(u,{variant:"h5",align:"center",fontWeight:"bold",children:"Login"})})]}),s.jsx(u,{variant:"body1",align:"center",children:"Login and start your journey."}),s.jsx("form",{onSubmit:r.handleSubmit,style:{marginTop:"30px"},children:s.jsxs(a,{container:!0,spacing:2,children:[s.jsx(a,{item:!0,xs:12,children:s.jsxs(w,{fullWidth:!0,variant:"outlined",children:[s.jsx(j,{error:r.touched.loginAs&&!!r.errors.loginAs,children:"Login as"}),s.jsxs(G,{style:{textAlign:"left"},name:"loginAs",label:"loginAs",value:r.values.loginAs,onChange:r.handleChange,onBlur:r.handleBlur,error:r.touched.loginAs&&!!r.errors.loginAs,children:[s.jsx(S,{value:"student",children:"Student"}),s.jsx(S,{value:"admin",children:"Admin/ORT Teacher"})]}),s.jsx(y,{error:r.touched.loginAs&&!!r.errors.loginAs,children:r.touched.loginAs&&r.errors.loginAs})]})}),r.values.loginAs==="admin"?s.jsx(a,{item:!0,xs:12,children:s.jsx(A,{id:"email",name:"email",label:"Email Address",variant:"outlined",fullWidth:!0,onChange:m,onBlur:r.handleBlur,value:r.values.email,error:r.touched.email&&!!r.errors.email,helperText:r.touched.email&&r.errors.email})}):s.jsx(a,{item:!0,xs:12,children:s.jsx(A,{id:"studentId",name:"studentId",label:"Student ID",variant:"outlined",fullWidth:!0,onChange:m,onBlur:r.handleBlur,value:r.values.studentId,error:r.touched.studentId&&!!r.errors.studentId,helperText:r.touched.studentId&&r.errors.studentId})}),s.jsx(a,{item:!0,xs:12,children:s.jsxs(w,{fullWidth:!0,variant:"outlined",children:[s.jsx(j,{variant:"outlined",error:r.touched.password&&!!r.errors.password,htmlFor:"outlined-adornment-password",children:"Password"}),s.jsx(_,{id:"outlined-adornment-password",name:"password",label:"Password",type:n?"text":"password",fullWidth:!0,onChange:m,onBlur:r.handleBlur,value:r.values.password,autoComplete:"current-password",endAdornment:s.jsx($,{position:"end",children:s.jsx(z,{"aria-label":"toggle password visibility",onClick:T,onMouseDown:k,edge:"end",children:n?s.jsx(H,{}):s.jsx(J,{})})}),error:r.touched.password&&!!r.errors.password}),s.jsx(y,{error:r.touched.password&&!!r.errors.password,children:r.touched.password&&r.errors.password})]})}),s.jsx(a,{item:!0,xs:12,children:s.jsx(u,{variant:"body2",align:"right",children:s.jsx(K,{style:{cursor:"pointer"},underline:"none",color:"primary",onClick:()=>i("/auth/forgetpassword",{state:{userType:r.values.loginAs}}),children:"Forgot your password?"})})}),s.jsx(a,{item:!0,xs:12,children:s.jsx(v,{type:"submit",variant:"contained",color:"primary",disabled:r.isSubmitting||g.isPending,fullWidth:!0,children:r.isSubmitting||g.isPending?s.jsx(Q,{size:24,color:"inherit"}):"Login"})}),s.jsx(a,{item:!0,xs:12,children:s.jsxs(l,{mt:{xs:0,md:4},textAlign:"center",children:[s.jsx(u,{variant:"body1",gutterBottom:!0,children:"New User?"}),s.jsx(v,{size:"large",variant:"contained",color:"primary",onClick:()=>i("/"),style:{padding:"6px 16px",fontSize:"0.875rem"},children:"Start the Assessment"})]})})]})})]})})})})};export{b as INVALID_LOGIN_MESSAGE,oe as StudentIdRegex,ae 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.