import{u as y,a as _,r as t,s as E,b as c,c as S,d as F,j as e,e as C,f as P}from"./index-Cx3SkgxC.js";import{F as A,a as D,b as L,c as q}from"./index-B_mBRvDV.js";const O=()=>{const i=y(),h=_();t.useEffect(()=>{i(E("Login"))},[i]),c(s=>s.themeConfig.theme==="dark"||s.themeConfig.isDarkMode),c(s=>s.themeConfig.rtlClass);const b=c(s=>s.themeConfig);let{data:o}=S();const[M,R]=t.useState(b.locale),[r,j]=t.useState(""),[n,w]=t.useState(""),[d,N]=t.useState(!1),[m,l]=t.useState(null),{postData:k,loading:x}=F(),v=async s=>{var g,p,u,f;if(s.preventDefault(),r===""){l("Email is required!");return}if(n===""){l("Password is required!");return}try{const a=await k("admin-login",{admin_email:r,admin_password:n});if(console.log(a),!a||a.success===!1){l(a.message||"Login failed");return}else C.set("adminToken",a.token,{expires:30}),i(P({name:a.isAdmin.admin_name,profilePic:a.isAdmin.profile_pic,isAdmin:!0,adminEmail:r})),console.log(a.isAdmin.profile_pic),h("/")}catch(a){console.error(((p=(g=a.response)==null?void 0:g.data)==null?void 0:p.message)||"An error occurred"),l(((f=(u=a.response)==null?void 0:u.data)==null?void 0:f.message)||"An error occurred")}};return e.jsxs("div",{children:[e.jsx("div",{className:"absolute inset-0",children:e.jsx("img",{src:"/assets/images/auth/bg-gradient.png",alt:"background",className:"h-full w-full object-cover"})}),e.jsxs("div",{className:"relative flex min-h-screen items-center justify-center bg-[url(/Final.png)] bg-cover bg-top bg-no-repeat px-6 py-10  sm:px-16",children:[e.jsx("img",{src:"/assets/images/auth/coming-soon-object1.png",alt:"object",className:"absolute left-0 top-1/2 h-full max-h-[893px] -translate-y-1/2"}),e.jsx("img",{src:"/assets/images/auth/coming-soon-object3.png",alt:"object",className:"absolute right-0 top-0 h-[300px]"}),e.jsx("div",{className:"relative w-full max-w-[870px] rounded-md p-2 bg-[linear-gradient(45deg,#fff9f9_0%,rgba(255,255,255,0)_25%,rgba(255,255,255,0)_75%,#fff9f9_100%)] bg-[length:200%_200%] animate-gradientRotation dark:bg-[linear-gradient(45deg,#fff9f9_0%,rgba(255,255,255,0)_25%,rgba(255,255,255,0)_75%,#fff9f9_100%)]",children:e.jsx("div",{className:"relative flex flex-col justify-center rounded-md bg-white/60 backdrop-blur-lg dark:bg-white/60 px-6 lg:min-h-[758px] py-20",children:e.jsxs("div",{className:"mx-auto w-full max-w-[440px]",children:[e.jsxs("div",{className:"mb-10 flex-col text-center justify-around",children:[e.jsx("img",{src:o==null?void 0:o.settings[0].website_logo,className:"w-32 mx-auto mb-20",alt:"Logo"}),e.jsx("h1",{className:"text-3xl font-extrabold uppercase !leading-snug text-black md:text-4xl",children:"Sign in"}),e.jsx("p",{className:"text-base font-bold leading-normal text-white-dark",children:"Enter your email and password to login"})]}),e.jsxs("form",{className:"space-y-5 dark:text-black",onSubmit:v,children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"admin_email",children:"Email"}),e.jsxs("div",{className:"relative text-white-dark",children:[e.jsx("input",{id:"admin_email",type:"email",placeholder:"Enter Email",className:"form-input dark:bg-white dark:text-dark dark:border-yellow-200 focus:border-[1px] focus:border-yellow-300 ps-10 placeholder:text-white-dark",value:r,onChange:s=>j(s.target.value)}),e.jsx("span",{className:"absolute start-4 top-1/2 -translate-y-1/2",children:e.jsx(A,{className:"text-xl"})})]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"admin_password",children:"Password"}),e.jsxs("div",{className:"relative text-white-dark",children:[e.jsx("input",{id:"admin_password",type:d?"text":"password",placeholder:"Enter Password",className:"form-input dark:bg-white dark:text-dark dark:border-yellow-200 focus:border-[1px] focus:border-yellow-300 ps-10 placeholder:text-white-dark",value:n,onChange:s=>w(s.target.value)}),e.jsx("span",{className:"absolute end-4 top-1/2 -translate-y-1/2 cursor-pointer",onClick:()=>N(!d),children:d?e.jsx(D,{className:"text-xl"}):e.jsx(L,{className:"text-xl"})}),e.jsx("span",{className:"absolute start-4 top-1/2 -translate-y-1/2",children:e.jsx(q,{className:"text-xl"})})]})]}),e.jsx("button",{type:"submit",className:"btn bg-gradient-to-tr hover:bg-gradient-to-tl from-yellow-400 to-white !mt-9 w-full border-0 uppercase shadow-[0_10px_20px_-10px_rgba(67,97,238,0.44)]",disabled:x,children:x?"Signing in...":"Sign in"}),m&&e.jsx("p",{className:"text-red-500",children:m})]})]})})})]})]})};export{O as default};
