From 7c1aa60c3f47fd150251e983fe6418ef5029c9c6 Mon Sep 17 00:00:00 2001 From: Timothy Armes Date: Mon, 30 Sep 2024 15:03:30 +0200 Subject: [PATCH] Add notification for "Other" tournament types --- .../(main)/zones/components/ZoneForm.tsx | 18 +++++++++++---- src/app/[locale]/(main)/zones/page.tsx | 1 + src/components/form/ZoneEditorField.tsx | 22 ++----------------- src/schemas.ts | 1 + src/server/models/zoneModel.ts | 1 + 5 files changed, 19 insertions(+), 24 deletions(-) diff --git a/src/app/[locale]/(main)/zones/components/ZoneForm.tsx b/src/app/[locale]/(main)/zones/components/ZoneForm.tsx index fe69530..0ea9a32 100644 --- a/src/app/[locale]/(main)/zones/components/ZoneForm.tsx +++ b/src/app/[locale]/(main)/zones/components/ZoneForm.tsx @@ -42,12 +42,14 @@ export const ZoneForm = ({ classicNotifications: zone.classicNotifications, rapidNotifications: zone.rapidNotifications, blitzNotifications: zone.blitzNotifications, + otherNotifications: zone.otherNotifications, features: zone.features as ZoneFormValues["features"], } : { classicNotifications: false, rapidNotifications: false, blitzNotifications: false, + otherNotifications: false, features: { type: "FeatureCollection", features: [], @@ -55,11 +57,14 @@ export const ZoneForm = ({ }, }); + const features = form.watch("features"); + console.log(features); + return (
-
-
+
+
-
+
@@ -93,8 +98,13 @@ export const ZoneForm = ({ control={form.control} label={at("timeControlEnum", { tc: TimeControl.Blitz })} /> + -
+
diff --git a/src/app/[locale]/(main)/zones/page.tsx b/src/app/[locale]/(main)/zones/page.tsx index 447e003..37b441e 100644 --- a/src/app/[locale]/(main)/zones/page.tsx +++ b/src/app/[locale]/(main)/zones/page.tsx @@ -77,6 +77,7 @@ const Zones = () => { ...(zone.classicNotifications ? [TimeControl.Classic] : []), ...(zone.rapidNotifications ? [TimeControl.Rapid] : []), ...(zone.blitzNotifications ? [TimeControl.Blitz] : []), + ...(zone.otherNotifications ? [TimeControl.Other] : []), ]; const notificationsList = format.list( diff --git a/src/components/form/ZoneEditorField.tsx b/src/components/form/ZoneEditorField.tsx index 8e297be..7fc12ea 100644 --- a/src/components/form/ZoneEditorField.tsx +++ b/src/components/form/ZoneEditorField.tsx @@ -2,12 +2,7 @@ import React from "react"; import { FeatureCollection } from "geojson"; import dynamic from "next/dynamic"; -import { - Controller, - FieldPath, - FieldValues, - useFormContext, -} from "react-hook-form"; +import { Controller, FieldPath, FieldValues } from "react-hook-form"; import { Prettify } from "@/types"; @@ -35,20 +30,7 @@ export const ZoneEditorField = < >( props: ZoneEditorFieldProps, ) => { - const { - name, - control, - label, - className, - labelClassName, - - childrenWrapperClassName, - hideErrorMessage, - - ...rest - } = props; - - const form = useFormContext(); + const { name, control, label, className, labelClassName } = props; return ( data.features.features.length > 0, { message: "FormValidation.zone", diff --git a/src/server/models/zoneModel.ts b/src/server/models/zoneModel.ts index 0b61875..32b72ee 100644 --- a/src/server/models/zoneModel.ts +++ b/src/server/models/zoneModel.ts @@ -10,5 +10,6 @@ export type ZoneModel = { classicNotifications: boolean; rapidNotifications: boolean; blitzNotifications: boolean; + otherNotifications: boolean; features: z.infer; };