mirror of
https://github.com/TheRealOwenRees/echecsfrance.git
synced 2026-07-23 04:26:57 +00:00
Add notification for "Other" tournament types
This commit is contained in:
@@ -42,12 +42,14 @@ export const ZoneForm = ({
|
|||||||
classicNotifications: zone.classicNotifications,
|
classicNotifications: zone.classicNotifications,
|
||||||
rapidNotifications: zone.rapidNotifications,
|
rapidNotifications: zone.rapidNotifications,
|
||||||
blitzNotifications: zone.blitzNotifications,
|
blitzNotifications: zone.blitzNotifications,
|
||||||
|
otherNotifications: zone.otherNotifications,
|
||||||
features: zone.features as ZoneFormValues["features"],
|
features: zone.features as ZoneFormValues["features"],
|
||||||
}
|
}
|
||||||
: {
|
: {
|
||||||
classicNotifications: false,
|
classicNotifications: false,
|
||||||
rapidNotifications: false,
|
rapidNotifications: false,
|
||||||
blitzNotifications: false,
|
blitzNotifications: false,
|
||||||
|
otherNotifications: false,
|
||||||
features: {
|
features: {
|
||||||
type: "FeatureCollection",
|
type: "FeatureCollection",
|
||||||
features: [],
|
features: [],
|
||||||
@@ -55,11 +57,14 @@ export const ZoneForm = ({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const features = form.watch("features");
|
||||||
|
console.log(features);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<FormProvider {...form}>
|
<FormProvider {...form}>
|
||||||
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-8">
|
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-8">
|
||||||
<div className="grid grid-cols-3 items-start gap-6">
|
<div className="grid grid-cols-4 items-start gap-6">
|
||||||
<div className="col-span-3">
|
<div className="col-span-4">
|
||||||
<TextField
|
<TextField
|
||||||
name="name"
|
name="name"
|
||||||
control={form.control}
|
control={form.control}
|
||||||
@@ -69,7 +74,7 @@ export const ZoneForm = ({
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="col-span-3">
|
<div className="col-span-4">
|
||||||
<div className="flex flex-col gap-4">
|
<div className="flex flex-col gap-4">
|
||||||
<Label>{t("notificationsLabel")}</Label>
|
<Label>{t("notificationsLabel")}</Label>
|
||||||
<div className="font-light text-gray-500 dark:text-gray-400">
|
<div className="font-light text-gray-500 dark:text-gray-400">
|
||||||
@@ -93,8 +98,13 @@ export const ZoneForm = ({
|
|||||||
control={form.control}
|
control={form.control}
|
||||||
label={at("timeControlEnum", { tc: TimeControl.Blitz })}
|
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} />
|
<ZoneEditorField name="features" control={form.control} />
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -77,6 +77,7 @@ const Zones = () => {
|
|||||||
...(zone.classicNotifications ? [TimeControl.Classic] : []),
|
...(zone.classicNotifications ? [TimeControl.Classic] : []),
|
||||||
...(zone.rapidNotifications ? [TimeControl.Rapid] : []),
|
...(zone.rapidNotifications ? [TimeControl.Rapid] : []),
|
||||||
...(zone.blitzNotifications ? [TimeControl.Blitz] : []),
|
...(zone.blitzNotifications ? [TimeControl.Blitz] : []),
|
||||||
|
...(zone.otherNotifications ? [TimeControl.Other] : []),
|
||||||
];
|
];
|
||||||
|
|
||||||
const notificationsList = format.list(
|
const notificationsList = format.list(
|
||||||
|
|||||||
@@ -2,12 +2,7 @@ import React from "react";
|
|||||||
|
|
||||||
import { FeatureCollection } from "geojson";
|
import { FeatureCollection } from "geojson";
|
||||||
import dynamic from "next/dynamic";
|
import dynamic from "next/dynamic";
|
||||||
import {
|
import { Controller, FieldPath, FieldValues } from "react-hook-form";
|
||||||
Controller,
|
|
||||||
FieldPath,
|
|
||||||
FieldValues,
|
|
||||||
useFormContext,
|
|
||||||
} from "react-hook-form";
|
|
||||||
|
|
||||||
import { Prettify } from "@/types";
|
import { Prettify } from "@/types";
|
||||||
|
|
||||||
@@ -35,20 +30,7 @@ export const ZoneEditorField = <
|
|||||||
>(
|
>(
|
||||||
props: ZoneEditorFieldProps<TFieldValues, TFieldName>,
|
props: ZoneEditorFieldProps<TFieldValues, TFieldName>,
|
||||||
) => {
|
) => {
|
||||||
const {
|
const { name, control, label, className, labelClassName } = props;
|
||||||
name,
|
|
||||||
control,
|
|
||||||
label,
|
|
||||||
className,
|
|
||||||
labelClassName,
|
|
||||||
|
|
||||||
childrenWrapperClassName,
|
|
||||||
hideErrorMessage,
|
|
||||||
|
|
||||||
...rest
|
|
||||||
} = props;
|
|
||||||
|
|
||||||
const form = useFormContext<TFieldValues>();
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Field
|
<Field
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ export const zoneSchema = z
|
|||||||
classicNotifications: z.boolean(),
|
classicNotifications: z.boolean(),
|
||||||
rapidNotifications: z.boolean(),
|
rapidNotifications: z.boolean(),
|
||||||
blitzNotifications: z.boolean(),
|
blitzNotifications: z.boolean(),
|
||||||
|
otherNotifications: z.boolean(),
|
||||||
})
|
})
|
||||||
.refine((data) => data.features.features.length > 0, {
|
.refine((data) => data.features.features.length > 0, {
|
||||||
message: "FormValidation.zone",
|
message: "FormValidation.zone",
|
||||||
|
|||||||
@@ -10,5 +10,6 @@ export type ZoneModel = {
|
|||||||
classicNotifications: boolean;
|
classicNotifications: boolean;
|
||||||
rapidNotifications: boolean;
|
rapidNotifications: boolean;
|
||||||
blitzNotifications: boolean;
|
blitzNotifications: boolean;
|
||||||
|
otherNotifications: boolean;
|
||||||
features: z.infer<typeof featureCollection>;
|
features: z.infer<typeof featureCollection>;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user