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 t,B as r,T as m,d as E}from"./index-c910e189.js";import"./CustomDatepicker-fa2ab383.js";import{F}from"./FormInput-a4f22564.js";import{P as I}from"./PasswordInput-e66c20d7.js";import"./index-f58a077c.js";import{P as _}from"./PageMetaData-1d38d5f3.js";import"./ScrollableList-4f192da2.js";import{c as A,b as p}from"./index.esm-4b824583.js";import"./SectionDivider-782acfa4.js";import{A as B}from"./AuthLayout-5c296379.js";import{u as D}from"./index.esm-cb7a914e.js";import{o as q}from"./yup-e6171339.js";import{L as C}from"./LoadingButton-97812789.js";import"./floating-ui.dom-cd6c919d.js";import"./OutlinedInput-5e0321ba.js";import"./useFormControl-2acc5484.js";import"./isHostComponent-73d6e646.js";import"./InputAdornment-9bf084ba.js";import"./index-3e499916.js";import"./index-eec67340.js";import"./useMediaQuery-f2cfdb18.js";import"./useControlled-e4156ecd.js";import"./InputLabel-8a73326d.js";import"./FormControlLabel-ef037a46.js";import"./Checkbox-9660f964.js";import"./SwitchBase-7c59984b.js";import"./createSvgIcon-482c4579.js";import"./useToggle-22184636.js";import"./TableCell-f4de0f25.js";import"./TableRow-778e2904.js";import"./resolveProps-d3929786.js";import"./composeClasses-b42b2e69.js";import"./toPropertyKey-d8419463.js";import"./typeof-7fd5df1e.js";import"./popper-f3391c26.js";import"./styled-015539db.js";import"./List-5ca02ce5.js";import"./AuthBGLayout-fb156280.js";import"./CardContent-66856645.js";import"./Avatar-4bda1c81.js";function N(){const{loading:s}=y(e=>b(e)),a=L(),o=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:q(u),defaultValues:{}}),n=i.useMemo(()=>{var e;return(e=a.state)==null||e.from.pathname,"/dashboard"},[a.state]),h=x(async e=>{const g=k(),f=localStorage.getItem("currentToken")?localStorage.getItem("currentToken"):"",j={username:e.username,password:e.password,user_type:"User",device_uuid:g,device_name:T,device_type:3,device_fcmtoken:f};c(P({data:j,redirectUrl:n,navigate:o,enqueueSnackbar:l}))});return i.useEffect(()=>{localStorage.getItem("currentToken")&&o(n)},[localStorage.getItem("currentToken")]),{loading:s,handleLogin:h,redirectUrl:n,control:d}}const U=()=>t.jsx(r,{sx:{my:"16px",display:"flex",justifyContent:"center"},children:t.jsxs(m,{variant:"body2",color:"text.secondary",sx:{display:"flex",flexWrap:"nowrap",gap:.5},children:["Don't have an account? ",t.jsx(E,{to:"/auth/register",children:t.jsx(m,{variant:"subtitle2",component:"span",children:"Register"})})]})}),kt=()=>{const{loading:s,handleLogin:a,control:o}=N();return t.jsxs(t.Fragment,{children:[t.jsx(_,{title:"Login"}),t.jsx(B,{authTitle:"",helpText:"",bottomLinks:t.jsx(U,{}),children:t.jsx(r,{sx:{px:3,height:"280px"},children:t.jsxs("form",{onSubmit:a,children:[t.jsx(r,{sx:{mt:5},children:t.jsx(F,{name:"username",type:"text",label:"User Name",placeholder:"Enter your user name",control:o})}),t.jsx(r,{sx:{mt:3},children:t.jsx(I,{name:"password",type:"password",label:"Password",placeholder:"Enter your password",control:o})}),t.jsx(r,{sx:{display:"flex",justifyContent:"space-between",mt:5},children:t.jsx(C,{loading:s,variant:"contained",sx:{bgcolor:"#0E484C"},type:"submit",disabled:s,size:"small",children:"Login"})})]})})})]})};export{kt as default};
