mirror of
https://github.com/TheRealOwenRees/echecsfrance.git
synced 2026-07-22 20:16:57 +00:00
Add notification for "Other" tournament types
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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,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
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -10,5 +10,6 @@ export type ZoneModel = {
|
||||
classicNotifications: boolean;
|
||||
rapidNotifications: boolean;
|
||||
blitzNotifications: boolean;
|
||||
otherNotifications: boolean;
|
||||
features: z.infer<typeof featureCollection>;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user