From 00736e72ddefcf780d12700400a70163863992e4 Mon Sep 17 00:00:00 2001 From: ppc Date: Thu, 5 Sep 2024 10:55:03 +0100 Subject: [PATCH] add startup alert to web --- amnet-web/src/pages/card-in-screen.tsx | 54 +++++++++++++++++--------- 1 file changed, 36 insertions(+), 18 deletions(-) diff --git a/amnet-web/src/pages/card-in-screen.tsx b/amnet-web/src/pages/card-in-screen.tsx index 5ac1080..50e9e53 100644 --- a/amnet-web/src/pages/card-in-screen.tsx +++ b/amnet-web/src/pages/card-in-screen.tsx @@ -1,8 +1,8 @@ import {useLiveQuery} from "dexie-react-hooks"; import {useEffect, useMemo, useState} from "react"; import {useNavigate, useParams} from "react-router-dom"; -import {performCardIn, fetchServerInfo, getGameName} from "amnet-shared"; -import {CircleDot, CircleCheckBig, Home, Nfc, Wallet, WifiOff} from "lucide-react"; +import {performCardIn, fetchServerInfo, getGameName, AMServerInfo} from "amnet-shared"; +import {CircleDot, CircleCheckBig, Home, Nfc, Wallet, WifiOff, TvMinimalPlay} from "lucide-react"; import {Button} from "@/components/ui/button"; import {useToast} from "@/components/ui/use-toast"; @@ -60,8 +60,6 @@ async function performCardInAction(card: AimeCard, server: AimeServer, setCardIn } } -/* eslint-enable @typescript-eslint/no-explicit-any */ - function CardList(props: { cards: ReadonlyArray | null, cardSelected: (card: AimeCard) => void }) { const navigate = useNavigate(); @@ -82,6 +80,39 @@ function CardList(props: { cards: ReadonlyArray | null, cardSelected: ); } +function AlertPanel(props: { server: AMServerInfo | null, connectionError: boolean, onReloadRequested: () => void}) { + if (!props.server) { + return + } + + if (props.connectionError) { + return + + Connection Issue + + There was an issue connecting to {props.server.serverAddress}. + Please check the game is running and try again. + + + } + + if (props.server.timeSinceLastPoll === null) { + return + + Server Startup + + Scanning a card below may not have any effect until the service has fully started up. reload this page to perform another check. + + + } + + return +} + function ServerCardInPage() { const {toast} = useToast(); const {serverId} = useParams<{ serverId: string }>(); @@ -153,20 +184,7 @@ function ServerCardInPage() { - {!server && ()} - {(server && !connectionError) && } - {(server && connectionError) && ( - - - Connection Issue - - There was an issue connecting to {server.serverAddress}. - Please check the game is running and setServerReloadCounter(serverReloadCounter + 1)}>try again. - - - )} + setServerReloadCounter(serverReloadCounter + 1)}/> {server && (