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-7d3dbb9c.js";import"./CustomDatepicker-6d5ad1ab.js";import{F}from"./FormInput-602ae51d.js";import{P as I}from"./PasswordInput-03f34751.js";import"./index-b5c17d61.js";import{P as _}from"./PageMetaData-69209ade.js";import"./ScrollableList-ffeab0b0.js";import{c as A,b as p}from"./index.esm-9d396c5f.js";import"./SectionDivider-be0a23cf.js";import{A as B}from"./AuthLayout-7008e480.js";import{u as D}from"./index.esm-12cc9f7b.js";import{o as U}from"./yup-55e79238.js";import{L as q}from"./LoadingButton-323cc52e.js";import"./floating-ui.dom-cd6c919d.js";import"./OutlinedInput-e6d419ce.js";import"./useFormControl-7314cc67.js";import"./isHostComponent-73d6e646.js";import"./InputAdornment-bbfa18ee.js";import"./index-7976e00d.js";import"./index-e9cb9551.js";import"./useMediaQuery-77b67f07.js";import"./useControlled-338e346b.js";import"./InputLabel-ade41a0b.js";import"./FormControlLabel-4a3a4313.js";import"./Checkbox-4b8e4bb1.js";import"./SwitchBase-d834be30.js";import"./createSvgIcon-25cfe1a8.js";import"./useToggle-5f2db218.js";import"./TableCell-26014f2c.js";import"./TableRow-23a8435a.js";import"./resolveProps-4b8623f7.js";import"./composeClasses-b42b2e69.js";import"./toPropertyKey-720374c3.js";import"./popper-f3391c26.js";import"./styled-446e5583.js";import"./List-d7c020ab.js";import"./AuthBGLayout-7ff33852.js";import"./CardContent-184f4e92.js";import"./Avatar-4afe3b6a.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};
