import{a as y,ko as b,u as k,z as w,d as L,kp as v,r as m,b0 as S,kq as T,kr as P,j as e,B as r,R as F,T as p,e as E}from"./index-0698dbe6.js";import"./GenericThumbnailView-dca658f3.js";import{F as I}from"./FormInput-98c39817.js";import{P as _}from"./PasswordInput-72cfeedd.js";import"./componentStyles-91278318.js";import{P as B}from"./PageMetaData-cd33e3c3.js";import"./ScrollableList-fc87149c.js";import"./TextArea-91c96faf.js";import{c as q,b as c,u as A}from"./index.esm-85d015f3.js";import{A as D}from"./AuthLayout-f0dadaed.js";import{o as z}from"./yup-7a53beb8.js";import{L as C}from"./LoadingButton-32ceeccc.js";import"./index-c9a9ee7a.js";import"./createClass-61c32f27.js";import"./popper-f3391c26.js";import"./Select-371fc2c6.js";import"./index-e5978b8b.js";import"./Grow-ea87e600.js";import"./InputAdornment-0c2174b6.js";import"./TextField-4222c766.js";import"./isMuiElement-d179539f.js";import"./FormControlLabel-5da20c5e.js";import"./Checkbox-987be799.js";import"./SwitchBase-6519d4d3.js";import"./useToggle-e2dc2782.js";import"./TableRow-2848b050.js";import"./CircularProgress-4f55e66c.js";import"./AuthBGLayout-321e3c6d.js";import"./Grid2-a3850bef.js";import"./CardContent-da6ab0f2.js";import"./Avatar-ee0f38ce.js";import"./composeClasses-b42b2e69.js";function N(){const{loading:s}=y(t=>b(t)),a=k(),o=w(),n=L(),{enqueueSnackbar:l}=v(),[u,U]=m.useState(""),d=q({username:c().required("Please enter username"),password:c().required("Please enter password")}),{control:x,handleSubmit:g}=A({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=S();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")&&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(p,{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(p,{variant:"subtitle2",component:"span",children:"Register"})})]})}),ye=()=>{const{loading:s,handleLogin:a,control:o}=N();return e.jsxs(e.Fragment,{children:[e.jsx(B,{title:"Login"}),e.jsx(D,{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(I,{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{ye as default};
