PageSourceSearch

https://toolvault.ai/assets/vendor-join-DAcZzndh.js

js toolvault.ai collected 2026-10-05 14:07:08 UTC 5,062 bytes, 1 lines download raw bytes

1import{j as e}from"./vendor-ui-DtCdGaG4.js";import{r as b}from"./vendor-react-DZFBK4sO.js";import{u as E,Q as L,f as I,R as S,C as h,p as f,q as v,_ as C,X as F,g as P,U as q,I as o,B as A,Y as T,o as R}from"./index--3Xg_vtW.js";import{u as M,d as V}from"./vendor-query-9w98Z1zS.js";import{u as $,t as Y,o as B,s as t}from"./types-BG97ADp0.js";import{F as J,a as d,b as c,c as m,d as l,e as u}from"./form-S_kQwmwD.js";import{A as O,b as Q}from"./alert-Cad9U3v1.js";import"./vendor-react-select-BVE5w0d3.js";import"./vendor-motion-DVh8ie-F.js";import"./label-CoGo4-Dp.js";const D=B({firstName:t().min(1,"First name is required"),lastName:t().min(1,"Last name is required"),password:t().min(8,"Password must be at least 8 characters"),confirmPassword:t().min(1,"Please confirm your password")}).refine(n=>n.password===n.confirmPassword,{message:"Passwords do not match",path:["confirmPassword"]});function re(){const[,n]=E(),w=L(),{toast:N}=I(),r=b.useMemo(()=>new URLSearchParams(w).get("token"),[w]),{isAuthenticated:y,login:k}=S();b.useEffect(()=>{y&&n("/vendor/dashboard")},[y,n]);const a=$({resolver:Y(D),defaultValues:{firstName:"",lastName:"",password:"",confirmPassword:""}}),{data:i,isLoading:U,error:p}=M({queryKey:["/api/vendor/user-invite",r],queryFn:async()=>{if(!r)throw new Error("No token provided");const s=await fetch(`/api/vendor/user-invite/${encodeURIComponent(r)}`);if(!s.ok){const g=await s.json();throw new Error(g.message??"Invalid invitation")}return await s.json()},enabled:!!r,retry:!1}),x=V({mutationFn:async s=>{if(!r)throw new Error("No token provided");return await(await R("POST","/api/vendor/user-invite/accept",{token:r,password:s.password,firstName:s.firstName,lastName:s.lastName})).json()},onSuccess:async s=>{N({title:"Welcome to the team",description:`You're now part of ${s.vendor.companyName}.`}),k({token:s.token,vendor:s.vendor,vendorUser:s.vendorUser}),T(s.vendor.id,{displayName:`${s.vendorUser.firstName} ${s.vendorUser.lastName}`,email:s.vendorUser.email,companyName:s.vendor.companyName??""}),n("/vendor/dashboard/analytics")},onError:s=>{N({title:"Could not join",description:s.message,variant:"destructive"})}});if(!r)return e.jsx("div",{className:"min-h-screen bg-muted flex items-center justify-center p-4",children:e.jsx(h,{className:"max-w-md w-full","data-testid":"vendor-join-invalid-link",children:e.jsxs(f,{children:[e.jsx(v,{children:"Invalid link"}),e.jsx(C,{children:"Open the invitation link from your email."})]})})});if(U)return e.jsx("div",{className:"min-h-screen bg-muted flex items-center justify-center",children:e.jsx(F,{className:"h-8 w-8 animate-spin text-muted-foreground"})});if(p||!(i!=null&&i.valid))return e.jsx("div",{className:"min-h-screen bg-muted flex items-center justify-center p-4",children:e.jsxs(h,{className:"max-w-md w-full","data-testid":"vendor-join-unavailable",children:[e.jsx(f,{children:e.jsx(v,{children:"Invitation unavailable"})}),e.jsx(P,{children:e.jsx(O,{variant:"destructive",children:e.jsx(Q,{children:p instanceof Error?p.message:"This invitation is invalid or has expired."})})})]})});const j=i.invite;return e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-background to-muted/60 flex items-center justify-center p-4",children:e.jsxs(h,{className:"max-w-md w-full shadow-lg border-border/80","data-testid":"vendor-join-accept-card",children:[e.jsxs(f,{className:"text-center space-y-2",children:[e.jsx("div",{className:"mx-auto flex h-12 w-12 items-center justify-center rounded-full bg-primary/10 text-primary",children:e.jsx(q,{className:"h-6 w-6"})}),e.jsxs(v,{children:["Join ",j.companyName]}),e.jsxs(C,{children:["You've been invited as"," ",e.jsx("span",{className:"font-medium text-foreground",children:j.role})," (",j.email,")"]})]}),e.jsx(P,{children:e.jsx(J,{...a,children:e.jsxs("form",{onSubmit:a.handleSubmit(s=>x.mutate(s)),className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(d,{control:a.control,name:"firstName",render:({field:s})=>e.jsxs(c,{children:[e.jsx(m,{children:"First name"}),e.jsx(l,{children:e.jsx(o,{autoComplete:"given-name",...s})}),e.jsx(u,{})]})}),e.jsx(d,{control:a.control,name:"lastName",render:({field:s})=>e.jsxs(c,{children:[e.jsx(m,{children:"Last name"}),e.jsx(l,{children:e.jsx(o,{autoComplete:"family-name",...s})}),e.jsx(u,{})]})})]}),e.jsx(d,{control:a.control,name:"password",render:({field:s})=>e.jsxs(c,{children:[e.jsx(m,{children:"Password"}),e.jsx(l,{children:e.jsx(o,{type:"password",autoComplete:"new-password",...s})}),e.jsx(u,{})]})}),e.jsx(d,{control:a.control,name:"confirmPassword",render:({field:s})=>e.jsxs(c,{children:[e.jsx(m,{children:"Confirm password"}),e.jsx(l,{children:e.jsx(o,{type:"password",autoComplete:"new-password",...s})}),e.jsx(u,{})]})}),e.jsx(A,{type:"submit",className:"w-full",disabled:x.isPending,"data-testid":"vendor-join-accept-submit",children:x.isPending?e.jsxs(e.Fragment,{children:[e.jsx(F,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating account…"]}):"Accept invitation"})]})})})]})})}export{re as default};

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.