From c86e5e556880e783e3ea4b0cb001150ed8dd1965 Mon Sep 17 00:00:00 2001 From: Dylan De Faoite Date: Wed, 29 Jul 2026 20:20:26 +0100 Subject: [PATCH] add colour and remove topbar --- frontend/index.html | 2 +- frontend/src/components/Sidebar.tsx | 89 ++++++++++++--- frontend/src/components/Topbar.tsx | 103 ------------------ .../src/components/buttons/MenuButton.tsx | 2 +- .../src/components/buttons/SidebarButton.tsx | 6 +- frontend/src/index.css | 34 ++---- frontend/src/layouts/MainLayout.tsx | 39 +------ frontend/src/main.tsx | 5 +- frontend/src/pages/Home.tsx | 81 ++------------ frontend/src/utils/AuthContext.tsx | 42 +++++++ 10 files changed, 147 insertions(+), 256 deletions(-) delete mode 100644 frontend/src/components/Topbar.tsx create mode 100644 frontend/src/utils/AuthContext.tsx diff --git a/frontend/index.html b/frontend/index.html index c27651a..54219dd 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -6,7 +6,7 @@ - + The VoD System diff --git a/frontend/src/components/Sidebar.tsx b/frontend/src/components/Sidebar.tsx index bb33d56..32d1f0e 100644 --- a/frontend/src/components/Sidebar.tsx +++ b/frontend/src/components/Sidebar.tsx @@ -1,27 +1,50 @@ import clsx from "clsx"; import SidebarButton from "./buttons/SidebarButton.tsx"; -import { Plus, Film, Home, User as UserIcon, Video, Radio } from 'lucide-react'; -import type {User} from "../utils/types.ts"; +import { Plus, Film, Home, Video, Radio } from 'lucide-react'; +import {useAuth} from "../utils/AuthContext.tsx"; +import {type CredentialResponse, GoogleLogin} from "@react-oauth/google"; +import {getUser, login, logout} from "../utils/api/users.ts"; type props = { - user: User | null; className?: string } -const Divider = () =>
; +const Divider = () =>
; + +const Sidebar = ({ className }: props) => { + const { user, setUser } = useAuth() + + const handleLogin = (response: CredentialResponse) => { + if (!response.credential) { + console.error("No credential received from Google login."); + return; + } + + login(response.credential) + .then(() => { + getUser().then(userData => setUser(userData)) + }) + .catch((error) => { + console.error("Login failed:", error); + }); + } + const handleLogout = () => { + logout() + .then(() => + setUser(null) + ) + .catch((error) => { + console.error("Logout failed:", error); + }); + } -const Sidebar = ({user, className}: props) => { return ( -