import{Q as h,_ as w}from"./logo-BSuvTd_7.js";import{ay 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,az as g,V,a8 as _,aA as L}from"./index-B9fjtFx2.js";import{Q as S}from"./QForm-BQcaYWC4.js";import{Q as k}from"./QPage-BGDlek_a.js";import{b as q,c as P}from"./QLayout-CjCkJmQp.js";import{a as R,M as F}from"./main-Bisw-J6k.js";import{_ as U}from"./_plugin-vue_export-helper-DlAUqK2U.js";import"./index-CxGn7mLN.js";const z=R.create({baseURL:"/admin-api"});class B{login(s,d){return new Promise((m,u)=>{z.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 B().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(),C=_({name:"LoginPage",computed:{...L(c,["organization","username","password","loading","error"])},methods:{async login(){await this.$refs.form.validate()&&f.login()}},mounted(){f.resetForm()}}),K={class:"row full-width"},N={class:"col-10 offset-1 col-sm-8 offset-sm-2 col-md-4 offset-md-4 col-lg-2 offset-lg-5"},A={class:"text-h5 text-center q-my-md text-grey-9"},D={class:"row"},E={class:"col-12 q-mt-md q-mb-lg"},W={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",K,[t("div",N,[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",A,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",D,[t("div",E,[o(V,{onClick:s[4]||(s[4]=r=>e.login()),class:"full-width",color:"primary",loading:e.loading},{default:a(()=>[t("span",W,i(e.$t("login")),1)]),_:1},8,["loading"])])])]),_:1},512)])])]),_:1})]),_:1})]),_:1})}const Y=U(C,[["render",I]]);export{Y as default};
