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-ba11e6ab.js";import"./GenericThumbnailView-511a7e33.js";import{F as I}from"./FormInput-3e62ad24.js";import{P as _}from"./PasswordInput-e3664409.js";import"./componentStyles-cc6f218d.js";import{P as B}from"./PageMetaData-e3d52899.js";import"./ScrollableList-b4fc4d99.js";import"./TextArea-1c46e0e4.js";import{c as A,b as c,u as D}from"./index.esm-39ef576a.js";import{A as q}from"./AuthLayout-1d442dd5.js";import{o as z}from"./yup-902af9ab.js";import{L as C}from"./LoadingButton-a3eae003.js";import"./index-33824b7d.js";import"./popper-f3391c26.js";import"./Select-f9434f8a.js";import"./index-e5978b8b.js";import"./Grow-1038181b.js";import"./InputAdornment-0f07311f.js";import"./TextField-16337ecc.js";import"./isMuiElement-f8265807.js";import"./FormControlLabel-8048035a.js";import"./Checkbox-3e187368.js";import"./SwitchBase-7d4e0bc8.js";import"./useToggle-627e15d8.js";import"./TableRow-e1616615.js";import"./CircularProgress-509803a6.js";import"./AuthBGLayout-6048f679.js";import"./Grid2-12794a3c.js";import"./CardContent-9c57d232.js";import"./Avatar-1c5fb46d.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};
