import{Q as f,_ as g}from"./logo-BSuvTd_7.js";import{R as y,S as h,T as i,U as t,W as l,X as d,j as w,ab as $,a4 as m,az as u,V as c,a8 as b}from"./index-B9fjtFx2.js";import{Q as V}from"./QSelect-DZN0Es7P.js";import{Q as v}from"./QForm-BQcaYWC4.js";import{Q}from"./QPage-BGDlek_a.js";import{b as q,c as R}from"./QLayout-CjCkJmQp.js";import{a as k,M as T}from"./main-Bisw-J6k.js";import{_ as U}from"./_plugin-vue_export-helper-DlAUqK2U.js";import"./format-Syc_4mV3.js";import"./index-CxGn7mLN.js";const z=k.create({baseURL:"/admin-api"});class N{register(s){return new Promise((o,p)=>{z.post("/register",s).then(n=>{o(n.data)}).catch(n=>{p(n)})})}}const a=T(),P=b({name:"RegisterPage",data(){return{form:{email:"",fullName:"",clientType:"",password:""},loading:!1,error:"",clientTypeOptions:[{label:this.$t("personal"),value:"personal"},{label:this.$t("company"),value:"company"}]}},methods:{async register(){if(await this.$refs.form.validate()){this.loading=!0,this.error="";try{const o=await new N().register(this.form);a.branding.registrationCompleted=!0,await a.saveAuthData(o.access_token,o.username),a.changePage("/")}catch(s){s.code==="ERR_NETWORK"?this.error=a.translate("network_error"):s.response&&s.response.data&&s.response.data.code_error?this.error=a.translate(s.response.data.code_error):this.error=a.translate("unknown_error")}finally{this.loading=!1}}}}}),S={class:"row full-width"},C={class:"col-10 offset-1 col-sm-8 offset-sm-2 col-md-4 offset-md-4 col-lg-2 offset-lg-5"},B={class:"text-h5 text-center q-my-md text-grey-9"},K={class:"row"},A={class:"col-12 q-mt-md q-mb-lg"},D={class:"q-mr-xs"};function L(e,s,o,p,n,O){return y(),h(R,{class:"bg-white",view:"lHh Lpr lFf"},{default:i(()=>[t(q,null,{default:i(()=>[t(Q,{class:"flex flex-center"},{default:i(()=>[l("div",S,[l("div",C,[t(v,{ref:"form",greedy:""},{default:i(()=>[t(f,{"error-src":g,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"]),l("div",B,d(e.$t("register_title")),1),w(l("p",{class:"text-negative text-center"},d(e.error),513),[[$,e.error]]),t(m,{modelValue:e.form.email,"onUpdate:modelValue":s[0]||(s[0]=r=>e.form.email=r),type:"email",label:e.$t("email")+" *","lazy-rules":"",rules:[r=>r&&r.length>0||e.$t("required_field"),r=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(r)||e.$t("invalid_email")]},null,8,["modelValue","label","rules"]),t(m,{modelValue:e.form.fullName,"onUpdate:modelValue":s[1]||(s[1]=r=>e.form.fullName=r),label:e.$t("full_name")+" *","lazy-rules":"",rules:[r=>r&&r.length>0||e.$t("required_field")]},null,8,["modelValue","label","rules"]),t(V,{modelValue:e.form.clientType,"onUpdate:modelValue":s[2]||(s[2]=r=>e.form.clientType=r),options:e.clientTypeOptions,label:e.$t("client_type")+" *","emit-value":"","map-options":"","lazy-rules":"",rules:[r=>!!r||e.$t("required_field")]},null,8,["modelValue","options","label","rules"]),t(m,{modelValue:e.form.password,"onUpdate:modelValue":s[3]||(s[3]=r=>e.form.password=r),type:"password",label:e.$t("password")+" *","lazy-rules":"",rules:[r=>r&&r.length>0||e.$t("required_field"),r=>r&&r.length>=8&&/[A-Z]/.test(r)&&/[a-z]/.test(r)&&/[0-9]/.test(r)||e.$t("password_policy")],onKeyup:s[4]||(s[4]=u(r=>e.register(),["enter"]))},null,8,["modelValue","label","rules"]),l("div",K,[l("div",A,[t(c,{onClick:s[5]||(s[5]=r=>e.register()),class:"full-width q-mt-md",color:"primary",loading:e.loading,onKeyup:s[6]||(s[6]=u(r=>e.register(),["enter"]))},{default:i(()=>[l("span",D,d(e.$t("register")),1)]),_:1},8,["loading"])])])]),_:1},512)])])]),_:1})]),_:1})]),_:1})}const G=U(P,[["render",L]]);export{G as default};
