upgrade Nodemailer to v10

fix dead code with knip

upgrade TS to v6 and fix linting errors

auto apply oxfmt rules

fix linting errors - unused deps etc

ignore file

remove all ignored files in knip

add knip - dead code analysis tool

swap prettier and eslint of oxfmt and oxlint

fix: fix map rendering in react strict mode

fix: headlessUI float replace

fix: disable Matomo if not URL and SITE ID exist

upgrade: 1st pass upgrade to Next.js v16

deps: upgrade react to v19
This commit is contained in:
2026-09-29 22:16:07 +02:00
parent df3a73df88
commit da78e82a44
122 changed files with 39491 additions and 32785 deletions
+11 -19
View File
@@ -2,13 +2,7 @@ import React, { useEffect, useRef, useState } from "react";
import { get, isArray, isNil } from "lodash";
import { useTranslations } from "next-intl";
import {
Controller,
FieldPath,
FieldValues,
useFormContext,
useWatch,
} from "react-hook-form";
import { Controller, FieldPath, FieldValues, useFormContext, useWatch } from "react-hook-form";
import { ActionMeta, GroupBase, OnChangeValue, Props } from "react-select";
import AsyncSelect from "react-select/async";
@@ -52,19 +46,16 @@ export const AsyncSelectField = <
hideErrorMessage,
required,
size,
loadOption,
loadOptions,
onInformChange,
placeholder,
separators,
...selectProps
}: AsyncSelectFieldProps<TFieldValues, TFieldName, IsMulti, T, D>) => {
const t = useTranslations("App");
const [loadingValues, setLoadingValues] = useState(false);
const [loadedInitialValues, setLoadedInitialValues] = useState(false);
const [_loadedInitialValues, setLoadedInitialValues] = useState(false);
const [loadingOptions, setLoadingOptions] = useState(false);
const valueOptions = useRef<BaseOption<T, D>[]>([]);
const searchOptions = useRef<BaseOption<T, D>[]>([]);
@@ -78,8 +69,7 @@ export const AsyncSelectField = <
const values = !value ? [] : isArray(value) ? value : [value];
const unFetchedValues = values.filter(
(v) =>
valueOptions.current.find((o) => o.value === value) === undefined,
() => valueOptions.current.find((o) => o.value === value) === undefined,
);
if (unFetchedValues.length > 0) {
@@ -98,9 +88,10 @@ export const AsyncSelectField = <
setLoadingValues(false);
onInformChange?.(
values.map(
(v) => valueOptions.current.find((o) => o.value === v)!,
) as BaseOption<T, D>[],
values.map((v) => valueOptions.current.find((o) => o.value === v)!) as BaseOption<
T,
D
>[],
);
// This forced a state update, which enures that the select is updated once the query has finished
@@ -122,9 +113,10 @@ export const AsyncSelectField = <
const hasError = !!get(errors, name)?.message;
const valueToOption = (value: T) =>
[...valueOptions.current, ...searchOptions.current].find(
(o) => o.value === value,
) ?? { value, label: "" };
[...valueOptions.current, ...searchOptions.current].find((o) => o.value === value) ?? {
value,
label: "",
};
const fetchOptions = async (searchString?: string) => {
setLoadingOptions(true);
@@ -12,10 +12,7 @@ interface InputProps {
}
type AllProps = Omit<
React.DetailedHTMLProps<
React.InputHTMLAttributes<HTMLInputElement>,
HTMLInputElement
>,
React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>,
"ref"
> &
InputProps;
@@ -24,12 +21,13 @@ export const InputDatePicker = forwardRef<HTMLInputElement, AllProps>(
(
{
error,
// oxlint-disable-next-line no-unused-vars
className,
// oxlint-disable-next-line no-unused-vars
children,
inputContainerClass,
inputClass,
mask,
...props
},
inputRef,
+4 -17
View File
@@ -1,16 +1,11 @@
import React, { useRef } from "react";
import { useRef } from "react";
import { getYear, isValid, parse } from "date-fns";
import fr from "date-fns/locale/fr";
import { get } from "lodash";
import { useLocale, useTranslations } from "next-intl";
import DatePicker, { registerLocale } from "react-datepicker";
import {
Controller,
FieldPath,
FieldValues,
useFormContext,
} from "react-hook-form";
import { Controller, FieldPath, FieldValues, useFormContext } from "react-hook-form";
import { twMerge } from "tailwind-merge";
import { Prettify } from "@/types";
@@ -45,10 +40,8 @@ export const DateField = <
dateFormat = "dd/MM/yyyy",
className,
datePickerPopperClass,
name,
control,
required,
...otherFieldProps
}: DateFieldProps<TFieldValues, TFieldName>) => {
const locale = useLocale();
@@ -93,11 +86,7 @@ export const DateField = <
// Called when the user types in the input
if (e?.currentTarget && "value" in e.currentTarget) {
const value = e.currentTarget.value;
const date = parse(
value as string,
at("dateParseFormat"),
new Date(),
);
const date = parse(value as string, at("dateParseFormat"), new Date());
if (
isValid(date) &&
date.getFullYear() >= min &&
@@ -124,9 +113,7 @@ export const DateField = <
minDate={minDate}
showFullMonthYearPicker
maxDate={maxDate}
renderCustomHeader={(props) => (
<DatePickerCustomHeader {...props} />
)}
renderCustomHeader={(props) => <DatePickerCustomHeader {...props} />}
customInput={
<InputDatePicker
mask={at("dateMask")}
+2 -13
View File
@@ -1,12 +1,7 @@
import { ReactNode } from "react";
import { get } from "lodash";
import {
Control,
FieldPath,
FieldValues,
useFormContext,
} from "react-hook-form";
import { Control, FieldPath, FieldValues, useFormContext } from "react-hook-form";
import { twMerge } from "tailwind-merge";
import { Prettify } from "@/types";
@@ -70,13 +65,7 @@ export const Field = <
</Label>
) : null}
<div
className={twMerge(
"flex w-full",
label && "mt-2",
childrenWrapperClassName,
)}
>
<div className={twMerge("flex w-full", label && "mt-2", childrenWrapperClassName)}>
{children}
</div>
+2 -6
View File
@@ -1,21 +1,17 @@
import React from "react";
import type { ReactNode } from 'react'
import { Switch, SwitchProps } from "@headlessui/react";
import { twMerge } from "tailwind-merge";
export const InlineSwitch = (
props: {
label?: React.ReactNode;
label?: ReactNode;
tooltip?: string;
tooltipId?: string;
} & SwitchProps<"button">,
) => {
const {
label,
tooltip,
tooltipId,
disabled,
...rest
} = props;
+1 -7
View File
@@ -1,18 +1,12 @@
import React from "react";
import { SwitchProps } from "@headlessui/react";
import { Controller, FieldPath, FieldValues } from "react-hook-form";
import { twMerge } from "tailwind-merge";
import { Field, GenericFieldProps } from "@/components/form/Field";
import { InlineSwitch } from "./InlineSwitch";
type InlineSwitchFieldProps<
TFieldValues extends FieldValues = FieldValues,
TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
> = GenericFieldProps<TFieldValues, TFieldName> &
Omit<SwitchProps<"button">, "name">;
> = GenericFieldProps<TFieldValues, TFieldName> & Omit<SwitchProps<"button">, "name">;
export const InlineSwitchField = <
TFieldValues extends FieldValues = FieldValues,
+5 -4
View File
@@ -1,3 +1,4 @@
import type { ComponentProps, ReactNode } from 'react'
import { VariantProps, cva } from "class-variance-authority";
import { twMerge } from "tailwind-merge";
@@ -26,12 +27,12 @@ export const inputVariants = cva(
},
);
export type InputVariants = VariantProps<typeof inputVariants>;
export type InputProps = Omit<React.ComponentProps<"input">, "size"> &
type InputVariants = VariantProps<typeof inputVariants>;
export type InputProps = Omit<ComponentProps<"input">, "size"> &
Omit<InputVariants, "state"> & {
hasError?: boolean;
startIcon?: React.ReactNode;
endIcon?: React.ReactNode;
startIcon?: ReactNode;
endIcon?: ReactNode;
};
export const Input = ({
+4 -13
View File
@@ -1,25 +1,16 @@
import type { LabelHTMLAttributes, ReactNode, DetailedHTMLProps } from "react";
import { twMerge } from "tailwind-merge";
import { Prettify } from "@/types";
type LabelProps = Prettify<
React.DetailedHTMLProps<
React.LabelHTMLAttributes<HTMLLabelElement>,
HTMLLabelElement
> & {
DetailedHTMLProps<LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement> & {
required?: boolean;
className?: string;
tooltip?: React.ReactNode;
tooltip?: ReactNode;
}
>;
export const Label = ({
required,
className,
children,
tooltip,
...labelProps
}: LabelProps) => {
export const Label = ({ required, className, children, ...labelProps }: LabelProps) => {
return (
<label
{...labelProps}
+4 -18
View File
@@ -1,23 +1,14 @@
import React from "react";
import { RadioGroup } from "@headlessui/react";
import { isNil } from "lodash";
import { useTranslations } from "next-intl";
import {
Controller,
FieldPath,
FieldValues,
useFormContext,
} from "react-hook-form";
import { Controller, FieldPath, FieldValues, useFormContext } from "react-hook-form";
import { twMerge } from "tailwind-merge";
import { Prettify } from "@/types";
import { Field, GenericFieldProps } from "./Field";
export type BaseOption<T = string, D = unknown> = {
type BaseOption<T = string, D = unknown> = {
value: T;
label: string | JSX.Element;
label: string | React.JSX.Element;
disabled?: boolean;
data?: D;
};
@@ -51,16 +42,13 @@ export const RadioGroupField = <
options,
}: RadioGroupFieldProps<TFieldValues, TFieldName, T, D>) => {
const t = useTranslations("App");
const form = useFormContext<TFieldValues>();
const {
// oxlint-disable-next-line no-unused-vars
formState: { errors },
} = form;
const valueToOption = (value: T): BaseOption<T, D> =>
options.find((o) => o.value === value) ?? { value, label: "" };
return (
<Field
{...{
@@ -78,8 +66,6 @@ export const RadioGroupField = <
name={name}
control={control}
render={({ field: { onChange, value } }) => {
const optionValue = isNil(value) ? null : valueToOption(value);
return (
<RadioGroup
value={value}
+8 -29
View File
@@ -8,17 +8,13 @@ import { Prettify } from "@/types";
export type BaseOption<T = string, D = unknown> = {
value: T;
label: string | JSX.Element;
label: string | React.JSX.Element;
disabled?: boolean;
data?: D;
};
export const createSelectClassNamesFn =
<Option, IsMulti extends boolean = false>({
size,
}: {
size?: "small" | "medium";
}) =>
<Option, IsMulti extends boolean = false>({ size }: { size?: "small" | "medium" }) =>
(
hasError: boolean,
separators: boolean,
@@ -26,8 +22,7 @@ export const createSelectClassNamesFn =
container: () => "w-full",
valueContainer: () => "text-gray-900 dark:text-white",
indicatorsContainer: () => "flex items-center self-stretch shrink-0",
clearIndicator: () =>
"flex items-center pr-2 text-gray-900 dark:text-white",
clearIndicator: () => "flex items-center pr-2 text-gray-900 dark:text-white",
dropdownIndicator: () =>
"pointer-events-none flex items-center pr-2 text-gray-900 dark:text-white",
indicatorSeparator: () => "w-px text-gray-900 dark:text-white",
@@ -45,8 +40,7 @@ export const createSelectClassNamesFn =
multiValue: () => "bg-fieldGray border rounded-lg flex space-x-1 pl-1 m-1",
multiValueLabel: () => "",
multiValueRemove: () => "items-center px-1 hover:text-primary",
placeholder: () =>
"block truncate pr-2 placeholder-gray dark:placeholder-gray-400",
placeholder: () => "block truncate pr-2 placeholder-gray dark:placeholder-gray-400",
menu: () =>
twMerge(
"!z-30 mt-2 rounded-lg border border-gray-200 bg-white p-1",
@@ -65,33 +59,18 @@ export const createSelectClassNamesFn =
"text-textGray p-2 bg-gray-50 border border-dashed border-gray-200 rounded-sm",
});
export type SelectProps<
IsMulti extends boolean = false,
T = string,
D = unknown,
> = Prettify<
export type SelectProps<IsMulti extends boolean = false, T = string, D = unknown> = Prettify<
Omit<Props<BaseOption<T, D>, IsMulti>, "classNames"> & {
required?: boolean;
separators?: boolean;
hasError?: boolean;
size?: "small" | "medium";
classNameOverrides?: ClassNamesConfig<
BaseOption<T, D>,
IsMulti,
GroupBase<BaseOption<T, D>>
>;
classNameOverrides?: ClassNamesConfig<BaseOption<T, D>, IsMulti, GroupBase<BaseOption<T, D>>>;
}
>;
export const Select = <
IsMulti extends boolean = false,
T = string,
D = unknown,
>({
className,
required,
export const Select = <IsMulti extends boolean = false, T = string, D = unknown>({
size,
placeholder,
separators,
hasError,
@@ -121,7 +100,7 @@ export const Select = <
}}
classNames={{
...classNames(hasError ?? false, separators ?? false),
...(classNameOverrides ?? {}),
...classNameOverrides,
}}
{...selectProps}
/>
+4 -22
View File
@@ -1,13 +1,5 @@
import React from "react";
import { flatMap, get, isArray, isNil, isObject } from "lodash";
import { useTranslations } from "next-intl";
import {
Controller,
FieldPath,
FieldValues,
useFormContext,
} from "react-hook-form";
import { Controller, FieldPath, FieldValues, useFormContext } from "react-hook-form";
import { GroupBase, OnChangeValue } from "react-select";
import { BaseOption, Select, SelectProps } from "@/components/form/Select";
@@ -23,10 +15,7 @@ export type SelectFieldProps<
D = unknown,
> = Prettify<
GenericFieldProps<TFieldValues, TFieldName> &
Omit<
SelectProps<IsMulti, T, D>,
"onChange" | "value" | "classNames" | "name"
> & {
Omit<SelectProps<IsMulti, T, D>, "onChange" | "value" | "classNames" | "name"> & {
required?: boolean;
separators?: boolean;
}
@@ -47,13 +36,9 @@ export const SelectField = <
label,
hideErrorMessage,
required,
placeholder,
separators,
options,
...selectProps
}: SelectFieldProps<TFieldValues, TFieldName, IsMulti, T, D>) => {
const t = useTranslations("App");
const form = useFormContext<TFieldValues>();
const {
@@ -64,8 +49,7 @@ export const SelectField = <
const isGroup = (
option: BaseOption<T, D> | GroupBase<BaseOption<T, D>>,
): option is GroupBase<BaseOption<T, D>> =>
isObject(option) && "options" in option;
): option is GroupBase<BaseOption<T, D>> => isObject(option) && "options" in option;
const flattenedOptions = flatMap(options, (option) => {
return isGroup(option) ? option.options : option;
@@ -91,9 +75,7 @@ export const SelectField = <
name={name}
control={control}
render={({ field: { onChange, value } }) => {
const onSelectChange = (
newValue: OnChangeValue<BaseOption<T, D>, IsMulti>,
) => {
const onSelectChange = (newValue: OnChangeValue<BaseOption<T, D>, IsMulti>) => {
if (isNil(newValue)) onChange(null);
else if (isArray(newValue)) {
onChange(newValue.map((option) => option.value));
+3 -25
View File
@@ -1,12 +1,7 @@
import React from "react";
import { Switch, SwitchProps } from "@headlessui/react";
import {
Controller,
FieldPath,
FieldValues,
useFormContext,
} from "react-hook-form";
import { Controller, FieldPath, FieldValues } from "react-hook-form";
import { twMerge } from "tailwind-merge";
import { Prettify } from "@/types";
@@ -16,10 +11,7 @@ import { Field, GenericFieldProps } from "./Field";
type SwitchFieldProps<
TFieldValues extends FieldValues = FieldValues,
TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
> = Prettify<
GenericFieldProps<TFieldValues, TFieldName> &
Omit<SwitchProps<"button">, "name">
>;
> = Prettify<GenericFieldProps<TFieldValues, TFieldName> & Omit<SwitchProps<"button">, "name">>;
export const SwitchField = <
TFieldValues extends FieldValues = FieldValues,
@@ -27,21 +19,7 @@ export const SwitchField = <
>(
props: SwitchFieldProps<TFieldValues, TFieldName>,
) => {
const {
name,
control,
label,
disabled,
className,
labelClassName,
childrenWrapperClassName,
hideErrorMessage,
...rest
} = props;
const form = useFormContext<TFieldValues>();
const { name, control, label, disabled, className, labelClassName, ...rest } = props;
return (
<Field
{...{
+4 -13
View File
@@ -1,12 +1,7 @@
import React from "react";
import type { HTMLProps, ReactNode } from "react";
import { get } from "lodash";
import {
Controller,
FieldPath,
FieldValues,
useFormContext,
} from "react-hook-form";
import { Controller, FieldPath, FieldValues, useFormContext } from "react-hook-form";
import { twMerge } from "tailwind-merge";
import { Prettify } from "@/types";
@@ -19,9 +14,9 @@ type TextAreaFieldProps<
TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
> = Prettify<
GenericFieldProps<TFieldValues, TFieldName> &
Omit<React.HTMLProps<HTMLTextAreaElement>, "ref" | "name"> & {
Omit<HTMLProps<HTMLTextAreaElement>, "ref" | "name"> & {
handleChanged?: (props: { name: string }) => void;
startIcon?: React.ReactNode;
startIcon?: ReactNode;
required?: boolean;
}
>;
@@ -40,11 +35,7 @@ export const TextAreaField = <
labelClassName,
childrenWrapperClassName,
hideErrorMessage = false,
startIcon,
handleChanged,
required,
disabled,
...rest
} = props;
+2 -11
View File
@@ -1,12 +1,7 @@
import React from "react";
import { get } from "lodash";
import {
Controller,
FieldPath,
FieldValues,
useFormContext,
} from "react-hook-form";
import { Controller, FieldPath, FieldValues, useFormContext } from "react-hook-form";
import { twMerge } from "tailwind-merge";
import { Prettify } from "@/types";
@@ -57,11 +52,7 @@ export const TextField = <
const hasError = !!get(errors, name)?.message;
const input = (value: string | number) => {
return typeof value === "number"
? isNaN(value)
? ""
: value.toString()
: (value ?? "");
return typeof value === "number" ? (isNaN(value) ? "" : value.toString()) : (value ?? "");
};
const output =
+4 -15
View File
@@ -1,16 +1,12 @@
import { useState } from "react";
import { on } from "events";
import { useTranslations } from "next-intl";
import { FieldPath, FieldValues } from "react-hook-form";
import { FaExternalLinkAlt } from "react-icons/fa";
import { TimeControlColours } from "@/constants";
import { getTournamentDetails } from "@/server/getTournamentDetails";
import {
SearchedTournament,
searchTournaments,
} from "@/server/searchTournaments";
import { SearchedTournament, searchTournaments } from "@/server/searchTournaments";
import { AsyncSelectField, AsyncSelectFieldProps } from "./AsyncSelectField";
@@ -18,13 +14,7 @@ type TournamentSelectFieldProps<
TFieldValues extends FieldValues = FieldValues,
TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
> = Omit<
AsyncSelectFieldProps<
TFieldValues,
TFieldName,
false,
string,
SearchedTournament
>,
AsyncSelectFieldProps<TFieldValues, TFieldName, false, string, SearchedTournament>,
"loadOptions" | "loadOption" | "separators"
>;
@@ -36,8 +26,7 @@ export const TournamentSelectField = <
...rest
}: TournamentSelectFieldProps<TFieldValues, TFieldName>) => {
const at = useTranslations("App");
const [selectedTournament, setSelectedTournament] =
useState<SearchedTournament | null>(null);
const [selectedTournament, setSelectedTournament] = useState<SearchedTournament | null>(null);
const loadOption = async (ffeId: string) => {
const result = await getTournamentDetails({ ffeId });
@@ -91,7 +80,7 @@ export const TournamentSelectField = <
background: `${TimeControlColours[option.data!.timeControl]}`,
}}
>
{at("timeControlEnum", { tc: option.data?.timeControl })}
{at("timeControlEnum", { tc: option.data!.timeControl })}
</div>
<div className="text-xs">{option.data?.date}</div>
</div>
+3 -7
View File
@@ -18,9 +18,9 @@ export type ZoneEditorProps = {
onChange: (geoJson: FeatureCollection) => void;
};
export const ZoneEditor = ({ value, onChange }: ZoneEditorProps) => {
const ZoneEditor = ({ value, onChange }: ZoneEditorProps) => {
const initialFeatures = React.useRef(value?.features);
const featureGroup = React.useRef<L.FeatureGroup>();
const featureGroup = React.useRef<L.FeatureGroup | null>(null);
const setFeatureCollectionRef = (element: L.FeatureGroup) => {
featureGroup.current = element;
@@ -52,11 +52,7 @@ export const ZoneEditor = ({ value, onChange }: ZoneEditorProps) => {
};
return (
<MapContainer
center={center}
zoom={5}
style={{ height: "600px", flexGrow: 1 }}
>
<MapContainer center={center} zoom={5} style={{ height: "600px", flexGrow: 1 }}>
<MapEvents
bounds={
(initialFeatures.current ?? []).length > 0
+1 -2
View File
@@ -20,8 +20,7 @@ type ZoneEditorFieldProps<
TFieldValues extends FieldValues = FieldValues,
TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
> = Prettify<
GenericFieldProps<TFieldValues, TFieldName> &
Omit<ZoneEditorProps, "value" | "onChange">
GenericFieldProps<TFieldValues, TFieldName> & Omit<ZoneEditorProps, "value" | "onChange">
>;
export const ZoneEditorField = <