import { Link } from "@remix-run/react"; import { useTranslation } from "react-i18next"; import { Avatar } from "~/components/Avatar"; import { SendouButton } from "~/components/elements/Button"; import { SendouPopover } from "~/components/elements/Popover"; import { UsersIcon } from "~/components/icons/Users"; import { Placement } from "~/components/Placement"; import { Table } from "~/components/Table"; import { databaseTimestampToDate } from "~/utils/dates"; import { calendarEventPage, tournamentBracketsPage, tournamentTeamPage, userPage, } from "~/utils/urls"; import type { UserResultsLoaderData } from "../loaders/u.$identifier.results.server"; import { ParticipationPill } from "./ParticipationPill"; export type UserResultsTableProps = { results: UserResultsLoaderData["results"]["value"]; id: string; hasHighlightCheckboxes?: boolean; }; export const HIGHLIGHT_CHECKBOX_NAME = "highlightTeamIds"; export const HIGHLIGHT_TOURNAMENT_CHECKBOX_NAME = "highlightTournamentTeamIds"; export function UserResultsTable({ results, id, hasHighlightCheckboxes, }: UserResultsTableProps) { const { t, i18n } = useTranslation("user"); const placementHeaderId = `${id}-th-placement`; return ( {hasHighlightCheckboxes && {results.map((result, i) => { // We are trying to construct a reasonable label for the checkbox // which shouldn't contain the whole information of the table row as // that can be also accessed when needed. // e.g. "20xx Placing 2nd", "Big House 10 Placing 20th" const placementCellId = `${id}-${result.teamId}-placement`; const nameCellId = `${id}-${result.teamId}-name`; const checkboxLabelIds = `${nameCellId} ${placementHeaderId} ${placementCellId}`; return ( {hasHighlightCheckboxes && ( )} ); })}
} {t("results.placing")} {t("results.date")} {t("results.tournament")} {t("results.participation")} {t("results.team")}
{" "}
/ {result.participantCount}
{databaseTimestampToDate(result.startTime).toLocaleDateString( i18n.language, { day: "numeric", month: "short", year: "numeric", }, )}
{result.eventId ? ( {result.eventName} ) : null} {result.tournamentId ? ( <> {result.logoUrl ? ( ) : null} {result.eventName} {result.div ? ( ({result.div}) ) : null} ) : null}
} size="miniscule" variant="minimal" data-testid="mates-button" /> } >
    {result.mates.map((player) => (
  • {player.name ? ( player.name ) : ( // as any but we know it's a user since it doesn't have name {player.username} )}
  • ))}
{result.tournamentId ? ( {result.teamName} ) : ( result.teamName )}
); }