1import{r as t,s as x,j as e,L as p}from"./index-CLTM18rh.js";import{R as v}from"./Filterleiste-Dovi1-bW.js";const l=s=>s?new Date(`${s.slice(0,10)}T12:00:00`).toLocaleDateString("de-CH"):"";function S(){const[s,j]=t.useState([]),[i,N]=t.useState([]),[_,b]=t.useState(new Map),[o,f]=t.useState("geplant"),[z,k]=t.useState(!0);t.useEffect(()=>{(async()=>{const[a,n]=await Promise.all([x.from("event_plans").select("id, title, event_date, status, instagram_am, instagram_url, instagram_gepostet_am, instagram_person_id").in("status",["planung","kommunikation","durchfuehrung"]).order("event_date",{ascending:!0,nullsFirst:!1}),x.from("event_plan_posts").select("id, kanal, url, posted_on, label, plan_id, created_by_name, event_plans(title)").order("posted_on",{ascending:!1})]),u=a.data??[];j(u),N(n.data??[]);const g=[...new Set(u.map(d=>d.instagram_person_id).filter(Boolean))];if(g.length){const{data:d}=await x.from("persons").select("id, first_name, last_name").in("id",g);b(new Map((d??[]).map(m=>[m.id,[m.first_name,m.last_name].filter(Boolean).join(" ")])))}k(!1)})()},[]);const r=t.useMemo(()=>s.filter(a=>a.instagram_am&&!a.instagram_url).sort((a,n)=>(a.instagram_am??"").localeCompare(n.instagram_am??"")),[s]),h=t.useMemo(()=>s.filter(a=>!a.instagram_am&&!a.instagram_url),[s]),c=new Date().toISOString().slice(0,10);return e.jsxs("div",{className:"max-w-5xl",children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h1",{className:"text-2xl font-bold text-zinc-900 dark:text-white",children:"Social Media"}),e.jsxs("p",{className:"text-sm text-zinc-500 dark:text-zinc-400 mt-0.5",children:["Instagram-Termine und -Beiträge aus allen Vorhaben. Geplant und verknüpft wird im Veranstaltungsplaner unter «Kommunikation»; hier siehst du das Ganze auf einen Blick. Konto: ",e.jsx("a",{href:"https://www.instagram.com/8004.ch/",target:"_blank",rel:"noopener",className:"text-red-600 hover:underline",children:"@8004.ch"})]})]}),e.jsx(v,{aktiv:o,onWechsel:f,reiter:[{key:"geplant",label:"Geplant",anzahl:r.length,wartet:r.some(a=>(a.instagram_am??"")<c)},{key:"gemacht",label:"Gemacht",anzahl:i.length}]}),z?e.jsx("p",{className:"text-sm text-zinc-400",children:"Ladeâ¦"}):o==="geplant"?e.jsxs("div",{className:"space-y-5",children:[r.length===0?e.jsx("p",{className:"text-sm text-zinc-400",children:"Kein Instagram-Post geplant."}):e.jsx("div",{className:"rounded-xl border border-zinc-200 dark:border-zinc-800 overflow-x-auto",children:e.jsxs("table",{className:"w-full text-[13px]",children:[e.jsx("thead",{className:"bg-zinc-50 dark:bg-zinc-800/60 text-left text-[11px] uppercase tracking-wide text-zinc-400",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-3 py-2",children:"Post am"}),e.jsx("th",{className:"px-3 py-2",children:"Vorhaben"}),e.jsx("th",{className:"px-3 py-2",children:"Anlass"}),e.jsx("th",{className:"px-3 py-2",children:"Zuständig"}),e.jsx("th",{className:"px-3 py-2"})]})}),e.jsx("tbody",{className:"divide-y divide-zinc-100 dark:divide-zinc-800",children:r.map(a=>e.jsxs("tr",{className:(a.instagram_am??"")<c?"bg-amber-50/60 dark:bg-amber-950/10":"",children:[e.jsxs("td",{className:"px-3 py-2 tabular-nums whitespace-nowrap",children:[l(a.instagram_am),(a.instagram_am??"")<c&&e.jsx("span",{className:"ml-1.5 text-[11px] text-amber-700",children:"überfällig"})]}),e.jsx("td",{className:"px-3 py-2 font-medium text-zinc-900 dark:text-zinc-100",children:a.title}),e.jsx("td",{className:"px-3 py-2 text-zinc-500 tabular-nums",children:l(a.event_date)}),e.jsx("td",{className:"px-3 py-2 text-zinc-600 dark:text-zinc-300",children:a.instagram_person_id?_.get(a.instagram_person_id)??"â¦":e.jsx("span",{className:"text-zinc-400",children:"niemand"})}),e.jsx("td",{className:"px-3 py-2 text-right whitespace-nowrap",children:e.jsx(p,{to:`/admin/veranstaltungsplaner?plan=${a.id}`,className:"text-red-600 dark:text-red-400 hover:underline",children:"Im Planer öffnen"})})]},a.id))})]})}),h.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[12px] font-bold uppercase tracking-wide text-zinc-400 mb-2",children:"Vorhaben ohne Instagram-Termin"}),e.jsx("ul",{className:"space-y-1",children:h.map(a=>e.jsxs("li",{className:"text-[13px] text-zinc-600 dark:text-zinc-300",children:[a.title,a.event_date?e.jsxs("span",{className:"text-zinc-400",children:[" · ",l(a.event_date)]}):null," · ",e.jsx(p,{to:`/admin/veranstaltungsplaner?plan=${a.id}`,className:"text-red-600 dark:text-red-400 hover:underline",children:"planen"})]},a.id))})]})]}):i.length===0?e.jsx("p",{className:"text-sm text-zinc-400",children:"Noch kein Beitrag verknüpft."}):e.jsx("div",{className:"rounded-xl border border-zinc-200 dark:border-zinc-800 overflow-x-auto",children:e.jsxs("table",{className:"w-full text-[13px]",children:[e.jsx("thead",{className:"bg-zinc-50 dark:bg-zinc-800/60 text-left text-[11px] uppercase tracking-wide text-zinc-400",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-3 py-2",children:"Gepostet"}),e.jsx("th",{className:"px-3 py-2",children:"Kanal"}),e.jsx("th",{className:"px-3 py-2",children:"Vorhaben"}),e.jsx("th",{className:"px-3 py-2",children:"Bemerkung"}),e.jsx("th",{className:"px-3 py-2",children:"Von"}),e.jsx("th",{className:"px-3 py-2"})]})}),e.jsx("tbody",{className:"divide-y divide-zinc-100 dark:divide-zinc-800",children:i.map(a=>{const n=Array.isArray(a.event_plans)?a.event_plans[0]:a.event_plans;return e.jsxs("tr",{children:[e.jsx("td",{className:"px-3 py-2 tabular-nums whitespace-nowrap",children:l(a.posted_on)}),e.jsx("td",{className:"px-3 py-2",children:a.kanal==="instagram"?"Instagram":a.kanal}),e.jsx("td",{className:"px-3 py-2 font-medium text-zinc-900 dark:text-zinc-100",children:n?.title??"â"}),e.jsx("td",{className:"px-3 py-2 text-zinc-500",children:a.label??""}),e.jsx("td",{className:"px-3 py-2 text-zinc-500",children:a.created_by_name??""}),e.jsxs("td",{className:"px-3 py-2 text-right whitespace-nowrap",children:[a.url&&e.jsx("a",{href:a.url,target:"_blank",rel:"noopener",className:"text-red-600 dark:text-red-400 hover:underline mr-3",children:"Beitrag öffnen"}),e.jsx(p,{to:`/admin/veranstaltungsplaner?plan=${a.plan_id}`,className:"text-zinc-500 hover:text-red-600",children:"Planer"})]})]},a.id)})})]})})]})}export{S as AdminSocialMedia};
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.