'use client'; import { useState } from 'react'; import InfiniteVideoGrid from '../components/InfiniteVideoGrid'; import { VideoData } from '../constants'; interface Props { videoId: string; regionLabel: string; initialMix: VideoData[]; // Initial 40:40:20 mix data for "All" tab initialRelated: VideoData[]; // Initial related data for "Related" tab initialSuggestions: VideoData[]; // Initial suggestions data for "For You" tab } const WATCH_TABS = ['All', 'Mix', 'Related', 'For You', 'Trending']; export default function WatchFeed({ videoId, regionLabel, initialMix, initialRelated, initialSuggestions }: Props) { const [activeTab, setActiveTab] = useState('All'); // Determine category id and initial videos based on active tab let currentCategory = 'WatchAll'; let videos = initialMix; if (activeTab === 'Related') { currentCategory = 'WatchRelated'; videos = initialRelated; } else if (activeTab === 'For You') { currentCategory = 'WatchForYou'; videos = initialSuggestions; } else if (activeTab === 'Trending') { currentCategory = 'Trending'; // 'Trending' falls back to standard fetchMoreVideos logic which handles normal categories or we can handle it specifically. // It's empty initially if missing, the infinite grid will load it. videos = []; } return (
{WATCH_TABS.map((tab) => { const isActive = tab === activeTab; return ( ); })}
); }