From aa2807d370cdd3d52c2af6cf3cfde3a9600807fb Mon Sep 17 00:00:00 2001 From: Pinapelz Date: Tue, 1 Jul 2025 18:31:01 -0700 Subject: add not found pages for site and feed --- site/src/App.tsx | 2 ++ site/src/pages/Homepage.tsx | 48 ++++++++++++++++++++++++++++++++++++-- site/src/pages/NotFound.tsx | 57 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 105 insertions(+), 2 deletions(-) create mode 100644 site/src/pages/NotFound.tsx diff --git a/site/src/App.tsx b/site/src/App.tsx index 79c64a1..b6823a6 100644 --- a/site/src/App.tsx +++ b/site/src/App.tsx @@ -1,5 +1,6 @@ import Home from './pages/Homepage'; import GameSelector from './pages/GameSelector' +import NotFound from './pages/NotFound'; import { Routes, Route } from "react-router-dom"; function App() { @@ -8,6 +9,7 @@ function App() { } /> } /> } /> + } /> ); } diff --git a/site/src/pages/Homepage.tsx b/site/src/pages/Homepage.tsx index 0d98206..5d202dc 100644 --- a/site/src/pages/Homepage.tsx +++ b/site/src/pages/Homepage.tsx @@ -20,10 +20,12 @@ export default function Home() { null, ); const [loading, setLoading] = useState(true); + const [error, setError] = useState(false); useEffect(() => { const fetchNews = async () => { setLoading(true); + setError(false); const newsDataFileName = gameId ? `${gameId}_news.json` : "news.json"; try { const response = await fetch( @@ -36,14 +38,15 @@ export default function Home() { setNewsFeedData(data); } catch (e) { console.error(e); + setError(true); } finally { setLoading(false); } }; fetchNews(); - }, [gameId]); // Re-fetch when gameId changes + }, [gameId, newsAPIBase]); // Re-fetch when gameId changes - if (loading || newsFeedData === null) { + if (loading) { return ( <> @@ -58,6 +61,47 @@ export default function Home() { ); } + if (error || newsFeedData === null) { + return ( + <> + +
+
+
+ 404 +
+

+ News Not Found +

+

+ {gameId + ? `Unable to fetch news for ${getGameTitle(gameId)}` + : "Unable to fetch news feed" + } +

+
+

+ The news feed you're looking for might be temporarily unavailable or doesn't exist. +

+ + Return Home + +
+
+
+ + ); + } + return ( <> diff --git a/site/src/pages/NotFound.tsx b/site/src/pages/NotFound.tsx new file mode 100644 index 0000000..62c978c --- /dev/null +++ b/site/src/pages/NotFound.tsx @@ -0,0 +1,57 @@ +import { useSearchParams } from "react-router-dom"; +import TitleBar from "../components/TitleBar"; + +export default function NotFound() { + const [searchParams] = useSearchParams(); + const isMoe = searchParams.has("moe"); + + return ( + <> + +
+
+
+

404

+

Page Not Found

+
+ Not found +
+

+ The page you're looking for doesn't exist or has been moved. +

+ +
+
+
+ + ); +} \ No newline at end of file -- cgit v1.2.3