import{a as y,r$ as b,u as L,l as w,c as v,s0 as S,r as i,c5 as k,s1 as T,s2 as P,j as e,B as o,T as m,d as E}from"./index-c1429e77.js";import"./CustomDatepicker-9a80af6c.js";import{F}from"./FormInput-42f8fb29.js";import{P as I}from"./PasswordInput-57ca4436.js";import"./index-938f4514.js";import{P as _}from"./PageMetaData-779a2dc1.js";import"./ScrollableList-85f6c22b.js";import{c as A,b as p}from"./index.esm-85841cf7.js";import"./SectionDivider-0f38a779.js";import{A as B}from"./AuthLayout-faad24af.js";import{u as D}from"./index.esm-e372dd1f.js";import{o as U}from"./yup-0d492cec.js";import{L as q}from"./LoadingButton-a5f23242.js";import"./floating-ui.dom-cd6c919d.js";import"./OutlinedInput-7d44f8dd.js";import"./useFormControl-674270c6.js";import"./isHostComponent-73d6e646.js";import"./InputAdornment-7b2a78bf.js";import"./index-6d8a6cf3.js";import"./index-10a98b8b.js";import"./useMediaQuery-6763b70c.js";import"./useControlled-f1a5b61d.js";import"./InputLabel-e729048c.js";import"./FormControlLabel-9a892c17.js";import"./Checkbox-46376d3a.js";import"./SwitchBase-89be1310.js";import"./createSvgIcon-74b4ff5d.js";import"./useToggle-37a1f586.js";import"./TableCell-f7ad5597.js";import"./TableRow-18e2a4e3.js";import"./resolveProps-3c56301c.js";import"./composeClasses-b42b2e69.js";import"./toPropertyKey-d8419463.js";import"./typeof-7fd5df1e.js";import"./popper-f3391c26.js";import"./styled-54544d88.js";import"./List-7dd83a15.js";import"./AuthBGLayout-da35bc30.js";import"./CardContent-195cd99b.js";import"./Avatar-9137e935.js";function C(){const{loading:s}=y(t=>b(t)),a=L(),r=w(),c=v(),{enqueueSnackbar:l}=S(),u=A({username:p().required("Please enter username"),password:p().required("Please enter password")}),{control:d,handleSubmit:x}=D({resolver:U(u),defaultValues:{}}),n=i.useMemo(()=>{var t;return(t=a.state)==null||t.from.pathname,"/dashboard"},[a.state]),h=x(async t=>{const g=k(),f=localStorage.getItem("currentToken")?localStorage.getItem("currentToken"):"",j={username:t.username,password:t.password,user_type:"User",device_uuid:g,device_name:T,device_type:3,device_fcmtoken:f};c(P({data:j,redirectUrl:n,navigate:r,enqueueSnackbar:l}))});return i.useEffect(()=>{localStorage.getItem("currentToken")&&r(n)},[localStorage.getItem("currentToken")]),{loading:s,handleLogin:h,redirectUrl:n,control:d}}const N=()=>e.jsx(o,{sx:{my:"16px",display:"flex",justifyContent:"center"},children:e.jsxs(m,{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(m,{variant:"subtitle2",component:"span",children:"Register"})})]})}),ke=()=>{const{loading:s,handleLogin:a,control:r}=C();return e.jsxs(e.Fragment,{children:[e.jsx(_,{title:"Login"}),e.jsx(B,{authTitle:"",helpText:"",bottomLinks:e.jsx(N,{}),children:e.jsx(o,{sx:{px:3,height:"280px"},children:e.jsxs("form",{onSubmit:a,children:[e.jsx(o,{sx:{mt:5},children:e.jsx(F,{name:"username",type:"text",label:"User Name",placeholder:"Enter your user name",control:r,disableUppercase:!0})}),e.jsx(o,{sx:{mt:3},children:e.jsx(I,{name:"password",type:"password",label:"Password",placeholder:"Enter your password",control:r})}),e.jsx(o,{sx:{display:"flex",justifyContent:"space-between",mt:5},children:e.jsx(q,{loading:s,variant:"contained",sx:{bgcolor:"#0E484C"},type:"submit",disabled:s,size:"small",children:"Login"})})]})})})]})};export{ke as default};
