'use client'; import { useSortable } from '@dnd-kit/sortable'; import { CSS } from '@dnd-kit/utilities'; import { DEFAULT_ALBUM_SORT } from '@/lib/albumSort'; import { IconCamera, IconGripVertical, IconImage, IconLock, IconPencil, IconTrash } from '../Icons'; import { SORT_LABELS } from './sortOptions'; import type { AlbumEntry } from './types'; export function SortableAlbumCard({ album, index, name, count, thumbnailId, onRemove, onEdit, highlighted, }: { album: AlbumEntry; index: number; name: string; count: number; thumbnailId: string | null; onRemove: () => void; onEdit: () => void; highlighted?: boolean; }) { const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable({ id: `album-${album.id}-${index}`, }); const style = { transform: CSS.Transform.toString(transform), transition, opacity: isDragging ? 0.5 : 1, zIndex: isDragging ? 10 : undefined, }; return (
); } interface AlbumCardProps { album: AlbumEntry; name: string; count: number; thumbnailId: string | null; onRemove: () => void; onEdit: () => void; dragListeners?: Record; /** Marked briefly when a diagnostics link pointed at this album. */ highlighted?: boolean; } export default function AlbumCard({ album, name, count, thumbnailId, onRemove, onEdit, dragListeners, highlighted, }: AlbumCardProps) { const heroThumb = album.heroImage || thumbnailId; const hasPassword = !!album.password; const hasTitleOverride = !!album.title; return (
{dragListeners && (
)} {heroThumb ? ( ) : (
)}
{album.title || name}
{hasPassword && ( )} {album.heroImage && ( )} {album.sort && album.sort !== DEFAULT_ALBUM_SORT && ( {album.sort === 'manual' ? ( ) : ( album.sort )} )}
{count} photos
); }