PageSourceSearch

https://ghostd.ai/assets/SeatInviteAccept-rJsub8eV.js

js ghostd.ai collected 2026-10-05 12:53:01 UTC 7,064 bytes, 1 lines download raw bytes

1import{bJ as L,bZ as S,bq as p,bP as E,bK as I,bh as e,C as r,m,n as x,l as u,k as c,j as d,aI as j,bw as A,a3 as b,bn as v,aT as P,t as U}from"./index-c8i37G0q.js";import{a as R}from"./PublicLayout-C8mLfScD.js";import{U as f}from"./user-plus-E90vJ7vr.js";function Y(){const[,a]=L(),{data:t,isLoading:w}=S(),[o,N]=p.useState(null);p.useEffect(()=>{const h=new URLSearchParams(window.location.search);N(h.get("token"))},[]);const{data:n,isLoading:y,error:g}=E({queryKey:[`/api/account/seats/accept?token=${o}`],enabled:!!o}),i=I({mutationFn:async()=>(await P("POST","/api/account/seats/accept",{token:o})).json(),onSuccess:()=>{v.invalidateQueries({queryKey:["/api/auth/me"]}),v.invalidateQueries({queryKey:["/api/projects"]}),a("/app/dashboard")}}),l=g?g?.message||"This invitation is no longer valid.":null;p.useEffect(()=>{t&&typeof l=="string"&&l.toLowerCase().includes("already accepted")&&a("/app/dashboard")},[l,t,a]);const k=!!(t&&n?.invitedEmail&&t.email?.toLowerCase()!==n.invitedEmail.toLowerCase()),C=!!(t&&t.accountSeatRole==="member");let s;if(!o)s=e.jsx(r,{className:"max-w-md w-full",children:e.jsxs(c,{className:"pt-6 text-center",children:[e.jsx(j,{className:"h-10 w-10 mx-auto text-muted-foreground/40 mb-3"}),e.jsx("p",{className:"text-sm text-muted-foreground","data-testid":"text-no-seat-token",children:"No invitation token found. Please use the link from your invitation email."})]})});else if(y||w)s=e.jsx(b,{className:"h-8 w-8 animate-spin text-primary"});else if(l&&!l.toLowerCase().includes("already accepted"))s=e.jsxs(r,{className:"max-w-md w-full",children:[e.jsxs(m,{className:"text-center",children:[e.jsx("div",{className:"flex justify-center mb-3",children:e.jsx("div",{className:"h-12 w-12 rounded-full bg-destructive/10 flex items-center justify-center",children:e.jsx(j,{className:"h-6 w-6 text-destructive"})})}),e.jsx(x,{"data-testid":"text-seat-invite-error-title",children:"Invitation Unavailable"}),e.jsx(u,{"data-testid":"text-seat-invite-error-message",children:l})]}),e.jsx(c,{className:"text-center",children:e.jsx(d,{variant:"outline",onClick:()=>a(t?"/app/dashboard":"/login"),"data-testid":"button-seat-go-login",children:t?"Go to Dashboard":"Go to Login"})})]});else if(t)k?s=e.jsxs(r,{className:"max-w-md w-full",children:[e.jsxs(m,{className:"text-center",children:[e.jsx("div",{className:"flex justify-center mb-3",children:e.jsx("div",{className:"h-12 w-12 rounded-full bg-amber-100 dark:bg-amber-900/30 flex items-center justify-center",children:e.jsx(j,{className:"h-6 w-6 text-amber-600 dark:text-amber-400"})})}),e.jsx(x,{"data-testid":"text-seat-invite-error-title",children:"Wrong account"}),e.jsxs(u,{className:"mt-2","data-testid":"text-seat-invite-error-message",children:["You're signed in as ",e.jsx("strong",{children:t.email}),". This invite was sent to ",e.jsx("strong",{children:n?.invitedEmail}),". Sign out and sign in with the correct address to accept."]})]}),e.jsxs(c,{className:"flex flex-col items-center gap-3",children:[e.jsx(d,{onClick:async()=>{await A.auth.signOut(),a(`/login?redirect=${encodeURIComponent(`/invite/seat?token=${o}`)}`)},"data-testid":"button-seat-sign-out-invite",children:"Sign out and switch account"}),e.jsx(d,{variant:"ghost",className:"text-xs text-muted-foreground",onClick:()=>a("/app/dashboard"),"data-testid":"button-seat-go-app",children:"Continue with current account"})]})]}):C?s=e.jsxs(r,{className:"max-w-md w-full",children:[e.jsxs(m,{className:"text-center",children:[e.jsx("div",{className:"flex justify-center mb-3",children:e.jsx("div",{className:"h-12 w-12 rounded-full bg-amber-100 dark:bg-amber-900/30 flex items-center justify-center",children:e.jsx(j,{className:"h-6 w-6 text-amber-600 dark:text-amber-400"})})}),e.jsx(x,{"data-testid":"text-seat-already-member-title",children:"Already in a workspace"}),e.jsx(u,{className:"mt-2","data-testid":"text-seat-already-member-message",children:"You're already a member of another Ghostd workspace. You can only belong to one workspace at a time. Leave your current workspace before accepting a new invitation."})]}),e.jsx(c,{className:"text-center",children:e.jsx(d,{variant:"outline",onClick:()=>a("/app/dashboard"),"data-testid":"button-seat-already-member-dashboard",children:"Go to Dashboard"})})]}):i.isSuccess?s=e.jsx(r,{className:"max-w-md w-full",children:e.jsxs(c,{className:"pt-6 text-center space-y-3",children:[e.jsx(U,{className:"h-10 w-10 mx-auto text-green-500"}),e.jsx("p",{className:"font-semibold","data-testid":"text-seat-invite-accepted",children:"Invitation Accepted"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Redirecting to your workspace…"})]})}):s=e.jsxs(r,{className:"max-w-md w-full",children:[e.jsxs(m,{className:"text-center",children:[e.jsx("div",{className:"flex justify-center mb-3",children:e.jsx("div",{className:"h-12 w-12 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(f,{className:"h-6 w-6 text-primary"})})}),e.jsxs(x,{"data-testid":"text-seat-invite-title",children:["Join ",n?.ownerName,"'s Workspace"]}),e.jsxs(u,{children:[e.jsx("strong",{children:n?.ownerName})," has invited you to collaborate on their Ghostd workspace."]})]}),e.jsxs(c,{className:"text-center space-y-4",children:[i.isError&&e.jsx("p",{className:"text-sm text-destructive","data-testid":"text-seat-accept-error",children:i.error?.message==="wrong_account"?"You're signed in with a different account. Sign out and use the email this invite was sent to.":i.error?.message==="already_member"?"You're already a member of another workspace. Leave it before accepting a new invitation.":i.error?.message||"Failed to accept invitation."}),e.jsxs(d,{onClick:()=>i.mutate(),disabled:i.isPending,"data-testid":"button-accept-seat-invite",children:[i.isPending?e.jsx(b,{className:"h-4 w-4 animate-spin mr-2"}):e.jsx(f,{className:"h-4 w-4 mr-2"}),"Accept Invitation"]})]})]});else{const h=`/invite/seat?token=${o}`;s=e.jsxs(r,{className:"max-w-md w-full",children:[e.jsxs(m,{className:"text-center",children:[e.jsx("div",{className:"flex justify-center mb-3",children:e.jsx("div",{className:"h-12 w-12 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(f,{className:"h-6 w-6 text-primary"})})}),e.jsx(x,{"data-testid":"text-seat-invite-login-title",children:"Worksp
1ace Invitation"}),e.jsxs(u,{children:[e.jsx("strong",{children:n?.ownerName})," has invited you to collaborate on their Ghostd workspace."]})]}),e.jsxs(c,{className:"text-center space-y-3",children:[e.jsxs("p",{className:"text-sm text-muted-foreground","data-testid":"text-seat-invite-email-hint",children:["Sign in or create an account using ",e.jsx("strong",{children:n?.invitedEmail})," to accept."]}),e.jsx(d,{onClick:()=>a(`/login?redirect=${encodeURIComponent(h)}`),"data-testid":"button-seat-invite-login",children:"Sign In to Accept"})]})]})}return e.jsxs("div",{className:"min-h-screen flex flex-col bg-background",children:[e.jsx(R,{}),e.jsx("div",{className:"flex-1 flex items-center justify-center p-4",children:s})]})}export{Y 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.