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)}
))}
);
}