From 1a08d06be929900fb8d8b61a1ac0611005c277e8 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Thu, 20 Mar 2025 19:41:38 +0900 Subject: feat: show submission date on ranking --- frontend/app/components/Gaming/RankingTable.tsx | 66 +++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 frontend/app/components/Gaming/RankingTable.tsx (limited to 'frontend/app/components/Gaming/RankingTable.tsx') diff --git a/frontend/app/components/Gaming/RankingTable.tsx b/frontend/app/components/Gaming/RankingTable.tsx new file mode 100644 index 0000000..e712ed9 --- /dev/null +++ b/frontend/app/components/Gaming/RankingTable.tsx @@ -0,0 +1,66 @@ +import React from "react"; +import type { components } from "../../api/schema"; + +type RankingEntry = components["schemas"]["RankingEntry"]; + +type Props = { + ranking: RankingEntry[]; +}; + +function TableHeaderCell({ children }: { children: React.ReactNode }) { + return ( + + {children} + + ); +} + +function TableBodyCell({ children }: { children: React.ReactNode }) { + return ( + {children} + ); +} + +function formatUnixTimestamp(timestamp: number) { + const date = new Date(timestamp * 1000); + + const year = date.getFullYear(); + const month = (date.getMonth() + 1).toString().padStart(2, "0"); + const day = date.getDate().toString().padStart(2, "0"); + const hours = date.getHours().toString().padStart(2, "0"); + const minutes = date.getMinutes().toString().padStart(2, "0"); + + return `${year}-${month}-${day} ${hours}:${minutes}`; +} + +export default function RankingTable({ ranking }: Props) { + return ( +
+ + + + 順位 + プレイヤー + スコア + 提出時刻 + + + + {ranking.map((entry, index) => ( + + {index + 1} + + {entry.player.display_name} + {entry.player.label && ` (${entry.player.label})`} + + {entry.score} + + {formatUnixTimestamp(entry.submitted_at)} + + + ))} + +
+
+ ); +} -- cgit v1.2.3-70-g09d2