-
+
{court.name}
{rows}
{noItemsAlert}
From b4dd0b761cdc689f771667ca521578369dec0c78 Mon Sep 17 00:00:00 2001
From: robigan <35210888+robigan@users.noreply.github.com>
Date: Sun, 25 Feb 2024 12:46:10 +0100
Subject: [PATCH 03/20] i18n support
---
frontend/src/components/modals/match_update_modal.tsx | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/frontend/src/components/modals/match_update_modal.tsx b/frontend/src/components/modals/match_update_modal.tsx
index 711bb4459..d737e1506 100644
--- a/frontend/src/components/modals/match_update_modal.tsx
+++ b/frontend/src/components/modals/match_update_modal.tsx
@@ -29,7 +29,7 @@ export default function MatchUpdateModal({
return (
<>
-
setOpened(false)} title={t('edit_match_title')}>
+ setOpened(false)} title={t('edit_match_modal_title')}>
From 6d10c1c94085f881c9fcdd215a900b97a109a322 Mon Sep 17 00:00:00 2001
From: robigan <35210888+robigan@users.noreply.github.com>
Date: Sun, 2 Jun 2024 14:48:27 +0200
Subject: [PATCH 12/20] Fix missing changes
---
.../components/forms/common_custom_times_matches.tsx | 8 +-------
frontend/src/components/modals/match_modal.tsx | 8 +++++++-
frontend/src/components/modals/match_update_modal.tsx | 11 ++++++-----
3 files changed, 14 insertions(+), 13 deletions(-)
diff --git a/frontend/src/components/forms/common_custom_times_matches.tsx b/frontend/src/components/forms/common_custom_times_matches.tsx
index 31396cdae..ab61be8d6 100644
--- a/frontend/src/components/forms/common_custom_times_matches.tsx
+++ b/frontend/src/components/forms/common_custom_times_matches.tsx
@@ -64,7 +64,7 @@ export default function CommonCustomTimeMatchesForm<
{t('minutes')}}
placeholder={`${match.duration_minutes}`}
@@ -112,12 +112,6 @@ export default function CommonCustomTimeMatchesForm<
- {/* */}
-
+ {
+ setCustomDurationEnabled(val);
+ if (val === false) form.setFieldValue('custom_duration_minutes', null);
+ }} setCustomMarginEnabled={(val) => {
+ setCustomMarginEnabled(val);
+ if (val === false) form.setFieldValue('custom_margin_minutes', null);
+ }} />
>
);
diff --git a/frontend/src/components/modals/match_modal.tsx b/frontend/src/components/modals/match_modal.tsx
index a30a986c9..f17e961a8 100644
--- a/frontend/src/components/modals/match_modal.tsx
+++ b/frontend/src/components/modals/match_modal.tsx
@@ -1,4 +1,4 @@
-import { Button, Center, Checkbox, Divider, Grid, Modal, NumberInput, Text } from '@mantine/core';
+import { Button, Divider, Modal, NumberInput } from '@mantine/core';
import { useForm } from '@mantine/form';
import { useTranslation } from 'next-i18next';
import React, { useState } from 'react';
@@ -132,10 +132,16 @@ export default function MatchModal({
/>
-
{
+ {
setCustomDurationEnabled(val);
if (val === false) form.setFieldValue('custom_duration_minutes', null);
- }} setCustomMarginEnabled={(val) => {
+ }}
+ setCustomMarginEnabled={(val) => {
setCustomMarginEnabled(val);
if (val === false) form.setFieldValue('custom_margin_minutes', null);
}} />
diff --git a/frontend/src/components/modals/match_update_modal.tsx b/frontend/src/components/modals/match_update_modal.tsx
index b29196ac2..62c1fccc0 100644
--- a/frontend/src/components/modals/match_update_modal.tsx
+++ b/frontend/src/components/modals/match_update_modal.tsx
@@ -1,13 +1,10 @@
import {
ActionIcon,
Button,
- Center,
Divider,
Grid,
Input,
Modal,
- NumberInput,
- Stack,
} from '@mantine/core';
import { DateTimePicker } from '@mantine/dates';
import { useForm } from '@mantine/form';
From b564c1f9befd84ef6771e8a8a9468325a6e9a646 Mon Sep 17 00:00:00 2001
From: robigan <35210888+robigan@users.noreply.github.com>
Date: Wed, 10 Jul 2024 14:56:47 +0200
Subject: [PATCH 14/20] Lint
---
frontend/src/components/brackets/match.tsx | 10 +++++++---
.../forms/common_custom_times_matches.tsx | 13 ++++++-------
.../src/components/modals/match_update_modal.tsx | 9 +--------
frontend/src/pages/tournaments/[id]/schedule.tsx | 9 ++++++---
4 files changed, 20 insertions(+), 21 deletions(-)
diff --git a/frontend/src/components/brackets/match.tsx b/frontend/src/components/brackets/match.tsx
index 118745597..f301dd1c4 100644
--- a/frontend/src/components/brackets/match.tsx
+++ b/frontend/src/components/brackets/match.tsx
@@ -1,4 +1,4 @@
-import { Center, Grid, UnstyledButton, useMantineTheme, Text } from '@mantine/core';
+import { Center, Grid, Text, UnstyledButton, useMantineTheme } from '@mantine/core';
import assert from 'assert';
import React, { useState } from 'react';
import { SWRResponse } from 'swr';
@@ -31,8 +31,12 @@ export function MatchBadge({ match, theme }: { match: MatchInterface; theme: any
>
- {match.court?.name}
- {match.start_time != null ? : null}
+
+ {match.court?.name}
+
+
+ {match.start_time != null ? : null}
+
diff --git a/frontend/src/components/forms/common_custom_times_matches.tsx b/frontend/src/components/forms/common_custom_times_matches.tsx
index ea3265de4..b53e3c19b 100644
--- a/frontend/src/components/forms/common_custom_times_matches.tsx
+++ b/frontend/src/components/forms/common_custom_times_matches.tsx
@@ -53,9 +53,11 @@ export default function CommonCustomTimeMatchesForm<
return value ?? 0;
}, [customMarginEnabled, match.custom_margin_minutes, match.margin_minutes]);
- const endDatetime = useMemo(() => fromUnixTime(
- getUnixTime(parseISO(match.start_time)) + matchDuration * 60 + matchMargin * 60
- ), [match.start_time, matchDuration, matchMargin]);
+ const endDatetime = useMemo(
+ () =>
+ fromUnixTime(getUnixTime(parseISO(match.start_time)) + matchDuration * 60 + matchMargin * 60),
+ [match.start_time, matchDuration, matchMargin]
+ );
return (
<>
@@ -110,10 +112,7 @@ export default function CommonCustomTimeMatchesForm<
-
+
{format(endDatetime, 'd LLLL yyyy HH:mm')}
diff --git a/frontend/src/components/modals/match_update_modal.tsx b/frontend/src/components/modals/match_update_modal.tsx
index 62c1fccc0..060fa68f0 100644
--- a/frontend/src/components/modals/match_update_modal.tsx
+++ b/frontend/src/components/modals/match_update_modal.tsx
@@ -1,11 +1,4 @@
-import {
- ActionIcon,
- Button,
- Divider,
- Grid,
- Input,
- Modal,
-} from '@mantine/core';
+import { ActionIcon, Button, Divider, Grid, Input, Modal } from '@mantine/core';
import { DateTimePicker } from '@mantine/dates';
import { useForm } from '@mantine/form';
import { showNotification } from '@mantine/notifications';
diff --git a/frontend/src/pages/tournaments/[id]/schedule.tsx b/frontend/src/pages/tournaments/[id]/schedule.tsx
index 3dead2cda..6cab51ce2 100644
--- a/frontend/src/pages/tournaments/[id]/schedule.tsx
+++ b/frontend/src/pages/tournaments/[id]/schedule.tsx
@@ -4,9 +4,10 @@ import { IconAlertCircle, IconCalendarPlus } from '@tabler/icons-react';
import { useTranslation } from 'next-i18next';
import { serverSideTranslations } from 'next-i18next/serverSideTranslations';
import React, { useState } from 'react';
-
import { SWRResponse } from 'swr';
+
import MatchModal from '../../../components/modals/match_modal';
+import MatchUpdateModal from '../../../components/modals/match_update_modal';
import { NoContent } from '../../../components/no_content/empty_table_info';
import { DateTime } from '../../../components/utils/datetime';
import { Translator } from '../../../components/utils/types';
@@ -23,7 +24,6 @@ import {
} from '../../../services/lookups';
import { rescheduleMatch, scheduleMatches } from '../../../services/match';
import TournamentLayout from '../_tournament_layout';
-import MatchUpdateModal from '../../../components/modals/match_update_modal';
function ScheduleRow({
index,
@@ -78,7 +78,10 @@ function ScheduleRow({
previousMatch={previousMatch}
/>
-
+
{matchesLookup[match.id].stageItem.name}
From def49feac09424590b1a3a6b13b4a78b841f938f Mon Sep 17 00:00:00 2001
From: robigan <35210888+robigan@users.noreply.github.com>
Date: Wed, 10 Jul 2024 23:22:27 +0200
Subject: [PATCH 15/20] Deprecate the use of my custom match update components
Addresses https://github.com/evroon/bracket/pull/530#issuecomment-1962903307
---
.../src/components/modals/match_modal.tsx | 83 +++++++++++++++++--
.../src/pages/tournaments/[id]/schedule.tsx | 11 ++-
2 files changed, 85 insertions(+), 9 deletions(-)
diff --git a/frontend/src/components/modals/match_modal.tsx b/frontend/src/components/modals/match_modal.tsx
index 801b2fbb1..a5109efcc 100644
--- a/frontend/src/components/modals/match_modal.tsx
+++ b/frontend/src/components/modals/match_modal.tsx
@@ -1,9 +1,10 @@
-import { Button, Divider, Modal, NumberInput } from '@mantine/core';
+import { Button, Center, Checkbox, Divider, Grid, Input, Modal, NumberInput, Text } from '@mantine/core';
import { useForm } from '@mantine/form';
import { useTranslation } from 'next-i18next';
-import React, { useState } from 'react';
+import React, { useMemo, useState } from 'react';
import { SWRResponse } from 'swr';
+import { format, fromUnixTime, getUnixTime, parseISO } from 'date-fns';
import {
MatchBodyInterface,
MatchInterface,
@@ -14,7 +15,6 @@ import { TournamentMinimal } from '../../interfaces/tournament';
import { getMatchLookup, getStageItemLookup } from '../../services/lookups';
import { deleteMatch, updateMatch } from '../../services/match';
import DeleteButton from '../buttons/delete';
-import CommonCustomTimeMatchesForm from '../forms/common_custom_times_matches';
function MatchDeleteButton({
tournamentData,
@@ -91,6 +91,24 @@ function MatchModalForm({
match.custom_margin_minutes != null
);
+ const matchDuration = useMemo(() => {
+ const value = customDurationEnabled
+ ? form.values.custom_duration_minutes
+ : match.duration_minutes;
+ return value ?? 0;
+ }, [customDurationEnabled, form.values.custom_duration_minutes, match.duration_minutes]);
+
+ const matchMargin = useMemo(() => {
+ const value = customMarginEnabled ? form.values.custom_margin_minutes : match.margin_minutes;
+ return value ?? 0;
+ }, [customMarginEnabled, form.values.custom_margin_minutes, match.margin_minutes]);
+
+ const endDatetime = useMemo(
+ () =>
+ fromUnixTime(getUnixTime(parseISO(match.start_time)) + matchDuration * 60 + matchMargin * 60),
+ [match.start_time, matchDuration, matchMargin]
+ );
+
const stageItemsLookup = getStageItemLookup(swrStagesResponse);
const matchesLookup = getMatchLookup(swrStagesResponse);
@@ -131,14 +149,69 @@ function MatchModalForm({
/>
-
+ /> */}
+
+
+ {t('minutes')}}
+ placeholder={`${match.duration_minutes}`}
+ rightSectionWidth={92}
+ {...form.getInputProps('custom_duration_minutes')}
+ />
+
+
+
+
+ {
+ setCustomDurationEnabled(event.currentTarget.checked);
+ }}
+ />
+
+
+
+
+
+
+ {t('minutes')}}
+ rightSectionWidth={92}
+ {...form.getInputProps('custom_margin_minutes')}
+ />
+
+
+
+
+ {
+ setCustomMarginEnabled(event.currentTarget.checked);
+ }}
+ />
+
+
+
+
+
+
+ {format(endDatetime, 'd LLLL yyyy HH:mm')}
+
+