import React, { useState, useEffect } from "react"; import DynamicPageContent from "../components/Layout/DynamicPageContent"; import { useAuth } from "../context/AuthContext"; import StreamDashboard from "../components/Stream/StreamDashboard"; import { CircleDotIcon as RecordIcon, SquarePlayIcon as PlaybackIcon, Undo2Icon } from "lucide-react"; import VodsDashboard from "../components/Stream/VodsDashboard"; import { useVods } from "../hooks/useContent"; interface DashboardPageProps { tab?: "dashboard" | "stream" | "vod"; } const DashboardPage: React.FC = ({ tab = "dashboard" }) => { const { username, isLive, userId, setIsLive } = useAuth(); const { vods } = useVods(`/api/vods/${username}`); const [selectedTab, setSelectedTab] = useState<"dashboard" | "stream" | "vod">(tab); const colors = { stream: "red-500", vod: "green-500", dashboard: "white", }; useEffect(() => { if (username) { checkUserStatus(); } }, [username]); const checkUserStatus = async () => { if (!username) return; try { const response = await fetch(`/api/user/${username}/status`); const data = await response.json(); setIsLive(data.is_live); } catch (error) { console.error("Error checking user status:", error); } }; return (
{selectedTab != "dashboard" && ( setSelectedTab("dashboard")} /> )}

Welcome {username}

{selectedTab === "stream" ? "Streaming" : selectedTab === "vod" ? "VODs" : "Dashboard"}

{selectedTab == "dashboard" ? (
setSelectedTab("stream")} > {isLive && (
LIVE
)}

Streaming

vods.length > 0 && setSelectedTab("vod")} >

VODs

0 ? "text-white" : "text-gray-600"} absolute bottom-5 text-sm`}> {vods.length} VOD{vods.length != 1 && "s"} available

) : selectedTab === "stream" && username && userId ? ( ) : ( )}
); }; export default DashboardPage;