import{d as v,c as p,a as e,x as f,t as m,b as y,q as i,v as n,p as _,w,s as b,R as C,r as u,k as d,l as S,i as k,A as x}from"./index-DPtT_PqD.js";import{c as V}from"./customerPortalService-DOIYbhW7.js";const N={class:"portal-layout"},P={class:"portal-card form-page"},q={key:0,class:"error"},B={class:"field"},E={class:"field"},L={class:"field"},M=["disabled"],A=v({__name:"CustomerPortalLoginPage",setup(R){const c=x(),l=u(!1),r=u(""),a=u({company_slug:"",email:"",password:""});async function g(){l.value=!0,r.value="";try{const t=await V.login({company_slug:a.value.company_slug.trim(),email:a.value.email.trim(),password:a.value.password,device_name:"web-customer-portal"});localStorage.setItem("customer_portal_token",t.token),localStorage.setItem("customer_portal_account",JSON.stringify(t.account)),await c.push("/customer-portal")}catch(t){r.value=k(t,"Company, email, or password did not match.")}finally{l.value=!1}}return(t,o)=>(d(),p("main",N,[e("section",P,[o[7]||(o[7]=e("div",null,[e("p",{class:"eyebrow"},"Customer Portal"),e("h1",null,"BizNovia")],-1)),e("form",{class:"form",onSubmit:f(g,["prevent"])},[r.value?(d(),p("p",q,m(r.value),1)):y("",!0),e("div",B,[o[3]||(o[3]=e("label",{for:"company_slug"},"Company Slug",-1)),i(e("input",{id:"company_slug","onUpdate:modelValue":o[0]||(o[0]=s=>a.value.company_slug=s),autocomplete:"organization",type:"text",required:""},null,512),[[n,a.value.company_slug]])]),e("div",E,[o[4]||(o[4]=e("label",{for:"portal_email"},"Email",-1)),i(e("input",{id:"portal_email","onUpdate:modelValue":o[1]||(o[1]=s=>a.value.email=s),autocomplete:"email",type:"email",required:""},null,512),[[n,a.value.email]])]),e("div",L,[o[5]||(o[5]=e("label",{for:"portal_password"},"Password",-1)),i(e("input",{id:"portal_password","onUpdate:modelValue":o[2]||(o[2]=s=>a.value.password=s),autocomplete:"current-password",type:"password",required:""},null,512),[[n,a.value.password]])]),e("button",{class:"button primary",type:"submit",disabled:l.value},m(l.value?"Signing in...":"Login"),9,M)],32),_(b(C),{class:"button ghost",to:"/login"},{default:w(()=>[...o[6]||(o[6]=[S("Company login",-1)])]),_:1})])]))}});export{A as default};
