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/pages/Homepage.tsx | 48 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 2 deletions(-) (limited to 'site/src/pages/Homepage.tsx') 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 ( <> -- cgit v1.2.3