1import{a1 as G,r as x,s as b,j as e,p as _,C as y,d as C,Q as F,bp as H,bq as q,br as D,D as g,bs as A,aC as V,aD as P,aE as z,aF as M,aG as J,aH as K,aI as O,aJ as Q,N as R,e as X,f as $,g as U,B as W,k as Y,bg as Z,I,P as ee}from"./index-C-GMF1w8.js";const se=()=>{G();const{toast:i}=R(),[S,T]=x.useState(!0),[v,c]=x.useState(!1),[l,j]=x.useState([]),[u,w]=x.useState({}),[o,p]=x.useState(null);x.useEffect(()=>{L()},[]);const L=async()=>{try{const{data:s,error:r}=await b.from("content_filters").select("*").order("filter_scope");if(r)throw r;j(s||[])}catch(s){i({title:"Fout",description:s.message,variant:"destructive"})}finally{T(!1)}},N=async s=>{var a;const r=(a=u[s])==null?void 0:a.trim().toLowerCase();if(!r){i({title:"Fout",description:"Voer een woord in",variant:"destructive"});return}const t=l.find(n=>n.id===s);if(t){if(t.forbidden_words.includes(r)){i({title:"Fout",description:"Dit woord bestaat al in de filter",variant:"destructive"});return}try{c(!0);const n=[...t.forbidden_words,r],{error:d}=await b.from("content_filters").update({forbidden_words:n}).eq("id",s);if(d)throw d;j(l.map(f=>f.id===s?{...f,forbidden_words:n}:f)),w({...u,[s]:""}),i({title:"Succes",description:"Woord toegevoegd aan filter"})}catch(n){i({title:"Fout",description:n.message,variant:"destructive"})}finally{c(!1)}}},B=async(s,r)=>{const t=l.find(a=>a.id===s);if(t)try{c(!0);const a=t.forbidden_words.filter(d=>d!==r),{error:n}=await b.from("content_filters").update({forbidden_words:a}).eq("id",s);if(n)throw n;j(l.map(d=>d.id===s?{...d,forbidden_words:a}:d)),i({title:"Succes",description:"Woord verwijderd uit filter"})}catch(a){i({title:"Fout",description:a.message,variant:"destructive"})}finally{c(!1),p(null)}},E=async(s,r)=>{try{c(!0);const{error:t}=await b.from("content_filters").update({is_active:!r}).eq("id",s);if(t)throw t;j(l.map(a=>a.id===s?{...a,is_active:!r}:a)),i({title:"Succes",description:`Filter ${r?"gedeactiveerd":"geactiveerd"}`})}catch(t){i({title:"Fout",description:t.message,variant:"destructive"})}finally{c(!1)}},k=s=>{var r;return e.jsxs(y,{className:"mb-4",children:[e.jsx(X,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs($,{className:"flex items-center gap-2",children:[s.filter_name,s.is_active?e.jsx(g,{variant:"default",children:"Actief"}):e.jsx(g,{variant:"secondary",children:"Inactief"})]}),e.jsx(U,{className:"mt-2",children:s.description})]}),e.jsx(W,{variant:s.is_active?"outline":"default",size:"sm",onClick:()=>E(s.id,s.is_active),disabled:v,children:s.is_active?"Deactiveren":"Activeren"})]})}),e.jsx(C,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs(Y,{children:["Verboden woorden (",s.forbidden_words.length,")"]}),e.jsx("div",{className:"flex flex-wrap gap-2 mt-2 p-3 bg-muted rounded-md min-h-[60px]",children:s.forbidden_words.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Geen verboden woorden"}):s.forbidden_words.map(t=>e.jsxs(g,{variant:"destructive",className:"flex items-center gap-1 cursor-pointer hover:bg-destructive/80",onClick:()=>p({filterId:s.id,word:t}),children:[t,e.jsx(Z,{className:"h-3 w-3"})]},t))})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("div",{className:"flex-1",children:e.jsx(I,{placeholder:"Nieuw woord toevoegen...",value:u[s.id]||"",onChange:t=>w({...u,[s.id]:t.target.value}),onKeyDown:t=>{t.key==="Enter"&&(t.preventDefault(),N(s.id))}})}),e.jsx(W,{onClick:()=>N(s.id),disabled:v||!((r=u[s.id])!=null&&r.trim()),children:v?e.jsx(_,{className:"h-4 w-4 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(ee,{className:"h-4 w-4 mr-2"}),"Toevoegen"]})})]}),e.jsxs("div",{className:"flex items-start gap-2 p-3 bg-amber-50 dark:bg-amber-950 rounded-md border border-amber-200 dark:border-amber-800",children:[e.jsx(F,{className:"h-5 w-5 text-amber-600 dark:text-amber-400 flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-sm text-amber-800 dark:text-amber-200",children:[e.jsx("strong",{children:"Let op:"}),' Woorden worden case-insensitive gecontroleerd. Het woord "spam" blokkeert ook "SPAM", "Spam", etc.']})]})]})})]},s.id)};if(S)return e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx(_,{className:"h-8 w-8 animate-spin text-primary"})});const m=l.find(s=>
1s.filter_scope==="global"),h=l.find(s=>s.filter_scope==="adult_category");return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-3xl font-bold tracking-tight",children:"Content Filter Beheer"}),e.jsx("p",{className:"text-muted-foreground mt-2",children:"Beheer verboden woorden voor de gehele platform en speciale filters voor volwassen categorieën"})]}),e.jsx(y,{className:"bg-blue-50 dark:bg-blue-950 border-blue-200 dark:border-blue-800",children:e.jsx(C,{className:"pt-6",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(F,{className:"h-6 w-6 text-blue-600 dark:text-blue-400 flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"font-semibold text-blue-900 dark:text-blue-100",children:"Hoe werken de filters?"}),e.jsxs("ul",{className:"text-sm text-blue-800 dark:text-blue-200 space-y-1 list-disc list-inside",children:[e.jsxs("li",{children:[e.jsx("strong",{children:"Global Filter:"})," Wordt toegepast op alle categorieën behalve volwassen categorieën"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Adult Category Filter:"})," Wordt alleen toegepast op leeftijd-gerelateerde categorieën"]}),e.jsx("li",{children:"Woorden worden automatisch gecontroleerd bij het aanmaken/bewerken van listings"}),e.jsx("li",{children:"Gebruikers krijgen een foutmelding als hun content verboden woorden bevat"})]})]})]})})}),e.jsxs(H,{defaultValue:"global",className:"space-y-4",children:[e.jsxs(q,{className:"grid w-full grid-cols-2",children:[e.jsxs(D,{value:"global",children:["Global Filter",e.jsxs(g,{variant:"outline",className:"ml-2",children:[(m==null?void 0:m.forbidden_words.length)||0," woorden"]})]}),e.jsxs(D,{value:"adult",children:["Adult Category Filter",e.jsxs(g,{variant:"outline",className:"ml-2",children:[(h==null?void 0:h.forbidden_words.length)||0," woorden"]})]})]}),e.jsx(A,{value:"global",children:m&&k(m)}),e.jsx(A,{value:"adult",children:h&&k(h)})]})]}),e.jsx(V,{open:!!o,onOpenChange:()=>p(null),children:e.jsxs(P,{children:[e.jsxs(z,{children:[e.jsx(M,{children:"Woord verwijderen?"}),e.jsxs(J,{children:['Weet je zeker dat je het woord "',e.jsx("strong",{children:o==null?void 0:o.word}),'" wilt verwijderen uit de filter? Dit kan niet ongedaan worden gemaakt.']})]}),e.jsxs(K,{children:[e.jsx(O,{children:"Annuleren"}),e.jsx(Q,{onClick:()=>{o&&B(o.filterId,o.word)},className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Verwijderen"})]})]})})]})},re=()=>e.jsx(se,{});export{re 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.