import type { Ranked } from "api/api"; type TopItemProps = { title: string; imageSrc: string; items: Ranked[]; getLabel: (item: T) => string; includeTime?: boolean; }; export function RewindTopItem< T extends { id: string | number; listen_count: number; time_listened: number; } >({ title, imageSrc, items, getLabel, includeTime }: TopItemProps) { const [top, ...rest] = items; if (!top) return null; return (

{title}

{getLabel(top.item)}

{`${top.item.listen_count} plays`} {includeTime ? ` (${Math.floor(top.item.time_listened / 60)} minutes)` : ``}
{rest.map((e) => (
{getLabel(e.item)} {` - ${e.item.listen_count} plays`} {includeTime ? ` (${Math.floor(e.item.time_listened / 60)} minutes)` : ``}
))}
); }