From 400d772cc391d979747510776fa8acfb5a1d00cb Mon Sep 17 00:00:00 2001 From: Pinapelz Date: Sat, 5 Jul 2025 21:42:22 -0700 Subject: implement generic score viewer and import deduplication --- frontend/src/pages/Home.tsx | 122 +++++++++++++++++--------------------------- 1 file changed, 46 insertions(+), 76 deletions(-) (limited to 'frontend/src/pages/Home.tsx') diff --git a/frontend/src/pages/Home.tsx b/frontend/src/pages/Home.tsx index 0ee6862..0aba7f0 100644 --- a/frontend/src/pages/Home.tsx +++ b/frontend/src/pages/Home.tsx @@ -1,9 +1,11 @@ -import { Link, useNavigate } from 'react-router'; -import { useAuth } from '../contexts/AuthContext'; -import type { SupportedGame } from '../types/game'; -import { useState, useEffect } from 'react'; +import { useNavigate } from "react-router"; +import { NavBar } from "../components/NavBar"; +import { useAuth } from "../contexts/AuthContext"; +import type { SupportedGame } from "../types/game"; +import SessionExpiredPopup from "../components/SessionExpiredPopup"; +import { useState, useEffect } from "react"; -import dancerushImage from '../assets/games/dancerush.webp'; +import dancerushImage from "../assets/games/dancerush.webp"; const Home = () => { const { user, isLoading, logout } = useAuth(); @@ -14,36 +16,38 @@ const Home = () => { const handleLogout = async () => { try { await logout(); - navigate('/'); + navigate("/"); } catch (error) { - console.error('Logout failed:', error); - alert('Network error during logout. Please try again.'); + console.error("Logout failed:", error); + alert("Network error during logout. Please try again."); } }; const getGameImage = (internalName: string) => { - switch(internalName){ + switch (internalName) { case "dancerush": { return dancerushImage; } - default: { - return null + default: { + return null; } } - } + }; useEffect(() => { const fetchSupportedGames = async () => { try { - const response = await fetch(import.meta.env.VITE_API_URL+'/supportedGames'); + const response = await fetch( + import.meta.env.VITE_API_URL + "/supportedGames", + ); if (!response.ok) { - throw new Error('Failed to fetch supported games'); + throw new Error("Failed to fetch supported games"); } const data = await response.json(); setSupportedGames(data); } catch (error) { - console.error('Failed to fetch supported games:', error); - alert('Failed to load supported games. Please refresh the page.'); + console.error("Failed to fetch supported games:", error); + alert("Failed to load supported games. Please refresh the page."); } finally { setGamesLoading(false); } @@ -63,69 +67,21 @@ const Home = () => { } if (!user) { - return ( -
-
-
-

Session Expired

-

Please sign in to access your dashboard.

-
- - Sign In - - - Back to Home - -
-
-
-
- ); + return ; } return (
- {/* Navigation */} - + {/* Main Content */}
{/* Header */}

Dashboard

-

Track your rhythm game progress and performance

+

+ Track your rhythm game progress and performance +

{/* Supported Games */} @@ -134,34 +90,48 @@ const Home = () => { {supportedGames.map((game) => (
navigate(`/score?game=${game.internalName}`)} >
{getGameImage(game.internalName) !== null ? ( {game.formattedName} ) : (
- - + +
)}
-

{game.formattedName}

-

{game.description}

+

+ {game.formattedName} +

+

+ {game.description} +

))}
- ); -- cgit v1.2.3