# Conflicts: # hifi/assets/AccountSettings-3Az7PIEf.js # hifi/assets/AccountSettings-C7P_TaTL.js # hifi/assets/AccountSettings-CfY49TlQ.js # hifi/assets/AdminUsers-C1zi3a_m.js # hifi/assets/Brands-V9s4vz2i.js # hifi/assets/ContactRequests-BcF_HxL3.js # hifi/assets/Dashboard-m6lX2kWI.js # hifi/assets/DatabaseSettings-pQejbEjR.js # hifi/assets/Downloads-DCZm2dP9.js # hifi/assets/EmailSettings-B_RqPmc9.js # hifi/assets/EmailSettings-DixrL0D8.js # hifi/assets/EmailSettings-VadOa5J3.js # hifi/assets/ExportImportSettings-Bkwm__tE.js # hifi/assets/Faqs-CDIDxeRo.js # hifi/assets/GalleryBrands-CeGo7QXi.js # hifi/assets/GalleryPhotos-NPKQDZMi.js # hifi/assets/GalleryProjects-CfB-fA4x.js # hifi/assets/HomeSections-BzNKNMho.js # hifi/assets/ImageUploadField-B8P2oQZ9.js # hifi/assets/ImageUploadField-DyLcJG5-.js # hifi/assets/ImageUploadField-oqjVVSSG.js # hifi/assets/LegalSettings-BnY85Lz7.js # hifi/assets/LegalSettings-CRgpL0dP.js # hifi/assets/LegalSettings-DGN-Kl_a.js # hifi/assets/Login-CFL8bhtC.js # hifi/assets/Login-Dc1nFqtx.js # hifi/assets/Login-pbnF9xt-.js # hifi/assets/MaintenanceSettings-CFGyPBuq.js # hifi/assets/MaintenanceSettings-DhcTJBUJ.js # hifi/assets/MaintenanceSettings-DsGBefLo.js # hifi/assets/Models-CyjYxQOO.js # hifi/assets/Packages-6JjKaOj1.js # hifi/assets/Partners-BRwobp6H.js # hifi/assets/PermissionGroups-CW64DGq9.js # hifi/assets/PermissionGroups-DI5xJ6TD.js # hifi/assets/PermissionGroups-_i9KMBTo.js # hifi/assets/ResetSettings-Bm64tgsK.js # hifi/assets/RichTextEditor-DJwdsoJ6.js # hifi/assets/RichTextEditor-DTscIhNf.js # hifi/assets/RichTextEditor-DcSNZ4jD.js # hifi/assets/Services-BTvu0ymy.js # hifi/assets/SettingsLayout-C5JQlIqD.js # hifi/assets/SetupWizard-BHY_FJd_.js # hifi/assets/SetupWizard-Cu-s4Wuc.js # hifi/assets/SetupWizard-DcHkEIZ7.js # hifi/assets/TextStyleWidget-BZdrb1Dr.js # hifi/assets/TextStyleWidget-CkwixV2h.js # hifi/assets/TextStyleWidget-Czb7ujSZ.js # hifi/assets/UpdateSettings-Ce5oqncR.js # hifi/assets/WebsiteSettings-B7CzBT2R.js # hifi/assets/eye-CZFeBsZS.js # hifi/assets/eye-YlN_9rkm.js # hifi/assets/eye-jJN30JHV.js # hifi/assets/iconRegistry-BJRytynd.js # hifi/assets/iconRegistry-C8CVLtUq.js # hifi/assets/iconRegistry-DUWamfSa.js # hifi/assets/index-QV-Szw5n.js # hifi/assets/trash-2-CQGOvKRj.js # hifi/assets/trash-2-CwY7wd8m.js # hifi/assets/trash-2-fu7u5OTF.js # hifi/index.html
1 line
5 KiB
JavaScript
1 line
5 KiB
JavaScript
import{o as M,r as n,p as R,j as e,L as F,c as h}from"./index-Tg8iNBwT.js";import{I as B}from"./ImageUploadField-Ds8_wHup.js";import{T as C}from"./TextStyleWidget-By2wExOQ.js";import{S as E,s as I}from"./SortableList-DRJ1jYgo.js";import"./resizeImage-C6PvAwh0.js";import"./sortable.esm-DhUbHeHx.js";import"./grip-vertical-By7l82Pv.js";const u={name:"",image_path:"",sort_order:0};function O(){const i=M(),[d,o]=n.useState([]),[s,c]=n.useState(u),[y,f]=n.useState(u),[a,k]=n.useState(null),[j,x]=n.useState(""),p=n.useRef(null);R(JSON.stringify(s)!==JSON.stringify(y),"brands");const g=()=>h.get("/brands").then(o);n.useEffect(()=>{g()},[]);const w=t=>{const r={name:t.name,image_path:t.image_path||"",sort_order:t.sort_order};k(t.id),c(r),f(r),x(""),requestAnimationFrame(()=>{var l,m,N;(l=p.current)==null||l.scrollIntoView({behavior:"smooth",block:"start"}),(N=(m=p.current)==null?void 0:m.querySelector("input"))==null||N.focus({preventScroll:!0})})},b=()=>{k(null),c(u),f(u)},v=async t=>{t.preventDefault(),x("");try{if(a)await h.put(`/brands/${a}`,s);else{const r=d.reduce((l,m)=>Math.max(l,Number(m.sort_order)||0),0)+10;await h.post("/brands",{...s,sort_order:r})}i.success(a?"Marke gespeichert.":"Marke angelegt."),b(),g()}catch(r){x(r.message)}},S=async t=>{if(confirm("Marke inkl. aller Modelle/Pakete/Produkte wirklich löschen?"))try{await h.delete(`/brands/${t}`),a===t&&b(),i.success("Marke gelöscht."),g()}catch(r){i.error(`Löschen fehlgeschlagen: ${r.message}`)}},_=async t=>{const r=d;o(t);try{o(await I("brands",t)),i.success("Reihenfolge gespeichert.")}catch(l){o(r),i.error(`Reihenfolge konnte nicht gespeichert werden: ${l.message}`)}};return e.jsxs("div",{className:"grid gap-6 lg:grid-cols-3",children:[e.jsxs("div",{className:"lg:col-span-2",children:[e.jsx("h1",{className:"mb-1 text-xl font-bold text-neutral-900 dark:text-white",children:"Marken"}),e.jsx("p",{className:"mb-4 text-sm text-neutral-500 dark:text-neutral-400",children:"Reihenfolge am Griff links per Ziehen ändern – so erscheinen die Marken auf der Website."}),e.jsx("div",{className:"overflow-x-auto rounded-xl border border-neutral-200 dark:border-neutral-800",children:e.jsxs("table",{className:"w-full text-left text-sm",children:[e.jsx("thead",{className:"bg-neutral-50 text-neutral-500 dark:bg-neutral-900 dark:text-neutral-400",children:e.jsxs("tr",{children:[e.jsx("th",{className:"w-8 px-2 py-2","aria-label":"Reihenfolge"}),e.jsx("th",{className:"px-4 py-2",children:"Bild"}),e.jsx("th",{className:"px-4 py-2",children:"Name"}),e.jsx("th",{className:"px-4 py-2 text-right",children:"Aktionen"})]})}),e.jsx(E,{items:d,onReorder:_,as:"tbody",className:"divide-y divide-neutral-100 dark:divide-neutral-800",children:(t,r)=>e.jsxs(e.Fragment,{children:[e.jsx("td",{className:"bg-white px-2 py-2 dark:bg-neutral-950",children:r}),e.jsx("td",{className:"bg-white px-4 py-2 dark:bg-neutral-950",children:t.image_path?e.jsx("img",{src:t.image_path,alt:"",className:"h-10 w-10 rounded-md object-cover"}):e.jsx("span",{className:"flex h-10 w-10 items-center justify-center rounded-md bg-neutral-100 text-xs text-neutral-400 dark:bg-neutral-800",children:"–"})}),e.jsx("td",{className:"bg-white px-4 py-2 font-medium text-neutral-800 dark:bg-neutral-950 dark:text-neutral-100",children:e.jsx(F,{to:`/fahrzeuge/${t.slug}`,target:"_blank",className:"hover:text-brand-500",children:t.name})}),e.jsxs("td",{className:"whitespace-nowrap bg-white px-4 py-2 text-right dark:bg-neutral-950",children:[e.jsx("button",{onClick:()=>w(t),className:"mr-3 text-brand-600 hover:underline",children:"Bearbeiten"}),e.jsx("button",{onClick:()=>S(t.id),className:"text-red-600 hover:underline",children:"Löschen"})]})]})}),d.length===0&&e.jsx("tbody",{children:e.jsx("tr",{children:e.jsx("td",{colSpan:4,className:"px-4 py-6 text-center text-neutral-400",children:"Noch keine Marken angelegt."})})})]})})]}),e.jsxs("form",{ref:p,onSubmit:v,className:"h-fit scroll-mt-20 space-y-4 rounded-xl border border-neutral-200 bg-white p-5 dark:border-neutral-800 dark:bg-neutral-900",children:[e.jsx("h2",{className:"font-bold text-neutral-900 dark:text-white",children:a?"Marke bearbeiten":"Neue Marke"}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm font-medium text-neutral-700 dark:text-neutral-300",children:"Name *"}),e.jsx("input",{required:!0,value:s.name,onChange:t=>c({...s,name:t.target.value}),className:"w-full rounded-md border border-neutral-300 bg-white px-3 py-2 text-sm dark:border-neutral-700 dark:bg-neutral-900"}),a&&e.jsx(C,{fieldKey:`brands.${a}.name`,previewText:s.name||"Beispieltext"})]}),e.jsx(B,{value:s.image_path,onChange:t=>c({...s,image_path:t}),label:"Bild (optional)"}),j&&e.jsx("p",{className:"text-sm text-red-600",children:j}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"submit",className:"rounded-md bg-brand-500 px-4 py-2 text-sm font-semibold text-white hover:bg-brand-600",children:a?"Speichern":"Anlegen"}),a&&e.jsx("button",{type:"button",onClick:b,className:"rounded-md border border-neutral-300 px-4 py-2 text-sm dark:border-neutral-700",children:"Abbrechen"})]})]})]})}export{O as default};
|