"use strict";(self.webpackChunkclient=self.webpackChunkclient||[]).push([[4537],{99679:(e,t,s)=>{s.d(t,{A:()=>n});s(65043);var a=s(70579);const n=()=>(0,a.jsx)("div",{class:"w-4 h-4 border-2 border-t-transparent border-white rounded-full animate-spin"})},78091:(e,t,s)=>{s.d(t,{A:()=>a});const a=()=>e=>{const t=document.getElementById(e);t&&(t.classList.add("shake"),t.querySelectorAll("input").forEach((e=>e.style.borderColor="red")),setTimeout((()=>{t.classList.remove("shake"),t.querySelectorAll("input").forEach((e=>e.style.borderColor="#ccc"))}),1e3))}},4537:(e,t,s)=>{s.r(t),s.d(t,{default:()=>m});var a=s(89379),n=(s(96166),s(82806)),r=s(65043),o=s(78091),l=s(66580),i=s(9435),c=s(1880),d=s(99679),u=s(70579);const m=()=>{const[e,t]=(0,r.useState)({email:"",password:""}),s=(0,o.A)(),m=(0,l.Zp)(),p=(0,i.A)(),[h,g]=(0,r.useState)(!1);return(0,u.jsxs)("main",{className:"login__main",children:[(0,u.jsx)("img",{src:n,alt:"Logo.png",className:"mb-5"}),(0,u.jsxs)("div",{className:"login__box flex flex-col",id:"loginBox",children:[(0,u.jsx)("h1",{className:"text-center text-[25px] mb-8 mt-4 text-white",children:"Sign In"}),(0,u.jsxs)("form",{onSubmit:async t=>{t.preventDefault();const a=Object.fromEntries(new FormData(t.target));for(let e of Object.keys(a))if(""===a[e]||void 0===a[e]||null===a[e])return void s("loginBox");try{g(!0);const t="https://ezybill.ureshiiweightloss.com/api/v1/user/login",s=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),a=await s.json();if(g(!1),200!==s.status||!a.login)return p(a.err,"error");c.A.set("token",a.token,{secure:!0}),m("/admin/dashboard")}catch(n){return g(!1),console.log(n),p("Something went wrong","error")}},children:[(0,u.jsx)("input",{type:"emial",name:"email",value:e.email,onChange:s=>t((0,a.A)((0,a.A)({},e),{},{email:s.target.value})),className:"input_style",placeholder:"Enter email"}),(0,u.jsx)("input",{type:"password",name:"pass",value:e.password,onChange:s=>t((0,a.A)((0,a.A)({},e),{},{password:s.target.value})),className:"input_style",placeholder:"Enter password"}),(0,u.jsxs)("button",{disabled:!!h,className:"button_style flex items-center gap-2 justify-center",children:[h?(0,u.jsx)(d.A,{}):null,"Sign in"]})]})]})]})}},96166:()=>{},82806:(e,t,s)=>{e.exports=s.p+"static/media/logo.fad19e63cefd8737e978.png"}}]);
//# sourceMappingURL=4537.02f81d99.chunk.js.map