1import{aV as L,aP as R,r as t,j as e}from"./vendor-react-BzspNr1T.js";import{v as T,u as D}from"./index-Ca0tFk1S.js";import{L as E}from"./LoadingButton-a1pvy6Vy.js";import{B as o,C as W,T as x,q as k,ae as z,ag as B,aQ as O,A as b,f as y,aR as V,I as q,aS as H,aJ as M}from"./vendor-mui-UOmyAJXi.js";import"./vendor-maps-C7wV7spV.js";import"./vendor-animations-TYrwaXAM.js";import"./vendor-redux-CWo-c314.js";import"./vendor-icons-DRsno-dh.js";/* empty css */const $=()=>{const d=L(),{theme:F}=T(),{login:g,isLoading:h,isAuthenticated:l,user:r,logout:N}=D();R.useEffect(()=>{!h&&l&&r?.role==="admin"&&(console.log("Already authenticated as admin, redirecting to /admin"),v(!0),d("/admin",{replace:!0}))},[h,l,r,d]);const[s,j]=t.useState({email:"",password:""}),[c,w]=t.useState(!1),[m,n]=t.useState(""),[i,p]=t.useState(!1),[S,v]=t.useState(!1),f=u=>{const{name:a,value:A}=u.target;j(P=>({...P,[a]:A})),m&&n("")},I=async u=>{u.preventDefault(),console.log("Login function available:",typeof g),p(!0),n("");try{const a=await g(s.email,s.password);a&&a.success?setTimeout(()=>{d("/admin",{replace:!0})},100):n(a?.error||"Login failed")}catch(a){console.error("Login error:",a),n("Login failed. Please try again.")}finally{p(!1)}},C=()=>{w(!c)};return S?e.jsxs(o,{sx:{minHeight:"100vh",background:"linear-gradient(135deg, #667eea 0%, #764ba2 100%)",display:"flex",alignItems:"center",justifyContent:"center",flexDirection:"column",gap:2},children:[e.jsx(W,{size:60,sx:{color:"common.white"}}),e.jsx(x,{variant:"h6",sx:{color:"common.white"},children:"Redirecting to Admin Dashboard..."})]}):e.jsx(o,{className:"admin-root",sx:{minHeight:"100vh",background:"linear-gradient(135deg, #667eea 0%, #764ba2 100%)",display:"flex",alignItems:"center",justifyContent:"center",py:4},children:e.jsx(k,{maxWidth:"sm",children:e.jsx(z,{sx:{borderRadius:3,boxShadow:"0 20px 40px rgba(0,0,0,0.1)",overflow:"hidden"},children:e.jsxs(B,{sx:{p:4},children:[e.jsxs(o,{sx:{textAlign:"center",mb:4},children:[e.jsx(o,{sx:{width:80,height:80,borderRadius:"50%",backgroundColor:"primary.main",display:"flex",alignItems:"center",justifyContent:"center",mx:"auto",mb:2},children:e.jsx(O,{sx:{fontSize:40,color:"common.white"}})}),e.jsx(x,{variant:"h4",sx:{textTransform:"uppercase",letterSpacing:"1px",color:"primary.main",mb:1},children:"Admin Login"}),e.jsx(x,{variant:"body1",color:"text.secondary",children:"Access the admin dashboard to manage orders and products"})]}),l&&r?.role==="admin"&&e.jsxs(b,{severity:"success",sx:{mb:3},children:["You are already logged in as ",r.name,". Redirecting to admin dashboard..."]}),m&&e.jsx(b,{severity:"error",sx:{mb:3},children:m}),e.jsxs("form",{onSubmit:I,noValidate:!0,children:[e.jsx(y,{fullWidth:!0,label:"Email Address",name:"email",type:"email",value:s.email,onChange:f,required:!0,disabled:i,sx:{mb:3},InputProps:{sx:{"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"}}}}),e.jsx(y,{fullWidth:!0,label:"Password",name:"password",type:c?"text":"password",value:s.password,onChange:f,required:!0,disabled:i,sx:{mb:3},InputProps:{endAdornment:e.jsx(V,{position:"end",children:e.jsx(q,{onClick:C,edge:"end",disabled:i,children:c?e.jsx(H,{}):e.jsx(M,{})})}),sx:{"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"}}}}),e.jsx(E,{type:"submit",fullWidth:!0,variant:"contained",size:"large",loading:i,loadingText:"Signing In...",sx:{py:1.5,fontSize:"1.1rem",fontWeight:600,textTransform:"uppercase",letterSpacing:"1px",boxShadow:"0 4px 12px rgba(211, 47, 47, 0.3)","&:hover":{boxShadow:"0 6px 16px rgba(211, 47, 47, 0.4)",transform:"translateY(-1px)"}},children:"Sign In"})]})]})})})})};export{$ as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.