diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 16d88d8..72b2a6b 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -16,6 +16,7 @@ import StreamDashboardPage from "./pages/StreamDashboardPage"; import { Brightness } from "./context/BrightnessContext"; import Sidebar from "./components/Navigation/Sidebar"; import LoadingScreen from "./components/Layout/LoadingScreen"; +import Following from "./pages/Following"; function App() { const [isLoggedIn, setIsLoggedIn] = useState(false); @@ -98,6 +99,7 @@ function App() { > }> } /> + } /> } /> diff --git a/frontend/src/components/Settings/QuickSettings.tsx b/frontend/src/components/Settings/QuickSettings.tsx index e02327a..fe4b149 100644 --- a/frontend/src/components/Settings/QuickSettings.tsx +++ b/frontend/src/components/Settings/QuickSettings.tsx @@ -2,8 +2,8 @@ import React from "react"; import ThemeSetting from "./ThemeSetting"; import { useTheme } from "../../context/ThemeContext"; import { useQuickSettings } from "../../context/QuickSettingsContext"; -import Screenshot from "../Functionality/Screenshot"; -import BrightnessControl from "../Functionality/BrightnessControl"; +import Screenshot from "../functionality/Screenshot"; +import BrightnessControl from "../functionality/BrightnessControl"; const QuickSettings: React.FC = () => { const { theme } = useTheme(); diff --git a/frontend/src/pages/Following.tsx b/frontend/src/pages/Following.tsx new file mode 100644 index 0000000..805c185 --- /dev/null +++ b/frontend/src/pages/Following.tsx @@ -0,0 +1,130 @@ +import React, { useEffect, useState } from "react"; +import { useAuth } from "../context/AuthContext"; +import { useSidebar } from "../context/SidebarContext"; +import { ToggleButton } from "../components/Input/Button"; +import { Sidebar as SidebarIcon } from "lucide-react"; +import { useNavigate } from "react-router-dom"; // Import useNavigate + +// Define TypeScript interfaces +interface Streamer { + user_id: number; + username: string; +} + +interface FollowingProps { + extraClasses?: string; +} + +const Following: React.FC = ({ extraClasses = "" }) => { + const { showSideBar, setShowSideBar } = useSidebar(); + const navigate = useNavigate(); + const { username, isLoggedIn } = useAuth(); + const [followedStreamers, setFollowedStreamers] = useState([]); + const [followedCategories, setFollowedCategories] = useState([]); + + // Fetch followed streamers + useEffect(() => { + const fetchFollowedStreamers = async () => { + try { + const response = await fetch("/api/user/following"); + if (!response.ok) throw new Error("Failed to fetch followed streamers"); + const data = await response.json(); + setFollowedStreamers(data.streamers || []); + setFollowedCategories(data.categories || []); + } catch (error) { + console.error("Error fetching followed streamers:", error); + } + }; + + if (isLoggedIn) { + fetchFollowedStreamers(); + } + }, [isLoggedIn]); + + // Handle sidebar toggle + const handleSideBar = () => { + setShowSideBar(!showSideBar); + }; + + return ( + <> + {/* Sidebar Toggle Button */} + + + + {showSideBar && ( + + Press S + + )} + + + {/* Sidebar Container */} + + {/* Profile Info */} + + navigate(`/user/${username}`)} + /> + + + Logged in as + + navigate(`/user/${username}`)} + > + {username} + + + + + {/* Following Section */} + + (e.currentTarget.style.boxShadow = "var(--follow-shadow)")} + onMouseLeave={(e) => (e.currentTarget.style.boxShadow = "none")} + > + + Following + + + + {/* Streamers Followed */} + + + Streamers + + + {followedStreamers.map((streamer) => ( + navigate(`/user/${streamer.username}`)} + > + {streamer.username} + + ))} + + + + + > + ); +}; + +export default Following; diff --git a/frontend/src/pages/UserPage.tsx b/frontend/src/pages/UserPage.tsx index 8bc6b7a..2ca0cf5 100644 --- a/frontend/src/pages/UserPage.tsx +++ b/frontend/src/pages/UserPage.tsx @@ -105,13 +105,12 @@ const UserPage: React.FC = () => { return ( - + {/* Profile Section - TOP */} @@ -271,9 +270,11 @@ const UserPage: React.FC = () => { } onMouseLeave={(e) => (e.currentTarget.style.boxShadow = "none")} > - - Following - + navigate(`/user/${username}/following`)} + > + Following + - - Streamers - + + + Streamers + + - - Category - + + + Category + +