/** * Photo Gallery Component * Agent 3: File Upload & Storage System * * Displays a grid of plant photos with lightbox view */ import React, { useState } from 'react'; interface Photo { id: string; url: string; thumbnailUrl?: string; width?: number; height?: number; caption?: string; uploadedAt?: string; } interface PhotoGalleryProps { photos: Photo[]; onDelete?: (photoId: string) => void; editable?: boolean; columns?: 2 | 3 | 4; className?: string; } export function PhotoGallery({ photos, onDelete, editable = false, columns = 3, className = '', }: PhotoGalleryProps) { const [selectedPhoto, setSelectedPhoto] = useState(null); const [isDeleting, setIsDeleting] = useState(null); const handleDelete = async (photoId: string) => { if (!onDelete) return; setIsDeleting(photoId); try { await onDelete(photoId); } finally { setIsDeleting(null); } }; const gridCols = { 2: 'grid-cols-2', 3: 'grid-cols-2 sm:grid-cols-3', 4: 'grid-cols-2 sm:grid-cols-3 md:grid-cols-4', }; if (photos.length === 0) { return (

No photos yet

); } return ( <>
{photos.map((photo) => (
{photo.caption setSelectedPhoto(photo)} loading="lazy" /> {/* Overlay on hover */}
{editable && onDelete && ( )}
{/* Caption */} {photo.caption && (

{photo.caption}

)}
))}
{/* Lightbox */} {selectedPhoto && (
setSelectedPhoto(null)} > {selectedPhoto.caption e.stopPropagation()} /> {selectedPhoto.caption && (

{selectedPhoto.caption}

)}
)} ); } export default PhotoGallery;