import{a as y,k0 as k,u as b,k as w,d as L,k1 as S,r as m,aR as v,k2 as T,k3 as P,j as e,B as r,z as F,T as c,e as I}from"./index-4dfc510b.js";import"./GenericThumbnailView-6256cad7.js";import{F as E}from"./FormInput-f887e69c.js";import{P as _}from"./PasswordInput-27b1d2c2.js";import"./componentStyles-df94248d.js";import{P as B}from"./PageMetaData-9d85e469.js";import"./ScrollableList-bef4a518.js";import"./TextArea-a0cc14f3.js";import{c as A,b as p,u as D}from"./index.esm-0a454763.js";import{A as q}from"./AuthLayout-90c7915e.js";import{o as z}from"./yup-80def618.js";import{L as C}from"./LoadingButton-09ba23cd.js";import"./index-9a385720.js";import"./popper-f3391c26.js";import"./Select-c8503f85.js";import"./index-e5978b8b.js";import"./Menu-0f556e12.js";import"./Grow-a7315f12.js";import"./InputAdornment-ccd6e8ff.js";import"./TextField-c0d4022e.js";import"./isMuiElement-7be61a21.js";import"./FormControlLabel-e49dd1e5.js";import"./useToggle-4d390b1e.js";import"./TableRow-bee40746.js";import"./CircularProgress-d36b5e75.js";import"./AuthBGLayout-779e18b6.js";import"./Grid2-713975b3.js";import"./CardContent-afcdca5e.js";import"./Avatar-dec2611f.js";import"./composeClasses-b42b2e69.js";function N(){const{loading:s}=y(t=>k(t)),a=b(),o=w(),n=L(),{enqueueSnackbar:l}=S(),[u,U]=m.useState(""),d=A({username:p().required("Please enter username"),password:p().required("Please enter password")}),{control:x,handleSubmit:g}=D({resolver:z(d),defaultValues:{}}),i=m.useMemo(()=>{var t;return(t=a.state)==null||t.from.pathname,"/dashboard"},[a.state]),h=g(async t=>{const f=v();localStorage.getItem("currentToken")&&localStorage.getItem("currentToken");const j={username:t.username,password:t.password,user_type:"User",device_uuid:f,device_name:T,device_type:3,device_fcmtoken:u};n(P({data:j,redirectUrl:i,navigate:o,enqueueSnackbar:l}))});return m.useEffect(()=>{localStorage.getItem("currentToken")&&(console.log("current token:",localStorage.getItem("currentToken")),o(i))},[localStorage.getItem("currentToken")]),{loading:s,handleLogin:h,redirectUrl:i,control:x}}const R=()=>e.jsx(r,{sx:{my:"16px",display:"flex",justifyContent:"center"},children:e.jsxs(c,{variant:"body2",color:"text.secondary",sx:{display:"flex",flexWrap:"nowrap",gap:.5},children:["Don't have an account? ",e.jsx(I,{to:"/auth/register",children:e.jsx(c,{variant:"subtitle2",component:"span",children:"Register"})})]})}),fe=()=>{const{loading:s,handleLogin:a,control:o}=N();return e.jsxs(e.Fragment,{children:[e.jsx(B,{title:"Login"}),e.jsx(q,{authTitle:"",helpText:"",bottomLinks:e.jsx(R,{}),children:e.jsx(r,{sx:{px:3,height:"280px"},children:e.jsxs("form",{onSubmit:a,children:[e.jsx(r,{sx:{mt:5},children:e.jsx(E,{name:"username",type:"text",label:"User Name",placeholder:"Enter your user name",control:o})}),e.jsx(r,{sx:{mt:3},children:e.jsx(_,{name:"password",type:"password",label:"Password",placeholder:"Enter your password",control:o})}),e.jsxs(r,{sx:{display:"flex",justifyContent:"space-between",mt:5},children:[e.jsx(C,{loading:s,variant:"contained",sx:{bgcolor:"#0E484C"},type:"submit",disabled:s,size:"small",children:"Login"}),e.jsx(F,{variant:"text",sx:n=>({color:n.palette.text.primary}),size:"large",children:"Forget your Password ?"})]})]})})})]})};export{fe as default};
