'use client' import { useState } from 'react' import { IconCamera, IconMapPin, IconCalendar, IconEye, IconHeart, IconStar } from '@tabler/icons-react' import { Photo } from '@/types/photo' interface PhotoThumbnailProps { photo: Photo size?: 'small' | 'medium' | 'large' showMetadata?: boolean onPhotoClick?: (photo: Photo) => void } export default function PhotoThumbnail({ photo, size = 'medium', showMetadata = false, onPhotoClick }: PhotoThumbnailProps) { const [imageError, setImageError] = useState(false) const [showDetails, setShowDetails] = useState(false) // Parse metadata let metadata: any = {} try { metadata = photo.metadata ? JSON.parse(photo.metadata) : {} } catch (error) { console.warn('Failed to parse photo metadata:', error) } const exif = metadata.exif || {} // Size configurations - keep square containers for grid layout const sizeConfig = { small: { container: 'aspect-square', thumbnail: 150 }, medium: { container: 'aspect-square', thumbnail: 200 }, large: { container: 'aspect-square', thumbnail: 300 } } const config = sizeConfig[size] // Format metadata for display const formatExposureTime = (time: number) => { if (time >= 1) return `${time}s` return `1/${Math.round(1 / time)}s` } const formatFocalLength = (length: number) => `${Math.round(length)}mm` const formatISO = (iso: number | number[]) => { const isoValue = Array.isArray(iso) ? iso[0] : iso return `ISO ${isoValue}` } const formatDate = (dateString: string) => { try { return new Date(dateString).toLocaleDateString() } catch { return 'Unknown' } } const formatFileSize = (bytes: number) => { if (bytes === 0) return '0 B' const k = 1024 const sizes = ['B', 'KB', 'MB', 'GB'] const i = Math.floor(Math.log(bytes) / Math.log(k)) return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i] } return (