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-d895656a.js";import"./GenericThumbnailView-532ea2d7.js";import{F as E}from"./FormInput-9b5da280.js";import{P as _}from"./PasswordInput-fdd9469f.js";import"./componentStyles-866300fe.js";import{P as B}from"./PageMetaData-47148824.js";import"./ScrollableList-e2b22048.js";import"./TextArea-fb0d0821.js";import{c as A,b as p,u as D}from"./index.esm-1087b2f3.js";import{A as q}from"./AuthLayout-c01ba4d1.js";import{o as z}from"./yup-9573aa79.js";import{L as C}from"./LoadingButton-c8915ab4.js";import"./index-45bf15b6.js";import"./popper-f3391c26.js";import"./Select-6d425a72.js";import"./index-e5978b8b.js";import"./Menu-1728e1dd.js";import"./Grow-d4be81a5.js";import"./InputAdornment-36977269.js";import"./TextField-6f73e19a.js";import"./isMuiElement-424c145f.js";import"./FormControlLabel-2fb7bcfb.js";import"./useToggle-ec04b654.js";import"./TableRow-5557ab84.js";import"./CircularProgress-1f3ca34c.js";import"./AuthBGLayout-d2920904.js";import"./Grid2-5bd460ea.js";import"./CardContent-26fc99d8.js";import"./Avatar-2ad4b384.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};
