import type { ImmichAlbum } from '@/lib/immich'; import type { PhotoItem } from './PhotoGrid'; import { PhotoGrid } from './PhotoGrid'; import { BackLink } from '@/components/BackLink'; import type { GridConfig } from '@/lib/config'; import type { LightboxWatermark } from '@/components/Lightbox'; import Image from 'next/image'; import React from 'react'; interface AlbumDetailViewProps { album: ImmichAlbum; images: PhotoItem[]; layout: GridConfig['layout']; gridStyle: React.CSSProperties; backLinkHref: string; backLinkLabel: string; subtitle?: string; heroImageUrl?: string; heroBlurDataURL?: string; watermark?: LightboxWatermark; } /** * Extra detail for the album header — shooting date and camera/lens, read off * the first asset that carries EXIF. Both are rendered in their own spans and * hidden by default; only presets that ask for them show them, so the header * keeps reading "86 photos" everywhere else. */ function albumMetaDetail(album: ImmichAlbum): { date?: string; gear?: string } { const first = album.assets.find((a) => a.exifInfo); const exif = first?.exifInfo; const taken = exif?.dateTimeOriginal || first?.fileCreatedAt; const gear = [exif?.model, exif?.lensModel].filter(Boolean).join(' · '); return { ...(taken ? { date: formatMonthYear(taken) } : {}), ...(gear ? { gear } : {}), }; } function formatMonthYear(iso: string): string | undefined { const d = new Date(iso); if (Number.isNaN(d.getTime())) return undefined; return `${String(d.getMonth() + 1).padStart(2, '0')}/${d.getFullYear()}`; } export function AlbumDetailView({ album, images, layout, gridStyle, backLinkHref, backLinkLabel, subtitle, heroImageUrl, heroBlurDataURL, watermark, }: AlbumDetailViewProps) { const metaDetail = albumMetaDetail(album); return ( <> {heroImageUrl && (
{subtitle}
)} {album.description &&{album.description}
}{images.length} {images.length === 1 ? 'photo' : 'photos'} {metaDetail.date && ( · {metaDetail.date} )} {metaDetail.gear && ( {metaDetail.gear} )}