Add notification for "Other" tournament types

This commit is contained in:
Timothy Armes
2024-09-30 15:03:30 +02:00
parent ee031588ff
commit 7c1aa60c3f
5 changed files with 19 additions and 24 deletions
@@ -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 (
<FormProvider {...form}>
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-8">
<div className="grid grid-cols-3 items-start gap-6">
<div className="col-span-3">
<div className="grid grid-cols-4 items-start gap-6">
<div className="col-span-4">
<TextField
name="name"
control={form.control}
@@ -69,7 +74,7 @@ export const ZoneForm = ({
/>
</div>
<div className="col-span-3">
<div className="col-span-4">
<div className="flex flex-col gap-4">
<Label>{t("notificationsLabel")}</Label>
<div className="font-light text-gray-500 dark:text-gray-400">
@@ -93,8 +98,13 @@ export const ZoneForm = ({
control={form.control}
label={at("timeControlEnum", { tc: TimeControl.Blitz })}
/>
<InlineSwitchField
name="otherNotifications"
control={form.control}
label={at("timeControlEnum", { tc: TimeControl.Other })}
/>
<section id="map" className="z-0 col-span-3 flex h-auto">
<section id="map" className="z-0 col-span-4 flex h-auto">
<ZoneEditorField name="features" control={form.control} />
</section>
</div>
+1
View File
@@ -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(
+2 -20
View File
@@ -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<TFieldValues, TFieldName>,
) => {
const {
name,
control,
label,
className,
labelClassName,
childrenWrapperClassName,
hideErrorMessage,
...rest
} = props;
const form = useFormContext<TFieldValues>();
const { name, control, label, className, labelClassName } = props;
return (
<Field
+1
View File
@@ -39,6 +39,7 @@ export const zoneSchema = z
classicNotifications: z.boolean(),
rapidNotifications: z.boolean(),
blitzNotifications: z.boolean(),
otherNotifications: z.boolean(),
})
.refine((data) => data.features.features.length > 0, {
message: "FormValidation.zone",
+1
View File
@@ -10,5 +10,6 @@ export type ZoneModel = {
classicNotifications: boolean;
rapidNotifications: boolean;
blitzNotifications: boolean;
otherNotifications: boolean;
features: z.infer<typeof featureCollection>;
};