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-858224db.js";import"./GenericThumbnailView-2d7b7363.js";import{F as I}from"./FormInput-8eacbbd9.js";import{P as _}from"./PasswordInput-d7e3dff6.js";import"./componentStyles-107bd37e.js";import{P as B}from"./PageMetaData-69741ff8.js";import"./ScrollableList-bf78e54b.js";import"./TextArea-78cda1eb.js";import{c as q,b as c,u as A}from"./index.esm-241dec99.js";import{A as D}from"./AuthLayout-034da150.js";import{o as z}from"./yup-9213c3af.js";import{L as C}from"./LoadingButton-4babbc5c.js";import"./index-9223140c.js";import"./createClass-042c577b.js";import"./popper-f3391c26.js";import"./Select-8b602eed.js";import"./index-e5978b8b.js";import"./Grow-b7b43b3f.js";import"./InputAdornment-583927e5.js";import"./TextField-bbb2480f.js";import"./isMuiElement-ec705bc2.js";import"./FormControlLabel-c742681c.js";import"./Checkbox-57cdf644.js";import"./SwitchBase-959e94f2.js";import"./useToggle-a6330f66.js";import"./TableRow-ef998644.js";import"./CircularProgress-5bd54bd6.js";import"./AuthBGLayout-2a666e50.js";import"./Grid2-274bb638.js";import"./CardContent-0d2efdc7.js";import"./Avatar-cdf09d52.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};
