Small fixes after pydantic migration and translations (#448)

This commit is contained in:
Erik Vroon
2024-02-09 12:45:02 +01:00
committed by GitHub
parent 61611066cd
commit 0b4c8412d0
4 changed files with 14 additions and 10 deletions

View File

@@ -1,6 +1,7 @@
import { Alert, Button, Container, Grid, Group, Skeleton } from '@mantine/core';
import { GoPlus } from '@react-icons/all-files/go/GoPlus';
import { IconAlertCircle } from '@tabler/icons-react';
import { TFunction } from 'i18next';
import { useTranslation } from 'next-i18next';
import React from 'react';
import { SWRResponse } from 'swr';
@@ -16,6 +17,7 @@ import { responseIsValid } from '../utils/util';
import Round from './round';
function getRoundsGridCols(
t: TFunction<'translation', undefined>,
stageItem: StageItemWithRounds,
tournamentData: TournamentMinimal,
swrStagesResponse: SWRResponse,
@@ -23,7 +25,6 @@ function getRoundsGridCols(
readOnly: boolean,
displaySettings: BracketDisplaySettings
) {
const { t } = useTranslation();
let rounds: React.JSX.Element[] | React.JSX.Element = stageItem.rounds
.sort((r1: any, r2: any) => (r1.name > r2.name ? 1 : -1))
.map((round: RoundInterface) => (
@@ -167,6 +168,8 @@ export default function Brackets({
selectedStageId: string | null;
displaySettings: BracketDisplaySettings;
}) {
const { t } = useTranslation();
if (swrStagesResponse.isLoading) {
return <LoadingSkeleton />;
}
@@ -191,6 +194,7 @@ export default function Brackets({
.sort((i1: StageItemWithRounds, i2: StageItemWithRounds) => (i1.name > i2.name ? 1 : -1))
.map((stageItem: StageItemWithRounds) =>
getRoundsGridCols(
t,
stageItem,
tournamentData,
swrStagesResponse,

View File

@@ -45,9 +45,9 @@ export default function PlayersTable({
const players: Player[] = swrPlayersResponse.data != null ? swrPlayersResponse.data.data : [];
const tableState = getTableState('name');
const minELOScore = Math.min(...players.map((player) => player.elo_score));
const maxELOScore = Math.max(...players.map((player) => player.elo_score));
const maxSwissScore = Math.max(...players.map((player) => player.swiss_score));
const minELOScore = Math.min(...players.map((player) => Number(player.elo_score)));
const maxELOScore = Math.max(...players.map((player) => Number(player.elo_score)));
const maxSwissScore = Math.max(...players.map((player) => Number(player.swiss_score)));
if (swrPlayersResponse.error) return <RequestErrorAlert error={swrPlayersResponse.error} />;
@@ -73,7 +73,7 @@ export default function PlayersTable({
</Table.Td>
<Table.Td>
<PlayerScore
score={player.elo_score}
score={Number(player.elo_score)}
min_score={minELOScore}
max_score={maxELOScore}
decimals={0}
@@ -81,7 +81,7 @@ export default function PlayersTable({
</Table.Td>
<Table.Td>
<PlayerScore
score={player.swiss_score}
score={Number(player.swiss_score)}
min_score={0}
max_score={maxSwissScore}
decimals={1}

View File

@@ -45,8 +45,8 @@ export default function TeamsTable({
<Table.Td>
<DateTime datetime={team.created} />
</Table.Td>
<Table.Td>{team.swiss_score.toFixed(1)}</Table.Td>
<Table.Td>{team.elo_score.toFixed(0)}</Table.Td>
<Table.Td>{Number(team.swiss_score).toFixed(1)}</Table.Td>
<Table.Td>{Number(team.elo_score).toFixed(0)}</Table.Td>
<Table.Td>
<TeamUpdateModal
tournament_id={tournamentData.id}

View File

@@ -24,7 +24,7 @@ import { SWRResponse } from 'swr';
import NotFoundTitle from '../../404';
import { DropzoneButton } from '../../../components/utils/file_upload';
import { GenericSkeleton } from '../../../components/utils/skeletons';
import { getBaseURL, getTournamentIdFromRouter } from '../../../components/utils/util';
import { capitalize, getBaseURL, getTournamentIdFromRouter } from '../../../components/utils/util';
import { Club } from '../../../interfaces/club';
import { Tournament, getTournamentEndpoint } from '../../../interfaces/tournament';
import { getBaseApiUrl, getClubs, getTournaments } from '../../../services/adapter';
@@ -101,7 +101,7 @@ function GeneralTournamentForm({
<Select
withAsterisk
data={clubs.map((p) => ({ value: `${p.id}`, label: p.name }))}
label={t('clubs_title')}
label={capitalize(t('clubs_title'))}
placeholder={t('club_select_placeholder')}
searchable
limit={20}