decocms
Version:
Deco CMS — Self-hostable MCP Gateway for managing AI connections and tools
2 lines (1 loc) • 4.17 kB
JavaScript
import{c as G,r as H,e as A,j as t,o as I,B as L,h as B}from"./index-ztdGKvBm.js";import{s as K}from"./Plus-DWySsEmB.js";async function T(r,e,p){const o=await fetch(r,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({organizationSlug:e})}),l=await o.json();if(!o.ok||!l.success)throw new Error(l.error||p);return l}function Y(r){const e=G.c(45),{organizations:p,domain:o,requestedSlugs:l,onRequestedSlug:C,onSelected:h,onJoined:c,onRequestCompleted:M,selectLabel:O,onCreateNew:w,createNewLabel:P}=r,j=O===void 0?"Select":O,_=P===void 0?"Create new organization":P;let N;e[0]===Symbol.for("react.memo_cache_sentinel")?(N=new Set,e[0]=N):N=e[0];const[J,$]=H.useState(N);let v;e[1]!==C?(v=i=>{$(s=>new Set(s).add(i)),C?.(i)},e[1]=C,e[2]=v):v=e[2];const E=v;let z;e[3]!==c?(z={mutationFn:V,onSuccess:i=>{const{organization:s,slug:x}=i;c?.(s,x)}},e[3]=c,e[4]=z):z=e[4];const n=A(z);let R;e[5]!==E||e[6]!==c||e[7]!==M?(R={mutationFn:Q,onSuccess:i=>{const{organization:s,slug:x,alreadyMember:F}=i;if(F&&x){c?.(s,x);return}E(s.slug),M?.(s)}},e[5]=E,e[6]=c,e[7]=M,e[8]=R):R=e[8];const a=A(R);let u;e[9]!==l?(u=l??[],e[9]=l,e[10]=u):u=e[10];let y;e[11]!==J||e[12]!==u?(y=new Set([...u,...J]),e[11]=J,e[12]=u,e[13]=y):y=e[13];const b=y,q=n.variables?.slug??null,S=a.variables?.slug??null;let d;e[14]!==_||e[15]!==w?(d=w&&t.jsxs("button",{type:"button",onClick:w,className:"rounded-xl border border-dashed border-border p-4 flex items-center justify-center gap-2 text-sm font-medium text-muted-foreground hover:text-foreground hover:border-foreground/40 transition-colors",children:[t.jsx(K,{size:16}),_]}),e[14]=_,e[15]=w,e[16]=d):d=e[16];let m;if(e[17]!==o||e[18]!==b||e[19]!==n||e[20]!==h||e[21]!==p||e[22]!==q||e[23]!==S||e[24]!==a||e[25]!==j){let i;e[27]!==o||e[28]!==b||e[29]!==n||e[30]!==h||e[31]!==q||e[32]!==S||e[33]!==a||e[34]!==j?(i=s=>{const x=n.isPending&&q===s.slug,F=a.isPending&&S===s.slug,D=b.has(s.slug),U=s.logo??(o?`https://www.google.com/s2/favicons?domain=${o}&sz=128`:null);return t.jsxs("div",{className:"surface p-4 flex items-center gap-4",children:[t.jsx(I,{url:U??void 0,fallback:s.name,shape:"square",size:"base",className:"h-10 w-10 shrink-0"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("p",{className:"text-sm font-medium truncate",children:s.name}),o&&t.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:["@",o]})]}),s.joinMode==="auto"?t.jsx(L,{size:"default",onClick:()=>n.mutate(s),disabled:n.isPending,children:x?t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(B,{className:"size-3.5"})," Joining..."]}):"Join"}):s.joinMode==="request"?D?t.jsx("span",{className:"text-xs text-muted-foreground shrink-0",children:"Request sent"}):t.jsx(L,{size:"default",variant:"outline",onClick:()=>a.mutate(s),disabled:a.isPending,children:F?t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(B,{className:"size-3.5"})," Requesting..."]}):"Request to join"}):t.jsx(L,{size:"default",onClick:()=>h?.(s),children:j})]},s.id)},e[27]=o,e[28]=b,e[29]=n,e[30]=h,e[31]=q,e[32]=S,e[33]=a,e[34]=j,e[35]=i):i=e[35],m=p.map(i),e[17]=o,e[18]=b,e[19]=n,e[20]=h,e[21]=p,e[22]=q,e[23]=S,e[24]=a,e[25]=j,e[26]=m}else m=e[26];let g;e[36]!==n.error?(g=n.error&&t.jsx("p",{className:"text-xs text-destructive",role:"alert",children:n.error instanceof Error?n.error.message:"Failed to join organization"}),e[36]=n.error,e[37]=g):g=e[37];let f;e[38]!==a.error?(f=a.error&&t.jsx("p",{className:"text-xs text-destructive",role:"alert",children:a.error instanceof Error?a.error.message:"Failed to request access"}),e[38]=a.error,e[39]=f):f=e[39];let k;return e[40]!==m||e[41]!==g||e[42]!==f||e[43]!==d?(k=t.jsxs("div",{className:"grid grid-cols-1 gap-2",children:[d,m,g,f]}),e[40]=m,e[41]=g,e[42]=f,e[43]=d,e[44]=k):k=e[44],k}async function Q(r){const e=await T("/api/auth/custom/domain-request-join",r.slug,"Failed to request access");return{organization:r,slug:e.slug,alreadyMember:e.alreadyMember}}async function V(r){const e=await T("/api/auth/custom/domain-join",r.slug,"Failed to join organization");return{organization:r,slug:e.slug??r.slug}}export{Y as O};