import{H as b,p as v,b as w,P as L,a as x,k as B,r,o as E,q as k,f as l,I as y,t as d,e as t,d as c,w as A,j as u,l as m}from"./index-0c00d6f8.js";import{c as I,a as p}from"./index.esm-17a8dbbe.js";const T={class:"flex flex-col flex-1 justify-center"},O={class:"text-text font-bold mb-4 text-2xl"},R={class:"space-y-4"},N=["disabled"],C=b({__name:"Login",setup(P){const _=v(),n=w();L({validateOnBlur:!0,validateOnChange:!0,validateOnInput:!1,validateOnModelUpdate:!0});const{t:e}=x(),h=I().shape({email:p().required(e("ERRORS.isRequired",{name:e("LABELS.email")})),password:p().required(e("ERRORS.password"))}),s=B(!1);async function f(i){s.value=!0,await u.post("auth/login",i).then(async a=>{localStorage.setItem("jwt_token_ngt_global",a.data.data.token),localStorage.setItem("ngt_global_user_data",JSON.stringify(a.data.data)),u.defaults.headers.common.Authorization=`Bearer ${a.data.data.token}`,setTimeout(()=>m.success(a.data.message),400),n.token=a.data.data.token,n.userData=a.data.data,n.user_type=a.data.data.user_type,_.is_auth=`Bearer ${a.data.data.token}`;const o=localStorage.getItem("lastPage");o?(localStorage.removeItem("lastPage"),location.href=o):(location.href="/",localStorage.removeItem("lastPage")),s.value=!1}).catch(a=>{s.value=!1,m.error(a.response.data.message)})}return(i,a)=>{const o=r("base-input"),g=r("base-password"),S=r("VeeForm");return E(),k("div",T,[l("h2",O,[y(d(t(e)("TITLES.welcomeTo"))+" ",1),l("span",null,", "+d(t(e)("TITLES.Login")),1)]),c(S,{class:"w-100",onSubmit:f,"validation-schema":t(h)},{default:A(()=>[l("div",R,[c(o,{id:"email",name:"email",placeholder:t(e)("LABELS.email"),label:t(e)("LABELS.email")},null,8,["placeholder","label"]),c(g,{id:"password",name:"password",placeholder:t(e)("LABELS.Enter",{name:t(e)("LABELS.password")}),icon:"key"},null,8,["placeholder"])]),l("button",{disabled:s.value,type:"submit",class:"base-btn w-full rounded-md mt-6"},d(t(e)("BUTTONS.login")),9,N)]),_:1},8,["validation-schema"])])}}});export{C as default};
