1import{r as n,j as e,B as o,f as l,s as f,v as N}from"./index-EhlWxbWg.js";import{P as _}from"./PageShell-DH7nPkNN.js";import{K as b}from"./key-round-CVNrT6b5.js";import{P as w}from"./plus-lMDjZTKL.js";import{U as x}from"./users-DW5YStzm.js";import{C as k}from"./clock-edBaNvj3.js";import"./BreakingBanner-BO31IdU1.js";const i=12;function S(s,a=140){const r=s.replace(/\s+/g," ").trim();return r.length<=a?r:r.slice(0,a).replace(/\s+\S*$/,"")+"â¦"}function z(s){return new Date(s).toLocaleDateString("sv-SE",{day:"numeric",month:"long",year:"numeric"})}function P({p:s}){const{t:a}=N();return e.jsxs(l,{to:"/foreningsnytt/$id",params:{id:s.id},className:"group block",children:[e.jsx("div",{className:"aspect-[4/3] overflow-hidden mb-3 bg-muted",children:s.image_url?e.jsx("img",{src:s.image_url,alt:s.headline,loading:"lazy",className:"w-full h-full object-cover group-hover:scale-[1.02] transition-transform duration-500"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-muted-foreground",children:e.jsx(x,{className:"size-10 opacity-40"})})}),e.jsxs("span",{className:"eyebrow text-primary inline-flex items-center gap-1.5",children:[e.jsx(x,{className:"size-3.5"})," ",s.association_name]}),e.jsx("h3",{className:"headline-md mt-2 group-hover:text-primary transition-colors",children:s.headline}),e.jsx("p",{className:"mt-1.5 text-sm text-muted-foreground line-clamp-2",children:S(s.content)}),e.jsxs("div",{className:"text-xs text-muted-foreground flex items-center gap-2 mt-2",children:[e.jsx(k,{className:"size-3"})," ",e.jsx("span",{children:z(s.approved_at??s.created_at)})]}),e.jsx("div",{className:"text-right mt-1",children:e.jsxs("span",{className:"text-xs text-primary group-hover:underline",children:[a("common.readMore")," â"]})})]})}function q(){const[s,a]=n.useState([]),[r,c]=n.useState(!1),[d,m]=n.useState(!1),[p,g]=n.useState(!0);async function h(){g(!0);const{data:t}=await f.from("foreningsnytt_posts").select("*").eq("status","approved").order("approved_at",{ascending:!1,nullsFirst:!1}).order("created_at",{ascending:!1}).range(0,i-1);a(t??[]),m((t??[]).length===i),g(!1)}n.useEffect(()=>{h()},[]);async function j(){if(r||!d)return;c(!0);const t=s.length,{data:y}=await f.from("foreningsnytt_posts").select("*").eq("status","approved").order("approved_at",{ascending:!1,nullsFirst:!1}).order("created_at",{ascending:!1}).range(t,t+i-1),u=y??[];a(v=>[...v,...u]),m(u.length===i),c(!1)}return e.jsxs(_,{title:"Föreningsnytt",eyebrow:"Föreningarnas egna sida",children:[e.jsxs("div",{className:"mb-6 flex flex-wrap justify-end gap-2",children:[e.jsx(o,{asChild:!0,variant:"outline",size:"sm",children:e.jsxs(l,{to:"/foreningsnytt/redigera",children:[e.jsx(b,{className:"size-4"})," Redigera inlägg med kod"]})}),e.jsx(o,{asChild:!0,size:"sm",className:"bg-primary text-primary-foreground",children:e.jsxs(l,{to:"/foreningsnytt/skapa",children:[e.jsx(w,{className:"size-4"})," Skicka in inlägg"]})})]}),p&&s.length===0?e.jsx("div",{className:"py-16 text-center text-muted-foreground",children:"Hämtar inläggâ¦"}):s.length===0?e.jsx("div",{className:"py-16 text-center text-muted-foreground",children:"Inga inlägg ännu â bli först att skicka in!"}):e.jsx("div",{className:"grid gap-8 sm:grid-cols-2 lg:grid-cols-3",children:s.map(t=>e.jsx(P,{p:t},t.id))}),d&&e.jsx("div",{className:"mt-10 flex justify-center",children:e.jsx(o,{variant:"outline",onClick:j,disabled:r,children:r?"Laddarâ¦":"Visa fler inlägg"})})]})}export{q 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.