import{a as y,kj as b,u as k,z as w,d as L,kk as v,r as m,b0 as S,kl as T,km as P,j as e,B as r,R as F,T as p,e as E}from"./index-83d9c1e2.js";import"./GenericThumbnailView-ceecb14e.js";import{F as I}from"./FormInput-03b7722e.js";import{P as _}from"./PasswordInput-27b210f0.js";import"./componentStyles-7858e543.js";import{P as B}from"./PageMetaData-1fb92714.js";import"./ScrollableList-2bb71a63.js";import"./TextArea-7d949f4d.js";import{c as A,b as c,u as D}from"./index.esm-82874186.js";import{A as q}from"./AuthLayout-0b88c48b.js";import{o as z}from"./yup-dfe9f223.js";import{L as C}from"./LoadingButton-f61ccca8.js";import"./index-1ceef347.js";import"./popper-f3391c26.js";import"./Select-1505055e.js";import"./index-e5978b8b.js";import"./Grow-6cc6748b.js";import"./InputAdornment-4b0a9854.js";import"./TextField-39c52322.js";import"./isMuiElement-5c2699ea.js";import"./FormControlLabel-af5c9791.js";import"./Checkbox-fe0b2cdb.js";import"./SwitchBase-ad42caec.js";import"./useToggle-b581a326.js";import"./TableRow-1c35ea2a.js";import"./CircularProgress-3ce9da74.js";import"./AuthBGLayout-83f74182.js";import"./Grid2-78565a55.js";import"./CardContent-fb0d7247.js";import"./Avatar-1662df64.js";import"./composeClasses-b42b2e69.js";function N(){const{loading:s}=y(t=>b(t)),a=k(),o=w(),n=L(),{enqueueSnackbar:l}=v(),[u,U]=m.useState(""),d=A({username:c().required("Please enter username"),password:c().required("Please enter password")}),{control:x,handleSubmit:g}=D({resolver:z(d),defaultValues:{}}),i=m.useMemo(()=>{var t;return(t=a.state)==null||t.from.pathname,"/dashboard"},[a.state]),h=g(async t=>{const f=S();localStorage.getItem("currentToken")&&localStorage.getItem("currentToken");const j={username:t.username,password:t.password,user_type:"User",device_uuid:f,device_name:T,device_type:3,device_fcmtoken:u};n(P({data:j,redirectUrl:i,navigate:o,enqueueSnackbar:l}))});return m.useEffect(()=>{localStorage.getItem("currentToken")&&o(i)},[localStorage.getItem("currentToken")]),{loading:s,handleLogin:h,redirectUrl:i,control:x}}const R=()=>e.jsx(r,{sx:{my:"16px",display:"flex",justifyContent:"center"},children:e.jsxs(p,{variant:"body2",color:"text.secondary",sx:{display:"flex",flexWrap:"nowrap",gap:.5},children:["Don't have an account? ",e.jsx(E,{to:"/auth/register",children:e.jsx(p,{variant:"subtitle2",component:"span",children:"Register"})})]})}),je=()=>{const{loading:s,handleLogin:a,control:o}=N();return e.jsxs(e.Fragment,{children:[e.jsx(B,{title:"Login"}),e.jsx(q,{authTitle:"",helpText:"",bottomLinks:e.jsx(R,{}),children:e.jsx(r,{sx:{px:3,height:"280px"},children:e.jsxs("form",{onSubmit:a,children:[e.jsx(r,{sx:{mt:5},children:e.jsx(I,{name:"username",type:"text",label:"User Name",placeholder:"Enter your user name",control:o})}),e.jsx(r,{sx:{mt:3},children:e.jsx(_,{name:"password",type:"password",label:"Password",placeholder:"Enter your password",control:o})}),e.jsxs(r,{sx:{display:"flex",justifyContent:"space-between",mt:5},children:[e.jsx(C,{loading:s,variant:"contained",sx:{bgcolor:"#0E484C"},type:"submit",disabled:s,size:"small",children:"Login"}),e.jsx(F,{variant:"text",sx:n=>({color:n.palette.text.primary}),size:"large",children:"Forget your Password ?"})]})]})})})]})};export{je as default};
