import React, { useState } from 'react'; import { X, Image as ImageIcon, Check } from 'lucide-react'; import { useTranslation } from 'react-i18next'; import { Button, Card, AuthenticatedImage } from '../common'; import { AdminPhoto } from '../../services/photos.service'; interface HeroPhotoSelectorProps { photos: AdminPhoto[]; currentHeroPhotoId?: number | null; onSelect: (photoId: number | null) => void; isEditing: boolean; } export const HeroPhotoSelector: React.FC = ({ photos, currentHeroPhotoId, onSelect, isEditing }) => { const { t } = useTranslation(); const [isOpen, setIsOpen] = useState(false); const [selectedPhotoId, setSelectedPhotoId] = useState(currentHeroPhotoId || null); const currentHeroPhoto = photos.find(p => p.id === currentHeroPhotoId); const handleSelect = (photoId: number) => { setSelectedPhotoId(photoId); onSelect(photoId); setIsOpen(false); }; const handleRemove = () => { setSelectedPhotoId(null); onSelect(null); }; if (!isEditing) { return (
{currentHeroPhoto ? (
) : (

{t('events.noHeroPhotoSelected')}

)}
); } return (

{t('events.heroPhotoHelp')}

{currentHeroPhoto ? (
) : ( )} {/* Photo Selection Modal */} {isOpen && (

{t('events.selectHeroPhoto')}

{photos.length === 0 ? (

{t('events.noPhotosAvailable')}

) : (
{photos.map((photo) => (
handleSelect(photo.id)} className={`relative cursor-pointer rounded-lg overflow-hidden border-2 transition-all ${ photo.id === selectedPhotoId ? 'border-primary-500 ring-2 ring-primary-500 ring-offset-2' : 'border-transparent hover:border-neutral-300' }`} >
{photo.id === selectedPhotoId && (
)}

{photo.filename}

))}
)}
)}
); };