1import{a as L,aX as R,t as V,r,aP as P,H as v,aD as c,j as e,h as l,l as o,L as N,i as m,k as u,p as g,b as n,M as w,aJ as S}from"./index-DXw5IyQz.js";import{H as D}from"./heart-CsBP8gML.js";function A(){const[,t]=L(),[H,T]=R("/invite"),{user:d,isLoading:x}=V(),[s,y]=r.useState(null),[h,f]=r.useState(!1),[b,k]=r.useState(!0);P({backgroundColor:"#ff0083"});const p=new URLSearchParams(window.location.search),a=p.get("token");p.get("from"),r.useEffect(()=>{if(!a){t("/community");return}I()},[a]);const I=async()=>{try{const i=await v("GET",`/api/invite/validate?token=${encodeURIComponent(a)}`);i.success&&i.invitation?(y(i.invitation),d&&!x&&await j()):(c({title:"Ongeldige uitnodiging",description:"Deze uitnodiging is verlopen of ongeldig.",variant:"destructive"}),t("/community"))}catch(i){console.error("[INVITE HANDLER] Error validating invitation:",i),c({title:"Fout",description:"Er ging iets mis bij het valideren van de uitnodiging.",variant:"destructive"}),t("/community")}finally{k(!1)}},j=async()=>{if(!(!a||!d)){f(!0);try{const i=await v("POST","/api/invite/accept",{token:a});if(i.success)c({title:"Vriendschapsverzoek ontvangen!",description:`Je hebt een vriendschapsverzoek ontvangen van ${s==null?void 0:s.inviterName}`}),t("/community?tab=requests");else throw new Error(i.message||"Er ging iets mis")}catch(i){console.error("[INVITE HANDLER] Error processing invitation:",i),c({title:"Fout",description:i.message||"Er ging iets mis bij het verwerken van de uitnodiging.",variant:"destructive"})}finally{f(!1)}}},C=()=>{localStorage.setItem("pendingInviteToken",a),t("/auth")},E=()=>{localStorage.setItem("pendingInviteToken",a),t(`/auth?mode=register&email=${encodeURIComponent((s==null?void 0:s.inviterEmail)||"")}`)};return b||x?e.jsx("div",{className:"min-h-screen-safe bg-gradient-to-br from-primary to-primary/80 flex items-center justify-center p-4",children:e.jsx(l,{className:"w-full max-w-md",children:e.jsxs(o,{className:"flex flex-col items-center justify-center py-8",children:[e.jsx(N,{className:"h-8 w-8 animate-spin text-primary mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"Uitnodiging valideren..."})]})})}):!s||!s.isValid?e.jsx("div",{className:"min-h-screen-safe bg-gradient-to-br from-primary to-primary/80 flex items-center justify-center p-4",children:e.jsxs(l,{className:"w-full max-w-md",children:[e.jsxs(m,{className:"text-center",children:[e.jsx(u,{className:"text-destructive",children:"Ongeldige uitnodiging"}),e.jsx(g,{children:"Deze uitnodiging is verlopen of ongeldig."})]}),e.jsx(o,{children:e.jsx(n,{onClick:()=>t("/community"),className:"w-full",children:"Naar Community"})})]})}):d?e.jsx("div",{className:"min-h-screen-safe bg-gradient-to-br from-primary to-primary/80 flex items-center justify-center p-4",children:e.jsxs(l,{className:"w-full max-w-md",children:[e.jsxs(m,{className:"text-center",children:[e.jsx("div",{className:"w-16 h-16 bg-primary/10 rounded-full flex items-center justify-center mx-auto mb-4",children:e.jsx(D,{className:"h-8 w-8 text-primary"})}),e.jsx(u,{children:"Vriendschapsuitnodiging"}),e.jsxs(g,{children:[s.inviterName," heeft je uitgenodigd om vrienden te worden op Brinqs!"]})]}),e.jsxs(o,{className:"space-y-4",children:[s.message&&e.jsx("div",{className:"bg-muted/50 p-4 rounded-lg",children:e.jsxs("p",{className:"text-sm italic",children:['"',s.message,'"']})}),e.jsx(n,{onClick:j,disabled:h,className:"w-full",children:h?e.jsxs(e.Fragment,{children:[e.jsx(N,{className:"h-4 w-4 animate-spin mr-2"}),"Verwerken..."]}):e.jsxs(e.Fragment,{children:[e.jsx(w,{className:"h-4 w-4 mr-2"}),"Vriendschapsverzoek accepteren"]})}),e.jsx(n,{variant:"outline",onClick:()=>t("/community"),className:"w-full",children:"Later beslissen"})]})]})}):e.jsx("div",{className:"min-h-screen-safe bg-gradient-to-br from-primary to-primary/80 flex items-center justify-center p-4",children:e.jsxs(l,{className:"w-full max-w-md",children:[e.jsxs(m,{className:"text-center",children:[e.jsx("div",{className:"text-4xl font-bold text-white mb-2",children:"Brinqs"}),e.jsx(u,{children:"Je bent uitgenodigd!"}),e.jsxs(g,{children:[s.inviterName," heeft je uitgenodigd om lid te worden van Brinqs"]})]}),e.jsxs(o,{className:"space-y-4",children:[s.message&&e.jsx("div",{className:"bg-muted/50 p-4 rounded-lg",children:e.jsxs("p",{className:"text-sm italic",children:['"',s.message,'"']})}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs(n,{onClick:E,className:"w-full",children:[e.jsx(w,{className:"h-4 w-4 mr-2"}),"Account aanmaken"]}),e.jsxs(n,{variant:"outline",onClick:C,className:"w-full",children:[e.jsx(S,{className:"h-4 w-4 mr-2"}),"Inloggen met bestaand account"]})]}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"Door je aan te melden ga je akkoord met onze voorwaarden en privacybeleid."})]})]})})}export{A 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.