(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,1182,e=>{"use strict";var t=e.i(43476),r=e.i(71645),o=e.i(18566),a=e.i(19838),i=e.i(55572);e.s(["default",0,function(){let[e,s]=(0,r.useState)(""),[d,n]=(0,r.useState)(""),l=(0,a.useAppDispatch)(),{loading:c,error:u}=(0,a.useAppSelector)(e=>e.auth),g=(0,o.useRouter)(),m=async t=>{t.preventDefault(),l((0,i.loginStart)());try{let t=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:e,password:d})}),r=await t.json();t.ok?(l((0,i.loginSuccess)({user:r.user,token:r.token})),document.cookie=`token=${r.token}; path=/; max-age=86400`,console.log("Login successful, token stored in cookie"),g.push("/admin")):l((0,i.loginFailure)(r.error))}catch(e){l((0,i.loginFailure)("Network error"))}};return(0,t.jsx)("div",{className:"flex min-h-screen items-center justify-center bg-gray-2 dark:bg-[#020d1a]",children:(0,t.jsxs)("div",{className:"w-full max-w-md rounded-lg bg-white p-8 shadow-lg dark:bg-gray-800",children:[(0,t.jsx)("h2",{className:"mb-6 text-center text-2xl font-bold text-gray-900 dark:text-white",children:"Admin Login"}),(0,t.jsxs)("form",{onSubmit:m,className:"space-y-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{htmlFor:"email",className:"block text-sm font-medium text-gray-700 dark:text-gray-300",children:"Email"}),(0,t.jsx)("input",{type:"email",id:"email",value:e,onChange:e=>s(e.target.value),required:!0,className:"mt-1 block w-full rounded-md border border-gray-300 px-3 py-2 shadow-sm focus:border-indigo-500 focus:outline-none focus:ring-indigo-500 dark:border-gray-600 dark:bg-gray-700 dark:text-white"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{htmlFor:"password",className:"block text-sm font-medium text-gray-700 dark:text-gray-300",children:"Password"}),(0,t.jsx)("input",{type:"password",id:"password",value:d,onChange:e=>n(e.target.value),required:!0,className:"mt-1 block w-full rounded-md border border-gray-300 px-3 py-2 shadow-sm focus:border-indigo-500 focus:outline-none focus:ring-indigo-500 dark:border-gray-600 dark:bg-gray-700 dark:text-white"})]}),u&&(0,t.jsx)("div",{className:"text-red-600 dark:text-red-400",children:u}),(0,t.jsx)("button",{type:"submit",disabled:c,className:"w-full rounded-md bg-indigo-600 px-4 py-2 text-white hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 disabled:opacity-50",children:c?"Logging in...":"Login"})]})]})})}])}]);