toggleColorScheme()} size={30}>
{colorScheme === 'dark' ? : }
diff --git a/frontend/src/components/tables/players.tsx b/frontend/src/components/tables/players.tsx
index 4750b4e1..6e33cc28 100644
--- a/frontend/src/components/tables/players.tsx
+++ b/frontend/src/components/tables/players.tsx
@@ -5,7 +5,7 @@ import { Player } from '../../interfaces/player';
import { TournamentMinimal } from '../../interfaces/tournament';
import { deletePlayer } from '../../services/player';
import DeleteButton from '../buttons/delete';
-import { PlayerELOScore } from '../info/player_elo_score';
+import { PlayerScore } from '../info/player_score';
import { PlayerStatistics } from '../info/player_statistics';
import PlayerModal from '../modals/player_modal';
import DateTime from '../utils/datetime';
@@ -23,6 +23,7 @@ export default function PlayersTable({
const tableState = getTableState('name');
const maxELOScore = Math.max(...players.map((player) => player.elo_score));
+ const maxSwissScore = Math.max(...players.map((player) => player.swiss_score));
if (swrPlayersResponse.error) return ;
@@ -38,7 +39,20 @@ export default function PlayersTable({
|
-
+
+ |
+
+
|
ELO score
+
+ Swiss score
+
{null}
diff --git a/frontend/src/components/tables/table.tsx b/frontend/src/components/tables/table.tsx
index 7d242752..a432ee9b 100644
--- a/frontend/src/components/tables/table.tsx
+++ b/frontend/src/components/tables/table.tsx
@@ -57,9 +57,9 @@ export const setSorting = (state: TableState, newSortField: string) => {
export const getTableState = (
initial_sort_field: string,
- initial_sort_direection: boolean = true
+ initial_sort_direction: boolean = true
) => {
- const [reversed, setReversed] = useState(initial_sort_direection);
+ const [reversed, setReversed] = useState(initial_sort_direction);
const [sortField, setSortField] = useState(initial_sort_field);
return {
sortField,
diff --git a/frontend/src/components/tables/upcoming_matches.tsx b/frontend/src/components/tables/upcoming_matches.tsx
index 09e442b9..abe9b1ca 100644
--- a/frontend/src/components/tables/upcoming_matches.tsx
+++ b/frontend/src/components/tables/upcoming_matches.tsx
@@ -34,6 +34,7 @@ export default function UpcomingMatchesTable({
team1_id: upcoming_match.team1.id,
team2_id: upcoming_match.team2.id,
round_id,
+ label: '',
};
await createMatch(tournamentData.id, match_to_schedule);
await swrRoundsResponse.mutate(null);
@@ -45,7 +46,7 @@ export default function UpcomingMatchesTable({
sortTableEntries(m1, m2, tableState)
)
.map((upcoming_match: UpcomingMatchInterface) => (
-
+
|
|
@@ -74,10 +75,10 @@ export default function UpcomingMatchesTable({
-
+
Team 1
-
+
Team 2
diff --git a/frontend/src/interfaces/match.tsx b/frontend/src/interfaces/match.tsx
index d4f29cef..c43a09a7 100644
--- a/frontend/src/interfaces/match.tsx
+++ b/frontend/src/interfaces/match.tsx
@@ -8,6 +8,7 @@ export interface MatchInterface {
team2_score: number;
team1: TeamInterface;
team2: TeamInterface;
+ label: string;
}
export interface MatchBodyInterface {
@@ -15,6 +16,7 @@ export interface MatchBodyInterface {
round_id: number;
team1_score: number;
team2_score: number;
+ label: string;
}
export interface UpcomingMatchInterface {
@@ -28,4 +30,5 @@ export interface MatchCreateBodyInterface {
round_id: number;
team1_id: number;
team2_id: number;
+ label: string;
}
diff --git a/frontend/src/interfaces/player.tsx b/frontend/src/interfaces/player.tsx
index 1ce09016..51fcebea 100644
--- a/frontend/src/interfaces/player.tsx
+++ b/frontend/src/interfaces/player.tsx
@@ -5,6 +5,7 @@ export interface Player {
tournament_id: number;
team_id: number;
elo_score: number;
+ swiss_score: number;
wins: number;
draws: number;
losses: number;
diff --git a/frontend/src/pages/login.tsx b/frontend/src/pages/login.tsx
index b6dbb3d0..40334327 100644
--- a/frontend/src/pages/login.tsx
+++ b/frontend/src/pages/login.tsx
@@ -12,14 +12,16 @@ export default function Login() {
const router = useRouter();
async function attemptLogin(email: string, password: string) {
- await performLogin(email, password);
- showNotification({
- color: 'green',
- title: 'Login successful',
- message: '',
- });
+ const success = await performLogin(email, password);
+ if (success) {
+ showNotification({
+ color: 'green',
+ title: 'Login successful',
+ message: '',
+ });
- await router.push('/');
+ await router.push('/');
+ }
}
const form = useForm({
initialValues: {
diff --git a/frontend/src/pages/tournaments/[id]/dashboard.tsx b/frontend/src/pages/tournaments/[id]/dashboard.tsx
index e1a9ed95..44553d55 100644
--- a/frontend/src/pages/tournaments/[id]/dashboard.tsx
+++ b/frontend/src/pages/tournaments/[id]/dashboard.tsx
@@ -8,6 +8,12 @@ import { getTournamentIdFromRouter } from '../../../components/utils/util';
import { Tournament } from '../../../interfaces/tournament';
import { getBaseApiUrl, getRounds, getTournaments } from '../../../services/adapter';
+function TournamentLogo({ tournamentDataFull }: { tournamentDataFull: Tournament }) {
+ return tournamentDataFull.logo_path ? (
+
+ ) : null;
+}
+
export default function Dashboard() {
const { tournamentData } = getTournamentIdFromRouter();
const swrRoundsResponse: SWRResponse = getRounds(tournamentData.id, true);
@@ -24,15 +30,12 @@ export default function Dashboard() {
}
return (
-
-
+
+
{tournamentDataFull.name}
-
+
-
+
{
+export function getTournaments(): SWRResponse {
return useSWR('tournaments', fetcher);
}
-export function getPlayers(
- tournament_id: number,
- not_in_team: boolean = false
-): SWRResponse {
+export function getPlayers(tournament_id: number, not_in_team: boolean = false): SWRResponse {
return useSWR(`tournaments/${tournament_id}/players?not_in_team=${not_in_team}`, fetcher);
}
-export function getTeams(tournament_id: number): SWRResponse {
+export function getTeams(tournament_id: number): SWRResponse {
return useSWR(`tournaments/${tournament_id}/teams`, fetcher);
}
-export function getRounds(
- tournament_id: number,
- no_draft_rounds: boolean = false
-): SWRResponse {
+export function getRounds(tournament_id: number, no_draft_rounds: boolean = false): SWRResponse {
return useSWR(`tournaments/${tournament_id}/rounds?no_draft_rounds=${no_draft_rounds}`, fetcher);
}
-export function getUpcomingMatches(tournament_id: number): SWRResponse {
+export function getUpcomingMatches(tournament_id: number): SWRResponse {
return useSWR(`tournaments/${tournament_id}/upcoming_matches`, fetcher);
}
diff --git a/frontend/src/services/club.tsx b/frontend/src/services/club.tsx
deleted file mode 100644
index 278ef2f3..00000000
--- a/frontend/src/services/club.tsx
+++ /dev/null
@@ -1,32 +0,0 @@
-import { createAxios } from './adapter';
-
-export async function createTeam(
- tournament_id: number,
- name: string,
- active: boolean,
- player_ids: number[]
-) {
- await createAxios().post(`tournaments/${tournament_id}/teams`, {
- name,
- active,
- player_ids,
- });
-}
-
-export async function deleteTeam(tournament_id: number, team_id: number) {
- await createAxios().delete(`tournaments/${tournament_id}/teams/${team_id}`);
-}
-
-export async function updateTeam(
- tournament_id: number,
- team_id: number,
- name: string,
- active: boolean,
- player_ids: number[]
-) {
- await createAxios().patch(`tournaments/${tournament_id}/teams/${team_id}`, {
- name,
- active,
- player_ids,
- });
-}
diff --git a/frontend/src/services/match.tsx b/frontend/src/services/match.tsx
index 39aef08a..e35d69c8 100644
--- a/frontend/src/services/match.tsx
+++ b/frontend/src/services/match.tsx
@@ -1,12 +1,16 @@
import { MatchBodyInterface, MatchCreateBodyInterface } from '../interfaces/match';
-import { createAxios } from './adapter';
+import { createAxios, handleRequestError } from './adapter';
export async function createMatch(tournament_id: number, match: MatchCreateBodyInterface) {
- return createAxios().post(`tournaments/${tournament_id}/matches`, match);
+ return createAxios()
+ .post(`tournaments/${tournament_id}/matches`, match)
+ .catch((response: any) => handleRequestError(response));
}
export async function deleteMatch(tournament_id: number, match_id: number) {
- return createAxios().delete(`tournaments/${tournament_id}/matches/${match_id}`);
+ return createAxios()
+ .delete(`tournaments/${tournament_id}/matches/${match_id}`)
+ .catch((response: any) => handleRequestError(response));
}
export async function updateMatch(
@@ -14,5 +18,7 @@ export async function updateMatch(
match_id: number,
match: MatchBodyInterface
) {
- return createAxios().patch(`tournaments/${tournament_id}/matches/${match_id}`, match);
+ return createAxios()
+ .patch(`tournaments/${tournament_id}/matches/${match_id}`, match)
+ .catch((response: any) => handleRequestError(response));
}
diff --git a/frontend/src/services/player.tsx b/frontend/src/services/player.tsx
index a1687d41..52589ecf 100644
--- a/frontend/src/services/player.tsx
+++ b/frontend/src/services/player.tsx
@@ -1,14 +1,18 @@
-import { createAxios } from './adapter';
+import { createAxios, handleRequestError } from './adapter';
export async function createPlayer(tournament_id: number, name: string, team_id: string | null) {
- return createAxios().post(`tournaments/${tournament_id}/players`, {
- name,
- team_id,
- });
+ return createAxios()
+ .post(`tournaments/${tournament_id}/players`, {
+ name,
+ team_id,
+ })
+ .catch((response: any) => handleRequestError(response));
}
export async function deletePlayer(tournament_id: number, player_id: number) {
- return createAxios().delete(`tournaments/${tournament_id}/players/${player_id}`);
+ return createAxios()
+ .delete(`tournaments/${tournament_id}/players/${player_id}`)
+ .catch((response: any) => handleRequestError(response));
}
export async function updatePlayer(
@@ -17,8 +21,10 @@ export async function updatePlayer(
name: string,
team_id: string | null
) {
- return createAxios().patch(`tournaments/${tournament_id}/players/${player_id}`, {
- name,
- team_id,
- });
+ return createAxios()
+ .patch(`tournaments/${tournament_id}/players/${player_id}`, {
+ name,
+ team_id,
+ })
+ .catch((response: any) => handleRequestError(response));
}
diff --git a/frontend/src/services/round.tsx b/frontend/src/services/round.tsx
index 9f3e05e9..d0b7a259 100644
--- a/frontend/src/services/round.tsx
+++ b/frontend/src/services/round.tsx
@@ -1,14 +1,20 @@
import { RoundInterface } from '../interfaces/round';
-import { createAxios } from './adapter';
+import { createAxios, handleRequestError } from './adapter';
export async function createRound(tournament_id: number) {
- return createAxios().post(`tournaments/${tournament_id}/rounds`);
+ return createAxios()
+ .post(`tournaments/${tournament_id}/rounds`)
+ .catch((response: any) => handleRequestError(response));
}
export async function deleteRound(tournament_id: number, round_id: number) {
- return createAxios().delete(`tournaments/${tournament_id}/rounds/${round_id}`);
+ return createAxios()
+ .delete(`tournaments/${tournament_id}/rounds/${round_id}`)
+ .catch((response: any) => handleRequestError(response));
}
export async function updateRound(tournament_id: number, round_id: number, round: RoundInterface) {
- return createAxios().patch(`tournaments/${tournament_id}/rounds/${round_id}`, round);
+ return createAxios()
+ .patch(`tournaments/${tournament_id}/rounds/${round_id}`, round)
+ .catch((response: any) => handleRequestError(response));
}
diff --git a/frontend/src/services/team.tsx b/frontend/src/services/team.tsx
index 278ef2f3..f1c659eb 100644
--- a/frontend/src/services/team.tsx
+++ b/frontend/src/services/team.tsx
@@ -1,4 +1,4 @@
-import { createAxios } from './adapter';
+import { createAxios, handleRequestError } from './adapter';
export async function createTeam(
tournament_id: number,
@@ -14,7 +14,9 @@ export async function createTeam(
}
export async function deleteTeam(tournament_id: number, team_id: number) {
- await createAxios().delete(`tournaments/${tournament_id}/teams/${team_id}`);
+ await createAxios()
+ .delete(`tournaments/${tournament_id}/teams/${team_id}`)
+ .catch((response: any) => handleRequestError(response));
}
export async function updateTeam(
@@ -24,9 +26,11 @@ export async function updateTeam(
active: boolean,
player_ids: number[]
) {
- await createAxios().patch(`tournaments/${tournament_id}/teams/${team_id}`, {
- name,
- active,
- player_ids,
- });
+ await createAxios()
+ .patch(`tournaments/${tournament_id}/teams/${team_id}`, {
+ name,
+ active,
+ player_ids,
+ })
+ .catch((response: any) => handleRequestError(response));
}
diff --git a/frontend/src/services/user.tsx b/frontend/src/services/user.tsx
index 2a650c4f..10db271a 100644
--- a/frontend/src/services/user.tsx
+++ b/frontend/src/services/user.tsx
@@ -1,4 +1,4 @@
-import { createAxios } from './adapter';
+import { createAxios, handleRequestError } from './adapter';
export async function performLogin(username: string, password: string) {
const bodyFormData = new FormData();
@@ -6,12 +6,21 @@ export async function performLogin(username: string, password: string) {
bodyFormData.append('username', username);
bodyFormData.append('password', password);
- const response = await createAxios().post('token', bodyFormData);
+ const response = await createAxios()
+ .post('token', bodyFormData)
+ .catch((err_response: any) => handleRequestError(err_response));
+
+ if (response == null) {
+ return false;
+ }
+
localStorage.setItem('login', JSON.stringify(response.data));
+ handleRequestError(response);
+
// Reload axios object.
createAxios();
- return response;
+ return true;
}
export function performLogout() {
|