import { useState, useEffect } from 'react'; import { Link, useParams } from 'react-router-dom'; import { api } from '../../api/client.js'; import usePageMeta from '../../hooks/usePageMeta.js'; import Reveal from '../../components/Reveal.jsx'; import Lightbox from '../../components/Lightbox.jsx'; import { useLanguage } from '../../context/LanguageContext.jsx'; export default function GalleryProjectPage() { const { brandSlug, projectSlug } = useParams(); const [data, setData] = useState(null); const [error, setError] = useState(''); const [openIndex, setOpenIndex] = useState(null); const { t } = useLanguage(); useEffect(() => { api .get(`/gallery-brands/${brandSlug}/${projectSlug}/photos`) .then(setData) .catch((e) => setError(e.message)); }, [brandSlug, projectSlug]); usePageMeta({ title: data ? `${data.project.name} – ${data.project.brand_name}` : t('galleryProjectPage.metaTitleFallback'), description: data ? t('galleryProjectPage.metaDescription')(data.project.name) : undefined, path: `/galerie/${brandSlug}/${projectSlug}`, }); const navigate = (delta) => { setOpenIndex((i) => { const total = data.photos.length; return (i + delta + total) % total; }); }; if (error) { return
{error}
; } if (!data) { return{t('galleryProjectPage.loading')}
; } return ({t('galleryProjectPage.breadcrumbGallery')} /{' '} {data.project.brand_name} / {data.project.name}
{t('galleryProjectPage.empty')}
)}