import { cc } from '@/utility/css'; import { Photo, PhotoDateRange, dateRangeForPhotos } from '.'; import ShareButton from '@/components/ShareButton'; export default function PhotoHeader({ entity, entityVerb, entityDescription, photos, selectedPhoto, sharePath, count, dateRange, }: { entity: JSX.Element entityVerb: string entityDescription: string photos: Photo[] selectedPhoto?: Photo sharePath: string count?: number dateRange?: PhotoDateRange }) { const { start, end } = dateRangeForPhotos(photos, dateRange); const selectedPhotoIndex = selectedPhoto ? photos.findIndex(photo => photo.id === selectedPhoto.id) : undefined; return (
{entity} {selectedPhotoIndex !== undefined // eslint-disable-next-line max-len ? `${entityVerb} ${selectedPhotoIndex + 1} of ${count ?? photos.length}` : entityDescription} {selectedPhotoIndex === undefined && } {start === end ? start : <>{start}
– {end}}
); }