From a3b1a3bfdf8714469e35d431f28d559619326c73 Mon Sep 17 00:00:00 2001 From: Pinapelz Date: Fri, 7 Nov 2025 23:02:37 -0800 Subject: add instance info to landing page --- frontend/src/pages/Landing.tsx | 78 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) (limited to 'frontend/src') diff --git a/frontend/src/pages/Landing.tsx b/frontend/src/pages/Landing.tsx index e3b7898..20eb887 100644 --- a/frontend/src/pages/Landing.tsx +++ b/frontend/src/pages/Landing.tsx @@ -1,7 +1,38 @@ import { Link } from "react-router"; +import { useEffect, useState } from "react"; +import type { SupportedGame } from "../types/game"; import sakuraMirageImage from "../assets/games/mirage.webp"; const Landing = () => { + const [requireInvite, setRequireInvite] = useState(false); + const [numUsers, setNumUsers] = useState(0); + const [supportedGames, setSupportedGames] = useState(null); + useEffect(() => { + const fetchServerInfo = async () => { + try { + const response = await fetch(import.meta.env.VITE_API_URL + "/info"); + const data = await response.json(); + setRequireInvite(Boolean(data.requireInvite)); + setNumUsers(Number(data.userCount)); + } catch (error) { + console.error('Error fetching server info:', error); + } + }; + + const fetchSupportedGames = async () => { + try { + const response = await fetch(import.meta.env.VITE_API_URL + "/supportedGames"); + const data = await response.json(); + setSupportedGames(data); + } catch (error) { + console.error('Error fetching supported games:', error); + } + }; + fetchServerInfo(); + fetchSupportedGames(); + }, []); + + return (
{/* Navigation */} @@ -64,6 +95,53 @@ const Landing = () => {
+ {/* Server Stats Section */} +
+
+
+

+ Server Status +

+
+
+

Users

+

{numUsers}

+

registered users

+
+
+

Registration

+

+ {requireInvite ? "Invite Only" : "Open"} +

+

+ {requireInvite ? "ask an admin" : "anyone can join"} +

+
+
+

Games

+

+ {supportedGames ? supportedGames.length : "Loading..."} +

+

supported games

+
+
+ {supportedGames && supportedGames.length > 0 && ( +
+

Supported Games

+
+ {supportedGames.map((game) => ( +
+

{game.formattedName}

+

{game.description}

+
+ ))} +
+
+ )} +
+
+
+ {/* Introduction Section */}
-- cgit v1.2.3