(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,1703,e=>{"use strict";var t=e.i(43476),a=e.i(71645),s=e.i(18566);function o(){(0,s.useRouter)();let[e,o]=(0,a.useState)(""),[l,n]=(0,a.useState)(""),[r,i]=(0,a.useState)(!1),[c,u]=(0,a.useState)(""),d=async t=>{t.preventDefault(),i(!0),u("");try{let t=await fetch("https://emela.malooz.com/admin/api/v1/login",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({username:e,password:l})}),a=await t.json();if("success"!==a.status)throw Error(a.message);document.cookie=`token=${a.token}; path=/; max-age=86400`,localStorage.setItem("user",JSON.stringify(a.user)),window.location.href="/dashboard"}catch(e){u(e.message)}finally{i(!1)}};return(0,t.jsxs)("div",{className:"max-w-md mx-auto my-24",children:[(0,t.jsx)("h1",{className:"text-2xl mb-4 font-semibold",children:"Login"}),(0,t.jsxs)("form",{onSubmit:d,className:"space-y-4",children:[(0,t.jsx)("input",{className:"w-full border px-3 py-2",placeholder:"Username",value:e,onChange:e=>o(e.target.value)}),(0,t.jsx)("input",{type:"password",className:"w-full border px-3 py-2",placeholder:"Password",value:l,onChange:e=>n(e.target.value)}),c&&(0,t.jsx)("p",{className:"text-red-600",children:c}),(0,t.jsx)("button",{className:"w-full bg-black text-white py-2",children:r?"Logging in...":"Login"})]})]})}e.s(["default",()=>o])}]);