HifiPlanet-Website/hifi/assets/GalleryPhotos-DGMVFfyC.js
Maaxxs 54928d1411 Add package badges/visibility and a download area, speed up the site
Customer feedback round (4 items):

- Packages: one-click "Sichtbar/Ausgeblendet" toggle per package (saved
  immediately). Hidden packages disappear from the model page; the tier
  look of the remaining cards is ranked across all packages so it stays
  stable.
- Packages: badge per card (Empfohlen, Am beliebtesten, Tipp, Coming soon
  or custom text) plus an optional video link shown as "Zum Video". Legacy
  is_featured maps to "Empfohlen".
- New download area (/downloads + Admin -> Downloads): upload with
  progress, inline audio player, allow-listed file types, optional access
  password, new permission downloads.manage. Files live in
  api/uploads/downloads/ (gitignored, created at runtime).
- Performance:
  - SetupGate no longer refetches and remounts the whole app on every
    navigation.
  - Page loader waits only for pending API calls and above-the-fold images
    (fixes an 8 s hang on /leistungen caused by lazy images inside the
    hidden container).
  - Admin pages lazy-loaded; icon library moved out of the main bundle
    (initial JS 2.2 MB -> 0.48 MB).
  - Background video loads only near the viewport and was re-encoded to
    720p (32 MB -> 8.5 MB).
  - Visitors without a session cookie get no PHP session, so their parallel
    API requests no longer queue on the session lock.
  - index.html is served with Cache-Control: no-cache so browsers don't
    keep a stale build after deploys.
- Fonts (Barlow, Barlow Condensed, Michroma) are self-hosted instead of
  loaded from Google Fonts; the default privacy policy mentions this, lists
  all local storage uses and uses the new TDDDG name.
- A code update that adds a table no longer sends the site into the setup
  wizard while an admin exists.

Run "Datenbankstruktur aktualisieren" after deploying (new package
columns, downloads table, app_settings.downloads_password).

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

1 line
3 KiB
JavaScript

import{e as w,r as l,j as t,L as P,a as n}from"./index-CA8nTsDv.js";function C(){const{projectId:d}=w(),[i,c]=l.useState([]),[m,h]=l.useState(""),[x,g]=l.useState(!1),[f,p]=l.useState(""),u=l.useRef(null),o=()=>n.get(`/gallery-projects/${d}/photos`).then(c);l.useEffect(()=>{o()},[d]);const j=async e=>{const r=Array.from(e.target.files||[]);if(r.length!==0){h(""),g(!0);try{for(let a=0;a<r.length;a++){p(`Lade Bild ${a+1} von ${r.length} hoch…`);const s=new FormData;s.append("file",r[a]);const v=await n.post("/uploads",s);await n.post("/gallery-photos",{gallery_project_id:Number(d),image_path:v.path,sort_order:i.length+a})}o()}catch(a){h(a.message)}finally{g(!1),p(""),u.current&&(u.current.value="")}}},N=(e,r)=>{c(a=>a.map(s=>s.id===e.id?{...s,caption:r}:s))},k=(e,r)=>{c(a=>a.map(s=>s.id===e.id?{...s,sort_order:r}:s))},b=async e=>{await n.put(`/gallery-photos/${e.id}`,{caption:e.caption,sort_order:e.sort_order}),o()},y=async e=>{confirm("Foto wirklich entfernen?")&&(await n.delete(`/gallery-photos/${e}`),o())};return t.jsxs("div",{children:[t.jsx("p",{className:"mb-2 text-sm",children:t.jsx(P,{to:"/admin/gallery-projects",className:"text-brand-600 hover:underline",children:"← Zurück zu den Projekten"})}),t.jsx("h1",{className:"mb-4 text-xl font-bold text-neutral-900 dark:text-white",children:"Fotos im Projekt"}),t.jsxs("div",{className:"mb-6 rounded-xl border border-neutral-200 bg-white p-4 dark:border-neutral-800 dark:bg-neutral-900",children:[t.jsx("label",{className:"mb-1 block text-sm font-medium text-neutral-700 dark:text-neutral-300",children:"Fotos hinzufügen (Mehrfachauswahl möglich)"}),t.jsx("input",{ref:u,type:"file",multiple:!0,accept:"image/png,image/jpeg,image/webp",onChange:j,disabled:x,className:"text-sm"}),x&&t.jsx("p",{className:"mt-2 text-sm text-neutral-500",children:f})]}),m&&t.jsx("p",{className:"mb-4 text-sm text-red-600",children:m}),t.jsxs("div",{className:"grid grid-cols-2 gap-4 sm:grid-cols-3 md:grid-cols-4",children:[i.map(e=>t.jsxs("div",{className:"overflow-hidden rounded-xl border border-neutral-200 bg-white dark:border-neutral-800 dark:bg-neutral-900",children:[t.jsx("img",{src:e.image_path,alt:e.caption||"",className:"aspect-square w-full object-cover"}),t.jsxs("div",{className:"space-y-2 p-3",children:[t.jsx("input",{value:e.caption||"",onChange:r=>N(e,r.target.value),onBlur:()=>b(e),placeholder:"Bildunterschrift (optional)",className:"w-full rounded-md border border-neutral-300 bg-white px-2 py-1 text-xs dark:border-neutral-700 dark:bg-neutral-900"}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{type:"number",value:e.sort_order,onChange:r=>k(e,Number(r.target.value)),onBlur:()=>b(e),className:"w-16 rounded-md border border-neutral-300 bg-white px-2 py-1 text-xs dark:border-neutral-700 dark:bg-neutral-900"}),t.jsx("button",{onClick:()=>y(e.id),className:"text-xs text-red-600 hover:underline",children:"Entfernen"})]})]})]},e.id)),i.length===0&&t.jsx("p",{className:"col-span-full py-6 text-center text-neutral-400",children:"Noch keine Fotos in diesem Projekt."})]})]})}export{C as default};