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

//# sourceMappingURL=src_app_login_page_jsx_7fb8ab7f._.js.map