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-3141de2d.js";import"./GenericThumbnailView-c2621934.js";import{F as I}from"./FormInput-abff9e70.js";import{P as _}from"./PasswordInput-d4242756.js";import"./componentStyles-24f97919.js";import{P as B}from"./PageMetaData-2b8c2cd7.js";import"./ScrollableList-fa62971d.js";import"./TextArea-ceaff311.js";import{c as A,b as c,u as D}from"./index.esm-8b0c9a99.js";import{A as q}from"./AuthLayout-ca2c85de.js";import{o as z}from"./yup-c2fea6fa.js";import{L as C}from"./LoadingButton-8bbad6d1.js";import"./index-a3f870f6.js";import"./popper-f3391c26.js";import"./Select-369b8a03.js";import"./index-e5978b8b.js";import"./Grow-e0aea29d.js";import"./InputAdornment-1680248d.js";import"./TextField-ec161c03.js";import"./isMuiElement-2bebf9f1.js";import"./FormControlLabel-c4983ca8.js";import"./Checkbox-8808455f.js";import"./SwitchBase-416973c8.js";import"./useToggle-c087b809.js";import"./TableRow-e26106d8.js";import"./CircularProgress-a64e9e1b.js";import"./AuthBGLayout-6252070b.js";import"./Grid2-488bb30d.js";import"./CardContent-97006932.js";import"./Avatar-ceef0f33.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};
