import { useState } from 'react'; import { X, ChevronLeft, ChevronRight } from 'lucide-react'; import { Dialog, DialogContent } from '@/components/ui/dialog'; import { Button } from '@/components/ui/button'; interface PhotoModalProps { photos: Array<{ id: string; url: string; filename?: string; caption?: string; }>; initialIndex: number; isOpen: boolean; onClose: () => void; } export function PhotoModal({ photos, initialIndex, isOpen, onClose }: PhotoModalProps) { const [currentIndex, setCurrentIndex] = useState(initialIndex); const currentPhoto = photos[currentIndex]; const goToPrevious = () => { setCurrentIndex((prev) => (prev > 0 ? prev - 1 : photos.length - 1)); }; const goToNext = () => { setCurrentIndex((prev) => (prev < photos.length - 1 ? prev + 1 : 0)); }; const handleKeyDown = (e: React.KeyboardEvent) => { if (e.key === 'ArrowLeft') goToPrevious(); if (e.key === 'ArrowRight') goToNext(); if (e.key === 'Escape') onClose(); }; return (
{/* Close button */} {/* Header */}

{currentPhoto?.filename || `Photo ${currentIndex + 1}`}

{photos.length > 1 && (

{currentIndex + 1} of {photos.length}

)}
{/* Image */}
{currentPhoto?.caption
{/* Navigation */} {photos.length > 1 && ( <> )} {/* Caption */} {currentPhoto?.caption && (

{currentPhoto.caption}

)}
); }