import React from 'react'; import { Link } from 'react-router-dom'; import { Card, CardContent } from '@/components/ui/card'; import { Button } from '@/components/ui/button'; import { usePollGalleryDelta } from '../polling/usePollGalleryDelta'; type Props = { slug: string }; export default function GalleryPreview({ slug }: Props) { const { photos, loading } = usePollGalleryDelta(slug); const [mode, setMode] = React.useState<'latest' | 'popular'>('latest'); const items = React.useMemo(() => { const arr = photos.slice(); if (mode === 'popular') { arr.sort((a: any, b: any) => (b.likes_count ?? 0) - (a.likes_count ?? 0)); } else { arr.sort((a: any, b: any) => new Date(b.created_at ?? 0).getTime() - new Date(a.created_at ?? 0).getTime()); } return arr.slice(0, 6); }, [photos, mode]); return (
{loading &&

Lädt…

} {!loading && items.length === 0 && ( Noch keine Fotos. Starte mit deinem ersten Upload! )}
{items.map((p: any) => ( Foto ))}
); }