'use client'; import Link from 'next/link'; import Image from 'next/image'; import { VideoData } from '../constants'; import { useEffect, useRef } from 'react'; const DEFAULT_THUMBNAIL = 'https://i.ytimg.com/vi/default/hqdefault.jpg'; interface PlaylistPanelProps { videos: VideoData[]; currentVideoId: string; listId: string; title: string; } function handleImageError(e: React.SyntheticEvent) { const img = e.target as HTMLImageElement; if (img.src !== DEFAULT_THUMBNAIL) { img.src = DEFAULT_THUMBNAIL; } } export default function PlaylistPanel({ videos, currentVideoId, listId, title }: PlaylistPanelProps) { const currentIndex = videos.findIndex(v => v.id === currentVideoId); const activeItemRef = useRef(null); useEffect(() => { if (activeItemRef.current) { activeItemRef.current.scrollIntoView({ behavior: 'smooth', block: 'nearest' }); } }, [currentVideoId]); return (

{title}

{currentIndex + 1} / {videos.length} videos
{videos.map((video, index) => { const isActive = video.id === currentVideoId; const thumbnailSrc = video.thumbnail || DEFAULT_THUMBNAIL; return (
{isActive ? '▶' : index + 1}
{video.title} {video.duration && (
{video.duration}
)}

{video.title}

{video.uploader}
); })}
); }