"use client"; import { useState } from 'react'; import { Image } from 'antd'; import { CloseOutlined, UserOutlined, CameraOutlined, BulbOutlined } from '@ant-design/icons'; import type { PhotoPreviewSectionProps, PhotoType } from './types'; import './styles.css'; /** * Photo Preview Section Component * Displays a horizontal list of photos with type indicators and delete functionality * @param photos - Array of photos with type information * @param onDelete - Callback when a photo is deleted * @param className - Additional CSS classes */ export default function PhotoPreviewSection({ photos = [], onDelete, className = '', }: PhotoPreviewSectionProps) { const [previewVisible, setPreviewVisible] = useState(false); const [previewImage, setPreviewImage] = useState(''); const [hoveredIndex, setHoveredIndex] = useState(null); /** * Get icon for photo type */ const getTypeIcon = (type: PhotoType) => { switch (type) { case 'character': return ; case 'scene': return ; case 'prop': return ; default: return null; } }; /** * Get label for photo type */ const getTypeLabel = (type: PhotoType) => { switch (type) { case 'character': return 'Character'; case 'scene': return 'Scene'; case 'prop': return 'Prop'; default: return ''; } }; /** * Handle photo preview */ const handlePreview = (url: string) => { setPreviewImage(url); setPreviewVisible(true); }; /** * Handle photo deletion */ const handleDelete = (index: number) => { onDelete?.(index); }; /** Don't render if no photos */ if (photos.length === 0) { return null; } return (
{/* Photo List Container with Horizontal Scroll */}
{photos.map((photo, index) => (
setHoveredIndex(index)} onMouseLeave={() => setHoveredIndex(null)} > {/* Photo Image */}
handlePreview(photo.url)} > {`${getTypeLabel(photo.type)}
{/* Type Icon - Bottom Left Corner */}
{getTypeIcon(photo.type)}
{/* Delete Button - Top Right Corner */} {hoveredIndex === index && ( )}
))}
{/* Preview Modal - Using absolute positioning to avoid layout space */}
{ setPreviewVisible(visible); }, }} />
); }