1import{a2 as y,a3 as b,a4 as w,m as C,o as I,r as n,j as e,L as p,B as c,a5 as u,a6 as A,a7 as S}from"./index-OkXy-d5Y.js";import{A as k,a as B}from"./alert-0QuNooNy.js";import{B as L}from"./badge-D70DEMXH.js";import{C as l,a as f,b as o,c as D,d as E,e as P}from"./card-BOYNs0rn.js";import{S as R}from"./separator-D5JjMsAa.js";import{S as m}from"./skeleton-CTnX7jIE.js";import{f as T}from"./date-utils-BapGj4Cw.js";import{U as Y,a as F}from"./teams-client-B1lQR8qa.js";import{B as z}from"./brain-miUL15Zz.js";import{L as H}from"./loader-circle-Cq8KN2OP.js";import{C as U}from"./circle-check-DAYyMIQA.js";import{C as G}from"./circle-x-Bh5g1r5S.js";async function M(t){return new y(b()).getPublicInfo({token:t})}function se(){const{token:t}=w(),r=C(),d=I(A),[a,i]=n.useState("loading"),[s,N]=n.useState(null),[g,x]=n.useState("");n.useEffect(()=>{if(!t){x("Invalid invitation link."),i("error");return}(async()=>{try{const h=await M(t);N(h),i("ready")}catch(h){x(u(h,"This invitation link is invalid or has expired.")),i("error")}})()},[t]);const v=async()=>{if(t){if(!d){S("/invitations/"+t),r("/auth/login");return}i("accepting");try{await F(t),i("accepted"),setTimeout(()=>r("/dashboard/teams",{replace:!0}),2e3)}catch(j){x(u(j,"Failed to accept invitation.")),i("error")}}};return e.jsx("div",{className:"min-h-screen flex flex-col items-center justify-center bg-muted/30 px-4",children:e.jsxs("div",{className:"w-full max-w-md",children:[e.jsx("div",{className:"flex justify-center mb-8",children:e.jsxs(p,{to:"/",className:"flex items-center gap-2",children:[e.jsx(z,{className:"h-8 w-8 text-primary"}),e.jsx("span",{className:"text-2xl",children:"Smritea"})]})}),a==="loading"&&e.jsxs(l,{children:[e.jsxs(f,{children:[e.jsx(m,{className:"h-6 w-48 mb-2"}),e.jsx(m,{className:"h-4 w-64"})]}),e.jsxs(o,{className:"space-y-3",children:[e.jsx(m,{className:"h-12 w-full"}),e.jsx(m,{className:"h-10 w-full"})]})]}),(a==="ready"||a==="accepting")&&s&&e.jsxs(l,{children:[e.jsxs(f,{className:"text-center",children:[e.jsx("div",{className:"flex justify-center mb-3",children:e.jsx("div",{className:"w-14 h-14 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(Y,{className:"h-7 w-7 text-primary"})})}),e.jsx(D,{children:"You've been invited!"}),e.jsx(E,{children:"You've been invited to join a team on Smritea"})]}),e.jsxs(o,{className:"space-y-4",children:[e.jsxs("div",{className:"bg-muted rounded-lg p-4 space-y-3",children:[!!s.teamName&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Team"}),e.jsx("span",{className:"text-sm font-medium",children:s.teamName})]}),!!s.orgName&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Organization"}),e.jsx("span",{className:"text-sm font-medium",children:s.orgName})]}),!!s.role&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Role"}),e.jsx(L,{variant:"secondary",className:"capitalize",children:s.role})]}),!!s.inviterName&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Invited by"}),e.jsx("span",{className:"text-sm",children:s.inviterName})]}),!!s.expiresAt&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Expires"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:T(s.expiresAt)})]})]}),!d&&e.jsx(k,{children:e.jsx(B,{children:"You'll need to log in or create an account to accept this invitation."})})]}),e.jsx(R,{}),e.jsxs(P,{className:"flex gap-3 pt-4",children:[e.jsx(c,{variant:"outline",className:"flex-1",onClick:()=>r("/"),disabled:a==="accepting",children:"Decline"}),e.jsx(c,{className:"flex-1",onClick:v,disabled:a==="accepting",children:a==="accepting"?e.jsxs(e.Fragment,{children:[e.jsx(H,{className:"mr-2 h-4 w-4 animate-spin"}),"Acceptingâ¦"]}):d?"Accept Invitation":"Log In to Accept"})]})]}),a==="accepted"&&e.jsx(l,{children:e.jsxs(o,{className:"flex flex-col items-center gap-4 py-10",children:[e.jsx(U,{className:"h-16 w-16 text-green-500"}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-lg font-medium",children:"Invitation Accepted!"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"You've joined the team. Redirecting to your dashboardâ¦"})]})]})}),a==="error"&&e.jsx(l,{children:e.jsxs(o,{className:"flex flex-col items-center gap-4 py-10",children:[e.jsx(G,{className:"h-16 w-16 text-destructive"}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-lg font-medium",children:"Invalid Invitation"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:g})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(c,{variant:"outline",asChild:!0,children:e.jsx(p,{to:"/",children:"Go Home"})}),e.jsx(c,{asChild:!0,children:e.jsx(p,{to:"/auth/login",children:"Sign In"})})]})]})})]})})}export{se as InvitationAcceptPage};
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.