'use client' export interface Track { id: string title: string artistName: string duration: number plays?: number position?: number } export interface TrackListProps { tracks: Track[] currentTrackId?: string onTrackPlay?: (trackId: string) => void showPosition?: boolean showPlays?: boolean } export function TrackList({ tracks, currentTrackId, onTrackPlay, showPosition = false, showPlays = false }: TrackListProps) { const formatDuration = (seconds: number) => { const mins = Math.floor(seconds / 60) const secs = seconds % 60 return `${mins}:${secs.toString().padStart(2, '0')}` } const formatPlays = (count: number) => { if (count >= 1000000) return `${(count / 1000000).toFixed(1)}M` if (count >= 1000) return `${(count / 1000).toFixed(1)}K` return count.toString() } return (
{tracks.map((track, index) => { const isPlaying = track.id === currentTrackId return (
onTrackPlay?.(track.id)} > {/* Position / Play Button */}
{isPlaying ? ( ) : ( <> {showPosition ? (track.position || index + 1) : ''} )}
{/* Track Info */}

{track.title}

{track.artistName}

{/* Stats */}
{showPlays && track.plays !== undefined && (
{formatPlays(track.plays)}
)} {formatDuration(track.duration)}
{/* More Options */}
) })}
) }