1import{j as e}from"./index-COia_u_c.js";import{u as w,Z as C,r as c,L as k,B as d}from"./error-boundary-f1in_24u.js";import{C as I,b as i,c as r,d as n,a as m}from"./card-9FFZVsXh.js";import{S}from"./seo-CDtyH7-O.js";import{U as L}from"./user-plus-l3b4peFW.js";import{C as p}from"./circle-x-WaO1jlO2.js";import{C as P}from"./circle-check-big-C2leDo0B.js";function M(){const[,j]=w(),g=C(),l=new URLSearchParams(g).get("invite"),[t,s]=c.useState("loading"),[N,b]=c.useState(""),[x,a]=c.useState("");c.useEffect(()=>{if(!l){s("invalid"),a("No invite token provided");return}async function y(){try{const o=await fetch(`/api/referrals/validate/${encodeURIComponent(l)}`,{credentials:"include"}),u=await o.json().catch(()=>({valid:!1,error:"Unable to parse response"}));if(!o.ok||!u.valid){const h=u.error||"Invalid invite link";h.toLowerCase().includes("expired")?(s("expired"),a("This invite link has expired")):h.toLowerCase().includes("already been used")?(s("already_joined"),a("This invite has already been used")):(s("invalid"),a(h));return}b(u.inviterName||"A friend"),s("valid"),localStorage.setItem("referral_invite_token",l)}catch(o){console.error("Error validating invite:",o),s("invalid"),a("Unable to validate invite link")}}y()},[l]);const v=()=>{j("/login")},f=()=>{j("/")};return e.jsxs(e.Fragment,{children:[e.jsx(S,{title:"Join usplus.ai - Human-AI Collaboration Platform",description:"You've been invited to join usplus.ai, a platform for human-AI collaboration on missions that matter."}),e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4","data-testid":"join-page-container",children:e.jsxs(I,{className:"w-full max-w-md","data-testid":"join-card",children:[t==="loading"&&e.jsx(e.Fragment,{children:e.jsxs(i,{className:"text-center",children:[e.jsx("div",{className:"mx-auto mb-4",children:e.jsx(k,{className:"h-12 w-12 animate-spin text-primary"})}),e.jsx(r,{children:"Validating Invite"}),e.jsx(n,{children:"Please wait while we verify your invitation..."})]})}),t==="valid"&&e.jsxs(e.Fragment,{children:[e.jsxs(i,{className:"text-center",children:[e.jsx("div",{className:"mx-auto mb-4",children:e.jsx("div",{className:"h-16 w-16 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(L,{className:"h-8 w-8 text-primary"})})}),e.jsx(r,{className:"text-2xl",children:"You're Invited!"}),e.jsxs(n,{className:"text-base",children:[e.jsx("span",{className:"font-medium text-foreground",children:N})," has invited you to join usplus.ai"]})]}),e.jsxs(m,{className:"space-y-4",children:[e.jsx("p",{className:"text-center text-muted-foreground text-sm",children:"usplus.ai is a platform for human-AI collaboration on missions that matter. Create campaigns, join communities, and work with AI to achieve your goals."}),e.jsx(d,{className:"w-full",size:"lg",onClick:v,"data-testid":"button-get-started",children:"Get Started"})]})]}),t==="expired"&&e.jsxs(e.Fragment,{children:[e.jsxs(i,{className:"text-center",children:[e.jsx("div",{className:"mx-auto mb-4",children:e.jsx("div",{className:"h-16 w-16 rounded-full bg-orange-100 dark:bg-orange-900/20 flex items-center justify-center",children:e.jsx(p,{className:"h-8 w-8 text-orange-500"})})}),e.jsx(r,{children:"Invite Expired"}),e.jsx(n,{children:x})]}),e.jsxs(m,{className:"space-y-4",children:[e.jsx("p",{className:"text-center text-muted-foreground text-sm",children:"Invite links expire after a certain period for security. Please ask your friend to send you a new invite."}),e.jsx(d,{variant:"outline",className:"w-full",onClick:f,"data-testid":"button-go-home",children:"Go to Homepage"})]})]}),t==="already_joined"&&e.jsxs(e.Fragment,{children:[e.jsxs(i,{className:"text-center",children:[e.jsx("div",{className:"mx-auto mb-4",children:e.jsx("div",{className:"h-16 w-16 rounded-full bg-green-100 dark:bg-green-900/20 flex items-center justify-center",children:e.jsx(P,{className:"h-8 w-8 text-green-500"})})}),e.jsx(r,{children:"Already a Member!"}),e.jsx(n,{children:x})]}),e.jsxs(m,{className:"space-y-4",children:[e.jsx("p",{className:"text-center text-muted-foreground text-sm",children:"Good news - you're already part of the usplus.ai community!"}),e.jsx(d,{className:"w-full",onClick:v,"data-testid":"button-login",children:"Log In"})]})]}),t==="invalid"&&e.jsxs(e.Fragment,{children:[e.jsxs(i,{className:"text-center",children:[e.jsx("div",{className:"mx-auto mb-4",children:e.jsx("div",{className:"h-16 w-16 rounded-full bg-destructive/10 flex items-center justify-center",children:e.jsx(p,{className:"h-8 w-8 text-destructive"})})}),e.jsx(r,{children:"Invalid Invite"}),e.jsx(n,{children:x})]}),e.jsxs(m,{className:"space-y-4",children:[e.jsx("p",{className:"text-center text-muted-foreground text-sm",children:"This invite link appears to be invalid. Please check the link or request a new invite."}),e.jsx(d,{variant:"outline",className:"w-full",onClick:f,"data-testid":"button-go-home-invalid",children:"Go to Homepage"})]})]})]})})]})}export{M 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.