1import{h as C,r as i,j as e,B as x,L as y,s as v,x as r,t as u}from"./index-BCGrvFuq.js";import{A as N}from"./AuthShell-BXPyFlHg.js";import{I as c}from"./input-DgtOFYLN.js";import{L as m}from"./label-opIYTMqD.js";import{s as S}from"./alerts.functions-DZop_vjM.js";import{o as A,s as l}from"./types-e6apbZGd.js";import"./index-DhMUBjnI.js";import"./auth-middleware-ret5nsuJ.js";const F=A({companyName:l().trim().min(1,"Company name is required").max(200),contactName:l().trim().min(1,"Contact name is required").max(120),email:l().trim().email("Invalid email").max(255),password:l().min(8,"At least 8 characters").max(72)});function $(){const j=C(),[s,n]=i.useState({companyName:"",contactName:"",email:"",password:""}),[p,g]=i.useState(!1),[o,b]=i.useState(null),[h,f]=i.useState(!1),w=async a=>{a.preventDefault();const t=F.safeParse(s);if(!t.success){u("form_error",{form_name:"vendor_signup",error_type:"validation",error_message:t.error.issues[0].message.slice(0,150)}),r.error(t.error.issues[0].message);return}g(!0);const{data:_,error:d}=await v.auth.signUp({email:t.data.email,password:t.data.password,options:{emailRedirectTo:`${window.location.origin}/vendors/portal`,data:{account_kind:"vendor",company_name:t.data.companyName,contact_name:t.data.contactName}}});if(g(!1),d){u("form_error",{form_name:"vendor_signup",error_type:"auth",error_message:d.message.slice(0,150)}),r.error(d.message);return}if(u("sign_up",{method:"email",form_name:"vendor_signup"}),S({data:{type:"vendor_signup",email:t.data.email,companyName:t.data.companyName,contactName:t.data.contactName}}).catch(()=>{}),!_.session){b(t.data.email),r.success("Account created. Check your email to confirm.");return}r.success("Account created. Welcome!"),j({to:"/vendors/portal"})},k=async()=>{if(!o)return;f(!0);const{error:a}=await v.auth.resend({type:"signup",email:o,options:{emailRedirectTo:`${window.location.origin}/vendors/portal`}});f(!1),a?r.error(a.message):r.success("Confirmation email sent again.")};return o?e.jsx(N,{title:"Confirm your email",subtitle:`We sent a confirmation link to ${o}.`,footer:e.jsxs(e.Fragment,{children:["Already confirmed?"," ",e.jsx(y,{to:"/vendors/login",className:"font-bold text-navy underline-offset-4 hover:underline",children:"Sign in"})]}),children:e.jsxs("div",{className:"space-y-5",children:[e.jsx("p",{className:"text-sm text-ink/75 leading-relaxed",children:"Click the link in that email to activate your vendor account. Until then you won't be able to sign in or start your vendor packet. Check your spam folder if it hasn't arrived in a few minutes."}),e.jsx(x,{type:"button",onClick:k,disabled:h,className:"w-full bg-gold text-ink hover:bg-gold-bright uppercase tracking-wider text-xs font-bold",children:h?"Sendingâ¦":"Resend confirmation email"})]})}):e.jsx(N,{title:"Vendor sign up",subtitle:"Create your account to start your vendor packet.",footer:e.jsxs(e.Fragment,{children:["Already have an account?"," ",e.jsx(y,{to:"/vendors/login",className:"font-bold text-navy underline-offset-4 hover:underline",children:"Sign in"})]}),children:e.jsxs("form",{onSubmit:w,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{htmlFor:"companyName",children:"Company name"}),e.jsx(c,{id:"companyName",value:s.companyName,onChange:a=>n({...s,companyName:a.target.value}),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{htmlFor:"contactName",children:"Your name"}),e.jsx(c,{id:"contactName",value:s.contactName,onChange:a=>n({...s,contactName:a.target.value}),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{htmlFor:"email",children:"Business email"}),e.jsx(c,{id:"email",type:"email",value:s.email,onChange:a=>n({...s,email:a.target.value}),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{htmlFor:"password",children:"Password"}),e.jsx(c,{id:"password",type:"password",value:s.password,onChange:a=>n({...s,password:a.target.value}),required:!0,minLength:8}),e.jsx("p",{className:"text-xs text-ink/75",children:"At least 8 characters."})]}),e.jsx(x,{type:"submit",disabled:p,className:"w-full bg-gold text-ink hover:bg-gold-bright uppercase tracking-wider text-xs font-bold",children:p?"Creating accountâ¦":"Create account"})]})})}export{$ as component};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.