mirror of
https://github.com/TheRealOwenRees/echecsfrance.git
synced 2026-11-18 07:22:06 +00:00
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:
@@ -7,7 +7,9 @@ export default function AddClubPage() {
|
||||
return (
|
||||
<section className="grid place-items-center bg-white pb-20 dark:bg-gray-800">
|
||||
<div className="mx-auto max-w-screen-md px-4 py-8 lg:py-16">
|
||||
<h2 className="mb-4 text-center text-4xl font-extrabold tracking-tight text-gray-900 dark:text-white">{t("title")}</h2>
|
||||
<h2 className="mb-4 text-center text-4xl font-extrabold tracking-tight text-gray-900 dark:text-white">
|
||||
{t("title")}
|
||||
</h2>
|
||||
|
||||
<p className="mb-8 text-center font-light text-gray-500 dark:text-gray-400 sm:text-xl lg:mb-16">
|
||||
{t("info")}
|
||||
@@ -16,5 +18,5 @@ export default function AddClubPage() {
|
||||
<ClubForm />
|
||||
</div>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -101,11 +101,7 @@ const TournamentForm = () => {
|
||||
name="tournament.time_control"
|
||||
control={form.control}
|
||||
label={t("tcLabel")}
|
||||
options={[
|
||||
TimeControl.Classic,
|
||||
TimeControl.Rapid,
|
||||
TimeControl.Blitz,
|
||||
].map((tc) => ({
|
||||
options={[TimeControl.Classic, TimeControl.Rapid, TimeControl.Blitz].map((tc) => ({
|
||||
value: tc,
|
||||
label: at("timeControlEnum", { tc }),
|
||||
}))}
|
||||
|
||||
@@ -4,16 +4,14 @@ import SignInClient from "@/app/[locale]/(main)/auth/sign-in/SignInClient";
|
||||
import { baseUrl } from "@/constants";
|
||||
|
||||
export async function generateMetadata({
|
||||
params: { locale },
|
||||
params,
|
||||
}: {
|
||||
params: { locale?: string };
|
||||
params: Promise<{ locale?: string }>;
|
||||
}): Promise<Metadata> {
|
||||
const { locale } = await params;
|
||||
return {
|
||||
alternates: {
|
||||
canonical:
|
||||
locale === "fr"
|
||||
? `${baseUrl}/auth/sign-in`
|
||||
: `${baseUrl}/${locale}/auth/sign-in`,
|
||||
canonical: locale === "fr" ? `${baseUrl}/auth/sign-in` : `${baseUrl}/${locale}/auth/sign-in`,
|
||||
languages: {
|
||||
fr: `${baseUrl}/auth/sign-in`,
|
||||
en: `${baseUrl}/en/auth/sign-in`,
|
||||
|
||||
@@ -94,10 +94,7 @@ export const ClubMarker = forwardRef<MarkerRef, ClubMarkerProps>(
|
||||
)}
|
||||
{club.email && (
|
||||
<div>
|
||||
<a
|
||||
href={`mailto:${club.email}`}
|
||||
className="text-primary hover:text-primary-800"
|
||||
>
|
||||
<a href={`mailto:${club.email}`} className="text-primary hover:text-primary-800">
|
||||
{club.email}
|
||||
</a>
|
||||
</div>
|
||||
|
||||
@@ -29,9 +29,7 @@ const ClubTable = () => {
|
||||
|
||||
useEffect(() => {
|
||||
if (!isLg || debouncedHoveredMapId === null) return;
|
||||
const clubRow = document.querySelector(
|
||||
`[data-group-id="${debouncedHoveredMapId}"]`,
|
||||
);
|
||||
const clubRow = document.querySelector(`[data-group-id="${debouncedHoveredMapId}"]`);
|
||||
|
||||
clubRow?.scrollIntoView({ behavior: "smooth" });
|
||||
}, [debouncedHoveredMapId, isLg]);
|
||||
@@ -87,9 +85,7 @@ const ClubTable = () => {
|
||||
hoveredMapId === club.id && "bg-gray-200 dark:bg-gray-900",
|
||||
)}
|
||||
>
|
||||
<td className="px-1 py-2 sm:px-3 sm:py-3 lg:px-3 lg:py-3">
|
||||
{club.name}
|
||||
</td>
|
||||
<td className="px-1 py-2 sm:px-3 sm:py-3 lg:px-3 lg:py-3">{club.name}</td>
|
||||
<td className="px-1 py-2 text-left sm:px-3 sm:py-3 lg:px-3 lg:py-3">
|
||||
{club.address && <div>{club.address}</div>}
|
||||
{club.website && (
|
||||
|
||||
@@ -44,14 +44,10 @@ export default function ClubsDisplay({ clubs }: ClubsDisplayProps) {
|
||||
.replace(/[\u0300-\u036f]/g, "") === regionSearchParam.toLowerCase(),
|
||||
);
|
||||
|
||||
const regionData = regionGeoJson.features.find(
|
||||
(f) => f.properties.nom === matchedRegion,
|
||||
);
|
||||
const regionData = regionGeoJson.features.find((f) => f.properties.nom === matchedRegion);
|
||||
|
||||
if (regionData) {
|
||||
setRegionFilter(
|
||||
regionData as Feature<Polygon | MultiPolygon, GeoJsonProperties>,
|
||||
);
|
||||
setRegionFilter(regionData as Feature<Polygon | MultiPolygon, GeoJsonProperties>);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,14 +12,14 @@ import ClubsDisplay from "./ClubsDisplay";
|
||||
export const revalidate = 3600; // Revalidate cache every 6 hours
|
||||
|
||||
export async function generateMetadata({
|
||||
params: { locale },
|
||||
params,
|
||||
}: {
|
||||
params: { locale?: string };
|
||||
params: Promise<{ locale?: string }>;
|
||||
}): Promise<Metadata> {
|
||||
const { locale } = await params;
|
||||
return {
|
||||
alternates: {
|
||||
canonical:
|
||||
locale === "fr" ? `${baseUrl}/clubs` : `${baseUrl}/${locale}/clubs`,
|
||||
canonical: locale === "fr" ? `${baseUrl}/clubs` : `${baseUrl}/${locale}/clubs`,
|
||||
languages: {
|
||||
fr: `${baseUrl}/clubs`,
|
||||
en: `${baseUrl}/en/clubs`,
|
||||
|
||||
@@ -49,11 +49,7 @@ export default function Footer() {
|
||||
<Link href="/contact-us" aria-label={t("contactAria")} className="mr-4">
|
||||
<FaRegEnvelope />
|
||||
</Link>
|
||||
<Link
|
||||
href="/privacy"
|
||||
aria-label={t("privacyPolicyAria")}
|
||||
className="mr-4"
|
||||
>
|
||||
<Link href="/privacy" aria-label={t("privacyPolicyAria")} className="mr-4">
|
||||
<MdOutlinePrivacyTip />
|
||||
</Link>
|
||||
<div className="mr-4 space-x-2 text-xs">
|
||||
|
||||
@@ -20,8 +20,7 @@ const Hamburger = () => {
|
||||
<div
|
||||
className={twMerge(
|
||||
"h-0.5 w-8 bg-gray-600 transition-all duration-300 ease-in-out dark:bg-white",
|
||||
burgerMenuIsOpen &&
|
||||
"translate-x-[1px] translate-y-2.5 rotate-45 bg-white",
|
||||
burgerMenuIsOpen && "translate-x-[1px] translate-y-2.5 rotate-45 bg-white",
|
||||
)}
|
||||
></div>
|
||||
<div
|
||||
|
||||
@@ -15,7 +15,7 @@ import { MapEvents } from "@/components/MapEvents";
|
||||
|
||||
const center: LatLngLiteral = { lat: 47.0844, lng: 2.3964 };
|
||||
|
||||
const MapCoordinateSelection = ( { page }: {page: "club" | "tournament"}) => {
|
||||
const MapCoordinateSelection = ({ page }: { page: "club" | "tournament" }) => {
|
||||
const { control, setValue } = useFormContext();
|
||||
|
||||
const latValue = useWatch({ control, name: `${page}.coordinates.0` });
|
||||
|
||||
@@ -21,9 +21,7 @@ export default function Navbar() {
|
||||
className="font-extrabold text-gray-900 no-underline hover:no-underline dark:text-white"
|
||||
href="/"
|
||||
>
|
||||
<span className="font-title text-2xl text-gray-800 dark:text-white">
|
||||
{t("title")}
|
||||
</span>
|
||||
<span className="font-title text-2xl text-gray-800 dark:text-white">{t("title")}</span>
|
||||
</Link>
|
||||
|
||||
<div className="md:hidden" data-test="mobile-menu">
|
||||
|
||||
@@ -57,28 +57,14 @@ export default function Contact() {
|
||||
{t("info")}
|
||||
</p>
|
||||
|
||||
{error && (
|
||||
<InfoMessage
|
||||
className="mb-8"
|
||||
type="error"
|
||||
message={t("failure")}
|
||||
/>
|
||||
)}
|
||||
{error && <InfoMessage className="mb-8" type="error" message={t("failure")} />}
|
||||
|
||||
<div className="flex items-center justify-center space-x-4 text-sm font-bold">
|
||||
<Button
|
||||
type="button"
|
||||
onClick={() => router.back()}
|
||||
intent="secondary"
|
||||
>
|
||||
<Button type="button" onClick={() => router.back()} intent="secondary">
|
||||
{at("cancelButton")}
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
onClick={() => onDeleteAccount()}
|
||||
disabled={deleting}
|
||||
intent="primary"
|
||||
>
|
||||
<Button onClick={() => onDeleteAccount()} disabled={deleting} intent="primary">
|
||||
{t("deleteButton")}
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
@@ -53,8 +53,7 @@ export default function EloClient() {
|
||||
const kFactorParam = searchParams.get("k");
|
||||
const player = searchParams.get("player") ?? "";
|
||||
|
||||
const kFactor =
|
||||
kFactorParam && kFactors.includes(kFactorParam) ? kFactorParam : "20";
|
||||
const kFactor = kFactorParam && kFactors.includes(kFactorParam) ? kFactorParam : "20";
|
||||
|
||||
const hasTournamentId = !isEmpty(tournamentId.trim());
|
||||
|
||||
@@ -109,11 +108,7 @@ export default function EloClient() {
|
||||
const subscription = form.watch((value, { name, type }) => {
|
||||
let update = false;
|
||||
if (type === "change") {
|
||||
if (
|
||||
name === "tournamentId" &&
|
||||
value.tournamentId !== tournamentId &&
|
||||
value.tournamentId
|
||||
) {
|
||||
if (name === "tournamentId" && value.tournamentId !== tournamentId && value.tournamentId) {
|
||||
current.set("tId", value.tournamentId);
|
||||
update = true;
|
||||
} else if (
|
||||
@@ -122,18 +117,10 @@ export default function EloClient() {
|
||||
value.tournamentId === null
|
||||
) {
|
||||
clearForm();
|
||||
} else if (
|
||||
name === "player" &&
|
||||
value.player !== player &&
|
||||
value.player
|
||||
) {
|
||||
} else if (name === "player" && value.player !== player && value.player) {
|
||||
current.set("player", value.player);
|
||||
update = true;
|
||||
} else if (
|
||||
name === "kFactor" &&
|
||||
value.kFactor !== kFactor &&
|
||||
value.kFactor
|
||||
) {
|
||||
} else if (name === "kFactor" && value.kFactor !== kFactor && value.kFactor) {
|
||||
current.set("k", value.kFactor);
|
||||
update = true;
|
||||
}
|
||||
@@ -146,17 +133,7 @@ export default function EloClient() {
|
||||
}
|
||||
});
|
||||
return () => subscription.unsubscribe();
|
||||
}, [
|
||||
clearForm,
|
||||
current,
|
||||
form,
|
||||
form.watch,
|
||||
kFactor,
|
||||
pathname,
|
||||
player,
|
||||
router,
|
||||
tournamentId,
|
||||
]);
|
||||
}, [clearForm, current, form, form.watch, kFactor, pathname, player, router, tournamentId]);
|
||||
|
||||
useEffect(() => {
|
||||
// When the URL changes, we update the form values
|
||||
@@ -184,9 +161,7 @@ export default function EloClient() {
|
||||
>
|
||||
{t("title")}
|
||||
</h2>
|
||||
<p className="mb-8 text-center font-light text-gray-500 dark:text-gray-400">
|
||||
{t("info")}
|
||||
</p>
|
||||
<p className="mb-8 text-center font-light text-gray-500 dark:text-gray-400">{t("info")}</p>
|
||||
|
||||
{hasTournamentId && !isFetching && !error && (
|
||||
<div className="mx-auto mb-8 flex justify-center">
|
||||
@@ -251,23 +226,17 @@ export default function EloClient() {
|
||||
</form>
|
||||
</FormProvider>
|
||||
|
||||
{hasTournamentId &&
|
||||
!isFetching &&
|
||||
player &&
|
||||
playerResults &&
|
||||
!error && (
|
||||
<TournamentResults
|
||||
playerId={player}
|
||||
kFactor={parseInt(kFactor)}
|
||||
results={allResults?.data ?? []}
|
||||
tournament={tournament}
|
||||
/>
|
||||
)}
|
||||
{hasTournamentId && !isFetching && player && playerResults && !error && (
|
||||
<TournamentResults
|
||||
playerId={player}
|
||||
kFactor={parseInt(kFactor)}
|
||||
results={allResults?.data ?? []}
|
||||
tournament={tournament}
|
||||
/>
|
||||
)}
|
||||
|
||||
{(!!error || allResults?.serverError) && (
|
||||
<ErrorBox
|
||||
error={<TranslatedError err={error ?? allResults?.serverError} />}
|
||||
/>
|
||||
<ErrorBox error={<TranslatedError err={error ?? allResults?.serverError} />} />
|
||||
)}
|
||||
|
||||
{((!hasTournamentId && !isFetching) || !!error) && (
|
||||
|
||||
@@ -23,29 +23,17 @@ export const KFactor = ({ className }: KFactorProps) => {
|
||||
</Disclosure.Button>
|
||||
|
||||
<Disclosure.Panel className="mt-4">
|
||||
<p className="text-sm text-gray-500 dark:text-neutral-400">
|
||||
{t("kFactorInfo1")}
|
||||
</p>
|
||||
<p className="mt-4 text-sm text-gray-500 dark:text-neutral-400">
|
||||
{t("kFactorInfo2")}
|
||||
</p>
|
||||
<p className="text-sm text-gray-500 dark:text-neutral-400">{t("kFactorInfo1")}</p>
|
||||
<p className="mt-4 text-sm text-gray-500 dark:text-neutral-400">{t("kFactorInfo2")}</p>
|
||||
|
||||
<ul className="mb-8 ml-4 mt-3 list-outside list-disc">
|
||||
{(
|
||||
[
|
||||
"kFactorInfo3",
|
||||
"kFactorInfo4",
|
||||
"kFactorInfo5",
|
||||
"kFactorInfo6",
|
||||
] as const
|
||||
).map((key) => (
|
||||
<li
|
||||
key={key}
|
||||
className="mt-2 text-sm text-gray-500 dark:text-neutral-400"
|
||||
>
|
||||
{t.rich(key, { b: (str) => <b>{str}</b> })}
|
||||
</li>
|
||||
))}
|
||||
{(["kFactorInfo3", "kFactorInfo4", "kFactorInfo5", "kFactorInfo6"] as const).map(
|
||||
(key) => (
|
||||
<li key={key} className="mt-2 text-sm text-gray-500 dark:text-neutral-400">
|
||||
{t.rich(key, { b: (str) => <b>{str}</b> })}
|
||||
</li>
|
||||
),
|
||||
)}
|
||||
</ul>
|
||||
</Disclosure.Panel>
|
||||
</Disclosure>
|
||||
|
||||
@@ -63,20 +63,16 @@ export const ManualEloForm = () => {
|
||||
storage: window.localStorage,
|
||||
});
|
||||
|
||||
// oxlint-disable-next-line no-unused-vars
|
||||
const onSubmit = async (data: EloFormValues) => {};
|
||||
|
||||
const [currentElo, kFactor, games] = form.watch([
|
||||
"currentElo",
|
||||
"kFactor",
|
||||
"games",
|
||||
]);
|
||||
const [currentElo, kFactor, games] = form.watch(["currentElo", "kFactor", "games"]);
|
||||
|
||||
const isDefault =
|
||||
isEmpty(currentElo) &&
|
||||
kFactor === "20" &&
|
||||
games?.length === 1 &&
|
||||
(isEmpty(games[0]) ||
|
||||
(isEmpty(games[0]?.opponentElo) && isEmpty(games[0]?.result)));
|
||||
(isEmpty(games[0]) || (isEmpty(games[0]?.opponentElo) && isEmpty(games[0]?.result)));
|
||||
|
||||
type Deltas = {
|
||||
rating: number;
|
||||
@@ -86,13 +82,8 @@ export const ManualEloForm = () => {
|
||||
const calculations = !Number.isNaN(currentElo)
|
||||
? (games ?? []).reduce<Deltas>(
|
||||
(acc, game) => {
|
||||
if (
|
||||
!isNil(game?.opponentElo) &&
|
||||
!Number.isNaN(game?.opponentElo) &&
|
||||
game?.result
|
||||
) {
|
||||
const result =
|
||||
game?.result === "win" ? 1 : game?.result === "loss" ? 0 : 0.5;
|
||||
if (!isNil(game?.opponentElo) && !Number.isNaN(game?.opponentElo) && game?.result) {
|
||||
const result = game?.result === "win" ? 1 : game?.result === "loss" ? 0 : 0.5;
|
||||
|
||||
const { delta } = getNewRating(
|
||||
currentElo!,
|
||||
@@ -117,9 +108,7 @@ export const ManualEloForm = () => {
|
||||
|
||||
const deltas = calculations.deltas;
|
||||
const hasDeltas = deltas.some((d) => d.delta !== undefined);
|
||||
const totalDelta = Math.round(
|
||||
deltas.reduce((acc, delta) => acc + (delta.delta ?? 0), 0),
|
||||
);
|
||||
const totalDelta = Math.round(deltas.reduce((acc, delta) => acc + (delta.delta ?? 0), 0));
|
||||
|
||||
return (
|
||||
<FormProvider {...form}>
|
||||
@@ -149,9 +138,7 @@ export const ManualEloForm = () => {
|
||||
|
||||
<KFactor className="mt-2" />
|
||||
|
||||
<h3 className="my-4 text-lg text-gray-900 dark:text-white">
|
||||
{t("resultsTitle")}
|
||||
</h3>
|
||||
<h3 className="my-4 text-lg text-gray-900 dark:text-white">{t("resultsTitle")}</h3>
|
||||
|
||||
<div className="flex w-full flex-col gap-6 sm:gap-2">
|
||||
{gameFields.map((game, i) => {
|
||||
|
||||
@@ -78,19 +78,13 @@ export const TournamentResults = ({
|
||||
|
||||
return {
|
||||
rating: acc.rating + delta,
|
||||
deltas: [
|
||||
...acc.deltas,
|
||||
{ rating: acc.rating + delta, delta, ...info },
|
||||
],
|
||||
deltas: [...acc.deltas, { rating: acc.rating + delta, delta, ...info }],
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
rating: acc.rating,
|
||||
deltas: [
|
||||
...acc.deltas,
|
||||
{ rating: acc.rating, delta: undefined, ...info },
|
||||
],
|
||||
deltas: [...acc.deltas, { rating: acc.rating, delta: undefined, ...info }],
|
||||
};
|
||||
},
|
||||
{ rating: currentElo!, deltas: [] },
|
||||
@@ -98,9 +92,7 @@ export const TournamentResults = ({
|
||||
: { rating: currentElo!, deltas: [] };
|
||||
|
||||
const deltas = calculations.deltas;
|
||||
const totalDelta = Math.round(
|
||||
deltas.reduce((acc, delta) => acc + (delta.delta ?? 0), 0),
|
||||
);
|
||||
const totalDelta = Math.round(deltas.reduce((acc, delta) => acc + (delta.delta ?? 0), 0));
|
||||
|
||||
const noChangeCount = (deltas ?? []).filter(
|
||||
({ wonByForfeit, lostByForfeit, estimated, national }) =>
|
||||
@@ -121,16 +113,12 @@ export const TournamentResults = ({
|
||||
{deltas.map((delta, i) => {
|
||||
const { estimated, national, lostByForfeit, wonByForfeit } = delta;
|
||||
const opponentElo = delta.opponentElo
|
||||
? ` (${delta.opponentElo} ${
|
||||
estimated ? "E" : national ? "N" : "F"
|
||||
})`
|
||||
? ` (${delta.opponentElo} ${estimated ? "E" : national ? "N" : "F"})`
|
||||
: "";
|
||||
|
||||
const opponentName = delta.opponentName ? (
|
||||
<span>
|
||||
<span className="whitespace-nowrap font-bold">
|
||||
{delta.opponentName}
|
||||
</span>
|
||||
<span className="whitespace-nowrap font-bold">{delta.opponentName}</span>
|
||||
{opponentElo}
|
||||
</span>
|
||||
) : (
|
||||
@@ -140,11 +128,8 @@ export const TournamentResults = ({
|
||||
const playedWhite = delta.colour === "white";
|
||||
|
||||
const whitePlayer = playedWhite ? playerResults.name : opponentName;
|
||||
const blackPlayer = !playedWhite
|
||||
? playerResults.name
|
||||
: opponentName;
|
||||
const noChange =
|
||||
wonByForfeit || lostByForfeit || estimated || national;
|
||||
const blackPlayer = !playedWhite ? playerResults.name : opponentName;
|
||||
const noChange = wonByForfeit || lostByForfeit || estimated || national;
|
||||
|
||||
const forfeit = delta.opponentName === null;
|
||||
|
||||
@@ -173,9 +158,7 @@ export const TournamentResults = ({
|
||||
{blackPlayer}
|
||||
</td>
|
||||
)}
|
||||
<td className="whitespace-nowrap px-2 pb-2 text-center">
|
||||
{!forfeit && result}
|
||||
</td>
|
||||
<td className="whitespace-nowrap px-2 pb-2 text-center">{!forfeit && result}</td>
|
||||
<td className="pb-2 text-right">
|
||||
{noChange ? (
|
||||
"-"
|
||||
|
||||
@@ -4,14 +4,14 @@ import EloClient from "@/app/[locale]/(main)/elo/EloClient";
|
||||
import { baseUrl } from "@/constants";
|
||||
|
||||
export async function generateMetadata({
|
||||
params: { locale },
|
||||
params,
|
||||
}: {
|
||||
params: { locale?: string };
|
||||
params: Promise<{ locale?: string }>;
|
||||
}): Promise<Metadata> {
|
||||
const { locale } = await params;
|
||||
return {
|
||||
alternates: {
|
||||
canonical:
|
||||
locale === "fr" ? `${baseUrl}/elo` : `${baseUrl}/${locale}/elo`,
|
||||
canonical: locale === "fr" ? `${baseUrl}/elo` : `${baseUrl}/${locale}/elo`,
|
||||
languages: {
|
||||
fr: `${baseUrl}/elo`,
|
||||
en: `${baseUrl}/en/elo`,
|
||||
|
||||
@@ -3,11 +3,7 @@ import { ReactNode } from "react";
|
||||
import Footer from "./components/Footer";
|
||||
import Navbar from "./components/Navbar";
|
||||
|
||||
export default async function MainLayout({
|
||||
children,
|
||||
}: {
|
||||
children: ReactNode;
|
||||
}) {
|
||||
export default async function MainLayout({ children }: { children: ReactNode }) {
|
||||
return (
|
||||
<>
|
||||
<Navbar />
|
||||
|
||||
@@ -33,11 +33,7 @@ export default function Contact() {
|
||||
<p>
|
||||
{t.rich("cookiesInfo", {
|
||||
link: (str) => (
|
||||
<a
|
||||
href="https://tinyanalytics.io"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
<a href="https://tinyanalytics.io" target="_blank" rel="noopener noreferrer">
|
||||
{str}
|
||||
</a>
|
||||
),
|
||||
|
||||
@@ -8,11 +8,7 @@ import "react-date-range/dist/theme/default.css";
|
||||
import { dateRangeAtom, maxDateAtom } from "@/atoms";
|
||||
import { DatePickerDirection } from "@/types";
|
||||
|
||||
const DatePicker = ({
|
||||
datePickerDirection,
|
||||
}: {
|
||||
datePickerDirection: DatePickerDirection;
|
||||
}) => {
|
||||
const DatePicker = ({ datePickerDirection }: { datePickerDirection: DatePickerDirection }) => {
|
||||
const [dateRange, setDateRange] = useAtom(dateRangeAtom);
|
||||
const maxDate = useAtomValue(maxDateAtom);
|
||||
|
||||
|
||||
@@ -16,12 +16,9 @@ const Legend = () => {
|
||||
|
||||
const timeControls = useMemo(
|
||||
() =>
|
||||
[
|
||||
TimeControl.Classic,
|
||||
TimeControl.Rapid,
|
||||
TimeControl.Blitz,
|
||||
TimeControl.Other,
|
||||
].filter((tc) => tournaments.some((t) => t.timeControl === tc)),
|
||||
[TimeControl.Classic, TimeControl.Rapid, TimeControl.Blitz, TimeControl.Other].filter((tc) =>
|
||||
tournaments.some((t) => t.timeControl === tc),
|
||||
),
|
||||
[tournaments],
|
||||
);
|
||||
|
||||
|
||||
@@ -1,13 +1,7 @@
|
||||
import { useAtom, useAtomValue } from "jotai";
|
||||
import { useTranslations } from "next-intl";
|
||||
|
||||
import {
|
||||
blitzAtom,
|
||||
classicAtom,
|
||||
otherAtom,
|
||||
rapidAtom,
|
||||
tournamentsAtom,
|
||||
} from "@/atoms";
|
||||
import { blitzAtom, classicAtom, otherAtom, rapidAtom, tournamentsAtom } from "@/atoms";
|
||||
import { TimeControl } from "@/types";
|
||||
|
||||
const TimeControlFilters = () => {
|
||||
|
||||
@@ -3,17 +3,14 @@
|
||||
import { useCallback, useMemo } from "react";
|
||||
|
||||
import { useAtomValue } from "jotai";
|
||||
import L, { LatLngLiteral } from "leaflet";
|
||||
import L from "leaflet";
|
||||
import "leaflet-defaulticon-compatibility";
|
||||
import "leaflet-defaulticon-compatibility/dist/leaflet-defaulticon-compatibility.css";
|
||||
import "leaflet.smooth_marker_bouncing";
|
||||
import "leaflet/dist/leaflet.css";
|
||||
import { countBy, groupBy } from "lodash";
|
||||
|
||||
import {
|
||||
filteredTournamentsByTimeControlAndZoneAtom,
|
||||
normsOnlyAtom,
|
||||
} from "@/atoms";
|
||||
import { filteredTournamentsByTimeControlAndZoneAtom, normsOnlyAtom } from "@/atoms";
|
||||
import { Map, MapMarker } from "@/components/Map";
|
||||
import { TimeControlColours } from "@/constants";
|
||||
import { TimeControl } from "@/types";
|
||||
@@ -49,15 +46,12 @@ const TournamentMap = () => {
|
||||
${generatePieSVG(
|
||||
"absolute w-[30px]",
|
||||
15,
|
||||
[
|
||||
TimeControl.Classic,
|
||||
TimeControl.Rapid,
|
||||
TimeControl.Blitz,
|
||||
TimeControl.Other,
|
||||
].map((tc) => ({
|
||||
value: timeControlCounts[tc] ?? 0,
|
||||
colour: TimeControlColours[tc],
|
||||
})),
|
||||
[TimeControl.Classic, TimeControl.Rapid, TimeControl.Blitz, TimeControl.Other].map(
|
||||
(tc) => ({
|
||||
value: timeControlCounts[tc] ?? 0,
|
||||
colour: TimeControlColours[tc],
|
||||
}),
|
||||
),
|
||||
)}
|
||||
<span class="text-white font-semibold relative z-[300]">${childCount}</span>
|
||||
</div>
|
||||
@@ -77,9 +71,7 @@ const TournamentMap = () => {
|
||||
return {
|
||||
markerId: groupId,
|
||||
tableIds: tournamentGroup.map((t) => t.id),
|
||||
component: (
|
||||
<TournamentMarker key={groupId} tournamentGroup={tournamentGroup} />
|
||||
),
|
||||
component: <TournamentMarker key={groupId} tournamentGroup={tournamentGroup} />,
|
||||
};
|
||||
}),
|
||||
[groupedTournaments],
|
||||
|
||||
@@ -43,19 +43,14 @@ const TournamentTable = () => {
|
||||
|
||||
const setDateRange = useSetAtom(dateRangeAtom);
|
||||
const [datePickerIsOpen, setDatePickerIsOpen] = useAtom(datePickerIsOpenAtom);
|
||||
const [dateDirectionState, setDateDirectionState] =
|
||||
useState<DatePickerDirection>("horizontal");
|
||||
const datePickerColour = datePickerIsOpen
|
||||
? "text-primary-600"
|
||||
: "text-gray-500";
|
||||
const [dateDirectionState, setDateDirectionState] = useState<DatePickerDirection>("horizontal");
|
||||
const datePickerColour = datePickerIsOpen ? "text-primary-600" : "text-gray-500";
|
||||
|
||||
useDatePickerWidth({ datePickerRef, setDateDirectionState });
|
||||
|
||||
useEffect(() => {
|
||||
if (!isLg || debouncedHoveredMapId === null) return;
|
||||
const tournamentRow = document.querySelector(
|
||||
`[data-group-id="${debouncedHoveredMapId}"]`,
|
||||
);
|
||||
const tournamentRow = document.querySelector(`[data-group-id="${debouncedHoveredMapId}"]`);
|
||||
|
||||
tournamentRow?.scrollIntoView({ behavior: "smooth" });
|
||||
}, [debouncedHoveredMapId, isLg]);
|
||||
@@ -112,9 +107,7 @@ const TournamentTable = () => {
|
||||
</div>
|
||||
|
||||
<div className="flex justify-center" ref={datePickerRef}>
|
||||
{datePickerIsOpen && (
|
||||
<DatePicker datePickerDirection={dateDirectionState} />
|
||||
)}
|
||||
{datePickerIsOpen && <DatePicker datePickerDirection={dateDirectionState} />}
|
||||
</div>
|
||||
|
||||
<div className="overflow-x-scroll">
|
||||
@@ -156,23 +149,15 @@ const TournamentTable = () => {
|
||||
onMouseLeave={() => setHoveredListId(null)}
|
||||
className={twMerge(
|
||||
"scroll-m-20 bg-white text-gray-900 hover:bg-gray-200 dark:bg-gray-800 dark:text-white dark:hover:bg-gray-900",
|
||||
hoveredMapId === tournament.groupId &&
|
||||
"bg-gray-200 dark:bg-gray-900",
|
||||
hoveredMapId === tournament.groupId && "bg-gray-200 dark:bg-gray-900",
|
||||
)}
|
||||
>
|
||||
<td className="px-1 py-2 sm:px-3 sm:py-3 lg:px-3 lg:py-3">
|
||||
{tournament.date}
|
||||
</td>
|
||||
<td className="px-1 py-2 sm:px-3 sm:py-3 lg:px-3 lg:py-3">
|
||||
{tournament.town}
|
||||
</td>
|
||||
<td className="px-1 py-2 sm:px-3 sm:py-3 lg:px-3 lg:py-3">{tournament.date}</td>
|
||||
<td className="px-1 py-2 sm:px-3 sm:py-3 lg:px-3 lg:py-3">{tournament.town}</td>
|
||||
<td className="px-1 py-2 text-left sm:px-3 sm:py-3 lg:px-3 lg:py-3">
|
||||
<span>
|
||||
{tournament.norm && (
|
||||
<FaTrophy
|
||||
className="mr-2 inline-block h-4 w-4"
|
||||
data-norm="norm"
|
||||
/>
|
||||
<FaTrophy className="mr-2 inline-block h-4 w-4" data-norm="norm" />
|
||||
)}
|
||||
{tournament.tournament}
|
||||
</span>
|
||||
|
||||
@@ -22,9 +22,7 @@ const TournamentMap = dynamic(() => import("./TournamentMap"), {
|
||||
loading: LoadingMap,
|
||||
});
|
||||
|
||||
export default function TournamentsDisplay({
|
||||
tournaments,
|
||||
}: TournamentsDisplayProps) {
|
||||
export default function TournamentsDisplay({ tournaments }: TournamentsDisplayProps) {
|
||||
useHydrateAtoms([[tournamentsAtom, tournaments]]);
|
||||
|
||||
return (
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
import {
|
||||
differenceInDays,
|
||||
isSameDay,
|
||||
parse,
|
||||
setDefaultOptions,
|
||||
} from "date-fns";
|
||||
import { differenceInDays, isSameDay, parse, setDefaultOptions } from "date-fns";
|
||||
import { fr } from "date-fns/locale";
|
||||
import { groupBy } from "lodash";
|
||||
import { Metadata } from "next";
|
||||
@@ -20,16 +15,14 @@ import TournamentsDisplay from "./TournamentsDisplay";
|
||||
setDefaultOptions({ locale: fr });
|
||||
|
||||
export async function generateMetadata({
|
||||
params: { locale },
|
||||
params,
|
||||
}: {
|
||||
params: { locale?: string };
|
||||
params: Promise<{ locale?: string }>;
|
||||
}): Promise<Metadata> {
|
||||
const { locale } = await params;
|
||||
return {
|
||||
alternates: {
|
||||
canonical:
|
||||
locale === "fr"
|
||||
? `${baseUrl}/tournois`
|
||||
: `${baseUrl}/${locale}/tournaments`,
|
||||
canonical: locale === "fr" ? `${baseUrl}/tournois` : `${baseUrl}/${locale}/tournaments`,
|
||||
languages: {
|
||||
fr: `${baseUrl}/tournois`,
|
||||
en: `${baseUrl}/en/tournaments`,
|
||||
@@ -107,10 +100,7 @@ const getTournaments = async () => {
|
||||
const goodData = data.filter((t) => !badIds.includes(t._id.toString()));
|
||||
|
||||
// Group the tournaments by their location
|
||||
const groupedByLocation = groupBy(
|
||||
goodData,
|
||||
(t) => `${t.coordinates[0]}_${t.coordinates[1]}`,
|
||||
);
|
||||
const groupedByLocation = groupBy(goodData, (t) => `${t.coordinates[0]}_${t.coordinates[1]}`);
|
||||
|
||||
// For each location, create an array of arrays of contiguous dates for this location
|
||||
const dateRangesByLocation: Record<string, Date[][]> = {};
|
||||
@@ -140,9 +130,7 @@ const getTournaments = async () => {
|
||||
const location = `${t.coordinates[0]}_${t.coordinates[1]}`;
|
||||
const date = parse(t.date, "dd/MM/yyyy", new Date());
|
||||
const dateRanges = dateRangesByLocation[location];
|
||||
const rangeIndex = dateRanges.findIndex((ranges) =>
|
||||
ranges.some((d) => isSameDay(d, date)),
|
||||
);
|
||||
const rangeIndex = dateRanges.findIndex((ranges) => ranges.some((d) => isSameDay(d, date)));
|
||||
|
||||
// We place each tournament into a group based on location and date and time control, so that
|
||||
// we can display a single map marker.
|
||||
|
||||
@@ -12,12 +12,12 @@ import { Zone } from "@/server/myZones";
|
||||
|
||||
const center: LatLngLiteral = { lat: 47.0844, lng: 2.3964 };
|
||||
|
||||
export type ZoneThumbnailProps = {
|
||||
type ZoneThumbnailProps = {
|
||||
features: Zone["features"];
|
||||
className?: string;
|
||||
};
|
||||
|
||||
export const ZoneThumbnail = ({ features, className }: ZoneThumbnailProps) => {
|
||||
const ZoneThumbnail = ({ features, className }: ZoneThumbnailProps) => {
|
||||
return (
|
||||
<MapContainer
|
||||
center={center}
|
||||
|
||||
@@ -46,11 +46,7 @@ const CreateZone = () => {
|
||||
{t("createTitle")}
|
||||
</h2>
|
||||
|
||||
<ZoneForm
|
||||
withInfo
|
||||
onSubmit={onSubmit}
|
||||
onCancel={() => router.push("/zones")}
|
||||
/>
|
||||
<ZoneForm withInfo onSubmit={onSubmit} onCancel={() => router.push("/zones")} />
|
||||
|
||||
{responseMessage && (
|
||||
<InfoMessage
|
||||
|
||||
@@ -49,7 +49,7 @@ const EditZone = () => {
|
||||
|
||||
await refetch();
|
||||
router.push("/zones");
|
||||
} catch (error) {
|
||||
} catch {
|
||||
setResponseMessage({
|
||||
type: "error",
|
||||
message: t("createFailure"),
|
||||
@@ -66,11 +66,7 @@ const EditZone = () => {
|
||||
{t("editTitle")}
|
||||
</h2>
|
||||
|
||||
<ZoneForm
|
||||
onSubmit={onSubmit}
|
||||
onCancel={() => router.push("/zones")}
|
||||
zone={zone}
|
||||
/>
|
||||
<ZoneForm onSubmit={onSubmit} onCancel={() => router.push("/zones")} zone={zone} />
|
||||
|
||||
{responseMessage && (
|
||||
<InfoMessage
|
||||
|
||||
@@ -160,11 +160,7 @@ const Zones = () => {
|
||||
)}
|
||||
|
||||
<div className="flex items-center justify-between space-x-4 text-sm font-bold">
|
||||
<Button
|
||||
intent="secondary"
|
||||
type="button"
|
||||
onClick={() => setDeletingZoneId(null)}
|
||||
>
|
||||
<Button intent="secondary" type="button" onClick={() => setDeletingZoneId(null)}>
|
||||
{at("cancelButton")}
|
||||
</Button>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user