1import{ae as f,t as i,s as l,aD as j,j as e,L as o}from"./index-dt5w-xvv.js";import{u as b}from"./useQuery-MBRo_HYG.js";import{u as m}from"./useMutation-D22cL2np.js";import{u as y}from"./createServerFn-CKvmrsJq.js";import{s as N,P as g,a as _,S as k}from"./SyndicationToggles-ClFKA00a.js";import{P as v}from"./plus-CfVZaelK.js";import{P as w}from"./pencil-jDeZFJqY.js";import{T as S}from"./trash-2-o3VPKpzU.js";import"./auth-middleware-B-zkoLch.js";function K(){const r=f(),{data:n=[]}=b({queryKey:["admin_case_studies"],queryFn:async()=>{const{data:s,error:t}=await l.from("case_studies").select("id, slug, client_name, hero_title, sector, featured, published, sort_order, syndicate_harbor, syndicate_sniper, syndicate_flare").order("sort_order",{ascending:!0});if(t)throw t;return s}}),u=y(N),c=m({mutationFn:async({id:s,project:t,next:a})=>{const p={[_[t]]:a},{error:d}=await l.from("case_studies").update(p).eq("id",s);if(d)throw d;return a?(await u({data:{id:s}}))?.results?.find(x=>x.project===t)??null:null},onSuccess:(s,t)=>{const a=g[t.project];t.next?s?s.status==="sent"?i.success(`Syndicated to ${a}`):s.status==="skipped"?i.info(`${a}: ${s.detail}`):i.error(`${a} failed: ${s.detail}`):i.success(`Enabled for ${a}`):i.info(`Removed from ${a}`),r.invalidateQueries({queryKey:["admin_case_studies"]})},onError:s=>i.error(s.message)}),h=m({mutationFn:j,onSuccess:()=>{i.success("Deleted"),r.invalidateQueries({queryKey:["admin_case_studies"]}),r.invalidateQueries({queryKey:["case_studies"]})},onError:s=>i.error(s.message)});return e.jsxs("div",{className:"p-12",children:[e.jsxs("div",{className:"flex justify-between items-center mb-12",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-5xl font-black tracking-tighter mb-2",children:"Case Studies"}),e.jsxs("p",{className:"text-white/40",children:[n.length," total"]})]}),e.jsxs(o,{to:"/admin/case-studies/$id",params:{id:"new"},className:"inline-flex items-center gap-2 bg-accent-cyan text-brand-black font-black px-6 py-3 rounded-pill text-sm uppercase tracking-widest",children:[e.jsx(v,{className:"w-4 h-4"})," New"]})]}),e.jsx("div",{className:"glass rounded-card border border-white/10 overflow-hidden",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{className:"bg-white/5",children:e.jsxs("tr",{className:"text-left text-[10px] font-black uppercase tracking-widest text-white/40",children:[e.jsx("th",{className:"p-4",children:"Client"}),e.jsx("th",{className:"p-4",children:"Title"}),e.jsx("th",{className:"p-4",children:"Sector"}),e.jsx("th",{className:"p-4",children:"Status"}),e.jsx("th",{className:"p-4",children:"Syndication"}),e.jsx("th",{className:"p-4"})]})}),e.jsx("tbody",{children:n.map(s=>e.jsxs("tr",{className:"border-t border-white/5 hover:bg-white/5",children:[e.jsx("td",{className:"p-4 font-bold",children:s.client_name}),e.jsx("td",{className:"p-4 text-white/60",children:s.hero_title}),e.jsx("td",{className:"p-4 text-white/40 text-sm",children:s.sector}),e.jsx("td",{className:"p-4",children:e.jsxs("div",{className:"flex gap-2",children:[s.featured&&e.jsx("span",{className:"text-[10px] px-2 py-1 rounded-pill bg-accent-pink/10 text-accent-pink font-black uppercase tracking-widest",children:"Featured"}),e.jsx("span",{className:`text-[10px] px-2 py-1 rounded-pill font-black uppercase tracking-widest ${s.published?"bg-accent-cyan/10 text-accent-cyan":"bg-white/5 text-white/40"}`,children:s.published?"Live":"Draft"})]})}),e.jsx("td",{className:"p-4",children:e.jsx(k,{size:"sm",disabled:c.isPending,value:{harbor:s.syndicate_harbor,sniper:s.syndicate_sniper,flare:s.syndicate_flare},onChange:(t,a)=>c.mutate({id:s.id,project:t,next:a})})}),e.jsx("td",{className:"p-4 text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(o,{to:"/admin/case-studies/$id",params:{id:s.id},className:"p-2 hover:bg-white/10 rounded-card",children:e.jsx(w,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>{confirm(`Delete "${s.client_name}"?`)&&h.mutate(s.id)},className:"p-2 hover:bg-red-500/20 text-red-400 rounded-card",children:e.jsx(S,{className:"w-4 h-4"})})]})})]},s.id))})]})})]})}export{K as component};
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.