PageSourceSearch

https://frimurer.no/assets/InfoMeetingModules-D-QqRQ7l.js

js frimurer.no collected 2026-09-25 00:00:38 UTC 8,693 bytes, 1 lines download raw bytes

1import{u as q,r as i,j as e}from"./vendor-react-GnwsTJfO.js";import{U as o,N as K,B as n,Y as P,R as C,C as S,g as F,am as U,E as z,G,n as H,a8 as Y,a9 as J,aa as Q,ab as W,I as d,i as L,j as T,k as D,l as E,m as I,ad as X,F as Z,f as _}from"./index-Bj2Y77AF.js";import{e as $}from"./AdminNavigation-DYLQ05kD.js";import{L as t}from"./label-9b9pu6HH.js";import{T as ee}from"./textarea-B-AJzF_c.js";import{S as p}from"./switch-DraYssLT.js";import{g as se}from"./auth-CTDXhLJm.js";import{u as ae}from"./useAdminAuth-BXhWp9H6.js";import{a as le,M as j,E as f}from"./infoMeetingModules-BWzSvy92.js";import{S as re}from"./square-pen-mOKYrOsG.js";import{T as te}from"./trash-2-D673yTlG.js";import"./vendor-cjs-BcELrC9x.js";import"./vendor-supabase-BWPZKnGU.js";import"./vendor-ui-C1xCQL2z.js";import"./vendor-utils-B2rm_Apj.js";import"./vendor-query-Dp4tHR6-.js";import"./MasonicCross-CB_Vslf8.js";import"./users-CHiFHZvy.js";import"./image-l440pP5V.js";const M={name:"",module_type:"card",heading:"",body:"",button_label:"",default_url:"",allow_local_url:!1,local_edit_mode:"locked",is_active:!0,sort_order:0,show_heading:!0};function ke(){const v=q(),{role:m,loading:b}=ae(),[u,O]=i.useState([]),[A,y]=i.useState(!0),[B,c]=i.useState(!1),[h,N]=i.useState(null),[l,r]=i.useState(M),w=m==="webmaster"||m==="editor_dnfo"||m==="editor_infomeeting";i.useEffect(()=>{if(!b){if(!w){o.error("Du har ikke tilgang til modulbiblioteket"),v("/admin/info-meetings");return}x()}},[b,w]);const x=async()=>{y(!0),O(await le(!1)),y(!1)},g=s=>{s?(N(s.id),r({name:s.name,module_type:s.module_type,heading:s.heading,body:s.body,button_label:s.button_label??"",default_url:s.default_url??"",allow_local_url:s.allow_local_url,local_edit_mode:s.local_edit_mode,is_active:s.is_active,sort_order:s.sort_order,show_heading:s.show_heading!==!1})):(N(null),r({...M,sort_order:u.length})),c(!0)},R=async()=>{if(!l.name.trim()){o.error("Navn er påkrevd");return}const s={name:l.name.trim(),module_type:l.module_type,heading:l.heading,body:l.body,button_label:l.button_label||null,default_url:l.default_url||null,allow_local_url:l.allow_local_url,local_edit_mode:l.local_edit_mode,is_active:l.is_active,sort_order:l.sort_order,show_heading:l.show_heading};try{if(h){const{error:a}=await _.from("info_meeting_content_modules").update(s).eq("id",h);if(a)throw a;o.success("Modul oppdatert")}else{const a=await se(),{error:k}=await _.from("info_meeting_content_modules").insert({...s,created_by:a});if(k)throw k;o.success("Modul opprettet")}c(!1),x()}catch(a){console.error("Error saving module:",a),o.error(a.message||"Kunne ikke lagre modulen")}},V=async s=>{if(!confirm("Slette denne modulen? Den forsvinner da fra alle møter som bruker den."))return;const{error:a}=await _.from("info_meeting_content_modules").delete().eq("id",s);if(a){o.error("Kunne ikke slette modulen");return}o.success("Modul slettet"),x()};return e.jsxs("div",{className:"min-h-screen flex flex-col bg-background",children:[e.jsx(K,{}),e.jsx($,{}),e.jsxs("main",{className:"flex-grow container mx-auto px-4 py-8",children:[e.jsx("div",{className:"flex items-center gap-4 mb-6",children:e.jsxs(n,{variant:"ghost",onClick:()=>v("/admin/info-meetings"),children:[e.jsx(P,{className:"w-4 h-4 mr-2"}),"Tilbake"]})}),e.jsxs("div",{className:"flex justify-between items-center mb-8",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-serif text-foreground",children:"Innholdsmoduler for informasjonsmøter"}),e.jsx("p",{className:"text-muted-foreground mt-2",children:"Sentralt budskap som logene kan velge å vise på sine påmeldingssider"})]}),e.jsxs(n,{onClick:()=>g(),children:[e.jsx(C,{className:"w-4 h-4 mr-2"}),"Ny modul"]})]}),A?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):u.length===0?e.jsx(S,{children:e.jsxs(F,{className:"py-12 text-center",children:[e.jsx(U,{className:"w-12 h-12 text-muted-foreground mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Ingen moduler opprettet ennå"}),e.jsxs(n,{onClick:()=>g(),children:[e.jsx(C,{className:"w-4 h-4 mr-2"}),"Opprett første modul"]})]})}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:u.map(s=>e.jsxs(S,{className:"bg-muted/50",children:[e.jsxs(z,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx(G,{className:"text-lg",children:s.name}),e.jsx(H,{variant:s.is_active?"default":"outline",className:"whitespace-nowrap",children:s.is_active?"Aktiv":"Skjult"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:j[s.module_type]})]}),e.jsxs(F,{className:"space-y-3",children:[s.heading&&e.jsx("p",{className:"font-medium text-sm",children:s.heading}),s.body&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-3",children:s.body}),e.jsx("p",{className:"text-xs text-muted-foreground",children:f[s.local_edit_mode]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(n,{variant:"outline",size:"sm",className:"flex-1",onClick:()=>g(s),children:[e.jsx(re,{className:"w-4 h-4 mr-2"}),"Rediger"]}),e.jsx(n,{variant:"outline",size:"icon",onClick:()=>V(s.id),children:e.jsx(te,{className:"w-4 h-4"})})]})]})]},s.id))}),e.jsx(Y,{open:B,onOpenChange:c,children:e.jsxs(J,{className:"max-w-2xl max-h-[85vh] overflow-y-auto",children:[e.jsx(Q,{children:e.jsx(W,{children:h?"Rediger modul":"Ny modul"})}),e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(t,{htmlFor:"module_name",children:"Navn (vises kun internt) *"}),e.jsx(d,{id:"module_name",value:l.name,onChange:s=>r(a=>({...a,name:s.target.value}
1)),placeholder:"F.eks. Omvisning i logebygget"})]}),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(t,{children:"Type"}),e.jsxs(L,{value:l.module_type,onValueChange:s=>r(a=>({...a,module_type:s})),children:[e.jsx(T,{children:e.jsx(D,{})}),e.jsx(E,{children:Object.keys(j).map(s=>e.jsx(I,{value:s,children:j[s]},s))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(t,{children:"Lokal redigering"}),e.jsxs(L,{value:l.local_edit_mode,onValueChange:s=>r(a=>({...a,local_edit_mode:s})),children:[e.jsx(T,{children:e.jsx(D,{})}),e.jsx(E,{children:Object.keys(f).map(s=>e.jsx(I,{value:s,children:f[s]},s))})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(t,{htmlFor:"module_heading",children:"Overskrift"}),e.jsx(d,{id:"module_heading",value:l.heading,onChange:s=>r(a=>({...a,heading:s.target.value}))}),e.jsxs("div",{className:"flex items-center justify-between rounded-md border p-3",children:[e.jsx(t,{htmlFor:"module_show_heading",className:"font-normal",children:"Vis overskriften på påmeldingssiden"}),e.jsx(p,{id:"module_show_heading",checked:l.show_heading,onCheckedChange:s=>r(a=>({...a,show_heading:s}))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(t,{htmlFor:"module_body",children:"Tekst"}),e.jsx(ee,{id:"module_body",rows:5,value:l.body,onChange:s=>r(a=>({...a,body:s.target.value}))})]}),l.module_type==="link_card"&&e.jsxs("div",{className:"space-y-4 rounded-md border p-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(t,{htmlFor:"module_button",children:"Knappetekst"}),e.jsx(d,{id:"module_button",value:l.button_label,onChange:s=>r(a=>({...a,button_label:s.target.value})),placeholder:"F.eks. Til påmelding"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(t,{htmlFor:"module_url",children:"Standard lenke"}),e.jsx(d,{id:"module_url",value:l.default_url,onChange:s=>r(a=>({...a,default_url:s.target.value})),placeholder:"https://..."})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(t,{htmlFor:"allow_local_url",children:"Logen kan endre lenken"}),e.jsx(p,{id:"allow_local_url",checked:l.allow_local_url,onCheckedChange:s=>r(a=>({...a,allow_local_url:s}))})]})]}),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(t,{htmlFor:"module_sort",children:"Sortering"}),e.jsx(d,{id:"module_sort",type:"number",value:l.sort_order,onChange:s=>r(a=>({...a,sort_order:parseInt(s.target.value)||0}))})]}),e.jsxs("div",{className:"flex items-center justify-between pt-6",children:[e.jsx(t,{htmlFor:"module_active",children:"Tilgjengelig for logene"}),e.jsx(p,{id:"module_active",checked:l.is_active,onCheckedChange:s=>r(a=>({...a,is_active:s}))})]})]})]}),e.jsxs(X,{children:[e.jsx(n,{variant:"outline",onClick:()=>c(!1),children:"Avbryt"}),e.jsx(n,{onClick:R,children:"Lagre"})]})]})})]}),e.jsx(Z,{})]})}export{ke 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.