'use client'; import Link from 'next/link'; import { useParams } from 'next/navigation'; import PageLayout from '../../components/PageLayout'; import { useActiveCoffees } from '../hooks/getActiveCoffees'; import CoffeeDetailGallery from '../components/CoffeeDetailGallery'; import { useCoffeePictures } from '../hooks/useCoffeePictures'; import { useTranslation } from '../../i18n/useTranslation'; export default function CoffeeAbonnementDetailPage() { const { t } = useTranslation(); const params = useParams(); const { coffees, loading, error } = useActiveCoffees(); const rawId = params?.id; const coffeeId = Array.isArray(rawId) ? rawId[0] : rawId; const { pictureUrls: endpointPictureUrls, loading: picturesLoading } = useCoffeePictures(coffeeId ? String(coffeeId) : undefined); const coffee = coffees.find((item) => item.id === String(coffeeId)); const fallbackGallery = coffee ? (coffee.gallery.length ? coffee.gallery : (coffee.image ? [coffee.image] : [])) : []; const gallery = endpointPictureUrls.length ? endpointPictureUrls : fallbackGallery; return (
{t('autofix.kbdc4e405')}

{t('autofix.k50bb594b')}

{t('autofix.ka157a704')}

{t('autofix.k96839795')}
{loading && (
)} {!loading && error && (
{error}
)} {!loading && !error && !coffee && (

{t('autofix.kbcb6ceea')}

{t('autofix.k8e0e178e')}

)} {!loading && !error && coffee && (

{coffee.name}

{coffee.description || t('autofix.kec078e54')}

{t('autofix.kab208d8e')} EUR {coffee.pricePer10.toFixed(2)}
{t('autofix.ke0eb10f2')} EUR {(coffee.pricePer10 / 10).toFixed(2)}
{t('autofix.k5bd8edf9')} {picturesLoading ? 'Loading...' : gallery.length}

{t('autofix.k31c4f5d9')}

{t('autofix.k47e6f301')}
)}
); }