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-5768b108.js";import"./CustomDatepicker-c97efda4.js";import{F}from"./FormInput-be88fa2a.js";import{P as I}from"./PasswordInput-d52ae3bc.js";import"./index-42cce9d5.js";import{P as _}from"./PageMetaData-84e26924.js";import"./ScrollableList-c8e84a4e.js";import{c as A,b as p}from"./index.esm-85e2fec5.js";import"./SectionDivider-bc494fef.js";import{A as B}from"./AuthLayout-44daad99.js";import{u as D}from"./index.esm-4803c918.js";import{o as q}from"./yup-7ddf262a.js";import{L as C}from"./LoadingButton-b684247e.js";import"./floating-ui.dom-cd6c919d.js";import"./OutlinedInput-8a98392b.js";import"./useFormControl-e91ce3d1.js";import"./isHostComponent-73d6e646.js";import"./InputAdornment-82d0c147.js";import"./index-c58b1ae1.js";import"./index-4ca9e290.js";import"./useMediaQuery-493fa36e.js";import"./useControlled-821282b7.js";import"./InputLabel-bfa922b7.js";import"./FormControlLabel-a8ce6f4f.js";import"./Checkbox-6b2ed436.js";import"./SwitchBase-6c1eb44c.js";import"./createSvgIcon-51b522b8.js";import"./useToggle-348f24bd.js";import"./TableCell-73fa51e5.js";import"./TableRow-3593e946.js";import"./resolveProps-5b0bdb14.js";import"./composeClasses-b42b2e69.js";import"./toPropertyKey-d8419463.js";import"./typeof-7fd5df1e.js";import"./popper-f3391c26.js";import"./styled-9a8473c9.js";import"./List-2cd167d2.js";import"./AuthBGLayout-7c059758.js";import"./CardContent-4b37116a.js";import"./Avatar-5307a35a.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};
