HifiPlanet-Website/hifi/assets/GalleryPhotos-BHp7wMr5.js
Maaxxs c6214637e8 Collapse overlong package card bullets instead of stretching the row
Since all cards in a row share one height, a single card with long
paragraphs in its description (e.g. Limitless) made every card as tall
as that one, leaving a lot of empty space in the others. Collapsed
bullets are now clamped to three lines; normal bullets fit, long
paragraphs end with an ellipsis and the card offers "Mehr anzeigen" to
show the full text.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-27 00:18:09 +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-CZwY_OSZ.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};