import{Q as h,_ as w}from"./logo-eHoYB6sL.js";import{aX as y,R as $,S as b,T as a,U as o,W as t,X as i,j as v,ab as Q,a4 as p,aY as g,V,a8 as _,aZ as L}from"./index-CRkL0E25.js";import{Q as S}from"./QForm-Bt9zuRZK.js";import{Q as k}from"./QPage-BQvLN6qt.js";import{b as q,c as P}from"./QLayout-DrzGiLUc.js";import{a as R,M as F}from"./main-B2ajQvEX.js";import{_ as U}from"./_plugin-vue_export-helper-DlAUqK2U.js";import"./index-JQkw9yeP.js";const B=R.create({baseURL:"/admin-api"});class C{login(s,d){return new Promise((m,u)=>{B.post("/login",{username:s,password:d}).then(l=>{m(l.data)}).catch(l=>{u(l)})})}}const n=F(),c=y("LoginStore",{state:()=>({username:"",password:"",loading:!1,error:""}),getters:{},actions:{async login(){this.loading=!0,this.error="";try{const s=await new C().login(this.username,this.password);n.saveAuthData(s.access_token,s.username),this.resetForm(),n.changePage("/")}catch(e){console.log("Error: ",e),e.code=="ERR_NETWORK"?this.error=n.translate("network_error"):e.response&&e.response.data?this.error=n.translate(e.response.data.code_error):this.error=n.translate("unknown_error")}finally{this.loading=!1}},resetForm(){this.username="",this.password="",this.error="",this.email="",this.message=""}}}),f=c(),K=_({name:"LoginPage",computed:{...L(c,["organization","username","password","loading","error"])},methods:{async login(){await this.$refs.form.validate()&&f.login()}},mounted(){f.resetForm()}}),N={class:"row full-width"},z={class:"col-10 offset-1 col-sm-8 offset-sm-2 col-md-4 offset-md-4 col-lg-2 offset-lg-5"},D={class:"text-h5 text-center q-my-md text-grey-9"},E={class:"row"},W={class:"col-12 q-mt-md q-mb-lg"},A={class:"q-mr-xs"};function I(e,s,d,m,u,l){return $(),b(P,{class:"bg-white",view:"lHh Lpr lFf"},{default:a(()=>[o(q,null,{default:a(()=>[o(k,{class:"flex flex-center"},{default:a(()=>[t("div",N,[t("div",z,[o(S,{ref:"form",greedy:""},{default:a(()=>[o(h,{"error-src":w,src:e.$store.branding.logoUrl,class:"items-center",style:{height:"80px","max-width":"80px",display:"block","margin-left":"auto","margin-right":"auto"}},null,8,["src"]),t("div",D,i(e.$store.branding.appName),1),v(t("p",{class:"text-negative text-center"},i(e.error),513),[[Q,e.error]]),o(p,{modelValue:e.username,"onUpdate:modelValue":s[0]||(s[0]=r=>e.username=r),onKeyup:s[1]||(s[1]=g(r=>e.login(),["enter"])),autocomplete:"username",label:e.$t("username")+" *","lazy-rules":"",rules:[r=>r&&r.length>0||e.$t("required_field")]},null,8,["modelValue","label","rules"]),o(p,{type:"password",onKeyup:s[2]||(s[2]=g(r=>e.login(),["enter"])),modelValue:e.password,"onUpdate:modelValue":s[3]||(s[3]=r=>e.password=r),autocomplete:"current-password",label:e.$t("password")+" *","lazy-rules":"",rules:[r=>r&&r.length>0||e.$t("required_field")]},null,8,["modelValue","label","rules"]),t("div",E,[t("div",W,[o(V,{onClick:s[4]||(s[4]=r=>e.login()),class:"full-width",color:"primary",loading:e.loading},{default:a(()=>[t("span",A,i(e.$t("login")),1)]),_:1},8,["loading"])])])]),_:1},512)])])]),_:1})]),_:1})]),_:1})}const G=U(K,[["render",I]]);export{G as default};
