1import{F as j,G as v,u as N,d as r,j as t,L as b,t as n}from"./index-DJIFzu0q.js";import{u as l}from"./useServerFn-Dcg-9NP2.js";import{B as c}from"./button-_fRotMMY.js";function k(){const m=l(j),u=l(v),x=N(),[a,g]=r.useState(null),[s,h]=r.useState("");async function i(){try{const e=await m();g(e)}catch(e){n.error(e instanceof Error?e.message:"Kunde inte hämta inlägg")}}r.useEffect(()=>{i()},[]);async function f(e,p){if(confirm(`Radera "${p}"?`))try{await u({data:{id:e}}),n.success("Raderat"),i()}catch(o){n.error(o instanceof Error?o.message:"Kunde inte radera")}}const d=(a??[]).filter(e=>!s||e.title.toLowerCase().includes(s.toLowerCase())||e.slug.toLowerCase().includes(s.toLowerCase()));return t.jsxs("div",{children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 mb-6",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-2xl font-semibold tracking-tight text-primary",children:"Nyhetsinlägg"}),t.jsxs("p",{className:"text-sm text-muted-foreground",children:[a?.length??0," inlägg totalt"]})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("input",{value:s,onChange:e=>h(e.target.value),placeholder:"Sökâ¦",className:"px-3 py-2 text-sm border border-input rounded-md bg-background"}),t.jsx(c,{onClick:()=>x({to:"/admin/posts/$id",params:{id:"new"}}),children:"Nytt inlägg"})]})]}),a===null?t.jsx("p",{className:"text-muted-foreground text-sm",children:"Laddarâ¦"}):d.length===0?t.jsx("p",{className:"text-muted-foreground text-sm",children:"Inga inlägg."}):t.jsx("div",{className:"border border-border rounded-md divide-y divide-border",children:d.map(e=>t.jsxs("div",{className:"flex items-center gap-4 px-4 py-3",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(b,{to:"/admin/posts/$id",params:{id:e.id},className:"font-medium text-foreground hover:text-accent truncate",children:e.title}),t.jsx("span",{className:"text-[10px] uppercase tracking-wider px-1.5 py-0.5 rounded "+(e.status==="published"?"bg-accent/15 text-accent":"bg-muted text-muted-foreground"),children:e.status})]}),t.jsxs("div",{className:"text-xs text-muted-foreground truncate",children:["/nyheter/",e.slug," · ",e.published_at?new Date(e.published_at).toLocaleDateString("sv-SE"):"â"]})]}),t.jsx(c,{size:"sm",variant:"ghost",onClick:()=>f(e.id,e.title),children:"Radera"})]},e.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.