PageSourceSearch

https://scorenordic.se/assets/AdminPosts-CzQCxiBc.js

js scorenordic.se collected 2026-10-09 22:03:41 UTC 8,485 bytes, 1 lines download raw bytes

1import{j as e}from"./ui-vendor-DTWwZ2r9.js";import{r as i}from"./react-vendor-CuhztHU7.js";import{u as I,A as L}from"./AdminLayout-BP-dYO8x.js";import{u as n,C as E,a as T,b as D,d as P,B as o,e as A,s as B}from"./index-DuwgqRxs.js";import{E as O,S as k}from"./switch-CyFCiCr0.js";import{I as d}from"./input-Cp5w6YsU.js";import{L as r}from"./label-DneG6m-l.js";import{T as v}from"./textarea-D1Hbc9RH.js";import{S as K,a as R,b as z,c as V,d as j}from"./select-Dn2Um4FG.js";import{D as F,a as H,b as Y,c as G,e as M}from"./dialog-cWca_CK6.js";import{N as U}from"./newspaper-DW6-dpnB.js";import{P as W}from"./plus-CxRb-1vb.js";import{P as $}from"./pen-line-RPVbQITd.js";import{T as q}from"./trash-2-DIkcprmJ.js";import{S as J}from"./save-eDdQT3xn.js";import"./swoosh-icon-D2iN30no.js";import"./popover-CJ43S5ES.js";import"./users-DQnqgNXQ.js";import"./file-text-DvFyslnJ.js";import"./mail-C5DEgMXC.js";import"./globe-CBsjnIC9.js";const Q={pilot:"Pilotprojekt",tech:"Tekniska insikter",news:"Nyheter",event:"Event"},_={slug:"",category:"news",title_sv:"",title_en:"",excerpt_sv:"",excerpt_en:"",body_sv:"",body_en:"",image_url:"",read_minutes:5,published_at:new Date().toISOString().slice(0,16),is_published:!1,sort_order:0};async function m(u,f={}){const{data:c,error:x}=await B.functions.invoke("manage-posts",{body:{action:u,...f}});if(x)throw x;if(c!=null&&c.error)throw new Error(c.error);return c}const fe=()=>{I("Aktuellt - Admin");const[u,f]=i.useState([]),[c,x]=i.useState(!0),[N,g]=i.useState(!1),[l,p]=i.useState(null),[a,t]=i.useState(_),[y,b]=i.useState(!1),h=i.useCallback(async()=>{try{const s=await m("list");f((s==null?void 0:s.data)??[])}catch(s){console.error(s),n.error("Kunde inte hämta inlägg")}finally{x(!1)}},[]);i.useEffect(()=>{h()},[h]),i.useEffect(()=>{t(l?{...l,image_url:l.image_url??"",published_at:new Date(l.published_at).toISOString().slice(0,16)}:{..._,published_at:new Date().toISOString().slice(0,16)})},[l]);const w=async()=>{if(!a.title_sv.trim()){n.error("Svensk rubrik krävs");return}b(!0);try{const s={...a,image_url:a.image_url||null,published_at:new Date(a.published_at).toISOString()};l?(await m("update",{id:l.id,...s}),n.success("Inlägget uppdaterat")):(await m("create",s),n.success("Inlägget skapat")),g(!1),p(null),await h()}catch(s){console.error(s),n.error("Kunde inte spara inlägget")}finally{b(!1)}},S=async s=>{try{await m("toggle_published",{id:s.id,is_published:!s.is_published}),await h()}catch{n.error("Kunde inte ändra status")}},C=async s=>{if(confirm("Ta bort detta inlägg?"))try{await m("delete",{id:s}),n.success("Borttaget"),await h()}catch{n.error("Kunde inte ta bort")}};return e.jsx(L,{title:"Aktuellt",description:"Skriv och publicera inlägg i nyhetskanalen",children:e.jsxs(E,{children:[e.jsx(T,{children:e.jsxs("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[e.jsxs("div",{children:[e.jsxs(D,{className:"flex items-center gap-2",children:[e.jsx(U,{className:"h-5 w-5"})," Inlägg"]}),e.jsx(P,{children:"Kategorier: Pilotprojekt, Tekniska insikter, Nyheter och Event. Publicerade inlägg visas överst i Aktuellt och på sidan Insikter."})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(o,{variant:"outline",size:"sm",onClick:()=>window.open("/#/insikter","_blank"),children:[e.jsx(O,{className:"h-4 w-4 mr-2"})," Visa publikt"]}),e.jsxs(o,{size:"sm",onClick:()=>{p(null),g(!0)},children:[e.jsx(W,{className:"h-4 w-4 mr-2"})," Nytt inlägg"]})]})]})}),e.jsx(A,{children:c?e.jsx("p",{className:"text-sm text-muted-foreground py-6 text-center",children:"Laddar..."}):u.length===0?e.jsx("p",{className:"text-sm text-muted-foreground py-6 text-center",children:"Inga inlägg ännu. Skriv ditt första inlägg."}):e.jsx("div",{className:"space-y-2",children:u.map(s=>e.jsxs("div",{className:`flex items-center gap-3 p-3 rounded-lg border ${s.is_published?"bg-background":"bg-muted/30 opacity-70"}`,children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"font-medium text-sm truncate",children:s.title_sv}),e.jsx("span",{className:"text-[10px] uppercase tracking-wider px-1.5 py-0.5 rounded bg-muted text-muted-foreground",children:Q[s.category]})]}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[new Date(s.published_at).toLocaleDateString("sv-SE")," · /",s.slug]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx(k,{checked:s.is_published,onCheckedChange:()=>S(s)}),e.jsx(o,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>{p(s),g(!0)},children:e.jsx($,{className:"h-4 w-4"})}),e.jsx(o,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive",onClick:()=>C(s.id),children:e.jsx(q,{className:"h-4 w-4"})})]})]},s.id))})}),e.jsx(F,{open:N,onOpenChange:s=>{g(s),s||p(null)}
1,children:e.jsxs(H,{className:"max-w-3xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Y,{children:e.jsx(G,{children:l?"Redigera inlägg":"Nytt inlägg"})}),e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{children:"Kategori"}),e.jsxs(K,{value:a.category,onValueChange:s=>t({...a,category:s}),children:[e.jsx(R,{children:e.jsx(z,{})}),e.jsxs(V,{children:[e.jsx(j,{value:"pilot",children:"Pilotprojekt"}),e.jsx(j,{value:"tech",children:"Tekniska insikter"}),e.jsx(j,{value:"news",children:"Nyheter"}),e.jsx(j,{value:"event",children:"Event"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{children:"Publiceringsdatum"}),e.jsx(d,{type:"datetime-local",value:a.published_at,onChange:s=>t({...a,published_at:s.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{children:"Lästid (minuter)"}),e.jsx(d,{type:"number",value:a.read_minutes,onChange:s=>t({...a,read_minutes:parseInt(s.target.value)||5})})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{children:"Rubrik (svenska) *"}),e.jsx(d,{value:a.title_sv,onChange:s=>t({...a,title_sv:s.target.value}),maxLength:160})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{children:"Rubrik (engelska)"}),e.jsx(d,{value:a.title_en,onChange:s=>t({...a,title_en:s.target.value}),maxLength:160})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{children:"Ingress (svenska)"}),e.jsx(v,{rows:3,value:a.excerpt_sv,onChange:s=>t({...a,excerpt_sv:s.target.value}),maxLength:400})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{children:"Ingress (engelska)"}),e.jsx(v,{rows:3,value:a.excerpt_en,onChange:s=>t({...a,excerpt_en:s.target.value}),maxLength:400})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{children:"Brödtext (svenska) — ett stycke per rad"}),e.jsx(v,{rows:10,value:a.body_sv,onChange:s=>t({...a,body_sv:s.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{children:"Brödtext (engelska)"}),e.jsx(v,{rows:10,value:a.body_en,onChange:s=>t({...a,body_en:s.target.value})})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{children:"Bild-URL (valfritt)"}),e.jsx(d,{value:a.image_url??"",onChange:s=>t({...a,image_url:s.target.value}),placeholder:"https://..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{children:"Webbadress (slug) — lämna tomt för automatiskt"}),e.jsx(d,{value:a.slug,onChange:s=>t({...a,slug:s.target.value}),placeholder:"pilot-i-stockholm"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 items-end",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{children:"Sorteringsordning (högre = överst)"}),e.jsx(d,{type:"number",value:a.sort_order,onChange:s=>t({...a,sort_order:parseInt(s.target.value)||0})})]}),e.jsxs("div",{className:"flex items-center gap-3 pb-2",children:[e.jsx(k,{checked:a.is_published,onCheckedChange:s=>t({...a,is_published:s})}),e.jsx(r,{children:"Publicerad (visas publikt)"})]})]})]}),e.jsxs(M,{children:[e.jsx(o,{variant:"outline",onClick:()=>g(!1),children:"Avbryt"}),e.jsxs(o,{onClick:w,disabled:y,children:[e.jsx(J,{className:"h-4 w-4 mr-2"})," ",y?"Sparar...":"Spara"]})]})]})})]})})};export{fe as default};

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.