mirror of
https://github.com/TheRealOwenRees/echecsfrance.git
synced 2026-11-18 07:22:06 +00:00
Compare commits
22
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
32b98a4da6 | ||
|
|
8269144df9 | ||
|
|
7fb84b5132 | ||
|
|
fefa38fc70 | ||
|
|
06c7418d6f | ||
|
|
63cd7e6de7 | ||
|
|
14e5038ff4 | ||
|
|
3ad0b2779e | ||
|
|
888cd01d7c | ||
|
|
70571a81a2 | ||
|
|
ee854151a3 | ||
|
|
3468d5cd50 | ||
|
|
9662f6d5b0 | ||
|
|
687d335625 | ||
|
|
6f32be40d4 | ||
|
|
6517af51c9 | ||
|
|
9fb78b2f78 | ||
|
|
a5112561c5 | ||
|
|
2cc5e7f6c3 | ||
|
|
11113efc9f | ||
|
|
61dcd11739 | ||
|
|
feadb465eb |
@@ -0,0 +1,12 @@
|
|||||||
|
version: 2
|
||||||
|
updates:
|
||||||
|
- package-ecosystem: npm
|
||||||
|
directory: /
|
||||||
|
schedule: { interval: weekly }
|
||||||
|
open-pull-requests-limit: 10
|
||||||
|
groups:
|
||||||
|
react: { patterns: ["react", "react-dom", "@types/react", "@types/react-dom"] }
|
||||||
|
next: { patterns: ["next", "@next/*", "@serwist/*", "serwist"] }
|
||||||
|
types: { patterns: ["@types/*"] }
|
||||||
|
leaflet: { patterns: ["leaflet", "leaflet-*", "react-leaflet*", "@types/leaflet"] }
|
||||||
|
labels: ["dependencies"]
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
name: CI
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
push:
|
||||||
|
branches: [main]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
check:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 10
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v7
|
||||||
|
- uses: actions/setup-node@v7
|
||||||
|
with:
|
||||||
|
node-version-file: .nvmrc
|
||||||
|
cache: yarn
|
||||||
|
- run: yarn install --frozen-lockfile
|
||||||
|
- run: yarn verify
|
||||||
+1
-1
@@ -1,8 +1,8 @@
|
|||||||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||||
|
|
||||||
/.idea/
|
/.idea/
|
||||||
|
|
||||||
/.yarn/
|
/.yarn/
|
||||||
|
/.codegraph/
|
||||||
|
|
||||||
# dependencies
|
# dependencies
|
||||||
/node_modules
|
/node_modules
|
||||||
|
|||||||
+2
-2
@@ -24,8 +24,8 @@ et est déployé sur [Vercel](https://vercel.com/)
|
|||||||
|
|
||||||
## Plugins VSCode requis
|
## Plugins VSCode requis
|
||||||
|
|
||||||
- ESLint
|
- Oxlint
|
||||||
- Prettier - Formateur de code
|
- Oxfmt
|
||||||
|
|
||||||
## Plugins VSCode recommandés
|
## Plugins VSCode recommandés
|
||||||
|
|
||||||
|
|||||||
@@ -24,8 +24,8 @@ and is deployed on [Vercel](https://vercel.com/)
|
|||||||
|
|
||||||
## Required VSCode plugins
|
## Required VSCode plugins
|
||||||
|
|
||||||
- ESLint
|
- Oxlint
|
||||||
- Prettier - Code formatter
|
- Oxfmt
|
||||||
|
|
||||||
## Recommended VSCode plugins
|
## Recommended VSCode plugins
|
||||||
|
|
||||||
|
|||||||
Vendored
+2
@@ -1,3 +1,5 @@
|
|||||||
|
/// <reference types="next/image-types/global" />
|
||||||
|
|
||||||
// Use type safe message keys with `next-intl`
|
// Use type safe message keys with `next-intl`
|
||||||
type Messages = typeof import("./src/messages/fr.json");
|
type Messages = typeof import("./src/messages/fr.json");
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,19 @@
|
|||||||
{
|
{
|
||||||
"$schema": "https://unpkg.com/knip@6/schema.json",
|
"$schema": "https://unpkg.com/knip@6/schema.json",
|
||||||
"ignore": [],
|
"ignore": ["src/app/sw.ts", "src/i18n.ts", "src/__tests__/clubs/helpers/clubData.ts"],
|
||||||
"ignoreDependencies": [],
|
"ignoreDependencies": [
|
||||||
|
"leaflet.markercluster",
|
||||||
|
"serwist",
|
||||||
|
"sharp",
|
||||||
|
"superjson",
|
||||||
|
"@swc-jotai/react-refresh",
|
||||||
|
"@testing-library/jest-dom",
|
||||||
|
"@headlessui/tailwindcss",
|
||||||
|
"@next/bundle-analyzer",
|
||||||
|
"@serwist/next",
|
||||||
|
"oxfmt",
|
||||||
|
"oxlint",
|
||||||
|
"vitest"
|
||||||
|
],
|
||||||
"tags": ["-lintignore"]
|
"tags": ["-lintignore"]
|
||||||
}
|
}
|
||||||
|
|||||||
+11195
-10337
File diff suppressed because it is too large
Load Diff
+32
-29
@@ -3,37 +3,35 @@
|
|||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "vitest --config vitetest.config.ts",
|
"test": "vitest",
|
||||||
|
"test:ci": "vitest run",
|
||||||
|
"test:coverage": "vitest --coverage",
|
||||||
"dev": "next dev",
|
"dev": "next dev",
|
||||||
"build": "next build --webpack",
|
"build": "next build --webpack",
|
||||||
"start": "next start",
|
"start": "next start",
|
||||||
"lint": "oxlint",
|
"lint": "oxlint",
|
||||||
"typeCheck": "tsc -p ./tsconfig.json",
|
"typeCheck": "tsc -p ./tsconfig.json --incremental false",
|
||||||
"postinstall": "patch-package",
|
"postinstall": "patch-package",
|
||||||
"format": "oxfmt --check",
|
"format": "oxfmt --check",
|
||||||
"format:fix": "oxfmt",
|
"format:fix": "oxfmt",
|
||||||
"knip": "knip",
|
"knip": "knip",
|
||||||
"knip:prod": "knip --production",
|
"knip:prod": "knip --production",
|
||||||
"knip:ci": "knip --production --cache"
|
"knip:ci": "knip --production --cache",
|
||||||
|
"verify": "yarn format && yarn lint && yarn typeCheck && yarn test:ci && yarn knip && yarn knip:prod"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@auth/mongodb-adapter": "^3.5.2",
|
"@auth/mongodb-adapter": "^3.5.2",
|
||||||
"@headlessui/react": "^2.1.8",
|
"@headlessui/react": "^2.1.8",
|
||||||
"@headlessui/tailwindcss": "^0.2.1",
|
|
||||||
"@hookform/resolvers": "^3.9.0",
|
"@hookform/resolvers": "^3.9.0",
|
||||||
"@infra-blocks/zod-utils": "^0.4.2",
|
"@infra-blocks/zod-utils": "^0.32.0",
|
||||||
"@next/bundle-analyzer": "^16.3.6",
|
|
||||||
"@serwist/next": "^9.5.12",
|
|
||||||
"@socialgouv/matomo-next": "^1.14.2",
|
"@socialgouv/matomo-next": "^1.14.2",
|
||||||
"@tanstack/react-query": "^5.29.0",
|
"@tanstack/react-query": "^5.104.2",
|
||||||
"@turf/boolean-point-in-polygon": "^7.0.0-alpha.114",
|
"@turf/boolean-point-in-polygon": "^7.0.0-alpha.114",
|
||||||
"@types/node": "^22.7.2",
|
|
||||||
"autoprefixer": "^10.4.16",
|
"autoprefixer": "^10.4.16",
|
||||||
"class-variance-authority": "^0.7.0",
|
"class-variance-authority": "^0.7.0",
|
||||||
"date-fns": "^4.1.0",
|
"date-fns": "^4.1.0",
|
||||||
"geojson": "^0.5.0",
|
"geojson": "^0.5.0",
|
||||||
"jotai": "^2.6.1",
|
"jotai": "^2.6.1",
|
||||||
"knip": "^6.38.0",
|
|
||||||
"leaflet": "^1.9.4",
|
"leaflet": "^1.9.4",
|
||||||
"leaflet-defaulticon-compatibility": "^0.1.2",
|
"leaflet-defaulticon-compatibility": "^0.1.2",
|
||||||
"leaflet-draw": "^1.0.4",
|
"leaflet-draw": "^1.0.4",
|
||||||
@@ -42,19 +40,16 @@
|
|||||||
"leaflet.smooth_marker_bouncing": "3.0.3",
|
"leaflet.smooth_marker_bouncing": "3.0.3",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"mongodb": "^7.0.0",
|
"mongodb": "^7.0.0",
|
||||||
"next": "^16.3.6",
|
"next": "^16.4.4",
|
||||||
"next-auth": "^5.0.0-beta.32",
|
"next-auth": "^5.0.0-beta.32",
|
||||||
"next-intl": "^4.14.7",
|
"next-intl": "^4.14.9",
|
||||||
"next-safe-action": "^7.9.3",
|
"next-safe-action": "^7.9.3",
|
||||||
"nodemailer": "^6.9.12",
|
"nodemailer": "^10.1.1",
|
||||||
"oxfmt": "^0.71.0",
|
"react": "^19.3.1",
|
||||||
"oxlint": "^1.86.0",
|
|
||||||
"postcss": "^8.4.47",
|
|
||||||
"react": "^19.3.0",
|
|
||||||
"react-date-range": "^2.0.1",
|
"react-date-range": "^2.0.1",
|
||||||
"react-datepicker": "^7.4.0",
|
"react-datepicker": "^7.4.0",
|
||||||
"react-dom": "^19.3.0",
|
"react-dom": "^19.3.1",
|
||||||
"react-hook-form": "^7.46.1",
|
"react-hook-form": "^7.90.0",
|
||||||
"react-icons": "^5.3.0",
|
"react-icons": "^5.3.0",
|
||||||
"react-input-mask": "^2.0.4",
|
"react-input-mask": "^2.0.4",
|
||||||
"react-leaflet": "^4.2.1",
|
"react-leaflet": "^4.2.1",
|
||||||
@@ -62,28 +57,36 @@
|
|||||||
"react-leaflet-draw": "^0.20.4",
|
"react-leaflet-draw": "^0.20.4",
|
||||||
"react-select": "^5.7.4",
|
"react-select": "^5.7.4",
|
||||||
"react-tooltip": "^5.18.0",
|
"react-tooltip": "^5.18.0",
|
||||||
"serwist": "^9.5.12",
|
"serwist": "^9.5.13",
|
||||||
"sharp": "^0.33.0",
|
"sharp": "^0.35.5",
|
||||||
"superjson": "^2.2.1",
|
"superjson": "^2.2.1",
|
||||||
"tailwind-merge": "^2.0.0",
|
"tailwind-merge": "^2.0.0",
|
||||||
"tailwindcss": "^3.3.5",
|
"zod": "^4.6.5"
|
||||||
"typescript": "^5.3.3",
|
|
||||||
"vitest": "^4.0.12",
|
|
||||||
"zod": "^3.22.4"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@headlessui/tailwindcss": "^0.2.1",
|
||||||
|
"@next/bundle-analyzer": "^16.4.4",
|
||||||
|
"@serwist/next": "^9.5.13",
|
||||||
"@swc-jotai/react-refresh": "^0.2.0",
|
"@swc-jotai/react-refresh": "^0.2.0",
|
||||||
"@tailwindcss/forms": "^0.5.4",
|
"@tailwindcss/forms": "^0.5.4",
|
||||||
"@tailwindcss/typography": "^0.5.15",
|
"@tailwindcss/typography": "^0.5.15",
|
||||||
"@testing-library/jest-dom": "^6.1.2",
|
"@testing-library/jest-dom": "^7.0.1",
|
||||||
"@types/leaflet": "^1.9.12",
|
"@types/leaflet": "^1.9.12",
|
||||||
"@types/lodash": "^4.14.195",
|
"@types/lodash": "^4.17.26",
|
||||||
"@types/nodemailer": "^6.4.8",
|
"@types/node": "^26.6.5",
|
||||||
"@types/react": "^19.3.0",
|
"@types/react": "^19.3.0",
|
||||||
"@types/react-date-range": "^1.4.9",
|
"@types/react-date-range": "^1.4.9",
|
||||||
"@types/react-dom": "^19.3.0",
|
"@types/react-dom": "^19.3.0",
|
||||||
"@types/react-input-mask": "^3.0.2",
|
"@types/react-input-mask": "^3.0.2",
|
||||||
"patch-package": "^8.0.1"
|
"knip": "^6.38.0",
|
||||||
|
"oxfmt": "^0.71.0",
|
||||||
|
"oxlint": "^1.89.0",
|
||||||
|
"patch-package": "^8.0.1",
|
||||||
|
"postcss": "^8.5.29",
|
||||||
|
"tailwindcss": "^3.3.5",
|
||||||
|
"typescript": "^7.0.2",
|
||||||
|
"vite": "8.3.4",
|
||||||
|
"vitest": "^5.0.3"
|
||||||
},
|
},
|
||||||
"packageManager": "yarn@1.22.22+sha1.ac34549e6aa8e7ead463a7407e1c7390f61a6610"
|
"packageManager": "yarn@1.22.22+sha1.ac34549e6aa8e7ead463a7407e1c7390f61a6610"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
import { describe, expect, test } from "vitest";
|
import { describe, expect, test } from "vitest";
|
||||||
|
|
||||||
import { IClub, filterClubsByManualEntry } from "@/utils/clubFilters";
|
import { IClub, filterClubsByManualEntry } from "@/utils/clubFilters";
|
||||||
|
|
||||||
import { clubData } from "./helpers/clubData";
|
import { clubData } from "./helpers/clubData";
|
||||||
|
|
||||||
describe("clubs", () => {
|
describe("clubs", () => {
|
||||||
@@ -12,11 +10,6 @@ describe("clubs", () => {
|
|||||||
expect(originalLength).toEqual(filteredLength);
|
expect(originalLength).toEqual(filteredLength);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("contains manually entered club non-pending", () => {
|
|
||||||
const containsManuallyEnteredClub = clubData.some((club) => club.manual_entry);
|
|
||||||
expect(containsManuallyEnteredClub).toBeTruthy;
|
|
||||||
});
|
|
||||||
|
|
||||||
test("manual entered club filters out auto-generated club of same name", () => {
|
test("manual entered club filters out auto-generated club of same name", () => {
|
||||||
const duplicateClubNames: Set<string> = new Set(clubData.map((club) => club.name));
|
const duplicateClubNames: Set<string> = new Set(clubData.map((club) => club.name));
|
||||||
|
|
||||||
@@ -29,11 +22,6 @@ describe("clubs", () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const filteredData: IClub[] = filterClubsByManualEntry(clubData);
|
const filteredData: IClub[] = filterClubsByManualEntry(clubData);
|
||||||
|
|
||||||
const hasManualEnteredClubs = filteredData.some((club) => club.manual_entry && !club.pending);
|
|
||||||
|
|
||||||
expect(filteredData.length).toEqual(clubData.length - duplicateClubNames.size);
|
expect(filteredData.length).toEqual(clubData.length - duplicateClubNames.size);
|
||||||
|
|
||||||
expect(hasManualEnteredClubs).toBeTruthy;
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ export const ManualEloForm = () => {
|
|||||||
storage: window.localStorage,
|
storage: window.localStorage,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// oxlint-disable-next-line no-unused-vars
|
||||||
const onSubmit = async (data: EloFormValues) => {};
|
const onSubmit = async (data: EloFormValues) => {};
|
||||||
|
|
||||||
const [currentElo, kFactor, games] = form.watch(["currentElo", "kFactor", "games"]);
|
const [currentElo, kFactor, games] = form.watch(["currentElo", "kFactor", "games"]);
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ export default function Contact() {
|
|||||||
<p>
|
<p>
|
||||||
{t.rich("cookiesInfo", {
|
{t.rich("cookiesInfo", {
|
||||||
link: (str) => (
|
link: (str) => (
|
||||||
<a href="https://tinyanalytics.io" target="_blank" rel="noopener noreferrer">
|
<a href="https://matomo.org" target="_blank" rel="noopener noreferrer">
|
||||||
{str}
|
{str}
|
||||||
</a>
|
</a>
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -0,0 +1,50 @@
|
|||||||
|
import { useAtom, useAtomValue } from "jotai";
|
||||||
|
import { useTranslations } from "next-intl";
|
||||||
|
import { twMerge } from "tailwind-merge";
|
||||||
|
import {
|
||||||
|
DurationFilter as DurationFilterValue,
|
||||||
|
durationFilterAtom,
|
||||||
|
tournamentsAtom,
|
||||||
|
} from "@/atoms";
|
||||||
|
|
||||||
|
const DurationFilter = () => {
|
||||||
|
const t = useTranslations("Tournaments");
|
||||||
|
const tournaments = useAtomValue(tournamentsAtom);
|
||||||
|
const [durationFilter, setDurationFilter] = useAtom(durationFilterAtom);
|
||||||
|
|
||||||
|
const show3Plus = tournaments.some((tt) => tt.durationDays >= 3);
|
||||||
|
|
||||||
|
const options: { value: DurationFilterValue; label: string }[] = [
|
||||||
|
{ value: "any", label: t("durationAny") },
|
||||||
|
{ value: "1", label: t("duration1Day") },
|
||||||
|
{ value: "2", label: t("duration2Days") },
|
||||||
|
...(show3Plus ? [{ value: "3+" as const, label: t("duration3PlusDays") }] : []),
|
||||||
|
];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="flex flex-wrap items-center gap-1">
|
||||||
|
{options.map(({ value, label }) => {
|
||||||
|
const isActive = durationFilter === value;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<button
|
||||||
|
key={value}
|
||||||
|
type="button"
|
||||||
|
aria-pressed={isActive}
|
||||||
|
onClick={() => setDurationFilter(value)}
|
||||||
|
className={twMerge(
|
||||||
|
"rounded-full border px-3 py-1 text-sm transition-colors focus:outline-none",
|
||||||
|
isActive
|
||||||
|
? "border-primary bg-primary text-white"
|
||||||
|
: "border-gray-400 text-gray-600 hover:border-primary hover:text-primary dark:border-gray-600 dark:text-gray-300 dark:hover:text-primary",
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{label}
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default DurationFilter;
|
||||||
@@ -4,7 +4,6 @@ import { forwardRef, useImperativeHandle, useMemo, useRef } from "react";
|
|||||||
|
|
||||||
import { useSetAtom } from "jotai";
|
import { useSetAtom } from "jotai";
|
||||||
import L from "leaflet";
|
import L from "leaflet";
|
||||||
import { last } from "lodash";
|
|
||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
import { FaTrophy } from "react-icons/fa";
|
import { FaTrophy } from "react-icons/fa";
|
||||||
import { Marker, MarkerProps, Popup } from "react-leaflet";
|
import { Marker, MarkerProps, Popup } from "react-leaflet";
|
||||||
@@ -37,7 +36,7 @@ export const TournamentMarker = forwardRef<MarkerRef, TournamentMarkerProps>(
|
|||||||
[],
|
[],
|
||||||
);
|
);
|
||||||
|
|
||||||
const { date, latLng, groupId, timeControl } = tournamentGroup[0];
|
const { startDate, endDate, latLng, groupId, timeControl } = tournamentGroup[0];
|
||||||
|
|
||||||
const setHoveredMapId = useSetAtom(debouncedHoveredMapIdAtom);
|
const setHoveredMapId = useSetAtom(debouncedHoveredMapIdAtom);
|
||||||
|
|
||||||
@@ -58,9 +57,6 @@ export const TournamentMarker = forwardRef<MarkerRef, TournamentMarkerProps>(
|
|||||||
[timeControl],
|
[timeControl],
|
||||||
);
|
);
|
||||||
|
|
||||||
const startDate = date;
|
|
||||||
const endDate = last(tournamentGroup)!.date;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Marker
|
<Marker
|
||||||
ref={markerRef}
|
ref={markerRef}
|
||||||
@@ -74,10 +70,7 @@ export const TournamentMarker = forwardRef<MarkerRef, TournamentMarkerProps>(
|
|||||||
>
|
>
|
||||||
<Popup maxWidth={10000}>
|
<Popup maxWidth={10000}>
|
||||||
<div className="flex max-w-[calc(100vw-80px)] flex-col gap-3 lg:max-w-[calc(100vw/2-80px)]">
|
<div className="flex max-w-[calc(100vw-80px)] flex-col gap-3 lg:max-w-[calc(100vw/2-80px)]">
|
||||||
<b>
|
<b>{startDate !== endDate ? `${startDate} -> ${endDate}` : startDate}</b>
|
||||||
{date}
|
|
||||||
{endDate !== startDate && ` - ${endDate}`}
|
|
||||||
</b>
|
|
||||||
|
|
||||||
<div className="flex flex-col gap-0">
|
<div className="flex flex-col gap-0">
|
||||||
{tournamentGroup.map((tournament) => (
|
{tournamentGroup.map((tournament) => (
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import { useBreakpoint } from "@/hooks/tailwind";
|
|||||||
import useDatePickerWidth from "@/hooks/useDatePickerWidth";
|
import useDatePickerWidth from "@/hooks/useDatePickerWidth";
|
||||||
import { DatePickerDirection } from "@/types";
|
import { DatePickerDirection } from "@/types";
|
||||||
|
|
||||||
|
import DurationFilter from "./DurationFilter";
|
||||||
import TimeControlFilters from "./TimeControlFilters";
|
import TimeControlFilters from "./TimeControlFilters";
|
||||||
|
|
||||||
const TournamentTable = () => {
|
const TournamentTable = () => {
|
||||||
@@ -75,6 +76,7 @@ const TournamentTable = () => {
|
|||||||
<div className="z-10 flex w-full flex-wrap items-center justify-start gap-3 p-3">
|
<div className="z-10 flex w-full flex-wrap items-center justify-start gap-3 p-3">
|
||||||
<div className="flex w-full flex-col gap-3 sm:flex-row">
|
<div className="flex w-full flex-col gap-3 sm:flex-row">
|
||||||
<SearchBar className="w-full sm:w-auto" />
|
<SearchBar className="w-full sm:w-auto" />
|
||||||
|
|
||||||
<RegionSelect
|
<RegionSelect
|
||||||
syncTitle={t("syncWithMapOption")}
|
syncTitle={t("syncWithMapOption")}
|
||||||
classNameOverrides={{
|
classNameOverrides={{
|
||||||
@@ -89,6 +91,8 @@ const TournamentTable = () => {
|
|||||||
onClick={handleDatePickerClick}
|
onClick={handleDatePickerClick}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<DurationFilter />
|
||||||
|
|
||||||
<div className="flex text-gray-900 dark:text-white">
|
<div className="flex text-gray-900 dark:text-white">
|
||||||
<label>
|
<label>
|
||||||
<input
|
<input
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import { unstable_cache } from "next/cache";
|
|||||||
import { baseUrl } from "@/constants";
|
import { baseUrl } from "@/constants";
|
||||||
import { tournamentModelSchema } from "@/server/models/tournamentModel";
|
import { tournamentModelSchema } from "@/server/models/tournamentModel";
|
||||||
import { collections, dbConnect } from "@/server/mongodb";
|
import { collections, dbConnect } from "@/server/mongodb";
|
||||||
import { TimeControl, Tournament, tcMap } from "@/types";
|
import { tcMap, TimeControl, Tournament } from "@/types";
|
||||||
import { errorLog } from "@/utils/logger";
|
import { errorLog } from "@/utils/logger";
|
||||||
|
|
||||||
import TournamentsDisplay from "./TournamentsDisplay";
|
import TournamentsDisplay from "./TournamentsDisplay";
|
||||||
@@ -65,7 +65,7 @@ const getTournaments = async () => {
|
|||||||
|
|
||||||
const bad = data.filter((t) => {
|
const bad = data.filter((t) => {
|
||||||
const result = tournamentModelSchema.safeParse(t);
|
const result = tournamentModelSchema.safeParse(t);
|
||||||
if (result.success === false) {
|
if (!result.success) {
|
||||||
console.log(JSON.stringify(result, null, 2));
|
console.log(JSON.stringify(result, null, 2));
|
||||||
console.log(JSON.stringify(t, null, 2));
|
console.log(JSON.stringify(t, null, 2));
|
||||||
|
|
||||||
@@ -93,7 +93,7 @@ const getTournaments = async () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result.success === false;
|
return !result.success;
|
||||||
});
|
});
|
||||||
|
|
||||||
const badIds = bad.map((t) => t._id.toString());
|
const badIds = bad.map((t) => t._id.toString());
|
||||||
@@ -108,7 +108,7 @@ const getTournaments = async () => {
|
|||||||
const tournaments = groupedByLocation[location];
|
const tournaments = groupedByLocation[location];
|
||||||
|
|
||||||
// Note that this works since the tournaments are sorted by date
|
// Note that this works since the tournaments are sorted by date
|
||||||
const dateRanges = tournaments.reduce<Date[][]>(
|
dateRangesByLocation[location] = tournaments.reduce<Date[][]>(
|
||||||
(acc, tournament) => {
|
(acc, tournament) => {
|
||||||
const group = acc[acc.length - 1];
|
const group = acc[acc.length - 1];
|
||||||
const date = parse(tournament.date, "dd/MM/yyyy", new Date());
|
const date = parse(tournament.date, "dd/MM/yyyy", new Date());
|
||||||
@@ -122,8 +122,6 @@ const getTournaments = async () => {
|
|||||||
},
|
},
|
||||||
[[]],
|
[[]],
|
||||||
);
|
);
|
||||||
|
|
||||||
dateRangesByLocation[location] = dateRanges;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return goodData.map<Tournament>((t) => {
|
return goodData.map<Tournament>((t) => {
|
||||||
@@ -137,6 +135,11 @@ const getTournaments = async () => {
|
|||||||
const timeControl = tcMap[t.time_control] ?? TimeControl.Other;
|
const timeControl = tcMap[t.time_control] ?? TimeControl.Other;
|
||||||
const groupId = `${location}_${rangeIndex}_${timeControl}`;
|
const groupId = `${location}_${rangeIndex}_${timeControl}`;
|
||||||
|
|
||||||
|
// calculate duration of the tournament in days, parsing the French locale date
|
||||||
|
const startDateISO = parse(t.start_date, "dd/MM/yyyy", new Date());
|
||||||
|
const endDateISO = parse(t.end_date, "dd/MM/yyyy", new Date());
|
||||||
|
const durationDays = differenceInDays(endDateISO, startDateISO) + 1;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: t._id.toString(),
|
id: t._id.toString(),
|
||||||
ffeId: t.tournament_id,
|
ffeId: t.tournament_id,
|
||||||
@@ -151,6 +154,9 @@ const getTournaments = async () => {
|
|||||||
norm: t.norm_tournament ?? false,
|
norm: t.norm_tournament ?? false,
|
||||||
pending: t.pending ?? false,
|
pending: t.pending ?? false,
|
||||||
status: t.status,
|
status: t.status,
|
||||||
|
startDate: t.start_date,
|
||||||
|
endDate: t.end_date,
|
||||||
|
durationDays,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -162,8 +168,7 @@ const getTournaments = async () => {
|
|||||||
export default async function Tournaments() {
|
export default async function Tournaments() {
|
||||||
const tournaments = await unstable_cache(
|
const tournaments = await unstable_cache(
|
||||||
async () => {
|
async () => {
|
||||||
const data = await getTournaments();
|
return getTournaments();
|
||||||
return data;
|
|
||||||
},
|
},
|
||||||
["tournaments"],
|
["tournaments"],
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -12,12 +12,12 @@ import { Zone } from "@/server/myZones";
|
|||||||
|
|
||||||
const center: LatLngLiteral = { lat: 47.0844, lng: 2.3964 };
|
const center: LatLngLiteral = { lat: 47.0844, lng: 2.3964 };
|
||||||
|
|
||||||
export type ZoneThumbnailProps = {
|
type ZoneThumbnailProps = {
|
||||||
features: Zone["features"];
|
features: Zone["features"];
|
||||||
className?: string;
|
className?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const ZoneThumbnail = ({ features, className }: ZoneThumbnailProps) => {
|
const ZoneThumbnail = ({ features, className }: ZoneThumbnailProps) => {
|
||||||
return (
|
return (
|
||||||
<MapContainer
|
<MapContainer
|
||||||
center={center}
|
center={center}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { ReactNode, Suspense } from "react";
|
import { type ReactNode, Suspense } from "react";
|
||||||
|
|
||||||
import { NextIntlClientProvider } from "next-intl";
|
import { NextIntlClientProvider } from "next-intl";
|
||||||
import { getTranslations } from "next-intl/server";
|
import { getTranslations } from "next-intl/server";
|
||||||
@@ -54,6 +54,7 @@ export default async function RootLayout({
|
|||||||
let messages;
|
let messages;
|
||||||
try {
|
try {
|
||||||
messages = (await import(`@/messages/${locale}.json`)).default;
|
messages = (await import(`@/messages/${locale}.json`)).default;
|
||||||
|
// oxlint-disable-next-line no-unused-vars
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
notFound();
|
notFound();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,9 @@ export const searchStringAtom = atom("");
|
|||||||
export const tournamentsAtom = atom<Tournament[]>([]);
|
export const tournamentsAtom = atom<Tournament[]>([]);
|
||||||
export const normsOnlyAtom = atom(false);
|
export const normsOnlyAtom = atom(false);
|
||||||
|
|
||||||
|
export type DurationFilter = "any" | "1" | "2" | "3+";
|
||||||
|
export const durationFilterAtom = atom<DurationFilter>("any");
|
||||||
|
|
||||||
export const classicAtom = atom(true);
|
export const classicAtom = atom(true);
|
||||||
export const rapidAtom = atom(true);
|
export const rapidAtom = atom(true);
|
||||||
export const blitzAtom = atom(true);
|
export const blitzAtom = atom(true);
|
||||||
@@ -69,14 +72,23 @@ export const filteredTournamentsByTimeControlAndZoneAtom = atom((get) => {
|
|||||||
const dateRange = get(dateRangeAtom);
|
const dateRange = get(dateRangeAtom);
|
||||||
const { startDate, endDate } = dateRange[0];
|
const { startDate, endDate } = dateRange[0];
|
||||||
|
|
||||||
|
const durationFilter = get(durationFilterAtom);
|
||||||
|
|
||||||
const filterByTimeControl = tournaments.filter((tournament) => {
|
const filterByTimeControl = tournaments.filter((tournament) => {
|
||||||
const tournamentDate = startOfDay(parse(tournament.date, "dd/MM/yyyy", new Date()));
|
const tournamentDate = startOfDay(parse(tournament.date, "dd/MM/yyyy", new Date()));
|
||||||
|
|
||||||
|
const durationMatch =
|
||||||
|
durationFilter === "any" ||
|
||||||
|
(durationFilter === "1" && tournament.durationDays === 1) ||
|
||||||
|
(durationFilter === "2" && tournament.durationDays === 2) ||
|
||||||
|
(durationFilter === "3+" && tournament.durationDays >= 3);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
!isBefore(tournamentDate, startDate) &&
|
!isBefore(tournamentDate, startDate) &&
|
||||||
(endDate === undefined || !isAfter(tournamentDate, endDate)) &&
|
(endDate === undefined || !isAfter(tournamentDate, endDate)) &&
|
||||||
!tournament.pending &&
|
!tournament.pending &&
|
||||||
tournament.status === "scheduled" &&
|
tournament.status === "scheduled" &&
|
||||||
|
durationMatch &&
|
||||||
((tournament.timeControl === TimeControl.Classic && classic) ||
|
((tournament.timeControl === TimeControl.Classic && classic) ||
|
||||||
(tournament.timeControl === TimeControl.Rapid && rapid) ||
|
(tournament.timeControl === TimeControl.Rapid && rapid) ||
|
||||||
(tournament.timeControl === TimeControl.Blitz && blitz) ||
|
(tournament.timeControl === TimeControl.Blitz && blitz) ||
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { type ComponentProps } from "react";
|
||||||
import { type VariantProps, cva } from "class-variance-authority";
|
import { type VariantProps, cva } from "class-variance-authority";
|
||||||
import { twMerge } from "tailwind-merge";
|
import { twMerge } from "tailwind-merge";
|
||||||
|
|
||||||
@@ -42,8 +43,8 @@ export const buttonVariants = cva("flex items-center justify-center transition-a
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export type ButtonVariants = VariantProps<typeof buttonVariants>;
|
type ButtonVariants = VariantProps<typeof buttonVariants>;
|
||||||
export type ButtonProps = React.ComponentProps<"button"> & ButtonVariants;
|
export type ButtonProps = ComponentProps<"button"> & ButtonVariants;
|
||||||
|
|
||||||
export const Button = ({
|
export const Button = ({
|
||||||
className,
|
className,
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
import { useTranslations } from "next-intl";
|
|
||||||
|
|
||||||
import { Spinner } from "./Spinner";
|
import { Spinner } from "./Spinner";
|
||||||
|
|
||||||
const LoadingMap = () => {
|
const LoadingMap = () => {
|
||||||
const t = useTranslations("Tournaments");
|
|
||||||
return (
|
return (
|
||||||
<div className="mt-20 flex h-content justify-center bg-white pt-20 text-center text-gray-900 dark:bg-gray-800 dark:text-white">
|
<div className="mt-20 flex h-content justify-center bg-white pt-20 text-center text-gray-900 dark:bg-gray-800 dark:text-white">
|
||||||
<Spinner />
|
<Spinner />
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ export const MapEvents = ({
|
|||||||
const t = useTranslations("Map");
|
const t = useTranslations("Map");
|
||||||
const map = useMap();
|
const map = useMap();
|
||||||
const setMapBounds = useSetAtom(mapBoundsAtom);
|
const setMapBounds = useSetAtom(mapBoundsAtom);
|
||||||
const [isPending, startTransition] = useTransition();
|
const [_isPending, startTransition] = useTransition();
|
||||||
|
|
||||||
useMapEvent("moveend", () => {
|
useMapEvent("moveend", () => {
|
||||||
if (!updateMapBoundsAtom) return;
|
if (!updateMapBoundsAtom) return;
|
||||||
@@ -46,9 +46,7 @@ export const MapEvents = ({
|
|||||||
map.setView(bounds.getCenter(), zoom === Infinity ? 10 : zoom);
|
map.setView(bounds.getCenter(), zoom === Infinity ? 10 : zoom);
|
||||||
map.setMaxBounds(worldBounds);
|
map.setMaxBounds(worldBounds);
|
||||||
map.options.maxBoundsViscosity = 1.0; // Prevents going past bounds while dragging
|
map.options.maxBoundsViscosity = 1.0; // Prevents going past bounds while dragging
|
||||||
|
|
||||||
map.addHandler("gestureHandling", GestureHandling);
|
map.addHandler("gestureHandling", GestureHandling);
|
||||||
|
|
||||||
map.gestureHandling?.enable();
|
map.gestureHandling?.enable();
|
||||||
}, [bounds, map]);
|
}, [bounds, map]);
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import { useTransition } from "react";
|
|||||||
import { useAtom } from "jotai/index";
|
import { useAtom } from "jotai/index";
|
||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
import { IoCloseOutline } from "react-icons/io5";
|
import { IoCloseOutline } from "react-icons/io5";
|
||||||
import { twMerge } from "tailwind-merge";
|
|
||||||
|
|
||||||
import { searchStringAtom } from "@/atoms";
|
import { searchStringAtom } from "@/atoms";
|
||||||
|
|
||||||
@@ -14,10 +13,11 @@ type SearchBarProps = {
|
|||||||
className?: string;
|
className?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// oxlint-disable-next-line no-unused-vars
|
||||||
const SearchBar = ({ className }: SearchBarProps) => {
|
const SearchBar = ({ className }: SearchBarProps) => {
|
||||||
const t = useTranslations("Tournaments");
|
const t = useTranslations("Tournaments");
|
||||||
const [searchString, setSearchString] = useAtom(searchStringAtom);
|
const [searchString, setSearchString] = useAtom(searchStringAtom);
|
||||||
const [isPending, startTransition] = useTransition();
|
const [_isPending, startTransition] = useTransition();
|
||||||
|
|
||||||
const updateSearchString = (str: string) => {
|
const updateSearchString = (str: string) => {
|
||||||
startTransition(() => {
|
startTransition(() => {
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ export const AsyncSelectField = <
|
|||||||
}: AsyncSelectFieldProps<TFieldValues, TFieldName, IsMulti, T, D>) => {
|
}: AsyncSelectFieldProps<TFieldValues, TFieldName, IsMulti, T, D>) => {
|
||||||
const t = useTranslations("App");
|
const t = useTranslations("App");
|
||||||
const [loadingValues, setLoadingValues] = useState(false);
|
const [loadingValues, setLoadingValues] = useState(false);
|
||||||
const [loadedInitialValues, setLoadedInitialValues] = useState(false);
|
const [_loadedInitialValues, setLoadedInitialValues] = useState(false);
|
||||||
const [loadingOptions, setLoadingOptions] = useState(false);
|
const [loadingOptions, setLoadingOptions] = useState(false);
|
||||||
const valueOptions = useRef<BaseOption<T, D>[]>([]);
|
const valueOptions = useRef<BaseOption<T, D>[]>([]);
|
||||||
const searchOptions = useRef<BaseOption<T, D>[]>([]);
|
const searchOptions = useRef<BaseOption<T, D>[]>([]);
|
||||||
@@ -69,7 +69,7 @@ export const AsyncSelectField = <
|
|||||||
const values = !value ? [] : isArray(value) ? value : [value];
|
const values = !value ? [] : isArray(value) ? value : [value];
|
||||||
|
|
||||||
const unFetchedValues = values.filter(
|
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) {
|
if (unFetchedValues.length > 0) {
|
||||||
|
|||||||
@@ -21,12 +21,13 @@ export const InputDatePicker = forwardRef<HTMLInputElement, AllProps>(
|
|||||||
(
|
(
|
||||||
{
|
{
|
||||||
error,
|
error,
|
||||||
|
// oxlint-disable-next-line no-unused-vars
|
||||||
className,
|
className,
|
||||||
|
// oxlint-disable-next-line no-unused-vars
|
||||||
children,
|
children,
|
||||||
inputContainerClass,
|
inputContainerClass,
|
||||||
inputClass,
|
inputClass,
|
||||||
mask,
|
mask,
|
||||||
|
|
||||||
...props
|
...props
|
||||||
},
|
},
|
||||||
inputRef,
|
inputRef,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React, { useRef } from "react";
|
import { useRef } from "react";
|
||||||
|
|
||||||
import { getYear, isValid, parse } from "date-fns";
|
import { getYear, isValid, parse } from "date-fns";
|
||||||
import fr from "date-fns/locale/fr";
|
import fr from "date-fns/locale/fr";
|
||||||
@@ -40,10 +40,8 @@ export const DateField = <
|
|||||||
dateFormat = "dd/MM/yyyy",
|
dateFormat = "dd/MM/yyyy",
|
||||||
className,
|
className,
|
||||||
datePickerPopperClass,
|
datePickerPopperClass,
|
||||||
|
|
||||||
name,
|
name,
|
||||||
control,
|
control,
|
||||||
required,
|
|
||||||
...otherFieldProps
|
...otherFieldProps
|
||||||
}: DateFieldProps<TFieldValues, TFieldName>) => {
|
}: DateFieldProps<TFieldValues, TFieldName>) => {
|
||||||
const locale = useLocale();
|
const locale = useLocale();
|
||||||
|
|||||||
@@ -1,23 +1,15 @@
|
|||||||
import React from "react";
|
import type { ReactNode } from "react";
|
||||||
|
|
||||||
import { Switch, SwitchProps } from "@headlessui/react";
|
import { Switch, SwitchProps } from "@headlessui/react";
|
||||||
import { twMerge } from "tailwind-merge";
|
import { twMerge } from "tailwind-merge";
|
||||||
|
|
||||||
export const InlineSwitch = (
|
export const InlineSwitch = (
|
||||||
props: {
|
props: {
|
||||||
label?: React.ReactNode;
|
label?: ReactNode;
|
||||||
tooltip?: string;
|
tooltip?: string;
|
||||||
tooltipId?: string;
|
tooltipId?: string;
|
||||||
} & SwitchProps<"button">,
|
} & SwitchProps<"button">,
|
||||||
) => {
|
) => {
|
||||||
const {
|
const { label, disabled, ...rest } = props;
|
||||||
label,
|
|
||||||
tooltip,
|
|
||||||
tooltipId,
|
|
||||||
disabled,
|
|
||||||
|
|
||||||
...rest
|
|
||||||
} = props;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Switch.Group>
|
<Switch.Group>
|
||||||
|
|||||||
@@ -1,11 +1,6 @@
|
|||||||
import React from "react";
|
|
||||||
|
|
||||||
import { SwitchProps } from "@headlessui/react";
|
import { SwitchProps } from "@headlessui/react";
|
||||||
import { Controller, FieldPath, FieldValues } from "react-hook-form";
|
import { Controller, FieldPath, FieldValues } from "react-hook-form";
|
||||||
import { twMerge } from "tailwind-merge";
|
|
||||||
|
|
||||||
import { Field, GenericFieldProps } from "@/components/form/Field";
|
import { Field, GenericFieldProps } from "@/components/form/Field";
|
||||||
|
|
||||||
import { InlineSwitch } from "./InlineSwitch";
|
import { InlineSwitch } from "./InlineSwitch";
|
||||||
|
|
||||||
type InlineSwitchFieldProps<
|
type InlineSwitchFieldProps<
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import type { ComponentProps, ReactNode } from "react";
|
||||||
import { VariantProps, cva } from "class-variance-authority";
|
import { VariantProps, cva } from "class-variance-authority";
|
||||||
import { twMerge } from "tailwind-merge";
|
import { twMerge } from "tailwind-merge";
|
||||||
|
|
||||||
@@ -26,12 +27,12 @@ export const inputVariants = cva(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
export type InputVariants = VariantProps<typeof inputVariants>;
|
type InputVariants = VariantProps<typeof inputVariants>;
|
||||||
export type InputProps = Omit<React.ComponentProps<"input">, "size"> &
|
export type InputProps = Omit<ComponentProps<"input">, "size"> &
|
||||||
Omit<InputVariants, "state"> & {
|
Omit<InputVariants, "state"> & {
|
||||||
hasError?: boolean;
|
hasError?: boolean;
|
||||||
startIcon?: React.ReactNode;
|
startIcon?: ReactNode;
|
||||||
endIcon?: React.ReactNode;
|
endIcon?: ReactNode;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Input = ({
|
export const Input = ({
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
|
import type { LabelHTMLAttributes, ReactNode, DetailedHTMLProps } from "react";
|
||||||
import { twMerge } from "tailwind-merge";
|
import { twMerge } from "tailwind-merge";
|
||||||
|
|
||||||
import { Prettify } from "@/types";
|
import { Prettify } from "@/types";
|
||||||
|
|
||||||
type LabelProps = Prettify<
|
type LabelProps = Prettify<
|
||||||
React.DetailedHTMLProps<React.LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement> & {
|
DetailedHTMLProps<LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement> & {
|
||||||
required?: boolean;
|
required?: boolean;
|
||||||
className?: string;
|
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 (
|
return (
|
||||||
<label
|
<label
|
||||||
{...labelProps}
|
{...labelProps}
|
||||||
|
|||||||
@@ -1,16 +1,12 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
import { RadioGroup } from "@headlessui/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 { twMerge } from "tailwind-merge";
|
||||||
|
|
||||||
import { Prettify } from "@/types";
|
import { Prettify } from "@/types";
|
||||||
|
|
||||||
import { Field, GenericFieldProps } from "./Field";
|
import { Field, GenericFieldProps } from "./Field";
|
||||||
|
|
||||||
export type BaseOption<T = string, D = unknown> = {
|
type BaseOption<T = string, D = unknown> = {
|
||||||
value: T;
|
value: T;
|
||||||
label: string | React.JSX.Element;
|
label: string | React.JSX.Element;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
@@ -46,16 +42,13 @@ export const RadioGroupField = <
|
|||||||
|
|
||||||
options,
|
options,
|
||||||
}: RadioGroupFieldProps<TFieldValues, TFieldName, T, D>) => {
|
}: RadioGroupFieldProps<TFieldValues, TFieldName, T, D>) => {
|
||||||
const t = useTranslations("App");
|
|
||||||
const form = useFormContext<TFieldValues>();
|
const form = useFormContext<TFieldValues>();
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
// oxlint-disable-next-line no-unused-vars
|
||||||
formState: { errors },
|
formState: { errors },
|
||||||
} = form;
|
} = form;
|
||||||
|
|
||||||
const valueToOption = (value: T): BaseOption<T, D> =>
|
|
||||||
options.find((o) => o.value === value) ?? { value, label: "" };
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Field
|
<Field
|
||||||
{...{
|
{...{
|
||||||
@@ -73,8 +66,6 @@ export const RadioGroupField = <
|
|||||||
name={name}
|
name={name}
|
||||||
control={control}
|
control={control}
|
||||||
render={({ field: { onChange, value } }) => {
|
render={({ field: { onChange, value } }) => {
|
||||||
const optionValue = isNil(value) ? null : valueToOption(value);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<RadioGroup
|
<RadioGroup
|
||||||
value={value}
|
value={value}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ export type ZoneEditorProps = {
|
|||||||
onChange: (geoJson: FeatureCollection) => void;
|
onChange: (geoJson: FeatureCollection) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const ZoneEditor = ({ value, onChange }: ZoneEditorProps) => {
|
const ZoneEditor = ({ value, onChange }: ZoneEditorProps) => {
|
||||||
const initialFeatures = React.useRef(value?.features);
|
const initialFeatures = React.useRef(value?.features);
|
||||||
const featureGroup = React.useRef<L.FeatureGroup | null>(null);
|
const featureGroup = React.useRef<L.FeatureGroup | null>(null);
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ const isSSR =
|
|||||||
const isBrowser = !isSSR;
|
const isBrowser = !isSSR;
|
||||||
const useIsomorphicEffect = isBrowser ? useLayoutEffect : useEffect;
|
const useIsomorphicEffect = isBrowser ? useLayoutEffect : useEffect;
|
||||||
|
|
||||||
export type CreatorReturnType = {
|
type CreatorReturnType = {
|
||||||
useBreakpoint<B>(breakpoint: B, defaultValue?: boolean): boolean;
|
useBreakpoint<B>(breakpoint: B, defaultValue?: boolean): boolean;
|
||||||
useBreakpointEffect<B>(breakpoint: B, effect: (match: boolean) => void): void;
|
useBreakpointEffect<B>(breakpoint: B, effect: (match: boolean) => void): void;
|
||||||
useBreakpointValue<B, T, U>(breakpoint: B, valid: T, invalid: U): T | U;
|
useBreakpointValue<B, T, U>(breakpoint: B, valid: T, invalid: U): T | U;
|
||||||
@@ -76,6 +76,4 @@ function create(screens: object | undefined) {
|
|||||||
} as CreatorReturnType;
|
} as CreatorReturnType;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const { useBreakpoint, useBreakpointEffect, useBreakpointValue } = create(
|
export const { useBreakpoint } = create(config.theme!.screens);
|
||||||
config.theme!.screens,
|
|
||||||
);
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ const useDatePickerWidth = ({
|
|||||||
const updateDatePickerDirection = () => {
|
const updateDatePickerDirection = () => {
|
||||||
const datePickerWidth = datePickerRef.current?.offsetWidth ?? 0;
|
const datePickerWidth = datePickerRef.current?.offsetWidth ?? 0;
|
||||||
const isLg = datePickerWidth >= 680;
|
const isLg = datePickerWidth >= 680;
|
||||||
|
// oxlint-disable-next-line no-unused-expressions
|
||||||
isLg ? setDateDirectionState("horizontal") : setDateDirectionState("vertical");
|
isLg ? setDateDirectionState("horizontal") : setDateDirectionState("vertical");
|
||||||
};
|
};
|
||||||
updateDatePickerDirection();
|
updateDatePickerDirection();
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { useCallback, useEffect } from "react";
|
|||||||
|
|
||||||
import { SetFieldValue } from "react-hook-form";
|
import { SetFieldValue } from "react-hook-form";
|
||||||
|
|
||||||
export interface FormPersistConfig {
|
interface FormPersistConfig {
|
||||||
storage?: Storage;
|
storage?: Storage;
|
||||||
watch: (names?: string | string[]) => any;
|
watch: (names?: string | string[]) => any;
|
||||||
setValue: SetFieldValue<any>;
|
setValue: SetFieldValue<any>;
|
||||||
|
|||||||
@@ -82,7 +82,7 @@
|
|||||||
"searchLabel": "Search",
|
"searchLabel": "Search",
|
||||||
"searchPlaceholder": "Search",
|
"searchPlaceholder": "Search",
|
||||||
"syncWithMapOption": "Only tournaments visible in the map view",
|
"syncWithMapOption": "Only tournaments visible in the map view",
|
||||||
"normsOnly": "Only norm tournaments",
|
"normsOnly": "Norms tournaments",
|
||||||
"noneFound": "No tournaments found",
|
"noneFound": "No tournaments found",
|
||||||
"date": "Date",
|
"date": "Date",
|
||||||
"town": "Town",
|
"town": "Town",
|
||||||
@@ -91,7 +91,11 @@
|
|||||||
"timeControl": "Time Control",
|
"timeControl": "Time Control",
|
||||||
"approx": "Geo-location is approximative",
|
"approx": "Geo-location is approximative",
|
||||||
"norm": "Norm Tournament",
|
"norm": "Norm Tournament",
|
||||||
"clearButton": "Clear"
|
"clearButton": "Clear",
|
||||||
|
"durationAny": "Any",
|
||||||
|
"duration1Day": "1 day",
|
||||||
|
"duration2Days": "2 days",
|
||||||
|
"duration3PlusDays": "3+ days"
|
||||||
},
|
},
|
||||||
|
|
||||||
"Clubs": {
|
"Clubs": {
|
||||||
@@ -319,7 +323,7 @@
|
|||||||
"shareTitle": "Data Sharing",
|
"shareTitle": "Data Sharing",
|
||||||
"shareInfo": "We do not share, sell, or provide access to your email address to any third parties. Your information is kept strictly confidential and is only used within our project.",
|
"shareInfo": "We do not share, sell, or provide access to your email address to any third parties. Your information is kept strictly confidential and is only used within our project.",
|
||||||
"cookiesTitle": "Cookies and Tracking",
|
"cookiesTitle": "Cookies and Tracking",
|
||||||
"cookiesInfo": "We do not track users in an intrusive manner. However, we use <link>TinyAnalytics.io</link>, an anonymous, GDPR-friendly analytics tool, to gather anonymized usage statistics. No personally identifiable information is collected by this tool, and its usage is strictly limited to improving user experience.",
|
"cookiesInfo": "We do not track users in an intrusive manner. However, we use <link>Matomo</link>, an anonymous, GDPR-friendly analytics tool, to gather anonymized usage statistics. No personally identifiable information is collected by this tool, and its usage is strictly limited to improving user experience.",
|
||||||
"changesTitle": "Changes to This Privacy Policy",
|
"changesTitle": "Changes to This Privacy Policy",
|
||||||
"changesInfo": "We may update this privacy policy from time to time. Any changes will be posted on this page, and we encourage you to review this policy periodically."
|
"changesInfo": "We may update this privacy policy from time to time. Any changes will be posted on this page, and we encourage you to review this policy periodically."
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,7 +81,7 @@
|
|||||||
"searchLabel": "Rechercher",
|
"searchLabel": "Rechercher",
|
||||||
"searchPlaceholder": "Rechercher",
|
"searchPlaceholder": "Rechercher",
|
||||||
"syncWithMapOption": "Seuls les tournois visibles dans la vue carte",
|
"syncWithMapOption": "Seuls les tournois visibles dans la vue carte",
|
||||||
"normsOnly": "Uniquement tournois à normes",
|
"normsOnly": "Tournois à normes",
|
||||||
"noneFound": "Pas de tournois trouvé",
|
"noneFound": "Pas de tournois trouvé",
|
||||||
"date": "Date",
|
"date": "Date",
|
||||||
"town": "Ville",
|
"town": "Ville",
|
||||||
@@ -90,7 +90,11 @@
|
|||||||
"timeControl": "Cadence",
|
"timeControl": "Cadence",
|
||||||
"approx": "Géolocalisation approximative",
|
"approx": "Géolocalisation approximative",
|
||||||
"norm": "Tournoi à norme",
|
"norm": "Tournoi à norme",
|
||||||
"clearButton": "Effacer"
|
"clearButton": "Effacer",
|
||||||
|
"durationAny": "Tous",
|
||||||
|
"duration1Day": "1 jour",
|
||||||
|
"duration2Days": "2 jours",
|
||||||
|
"duration3PlusDays": "3+ jours"
|
||||||
},
|
},
|
||||||
|
|
||||||
"Clubs": {
|
"Clubs": {
|
||||||
@@ -320,7 +324,7 @@
|
|||||||
"shareTitle": "Partage de Données",
|
"shareTitle": "Partage de Données",
|
||||||
"shareInfo": "Nous ne partageons, ne vendons ni ne fournissons l'accès à votre adresse email à des tiers. Vos informations sont strictement confidentielles et sont utilisées uniquement dans le cadre de notre projet.",
|
"shareInfo": "Nous ne partageons, ne vendons ni ne fournissons l'accès à votre adresse email à des tiers. Vos informations sont strictement confidentielles et sont utilisées uniquement dans le cadre de notre projet.",
|
||||||
"cookiesTitle": "Cookies et Suivi",
|
"cookiesTitle": "Cookies et Suivi",
|
||||||
"cookiesInfo": "Nous ne suivons pas les utilisateurs de manière intrusive. Toutefois, nous utilisons <link>TinyAnalytics.io</link>, un outil d'analyse anonyme et conforme au RGPD (Règlement Général sur la Protection des Données), pour obtenir des statistiques d'utilisation anonymisées. Aucune donnée personnelle identifiable n'est collectée par cet outil, et son utilisation est strictement limitée à des fins d'amélioration de l'expérience utilisateur.",
|
"cookiesInfo": "Nous ne suivons pas les utilisateurs de manière intrusive. Toutefois, nous utilisons <link>Matomo</link>, un outil d'analyse anonyme et conforme au RGPD (Règlement Général sur la Protection des Données), pour obtenir des statistiques d'utilisation anonymisées. Aucune donnée personnelle identifiable n'est collectée par cet outil, et son utilisation est strictement limitée à des fins d'amélioration de l'expérience utilisateur.",
|
||||||
"changesTitle": "Modifications de Cette Politique de Confidentialité",
|
"changesTitle": "Modifications de Cette Politique de Confidentialité",
|
||||||
"changesInfo": "Nous pouvons mettre à jour cette politique de confidentialité de temps à autre. Toutes les modifications seront publiées sur cette page, et nous vous encourageons à consulter régulièrement cette politique."
|
"changesInfo": "Nous pouvons mettre à jour cette politique de confidentialité de temps à autre. Toutes les modifications seront publiées sur cette page, et nous vous encourageons à consulter régulièrement cette politique."
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-7
@@ -4,28 +4,28 @@ import { z } from "zod";
|
|||||||
import { TimeControl } from "@/types";
|
import { TimeControl } from "@/types";
|
||||||
|
|
||||||
export const contactUsSchema = z.object({
|
export const contactUsSchema = z.object({
|
||||||
email: z.string().email(),
|
email: z.email(),
|
||||||
subject: z.string().min(1, { message: "FormValidation.required" }),
|
subject: z.string().min(1, { message: "FormValidation.required" }),
|
||||||
message: z.string().min(1, { message: "FormValidation.required" }),
|
message: z.string().min(1, { message: "FormValidation.required" }),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const addClubSchema = z.object({
|
export const addClubSchema = z.object({
|
||||||
name: z.string().min(1, { message: "FormValidation.required" }),
|
name: z.string().min(1, { message: "FormValidation.required" }),
|
||||||
email: z.string().email(),
|
email: z.email(),
|
||||||
message: z.string().optional(),
|
message: z.string().optional(),
|
||||||
|
|
||||||
club: z.object({
|
club: z.object({
|
||||||
name: z.string().min(1, { message: "FormValidation.required" }),
|
name: z.string().min(1, { message: "FormValidation.required" }),
|
||||||
email: z.string().email().optional(),
|
email: z.email().optional(),
|
||||||
address: z.string().min(1, { message: "FormValidation.required" }),
|
address: z.string().min(1, { message: "FormValidation.required" }),
|
||||||
website: z.string().url({ message: "FormValidation.url" }).optional(),
|
website: z.url({ message: "FormValidation.url" }).optional(),
|
||||||
coordinates: z.array(z.number()).length(2),
|
coordinates: z.array(z.number()).length(2),
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const addTournamentSchema = z.object({
|
export const addTournamentSchema = z.object({
|
||||||
name: z.string().min(1, { message: "FormValidation.required" }),
|
name: z.string().min(1, { message: "FormValidation.required" }),
|
||||||
email: z.string().email(),
|
email: z.email(),
|
||||||
message: z.string().optional(),
|
message: z.string().optional(),
|
||||||
|
|
||||||
tournament: z.object({
|
tournament: z.object({
|
||||||
@@ -33,8 +33,8 @@ export const addTournamentSchema = z.object({
|
|||||||
town: z.string().min(1, { message: "FormValidation.required" }),
|
town: z.string().min(1, { message: "FormValidation.required" }),
|
||||||
department: z.string().min(1, { message: "FormValidation.required" }),
|
department: z.string().min(1, { message: "FormValidation.required" }),
|
||||||
tournament: z.string().min(1, { message: "FormValidation.required" }),
|
tournament: z.string().min(1, { message: "FormValidation.required" }),
|
||||||
url: z.string().url({ message: "FormValidation.url" }),
|
url: z.url({ message: "FormValidation.url" }),
|
||||||
time_control: z.nativeEnum(TimeControl),
|
time_control: z.enum(TimeControl),
|
||||||
norm_tournament: z.boolean(),
|
norm_tournament: z.boolean(),
|
||||||
date: z.date(),
|
date: z.date(),
|
||||||
coordinates: z.array(z.number()).length(2),
|
coordinates: z.array(z.number()).length(2),
|
||||||
|
|||||||
+4
-8
@@ -2,7 +2,7 @@ import { LatLngLiteral } from "leaflet";
|
|||||||
|
|
||||||
import { TournamentModel } from "./server/models/tournamentModel";
|
import { TournamentModel } from "./server/models/tournamentModel";
|
||||||
|
|
||||||
export type Status = "scheduled" | "ongoing" | "finished" | "in-play";
|
type Status = "scheduled" | "ongoing" | "finished" | "in-play";
|
||||||
|
|
||||||
export enum TimeControl {
|
export enum TimeControl {
|
||||||
Classic = "Classic",
|
Classic = "Classic",
|
||||||
@@ -25,6 +25,9 @@ export type Tournament = {
|
|||||||
norm: boolean;
|
norm: boolean;
|
||||||
pending: boolean;
|
pending: boolean;
|
||||||
status: Status;
|
status: Status;
|
||||||
|
startDate: string;
|
||||||
|
endDate: string;
|
||||||
|
durationDays: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const tcMap: Record<TournamentModel["time_control"], TimeControl> = {
|
export const tcMap: Record<TournamentModel["time_control"], TimeControl> = {
|
||||||
@@ -43,15 +46,8 @@ export type Club = {
|
|||||||
latLng: LatLngLiteral;
|
latLng: LatLngLiteral;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ResponseMessage = {
|
|
||||||
isSuccessful: boolean;
|
|
||||||
message: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type DatePickerDirection = "horizontal" | "vertical";
|
export type DatePickerDirection = "horizontal" | "vertical";
|
||||||
|
|
||||||
export type ScrollableElement = Window | HTMLElement;
|
|
||||||
|
|
||||||
// Prettify takes a type as its argument and returns a new type that has the same properties as the original type,
|
// Prettify takes a type as its argument and returns a new type that has the same properties as the original type,
|
||||||
// but the properties are not intersected. This means that the new type is easier to read and understand.
|
// but the properties are not intersected. This means that the new type is easier to read and understand.
|
||||||
// https://gist.github.com/palashmon/db68706d4f26d2dbf187e76409905399
|
// https://gist.github.com/palashmon/db68706d4f26d2dbf187e76409905399
|
||||||
|
|||||||
@@ -1,10 +0,0 @@
|
|||||||
const formatDate = (inputDate: any) => {
|
|
||||||
// TODO fix type
|
|
||||||
const date = new Date(inputDate);
|
|
||||||
const day = String(date.getDate()).padStart(2, "0");
|
|
||||||
const month = String(date.getMonth() + 1).padStart(2, "0");
|
|
||||||
const year = date.getFullYear();
|
|
||||||
return `${day}/${month}/${year}`;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default formatDate;
|
|
||||||
+3
-3
@@ -1,6 +1,6 @@
|
|||||||
export const infoLog = (...params: any[]) => {
|
// export const infoLog = (...params: any[]) => {
|
||||||
console.log(...params);
|
// console.log(...params);
|
||||||
};
|
// };
|
||||||
|
|
||||||
export const errorLog = (...params: any[]) => {
|
export const errorLog = (...params: any[]) => {
|
||||||
console.error(...params);
|
console.error(...params);
|
||||||
|
|||||||
@@ -1,18 +1,17 @@
|
|||||||
import { AuthError } from "next-auth";
|
|
||||||
import { EmailConfig } from "next-auth/providers/email";
|
import { EmailConfig } from "next-auth/providers/email";
|
||||||
import { getTranslations } from "next-intl/server";
|
import { getTranslations } from "next-intl/server";
|
||||||
import { createTransport } from "nodemailer";
|
import { createTransport } from "nodemailer";
|
||||||
import type { Transport, TransportOptions } from "nodemailer";
|
import type { Transport, TransportOptions } from "nodemailer";
|
||||||
import * as JSONTransport from "nodemailer/lib/json-transport/index.js";
|
import SMTPTransport from "nodemailer/lib/smtp-transport";
|
||||||
import * as SendmailTransport from "nodemailer/lib/sendmail-transport/index.js";
|
import SMTPPool from "nodemailer/lib/smtp-pool";
|
||||||
import * as SESTransport from "nodemailer/lib/ses-transport/index.js";
|
import SendmailTransport from "nodemailer/lib/sendmail-transport";
|
||||||
import * as SMTPPool from "nodemailer/lib/smtp-pool/index.js";
|
import StreamTransport from "nodemailer/lib/stream-transport";
|
||||||
import * as SMTPTransport from "nodemailer/lib/smtp-transport/index.js";
|
import JSONTransport from "nodemailer/lib/json-transport";
|
||||||
import * as StreamTransport from "nodemailer/lib/stream-transport/index.js";
|
import SESTransport from "nodemailer/lib/ses-transport";
|
||||||
|
|
||||||
type Awaitable<T> = T | PromiseLike<T>;
|
type Awaitable<T> = T | PromiseLike<T>;
|
||||||
|
|
||||||
export function html(params: {
|
function html(params: {
|
||||||
url: string;
|
url: string;
|
||||||
host: string;
|
host: string;
|
||||||
t: Awaited<ReturnType<typeof getTranslations<"SignIn">>>;
|
t: Awaited<ReturnType<typeof getTranslations<"SignIn">>>;
|
||||||
@@ -44,7 +43,7 @@ export function html(params: {
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td align="center" style="padding: 20px 0;">
|
<td align="center" style="padding: 20px 0px;">
|
||||||
<table border="0" cellspacing="0" cellpadding="0">
|
<table border="0" cellspacing="0" cellpadding="0">
|
||||||
<tr>
|
<tr>
|
||||||
<td align="center" style="border-radius: 5px;" bgcolor="${color.buttonBackground}">
|
<td align="center" style="border-radius: 5px;" bgcolor="${color.buttonBackground}">
|
||||||
@@ -70,7 +69,7 @@ export function html(params: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Email Text body (fallback for email clients that don't render HTML, e.g. feature phones) */
|
/** Email Text body (fallback for email clients that don't render HTML, e.g. feature phones) */
|
||||||
export function text({
|
function text({
|
||||||
url,
|
url,
|
||||||
host,
|
host,
|
||||||
t,
|
t,
|
||||||
|
|||||||
@@ -61,4 +61,4 @@ export const routing = defineRouting({
|
|||||||
export type Pathnames = keyof typeof routing.pathnames;
|
export type Pathnames = keyof typeof routing.pathnames;
|
||||||
export type Locale = (typeof routing.locales)[number];
|
export type Locale = (typeof routing.locales)[number];
|
||||||
|
|
||||||
export const { Link, redirect, usePathname, useRouter, getPathname } = createNavigation(routing);
|
export const { Link, usePathname, useRouter, getPathname } = createNavigation(routing);
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
import { ScrollableElement } from "@/types";
|
|
||||||
|
|
||||||
const isBrowser = () => typeof window !== "undefined";
|
|
||||||
|
|
||||||
export const handleScrollToTop = (element: ScrollableElement | null) => {
|
|
||||||
if (!isBrowser()) return;
|
|
||||||
element?.scrollTo({ top: 0, behavior: "smooth" });
|
|
||||||
};
|
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"target": "es5",
|
"target": "es2022",
|
||||||
"lib": ["dom", "dom.iterable", "esnext"],
|
"lib": ["dom", "dom.iterable", "esnext"],
|
||||||
"allowJs": true,
|
"allowJs": true,
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
|
|||||||
@@ -2,12 +2,12 @@ import path from "node:path";
|
|||||||
import { defineConfig } from "vitest/config";
|
import { defineConfig } from "vitest/config";
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
test: {
|
|
||||||
exclude: ["**/node_modules/**", "**/dist/**"],
|
|
||||||
},
|
|
||||||
resolve: {
|
resolve: {
|
||||||
alias: {
|
alias: {
|
||||||
"@": path.resolve(__dirname, "./src"),
|
"@": path.resolve(__dirname, "./src"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
test: {
|
||||||
|
exclude: ["**/node_modules/**", "**/dist/**"],
|
||||||
|
},
|
||||||
});
|
});
|
||||||
Reference in New Issue
Block a user