PageSourceSearch

https://frimurer.no/assets/FollowUpList-Bk6VM8q8.js

js frimurer.no collected 2026-09-25 00:00:51 UTC 7,908 bytes, 1 lines download raw bytes

1import{u as E,r as i,j as e}from"./vendor-react-GnwsTJfO.js";import{f as S,U as f,N as O,b7 as j,C as d,ae as o,g as m,S as R,I as P,i as $,j as q,k as z,l as K,m as v,n as Q,B as C,aA as V,F as X,M as G,X as H}from"./index-Bj2Y77AF.js";import{u as J,e as W,R as Y}from"./AdminNavigation-DYLQ05kD.js";import{a as N,g as w,b as Z}from"./followUpUtils-CT9KShCm.js";import{A as ee}from"./arrow-up-down-BSVCW9na.js";import{C as se}from"./circle-check-Cnu4nfnq.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";import"./addMonths-CjnW2nDd.js";import"./differenceInDays-B48RAmJG.js";import"./addDays-5VaWIMAm.js";const ve=()=>{const F=E(),A=J(),[c,h]=i.useState([]),[I,b]=i.useState(!0),[u,T]=i.useState(""),[n,x]=i.useState("all"),[p,D]=i.useState("date_asc"),[y,_]=i.useState(null);i.useEffect(()=>{U()},[]);const U=async()=>{b(!0);try{const{data:s,error:t}=await S.from("articles").select("id, title, updated_at, follow_up_type, follow_up_date, follow_up_interval_months, follow_up_note, status, author_id, categories(name)").neq("follow_up_type","none").not("follow_up_type","is",null).in("status",["published","draft","pending_review","unpublished"]);if(t)throw t;h(s||[])}catch(s){console.error("Error loading follow-up articles:",s),f.error("Kunne ikke laste oppfølgingsliste")}finally{b(!1)}},L=async s=>{_(s.id);try{const t=s.follow_up_type==="interval"?{updated_at:new Date().toISOString()}:{follow_up_type:"none",follow_up_date:null,follow_up_note:null},{error:a}=await S.from("articles").update(t).eq("id",s.id);if(a)throw a;s.follow_up_type==="interval"?(f.success("Oppfølging tilbakestilt – neste frist beregnet fra nå"),h(l=>l.map(r=>r.id===s.id?{...r,updated_at:new Date().toISOString()}:r))):(f.success("Oppfølging fjernet"),h(l=>l.filter(r=>r.id!==s.id)))}catch(t){console.error("Error marking follow-up done:",t),f.error("Kunne ikke oppdatere oppfølging")}finally{_(null)}},k=i.useMemo(()=>{let s=c.filter(t=>!(u&&!t.title.toLowerCase().includes(u.toLowerCase())||n!=="all"&&N(t)!==n));return s.sort((t,a)=>{if(p==="title")return t.title.localeCompare(a.title,"nb");const l=w(t),r=w(a);return!l&&!r?0:l?r?p==="date_asc"?l.getTime()-r.getTime():r.getTime()-l.getTime():-1:1}),s},[c,u,n,p]),g=i.useMemo(()=>{let s=0,t=0,a=0;return c.forEach(l=>{const r=N(l);r==="overdue"?s++:r==="upcoming"?t++:r==="normal"&&a++}),{overdue:s,upcoming:t,normal:a,total:c.length}},[c]),M=s=>{switch(s){case"overdue":return e.jsx(H,{className:"h-4 w-4 text-destructive"});case"upcoming":return e.jsx(G,{className:"h-4 w-4 text-amber-500"});default:return e.jsx(j,{className:"h-4 w-4 text-muted-foreground"})}},B=s=>({published:"Publisert",draft:"Utkast",pending_review:"Til godkjenning",unpublished:"Avpublisert"})[s]||s;return e.jsxs("div",{className:"min-h-screen flex flex-col",children:[e.jsx(O,{}),e.jsx(W,{}),e.jsx("main",{className:"flex-1 container mx-auto px-4 py-8",children:e.jsxs("div",{className:"max-w-5xl mx-auto",children:[e.jsx("div",{className:"flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4 mb-6",children:e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl md:text-3xl font-bold flex items-center gap-2",children:[e.jsx(j,{className:"h-7 w-7"}),"Oppfølgingsliste"]}),e.jsx("p",{className:"text-muted-foreground text-sm mt-1",children:"Artikler som trenger gjennomgang og oppdatering"})]})}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3 mb-6",children:[e.jsx(d,{className:o("cursor-pointer transition-colors",n==="all"&&"ring-2 ring-primary"),onClick:()=>x("all"),children:e.jsxs(m,{className:"p-4",children:[e.jsx("div",{className:"text-2xl font-bold",children:g.total}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Totalt"})]})}),e.jsx(d,{className:o("cursor-pointer transition-colors border-destructive/50",n==="overdue"&&"ring-2 ring-destructive"),onClick:()=>x("overdue"),children:e.jsxs(m,{className:"p-4",children:[e.jsx("div",{className:"text-2xl font-bold text-destructive",children:g.overdue}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Forfalt"})]})}),e.jsx(d,{className:o("cursor-pointer transition-colors border-amber-500/50",n==="upcoming"&&"ring-2 ring-amber-500"),onClick:()=>x("upcoming"),children:e.jsxs(m,{className:"p-4",children:[e.jsx("div",{className:"text-2xl font-bold text-amber-600",children:g.upcoming}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Snart"})]})}),e.jsx(d,{className:o("cursor-pointer transition-colors",n==="normal"&&"ring-2 ring-primary"),onClick:()=>x("normal"),children:e.jsxs(m,{className:"p-4",children:[e.jsx("div",{className:"text-2xl font-bold text-muted-foreground",children:g.normal}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Planlagt"})]})})]}),e.jsxs("div",{className:"flex flex-wrap gap-3 mb-4",children:[e.jsxs("div",{className:"relative flex-1 min-w-[180px] max-w-sm",children:[e.jsx(R,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(P,{placeholder:"Søk i tittel...",value:u,onChange:s=>T(s.target.value),className:"pl-9"})]}),e.jsxs($,{value:p,onValueChange:s=>D(s),children:[e.jsxs(q,{className:"w-[180px]",children:[e.jsx(ee,{className:"h-4 w-4 mr-2"}),e.jsx(z,{})]}),e.jsxs(K,{children:[e.jsx(v,{value:"date_asc",children:"Forfallsdato ↑"}),e.jsx(v,{value:"date_desc",children:"Forfallsdato ↓"}),e.jsx(v,{value:"title",children:"Tittel A-Å"})]})]})]}),I?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("p",{className:"text-muted-foreground",children:"Laster..."})}):k.length===0?e.jsx(d,{children:e.jsxs(m,{className:"flex flex-col items-center justify-center py-12",children:[e.jsx(j,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:c.length===0?"Ingen artikler har oppfølging satt":"Ingen artikler matcher filteret"})]})}):e.jsx("div",{className:"space-y-2",children:k.map(s=>{const t=N(s),a=Z(s);return w(s),e.jsx(d,{className:o("transition-colors",t==="overdue"&&"border-destructive/40 bg-destructive/5",t==="upcoming"&&"border-amber-500/40 bg-amber-50/50 dark:bg-amber-950/10"),children:e.jsx(m,{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"mt-1 shrink-0",children:M(t)}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"font-medium truncate",children:s.title}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mt-1 text-sm",children:[e.jsx("span",{className:o("font-medium whitespace-nowrap",t==="overdue"&&"text-destructive",t==="upcoming"&&"text-amber-600"),children:a}),s.category&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-muted-foreground",children:"·"}),e.jsx("span",{className:"text-muted-foreground truncate",children:s.category.name})]}),e.jsx(Q,{variant:"outline",className:"text-xs",children:B(s.status)})]})]}),e.jsxs("div",{className:o("flex gap-1 shrink-0",A?"flex-col":"flex-row"),children:[e.jsxs(C,{variant:"outline",size:"sm",onClick:()=>L(s),disabled:y===s.id,className:"gap-1 text-xs",children:[y===s.id?e.jsx(Y,{className:"h-3 w-3 animate-spin"}):e.jsx(se,{className:"h-3 w-3"}),s.follow_up_type==="interval"?"Tilbakestill":"Ferdig"]}),e.jsxs(C,{variant:"ghost",size:"sm",onClick:()=>{sessionStorage.setItem("articleList_returnUrl",`${window.location.pathname}${window.location.search}`),F(`/admin/articles/edit/${s.id}`)},className:"gap-1 text-xs",children:[e.jsx(V,{className:"h-3 w-3"}),"Rediger"]})]})]})})]})})},s.id)})})]})}),e.jsx(X,{})]})};export{ve 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.