PageSourceSearch

https://app.vibenetwork.ai/assets/AdminVibesPage-BoqyDWOG.js

js vibenetwork.ai collected 2026-10-05 14:00:38 UTC 5,310 bytes, 1 lines download raw bytes

1import{j as e,c as N,u as h,b as c,d as g}from"./vendor-De2NIrSl.js";import{k as y,S as p,L as w,E as k,j as b,B as m,z as C,x as S}from"./index-BNKu6i1-.js";function _(s){return N({queryKey:["admin","vibes"],queryFn:()=>b.get("/v1/social/admin/vibes"),enabled:s})}function P({v:s}){const n=h(),[r,i]=c.useState(!1),[o,x]=c.useState(s.name),[u,l]=c.useState(s.description??""),[t,f]=c.useState(String(s.sort_order)),v=C(),d=g({mutationFn:a=>b.patch(`/v1/social/admin/vibes/${s.id}`,a),onSuccess:()=>{n.invalidateQueries({queryKey:["admin","vibes"]}),i(!1)},onError:a=>v.error(a instanceof S?a.message:"That change didn’t save. Try again.")}),j=()=>d.mutate({name:o.trim(),description:u,sortOrder:Number.parseInt(t,10)||0});return e.jsxs("li",{className:"flex flex-wrap items-center gap-3 rounded-lg border border-border bg-card p-3",children:[r?e.jsxs("div",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-2",children:[e.jsx("input",{"aria-label":`Name for ${s.slug}`,value:o,onChange:a=>x(a.target.value),className:"rounded-md border border-border bg-background px-2 py-1 text-sm"}),e.jsx("input",{"aria-label":`Description for ${s.slug}`,value:u,placeholder:"Description",onChange:a=>l(a.target.value),className:"min-w-40 flex-1 rounded-md border border-border bg-background px-2 py-1 text-sm"}),e.jsx("input",{"aria-label":`Order for ${s.slug}`,value:t,onChange:a=>f(a.target.value),inputMode:"numeric",className:"w-16 rounded-md border border-border bg-background px-2 py-1 text-sm"}),e.jsx(m,{size:"sm",disabled:d.isPending,onClick:j,children:d.isPending?e.jsx(p,{}):"Save"}),e.jsx(m,{size:"sm",variant:"ghost",onClick:()=>i(!1),children:"Cancel"})]}):e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("p",{className:"flex flex-wrap items-center gap-2 text-sm font-medium",children:[s.name,e.jsxs("span",{className:"text-xs text-muted-foreground",children:["/",s.slug]}),s.is_private&&e.jsx("span",{className:"rounded-sm bg-muted px-2 py-0.5 text-[10px] font-medium uppercase text-muted-foreground",children:"Private"}),s.is_archived&&e.jsx("span",{className:"rounded-sm bg-destructive/10 px-2 py-0.5 text-[10px] font-medium uppercase text-destructive",children:"Archived"})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[s.follower_count," ",s.follower_count===1?"follower":"followers"," · order ",s.sort_order,s.description?e.jsxs(e.Fragment,{children:[" · ",s.description]}):null]})]}),!r&&e.jsxs("div",{className:"flex shrink-0 gap-2",children:[e.jsx(m,{size:"sm",variant:"secondary",onClick:()=>i(!0),children:"Edit"}),e.jsx(m,{size:"sm",variant:"ghost",disabled:d.isPending,onClick:()=>d.mutate({isPrivate:!s.is_private}),children:s.is_private?"Make public":"Make private"}),e.jsx(m,{size:"sm",variant:s.is_archived?"secondary":"destructive",disabled:d.isPending,onClick:()=>{(s.is_archived||window.confirm(`Archive "${s.name}"? It disappears from all public surfaces (posts keep their history).`))&&d.mutate({isArchived:!s.is_archived})},children:s.is_archived?"Unarchive":"Archive"})]})]})}function A(){const s=h(),[n,r]=c.useState(""),[i,o]=c.useState(""),[x,u]=c.useState(!1),l=g({mutationFn:()=>b.post("/v1/social/admin/vibes",{name:n.trim(),description:i,isPrivate:x}),onSuccess:()=>{s.invalidateQueries({queryKey:["admin","vibes"]}),r(""),o(""),u(!1)}});return e.jsxs("form",{className:"flex flex-wrap items-center gap-2 rounded-lg border border-border bg-card p-3",onSubmit:t=>{t.preventDefault(),n.trim()&&l.mutate()},children:[e.jsx("input",{"aria-label":"New vibe name",placeholder:"New Vibe name",value:n,onChange:t=>r(t.target.value),className:"rounded-md border border-border bg-background px-2 py-1.5 text-sm"}),e.jsx("input",{"aria-label":"New vibe description",placeholder:"Description (optional)",value:i,onChange:t=>o(t.target.value),className:"min-w-48 flex-1 rounded-md border border-border bg-background px-2 py-1.5 text-sm"}),e.jsxs("label",{className:"flex items-center gap-1.5 text-sm text-muted-foreground",children:[e.jsx("input",{type:"checkbox",checked:x,onChange:t=>u(t.target.checked)}),"Start private"]}),e.jsx(m,{type:"submit",size:"sm",disabled:!n.trim()||l.isPending,children:l.isPending?e.jsx(p,{}):"Create Vibe"}),l.isError&&e.jsx("span",{role:"alert",className:"text-xs text-destructive",children:"Could not create. Is the name unique enough?"})]})}function V(){var i;const{user:s,isLoading:n}=y(),r=_((s==null?void 0:s.role)==="admin");return n?e.jsx("div",{className:"grid min-h-[50vh] place-items-center",children:e.jsx(p,{className:"size-6"})}):!s||s.role!=="admin"?e.jsx("p",{className:"py-16 text-center text-sm text-muted-foreground",children:"Admins only."}):e.jsxs("div",{className:"mx-auto max-w-3xl",children:[e.jsx("h1",{className:"text-2xl font-semibold",children:"Vibes"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Curate the topic tags members attach to posts. Archiving hides a Vibe everywhere without touching its history."}),e.jsx("div",{className:"mt-4",children:e.jsx(A,{})}),r.isLoading?e.jsx(w,{className:"mt-4",rows:3}):r.isError?e.jsx(k,{className:"mt-4",message:"Could not load vibes.",onRetry:()=>void r.refetch()}):e.jsx("ul",{className:"mt-4 space-y-2",children:(((i=r.data)==null?void 0:i.vibes)??[]).map(o=>e.jsx(P,{v:o},o.id))})]})}export{V as AdminVibesPage};

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.