From c889a9ad33374eae03cec5b0358d79016d6fd97e Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sat, 8 Mar 2025 10:32:05 +0900 Subject: show ranking --- .../GolfWatchAppGamingMultiplayer.tsx | 102 +++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 frontend/app/components/GolfWatchApps/GolfWatchAppGamingMultiplayer.tsx (limited to 'frontend/app/components/GolfWatchApps/GolfWatchAppGamingMultiplayer.tsx') diff --git a/frontend/app/components/GolfWatchApps/GolfWatchAppGamingMultiplayer.tsx b/frontend/app/components/GolfWatchApps/GolfWatchAppGamingMultiplayer.tsx new file mode 100644 index 0000000..b6d2ac3 --- /dev/null +++ b/frontend/app/components/GolfWatchApps/GolfWatchAppGamingMultiplayer.tsx @@ -0,0 +1,102 @@ +import { useAtomValue } from "jotai"; +import type { components } from "../../api/schema"; +import { gamingLeftTimeSecondsAtom } from "../../states/watch"; +import BorderedContainer from "../BorderedContainer"; + +type RankingEntry = components["schemas"]["RankingEntry"]; + +type Props = { + gameDisplayName: string; + ranking: RankingEntry[]; + problemTitle: string; + problemDescription: string; + gameResult: "winA" | "winB" | "draw" | null; +}; + +export default function GolfWatchAppGamingMultiplayer({ + gameDisplayName, + ranking, + problemTitle, + problemDescription, + gameResult, +}: Props) { + const leftTimeSeconds = useAtomValue(gamingLeftTimeSecondsAtom)!; + + const leftTime = (() => { + const m = Math.floor(leftTimeSeconds / 60); + const s = leftTimeSeconds % 60; + return `${m.toString().padStart(2, "0")}:${s.toString().padStart(2, "0")}`; + })(); + + const topBg = gameResult + ? gameResult === "winA" + ? "bg-orange-400" + : gameResult === "winB" + ? "bg-purple-400" + : "bg-pink-500" + : "bg-sky-600"; + + return ( +
+
+
+
+
{gameDisplayName}
+
{leftTime}
+
+
+
+
+
+
+
+ {problemTitle} +
+ {problemDescription} +
+
+
+ + + + + + + + + + {ranking.map((entry, index) => ( + + + + + + ))} + +
+ 順位 + + 名前 + + スコア +
+ {index + 1} + + {entry.player.display_name} + + {entry.score} +
+
+
+
+ ); +} -- cgit v1.2.3-70-g09d2