HifiPlanet-Website/hifi/assets/ContactRequests-C7zOuKRw.js
Maaxxs 29f15d0133 Package editor: products, upgrades and prices for a model on one page
Tested locally on a separate branch before merging.

- Selected model (and package to open) live in the URL (?model=…&paket=…),
  so going back or reloading returns to the same vehicle.
- Packages are compact rows (price, product/upgrade count, badge,
  visibility); a click expands one package with its texts on the left and
  markup, live price calculation, products and upgrades on the right.
- Products and upgrades are edited inline and saved immediately. Several
  audio4cars links can be pasted at once, and products/upgrades are
  reordered by drag & drop (@dnd-kit). The separate product/upgrade pages
  are gone; old links redirect to the package in the editor.
- New GET /models/{id}/package-items loads all products and upgrades of a
  model in one request.
- "Pakete kopieren" can include upgrades (include_upgrades).

No database changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-26 23:48:57 +02:00

1 line
4.3 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import{b as f,r as l,j as t,a as c}from"./index-D6g8QQLx.js";const j=d=>new Intl.NumberFormat("de-DE",{style:"currency",currency:"EUR"}).format(d),k={new:"Neu",in_progress:"In Bearbeitung",done:"Erledigt"},v={new:"bg-brand-100 text-brand-700 dark:bg-brand-900/40 dark:text-brand-300",in_progress:"bg-amber-100 text-amber-700 dark:bg-amber-900/40 dark:text-amber-300",done:"bg-green-100 text-green-700 dark:bg-green-900/40 dark:text-green-300"},N=()=>t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",className:"h-4 w-4",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 7h16M9 7V5a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2m3 0-.8 12.1a1 1 0 0 1-1 .9H7.8a1 1 0 0 1-1-.9L6 7h12ZM10 11v6M14 11v6"})});function _(){const{hasPermission:d}=f(),[n,u]=l.useState([]),[s,m]=l.useState("all"),i=()=>c.get("/contact").then(u);l.useEffect(()=>{i()},[]);const x=async(e,r)=>{await c.patch(`/contact/${e}`,{status:r}),i()},h=async e=>{confirm("Diese Kontaktanfrage wirklich unwiderruflich löschen?")&&(await c.delete(`/contact/${e}`),i())},g=l.useMemo(()=>({all:n.length,new:n.filter(e=>e.status==="new").length,in_progress:n.filter(e=>e.status==="in_progress").length,done:n.filter(e=>e.status==="done").length}),[n]),o=s==="all"?n:n.filter(e=>e.status===s),b=[{value:"all",label:"Alle"},{value:"new",label:"Neu"},{value:"in_progress",label:"In Bearbeitung"},{value:"done",label:"Erledigt"}];return t.jsxs("div",{children:[t.jsx("h1",{className:"mb-1 text-xl font-bold text-neutral-900 dark:text-white",children:"Kontaktanfragen"}),t.jsx("p",{className:"mb-4 text-sm text-neutral-500 dark:text-neutral-400",children:"Alle Anfragen deiner Kunden. Wähle oben einen Reiter, um nur bestimmte Anfragen zu sehen."}),t.jsx("div",{className:"mb-5 flex flex-wrap gap-2",children:b.map(e=>t.jsxs("button",{onClick:()=>m(e.value),className:`rounded-full px-4 py-1.5 text-sm font-medium transition ${s===e.value?"bg-brand-500 text-white":"bg-neutral-100 text-neutral-600 hover:bg-neutral-200 dark:bg-neutral-800 dark:text-neutral-300 dark:hover:bg-neutral-700"}`,children:[e.label," (",g[e.value],")"]},e.value))}),t.jsxs("div",{className:"space-y-3",children:[o.map(e=>{var r;return t.jsxs("div",{className:"rounded-xl border border-neutral-200 bg-white p-4 dark:border-neutral-800 dark:bg-neutral-900",children:[t.jsxs("div",{className:"mb-2 flex flex-wrap items-start justify-between gap-2",children:[t.jsxs("div",{children:[t.jsxs("p",{className:"font-semibold text-neutral-800 dark:text-neutral-100",children:[e.name," · ",e.email,e.phone?` · ${e.phone}`:""]}),e.vin&&t.jsxs("p",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:["FIN: ",t.jsx("span",{className:"font-mono",children:e.vin})]}),t.jsx("p",{className:"text-xs text-neutral-400",children:new Date(e.created_at.replace(" ","T")).toLocaleString("de-DE")})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("select",{value:e.status,onChange:a=>x(e.id,a.target.value),className:`rounded-full border-0 px-3 py-1 text-xs font-medium ${v[e.status]}`,children:Object.entries(k).map(([a,p])=>t.jsx("option",{value:a,children:p},a))}),d("contact.delete")&&t.jsx("button",{onClick:()=>h(e.id),"aria-label":"Anfrage löschen",title:"Anfrage löschen",className:"rounded-md p-1.5 text-neutral-400 hover:bg-red-50 hover:text-red-600 dark:hover:bg-red-900/20",children:t.jsx(N,{})})]})]}),(e.brand_name||e.model_name||e.package_name||e.product_name)&&t.jsx("p",{className:"mb-2 text-sm text-neutral-500 dark:text-neutral-400",children:[e.brand_name,e.model_name,e.package_name,e.product_name].filter(Boolean).join(" · ")}),((r=e.selected_upgrades)==null?void 0:r.length)>0&&t.jsxs("div",{className:"mb-2 rounded-md bg-brand-50 p-2 text-sm text-brand-800 dark:bg-brand-900/20 dark:text-brand-200",children:[t.jsx("p",{className:"font-semibold",children:"Gewünschte Upgrades:"}),t.jsx("ul",{className:"list-disc pl-5",children:e.selected_upgrades.map(a=>t.jsxs("li",{children:[a.name," – ",j(a.price)]},a.id))})]}),e.message&&t.jsx("p",{className:"text-sm text-neutral-700 dark:text-neutral-300",children:e.message})]},e.id)}),o.length===0&&t.jsx("p",{className:"text-neutral-400",children:s==="all"?"Noch keine Kontaktanfragen eingegangen.":"Keine Anfragen mit diesem Status."})]})]})}export{_ as default};