PageSourceSearch

https://autosleutellimburg.nl/assets/BrandsAdmin-BemxJ_M9.js

js autosleutellimburg.nl collected 2026-10-08 01:37:49 UTC 10,158 bytes, 1 lines download raw bytes

1import{p as E,s as m,j as e,ag as w,e as Y,d as h,c9 as Z,aS as ee,aT as se,aU as re,aV as ae,aW as z,r as k,bp as te,bw as f,av as d,ay as ie,c$ as ne,ao as oe,bF as le,aw as ce,az as de,aA as ue,aB as me,ah as F,aD as he,bP as xe}from"./index-hWVpbWs7.js";import{T as je,a as ge,b as T,c as g,d as ve,e as v}from"./table-DpKL9yzv.js";import{I as pe}from"./ImageUpload-qojPGSrL.js";import{C as $}from"./checkbox-CPGqmlCs.js";import{k as fe,l as M,o as ye,P as we,D as be,m as ke,C as _e}from"./core.esm-D3N7VKsD.js";import{s as Se,S as Ce,v as Ne,u as Fe,a as qe}from"./sortable.esm-ByyCsjai.js";import{T as A}from"./trash-2-DWL5qcLt.js";import{G as De}from"./grip-vertical-CBHajWKz.js";import{P as Be}from"./pencil-DASBrmhK.js";import"./uploaderStyles-COtDny0v.js";import"./camera-D7t_sxFM.js";const ze=({value:o,onChange:p,label:x="Galerij",entityType:j})=>{const{data:t}=E({queryKey:["galleries",j],queryFn:async()=>{let i=m.from("galleries").select("*").order("name",{ascending:!0});j&&(i=i.or(`entity_type.eq.${j},entity_type.eq.none`));const{data:n,error:c}=await i;if(c)throw c;return n}});return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(w,{children:x}),e.jsx(Y,{to:"/admin/galleries",children:e.jsxs(h,{type:"button",variant:"ghost",size:"sm",children:[e.jsx(Z,{className:"h-4 w-4 mr-2"}),"Beheer"]})})]}),e.jsxs(ee,{value:o||"none",onValueChange:i=>p(i==="none"?null:i),children:[e.jsx(se,{children:e.jsx(re,{placeholder:"Selecteer een galerij"})}),e.jsxs(ae,{children:[e.jsx(z,{value:"none",children:"Geen galerij"}),t==null?void 0:t.map(i=>e.jsxs(z,{value:i.id,children:[i.name," (",i.type,")"]},i.id))]})]})]})},Me=({brand:o,onEdit:p,onDelete:x,isSelected:j,onSelectChange:t})=>{const{attributes:i,listeners:n,setNodeRef:c,transform:u,transition:l,isDragging:_}=Fe({id:o.id}),S={transform:_e.Transform.toString(u),transition:l,opacity:_?.5:1};return e.jsxs(T,{ref:c,style:S,children:[e.jsx(v,{children:e.jsx($,{checked:j,onCheckedChange:C=>t(o.id,C)})}),e.jsx(v,{children:e.jsx("div",{...i,...n,className:"cursor-grab active:cursor-grabbing hover:bg-muted/50 p-2 rounded",children:e.jsx(De,{className:"w-4 h-4 text-muted-foreground"})})}),e.jsx(v,{children:e.jsx("img",{src:o.logo_url,alt:o.name,className:"h-12 w-auto object-contain"})}),e.jsx(v,{className:"font-medium",children:o.name}),e.jsx(v,{children:o.website_url&&e.jsx("a",{href:o.website_url,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"Link"})}),e.jsx(v,{children:e.jsx("span",{className:`px-2 py-1 rounded-full text-xs ${o.is_active?"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200":"bg-gray-100 text-gray-800 dark:bg-gray-900 dark:text-gray-200"}`,children:o.is_active?"Actief":"Inactief"})}),e.jsx(v,{children:o.display_order}),e.jsx(v,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(h,{variant:"outline",size:"sm",onClick:()=>p(o),children:e.jsx(Be,{className:"w-4 h-4"})}),e.jsx(h,{variant:"destructive",size:"sm",onClick:()=>x(o.id),children:e.jsx(A,{className:"w-4 h-4"})})]})})]})},Ee=()=>{const[o,p]=k.useState(!1),[x,j]=k.useState(null),[t,i]=k.useState(new Set),[n,c]=k.useState({name:"",logo_url:"",description:"",website_url:"",is_active:!0,display_order:0,gallery_id:null}),u=te(),{data:l,isLoading:_}=E({queryKey:["brands"],queryFn:async()=>{const{data:s,error:r}=await m.from("brands").select("*").order("display_order",{ascending:!0});if(r)throw r;return s}}),S=f({mutationFn:async s=>{const{error:r}=await m.from("brands").insert([s]);if(r)throw r},onSuccess:()=>{u.invalidateQueries({queryKey:["brands"]}),d.success("Merk succesvol toegevoegd"),b()},onError:s=>{d.error(`Fout bij toevoegen: ${s.message}`)}}),C=f({mutationFn:async({id:s,data:r})=>{const{error:a}=await m.from("brands").update(r).eq("id",s);if(a)throw a},onSuccess:()=>{u.invalidateQueries({queryKey:["brands"]}),d.success("Merk succesvol bijgewerkt"),b()},onError:s=>{d.error(`Fout bij bijwerken: ${s.message}`)}}),I=f({mutationFn:async s=>{const{error:r}=await m.from("brands").delete().eq("id",s);if(r)throw r},onSuccess:()=>
1{u.invalidateQueries({queryKey:["brands"]}),d.success("Merk succesvol verwijderd")},onError:s=>{d.error(`Fout bij verwijderen: ${s.message}`)}}),K=f({mutationFn:async s=>{const r=s.map((a,y)=>({id:a.id,display_order:y}));for(const a of r){const{error:y}=await m.from("brands").update({display_order:a.display_order}).eq("id",a.id);if(y)throw y}},onSuccess:()=>{u.invalidateQueries({queryKey:["brands"]}),d.success("Volgorde succesvol bijgewerkt")},onError:s=>{d.error(`Fout bij herordenen: ${s.message}`)}}),L=fe(M(we),M(ye,{coordinateGetter:Se})),P=s=>{const{active:r,over:a}=s;if(r.id!==a.id&&l){const y=l.findIndex(N=>N.id===r.id),O=l.findIndex(N=>N.id===a.id),X=qe(l,y,O);K.mutate(X)}},q=f({mutationFn:async s=>{for(const r of s){const{error:a}=await m.from("brands").update({is_active:!0}).eq("id",r);if(a)throw a}},onSuccess:()=>{u.invalidateQueries({queryKey:["brands"]}),d.success(`${t.size} merk(en) geactiveerd`),i(new Set)},onError:s=>{d.error(`Fout bij activeren: ${s.message}`)}}),D=f({mutationFn:async s=>{for(const r of s){const{error:a}=await m.from("brands").update({is_active:!1}).eq("id",r);if(a)throw a}},onSuccess:()=>{u.invalidateQueries({queryKey:["brands"]}),d.success(`${t.size} merk(en) gedeactiveerd`),i(new Set)},onError:s=>{d.error(`Fout bij deactiveren: ${s.message}`)}}),B=f({mutationFn:async s=>{for(const r of s){const{error:a}=await m.from("brands").delete().eq("id",r);if(a)throw a}},onSuccess:()=>{u.invalidateQueries({queryKey:["brands"]}),d.success(`${t.size} merk(en) verwijderd`),i(new Set)},onError:s=>{d.error(`Fout bij verwijderen: ${s.message}`)}}),Q=(s,r)=>{const a=new Set(t);r?a.add(s):a.delete(s),i(a)},V=s=>{i(s&&l?new Set(l.map(r=>r.id)):new Set)},G=()=>{t.size!==0&&q.mutate(Array.from(t))},R=()=>{t.size!==0&&D.mutate(Array.from(t))},W=()=>{t.size!==0&&confirm(`Weet je zeker dat je ${t.size} merk(en) wilt verwijderen?`)&&B.mutate(Array.from(t))},H=s=>{s.preventDefault(),x?C.mutate({id:x.id,data:n}):S.mutate(n)},U=s=>{j(s),c({name:s.name,logo_url:s.logo_url,description:s.description||"",website_url:s.website_url||"",is_active:s.is_active,display_order:s.display_order,gallery_id:s.gallery_id}),p(!0)},J=s=>{confirm("Weet je zeker dat je dit merk wilt verwijderen?")&&I.mutate(s)},b=()=>{c({name:"",logo_url:"",description:"",website_url:"",is_active:!0,display_order:0,gallery_id:null}),j(null),p(!1)};return _?e.jsx("div",{className:"p-8 text-center",children:"Laden..."}):e.jsxs("div",{className:"p-8",children:[e.jsxs("div",{className:"flex justify-between items-center mb-6",children:[e.jsx("h1",{className:"text-3xl font-bold",children:"Merken Beheer"}),!o&&e.jsxs(h,{onClick:()=>p(!0),children:[e.jsx(ie,{className:"w-4 h-4 mr-2"}),"Nieuw Merk"]})]}),t.size>0&&e.jsxs("div",{className:"bg-primary/10 border border-primary/20 rounded-lg p-4 mb-6 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ne,{className:"w-5 h-5 text-primary"}),e.jsxs("span",{className:"font-medium",children:[t.size," merk(en) geselecteerd"]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(h,{variant:"outline",size:"sm",onClick:G,disabled:q.isPending,children:[e.jsx(oe,{className:"w-4 h-4 mr-2"}),"Activeren"]}),e.jsxs(h,{variant:"outline",size:"sm",onClick:R,disabled:D.isPending,children:[e.jsx(le,{className:"w-4 h-4 mr-2"}),"Deactiveren"]}),e.jsxs(h,{variant:"destructive",size:"sm",onClick:W,disabled:B.isPending,children:[e.jsx(A,{className:"w-4 h-4 mr-2"}),"Verwijderen"]})]})]}),e.jsx(ce,{open:o,onOpenChange:s=>{s||b()},children:e.jsxs(de,{className:"sm:max-w-[600px] max-h-[90vh] overflow-y-auto",children:[e.jsx(ue,{children:e.jsx(me,{children:x?"Merk Bewerken":"Nieuw Merk Toevoegen"})}),e.jsxs("form",{onSubmit:H,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(w,{htmlFor:"name",children:"Merknaam *"}),e.jsx(F,{id:"name",value:n.name,onChange:s=>c({...n,name:s.target.value}),required:!0})]}),e.jsx("div",{children:e.jsx(pe,{label:"Logo",value:n.logo_url,onChange:s=>c({...n,logo_url:s}),bucketName:"brand-logos"})}),e.jsxs("div",{children:[e.jsx(w,{htmlFor:"description",children:"Beschrijving"}),e.jsx(he,{id:"description",value:n.description,onChange:s=>c({...n,description:s.target.value}),rows:3})]}),e.jsxs("div",{children:[e.jsx(w,{htmlFor:"website_url",children:"Website URL"}),e.jsx(F,{id:"website_url",type:"url",value:n.website_url,onChange:s=>c({...n,website_url:s.target.value}),placeholder:"https://..."})]}),e.jsxs("div",{children:[e.jsx(w,{htmlFor:"display_order",children:"Volgorde"}),e.jsx(F,{id:"display_order",type:"number",value:n.display_order,onChange:s=>c({...n,display_order:parseInt(s.target.value)})})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(xe,{id:"is_active",checked:n.is_active,onCheckedChange:s=>c({...n,is_active:s})}),e.jsx(w,{htmlFor:"is_active",children:"Actief"})]}),e.jsx(ze,{value:n.gallery_id,onChange:s=>c({...n,gallery_id:s}),label:"Merk Galerij (optioneel)",entityType:"brand"}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsx(h,{type:"submit",children:x?"Bijwerken":"Toevoegen"}),e.jsx(h,{type:"button",variant:"outline",onClick:b,children:"Annuleren"})]})]})]})}),e.jsx("div",{className:"bg-card rounded-lg border",children:e.jsx(be,{sensors:L,collisionDetection:ke,onDragEnd:P,children:e.jsxs(je,{children:[e.jsx(ge,{children:e.jsxs(T,{children:[e.jsx(g,{className:"w-12",children:e.jsx($,{checked:l&&t.size===l.length&&l.length>0,onCheckedChange:V})}),e.jsx(g,{className:"w-12"}),e.jsx(g,{children:"Logo"}),e.jsx(g,{children:"Naam"}),e.jsx(g,{children:"Website"}),e.jsx(g,{children:"Status"}),e.jsx(g,{children:"Volgorde"}),e.jsx(g,{className:"text-right",children:"Acties"})]})}),e.jsx(ve,{children:e.jsx(Ce,{items:(l==null?void 0:l.map(s=>s.id))||[],strategy:Ne,children:l==null?void 0:l.map(s=>e.jsx(Me,{brand:s,onEdit:U,onDelete:J,isSelected:t.has(s.id),onSelectChange:Q},s.id))})})]})})})]})},We=()=>e.jsx(Ee,{});export{We as BrandsAdmin};

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.