import{a as y,s3 as b,u as L,l as w,c as k,s4 as v,r as i,ck as S,s5 as T,s6 as P,j as e,B as o,T as m,d as E}from"./index-d9e0bbb9.js";import"./CustomDatepicker-9495774a.js";import{F}from"./FormInput-44ad439a.js";import{P as I}from"./PasswordInput-f1f4f54b.js";import"./index-e61c8ded.js";import{P as _}from"./PageMetaData-c80444e2.js";import"./ScrollableList-03cda798.js";import{c as A,b as p}from"./index.esm-65c50bc3.js";import"./SectionDivider-95fcfa90.js";import{A as B}from"./AuthLayout-888464a6.js";import{u as D}from"./index.esm-97139da9.js";import{o as U}from"./yup-267c2267.js";import{L as q}from"./LoadingButton-378d10f9.js";import"./floating-ui.dom-cd6c919d.js";import"./OutlinedInput-8f17518b.js";import"./useFormControl-8bb67ca0.js";import"./isHostComponent-73d6e646.js";import"./InputAdornment-978b4608.js";import"./index-3bec8271.js";import"./index-1253245b.js";import"./useMediaQuery-1b7ae287.js";import"./useControlled-ba6710bb.js";import"./InputLabel-8c8abfdd.js";import"./FormControlLabel-685586a9.js";import"./Checkbox-74feb846.js";import"./SwitchBase-8b88dd2c.js";import"./createSvgIcon-c99d086f.js";import"./useToggle-b6ab51df.js";import"./TableCell-643437b4.js";import"./TableRow-113a14fe.js";import"./resolveProps-ba55e2df.js";import"./composeClasses-b42b2e69.js";import"./toPropertyKey-720374c3.js";import"./popper-f3391c26.js";import"./styled-8fd62552.js";import"./List-c3ed6b04.js";import"./AuthBGLayout-07506df1.js";import"./CardContent-0df4f94a.js";import"./Avatar-1439ea34.js";function C(){const{loading:s}=y(t=>b(t)),a=L(),r=w(),c=k(),{enqueueSnackbar:l}=v(),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=S(),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"})})]})}),ve=()=>{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{ve as default};
