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-c5c88b67.js";import"./GenericThumbnailView-43782201.js";import{F as E}from"./FormInput-86f14880.js";import{P as _}from"./PasswordInput-912268e4.js";import"./componentStyles-a5e5a830.js";import{P as B}from"./PageMetaData-deabce52.js";import"./ScrollableList-21ab2b9c.js";import"./TextArea-aad9dffe.js";import{c as A,b as p,u as D}from"./index.esm-81620445.js";import{A as q}from"./AuthLayout-5581ee5f.js";import{o as z}from"./yup-41605283.js";import{L as C}from"./LoadingButton-3a5d0643.js";import"./index-c98d1d89.js";import"./createClass-fb49042e.js";import"./popper-f3391c26.js";import"./Select-4ed8db5d.js";import"./index-e5978b8b.js";import"./Menu-e7d2b2ee.js";import"./Grow-7345f8ea.js";import"./InputAdornment-d66117f3.js";import"./TextField-78388962.js";import"./isMuiElement-b3c21f38.js";import"./FormControlLabel-d6955dc8.js";import"./useToggle-88e8998b.js";import"./TableRow-2b359fa8.js";import"./CircularProgress-13afa056.js";import"./AuthBGLayout-38d20a14.js";import"./Grid2-0ff60c92.js";import"./CardContent-5f043396.js";import"./Avatar-94102376.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"})})]})}),je=()=>{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{je as default};
