import { useParams, Link } from 'react-router-dom'; import { PageLayout } from '@/components/layout/PageLayout'; import { PlanBadge } from '@/components/shared/PlanBadge'; import { StatusBadge } from '@/components/shared/StatusBadge'; import { Pagination } from '@/components/shared/Pagination'; import { EmptyState } from '@/components/shared/EmptyState'; import { ImageGridSkeleton } from '@/components/shared/Skeleton'; import { SearchInput } from '@/components/shared/SearchInput'; import { ImageLoader } from '@/components/shared/ImageLoader'; import { useImages } from '@/hooks/useImages'; import { useClient } from '@/hooks/useClients'; import { formatDate, formatBytes, truncate } from '@/utils/formatters'; import { ArrowLeft, ExternalLink, Images, Camera } from 'lucide-react'; import { useState, useCallback } from 'react'; export default function ClientGallery() { const { clientId } = useParams<{ clientId: string }>(); const { data: client } = useClient(clientId); const [page, setPage] = useState(1); const [search, setSearch] = useState(''); const { data, isLoading } = useImages({ client_id: clientId, search: search || undefined, page, page_size: 20, sort_by: 'uploaded_at', sort_order: 'desc', }); const images = data?.items ?? []; const total = data?.total ?? 0; const totalPages = data?.pages ?? 1; const handleSearch = useCallback((value: string) => { setSearch(value); setPage(1); }, []); return ( {client && } {client && ( Détail client )} Toutes les images } > {/* Search */}
{/* Grid */} {isLoading ? ( ) : images.length === 0 ? ( } /> ) : (
{images.map((img) => (

{truncate(img.original_name, 25)}

{img.ai_tags?.length > 0 && (
{img.ai_tags?.slice(0, 3).map((tag) => ( {tag} ))}
)}
{formatDate(img.uploaded_at)} {img.exif_make && ( {img.exif_make} )}
))}
)} {/* Pagination */} {totalPages > 1 && (
)}
); }