'use client'; import Link from 'next/link'; import Image from 'next/image'; import { VideoData } from '../constants'; import { useEffect, useRef } from 'react'; interface PlaylistPanelProps { videos: VideoData[]; currentVideoId: string; listId: string; title: string; } export default function PlaylistPanel({ videos, currentVideoId, listId, title }: PlaylistPanelProps) { const currentIndex = videos.findIndex(v => v.id === currentVideoId); const activeItemRef = useRef(null); // Auto-scroll to active item on mount useEffect(() => { if (activeItemRef.current) { activeItemRef.current.scrollIntoView({ behavior: 'smooth', block: 'nearest' }); } }, [currentVideoId]); return (
{/* Header */}

{title}

{currentIndex + 1} / {videos.length} videos
{/* List */}
{videos.map((video, index) => { const isActive = video.id === currentVideoId; return ( {/* Number or Playing Icon */}
{isActive ? '▶' : index + 1}
{/* Thumbnail */}
{video.title} {video.duration && (
{video.duration}
)}
{/* Info */}

{video.title}

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