mirror of
https://github.com/TheRealOwenRees/echecsfrance.git
synced 2026-11-18 07:22:06 +00:00
Compare commits
20
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0909ba8735 | ||
|
|
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
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"$schema": "./node_modules/oxfmt/configuration_schema.json",
|
"$schema": "./node_modules/oxfmt/configuration_schema.json",
|
||||||
"ignorePatterns": ["leaflet.d.ts"]
|
"ignorePatterns": ["**/leaflet.d.ts"]
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-5
@@ -1,10 +1,7 @@
|
|||||||
{
|
{
|
||||||
"$schema": "./node_modules/oxlint/configuration_schema.json",
|
"$schema": "./node_modules/oxlint/configuration_schema.json",
|
||||||
"plugins": [
|
"ignorePatterns": ["**/leaflet.d.ts"],
|
||||||
"typescript",
|
"plugins": ["typescript", "unicorn", "oxc"],
|
||||||
"unicorn",
|
|
||||||
"oxc"
|
|
||||||
],
|
|
||||||
"categories": {
|
"categories": {
|
||||||
"correctness": "error"
|
"correctness": "error"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -5,10 +5,12 @@ When contributing to this repository, please first discuss the change you wish t
|
|||||||
## Development Environment Setup
|
## Development Environment Setup
|
||||||
|
|
||||||
### Prerequisites
|
### Prerequisites
|
||||||
|
|
||||||
- [Yarn](https://classic.yarnpkg.com/lang/en/docs/install/#debian-stable)
|
- [Yarn](https://classic.yarnpkg.com/lang/en/docs/install/#debian-stable)
|
||||||
- [Docker](https://docs.docker.com/engine/install/)
|
- [Docker](https://docs.docker.com/engine/install/)
|
||||||
|
|
||||||
### Setup
|
### Setup
|
||||||
|
|
||||||
1. Fork the repository
|
1. Fork the repository
|
||||||
2. Clone your fork locally
|
2. Clone your fork locally
|
||||||
3. Run `yarn` to install dependencies
|
3. Run `yarn` to install dependencies
|
||||||
@@ -18,11 +20,13 @@ When contributing to this repository, please first discuss the change you wish t
|
|||||||
The test data is not persisted between restarts. Create a Docker volume if you wish for this to be the case.
|
The test data is not persisted between restarts. Create a Docker volume if you wish for this to be the case.
|
||||||
|
|
||||||
### Branching
|
### Branching
|
||||||
|
|
||||||
- We use the [GitHub Flow](https://www.gitkraken.com/learn/git/best-practices/git-branch-strategy#github-flow-considerations) branching strategy.
|
- We use the [GitHub Flow](https://www.gitkraken.com/learn/git/best-practices/git-branch-strategy#github-flow-considerations) branching strategy.
|
||||||
- Use `feature/feature-name` as your branch name.
|
- Use `feature/feature-name` as your branch name.
|
||||||
- Non-feature branches are allowed, but please give a clear name to your branch such as `hotfix/fix-bug`
|
- Non-feature branches are allowed, but please give a clear name to your branch such as `hotfix/fix-bug`
|
||||||
|
|
||||||
## Pull Request Process
|
## Pull Request Process
|
||||||
|
|
||||||
1. Squash all your commits into a single commit before pushing your branch
|
1. Squash all your commits into a single commit before pushing your branch
|
||||||
2. Give a clear overview of your changes in the commit message
|
2. Give a clear overview of your changes in the commit message
|
||||||
3. When opening a PR, give a clear overview of what your changes are and why
|
3. When opening a PR, give a clear overview of what your changes are and why
|
||||||
|
|||||||
+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"]
|
||||||
}
|
}
|
||||||
|
|||||||
+971
-3873
File diff suppressed because it is too large
Load Diff
+10983
-11623
File diff suppressed because it is too large
Load Diff
+34
-31
@@ -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",
|
"@socialgouv/matomo-next": "^1.14.2",
|
||||||
"@serwist/next": "^9.5.12",
|
"@tanstack/react-query": "^5.104.2",
|
||||||
"@socialgouv/matomo-next": "^1.10.0",
|
|
||||||
"@tanstack/react-query": "^5.29.0",
|
|
||||||
"@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.2",
|
||||||
"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": "^9.1.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.2",
|
||||||
|
"@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.86.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,17 +10,8 @@ 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(
|
const duplicateClubNames: Set<string> = new Set(clubData.map((club) => club.name));
|
||||||
clubData.map((club) => club.name),
|
|
||||||
);
|
|
||||||
|
|
||||||
for (const club of clubData) {
|
for (const club of clubData) {
|
||||||
if (duplicateClubNames.has(club.name)) {
|
if (duplicateClubNames.has(club.name)) {
|
||||||
@@ -33,15 +22,6 @@ describe("clubs", () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const filteredData: IClub[] = filterClubsByManualEntry(clubData);
|
const filteredData: IClub[] = filterClubsByManualEntry(clubData);
|
||||||
|
expect(filteredData.length).toEqual(clubData.length - duplicateClubNames.size);
|
||||||
const hasManualEnteredClubs = filteredData.some(
|
|
||||||
(club) => club.manual_entry && !club.pending,
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(filteredData.length).toEqual(
|
|
||||||
clubData.length - duplicateClubNames.size,
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(hasManualEnteredClubs).toBeTruthy;
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -5,8 +5,7 @@ export const clubData = [
|
|||||||
_id: new ObjectId("690586c9e06ce80de6cd7315"),
|
_id: new ObjectId("690586c9e06ce80de6cd7315"),
|
||||||
name: '"Le Gambit "de Muret',
|
name: '"Le Gambit "de Muret',
|
||||||
url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=1264",
|
url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=1264",
|
||||||
address:
|
address: "Maison des Associations 5 Sq des Combattants d'Afrique du Nord Salle B3 31600 MURET",
|
||||||
"Maison des Associations 5 Sq des Combattants d'Afrique du Nord Salle B3 31600 MURET",
|
|
||||||
email: "gambitdemuret@gmail.com",
|
email: "gambitdemuret@gmail.com",
|
||||||
website: "http://www.gambit-de-muret.webou.net",
|
website: "http://www.gambit-de-muret.webou.net",
|
||||||
coordinates: [43.46106289999999, 1.3218611],
|
coordinates: [43.46106289999999, 1.3218611],
|
||||||
@@ -191,8 +190,7 @@ export const clubData = [
|
|||||||
_id: new ObjectId("690586c9e06ce80de6cd7336"),
|
_id: new ObjectId("690586c9e06ce80de6cd7336"),
|
||||||
name: "ASSM - Ass sportive St Medard en Jalles",
|
name: "ASSM - Ass sportive St Medard en Jalles",
|
||||||
url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=3104",
|
url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=3104",
|
||||||
address:
|
address: "Complexe Sportif R. Monseau rue Charles Capsec 33160 ST MEDARD EN JALLES",
|
||||||
"Complexe Sportif R. Monseau rue Charles Capsec 33160 ST MEDARD EN JALLES",
|
|
||||||
email: "stephane.bastin1805@gmail.com",
|
email: "stephane.bastin1805@gmail.com",
|
||||||
website: "",
|
website: "",
|
||||||
coordinates: [44.8839858, -0.7063288999999999],
|
coordinates: [44.8839858, -0.7063288999999999],
|
||||||
@@ -255,8 +253,7 @@ export const clubData = [
|
|||||||
_id: new ObjectId("690586c9e06ce80de6cd74c5"),
|
_id: new ObjectId("690586c9e06ce80de6cd74c5"),
|
||||||
name: "Albertville Savoie Echecs",
|
name: "Albertville Savoie Echecs",
|
||||||
url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=3200",
|
url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=3200",
|
||||||
address:
|
address: "Maison des Associations 21 rue Georges Lamarque 73200 ALBERTVILLE",
|
||||||
"Maison des Associations 21 rue Georges Lamarque 73200 ALBERTVILLE",
|
|
||||||
email: "albertville.savoie.echecs@gmail.com",
|
email: "albertville.savoie.echecs@gmail.com",
|
||||||
website: "https://www.albertville-savoie-echecs.fr",
|
website: "https://www.albertville-savoie-echecs.fr",
|
||||||
coordinates: [45.6680374, 6.377434999999999],
|
coordinates: [45.6680374, 6.377434999999999],
|
||||||
@@ -302,8 +299,7 @@ export const clubData = [
|
|||||||
_id: new ObjectId("690586c9e06ce80de6cd7241"),
|
_id: new ObjectId("690586c9e06ce80de6cd7241"),
|
||||||
name: "Amicale Echecs de Divonne les Bains",
|
name: "Amicale Echecs de Divonne les Bains",
|
||||||
url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=3410",
|
url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=3410",
|
||||||
address:
|
address: "Bet Adonide Res Divona Park 268 Bld des Epinettes 01220 DIVONNE LES BAINS",
|
||||||
"Bet Adonide Res Divona Park 268 Bld des Epinettes 01220 DIVONNE LES BAINS",
|
|
||||||
email: "echecs@lalieu.com",
|
email: "echecs@lalieu.com",
|
||||||
website: "",
|
website: "",
|
||||||
coordinates: [46.3464497, 6.1342244],
|
coordinates: [46.3464497, 6.1342244],
|
||||||
@@ -321,8 +317,7 @@ export const clubData = [
|
|||||||
_id: new ObjectId("690586c9e06ce80de6cd7324"),
|
_id: new ObjectId("690586c9e06ce80de6cd7324"),
|
||||||
name: "Arcachon Echecs",
|
name: "Arcachon Echecs",
|
||||||
url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=98",
|
url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=98",
|
||||||
address:
|
address: "Nouveau Cercle Arcachonnais 195 boulevard de la Plage 33120 ARCACHON",
|
||||||
"Nouveau Cercle Arcachonnais 195 boulevard de la Plage 33120 ARCACHON",
|
|
||||||
email: "regislegendre@free.fr",
|
email: "regislegendre@free.fr",
|
||||||
website: "http://www.ncarcachon.fr/",
|
website: "http://www.ncarcachon.fr/",
|
||||||
coordinates: [44.6626304, -1.1692262],
|
coordinates: [44.6626304, -1.1692262],
|
||||||
@@ -340,8 +335,7 @@ export const clubData = [
|
|||||||
_id: new ObjectId("690586c9e06ce80de6cd75b8"),
|
_id: new ObjectId("690586c9e06ce80de6cd75b8"),
|
||||||
name: "Arcueil Chessland",
|
name: "Arcueil Chessland",
|
||||||
url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=678",
|
url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=678",
|
||||||
address:
|
address: "1-2 rue Fernand Forest groupe Scolaire Jean Mace Cote Gardienne 94110 ARCUEIL",
|
||||||
"1-2 rue Fernand Forest groupe Scolaire Jean Mace Cote Gardienne 94110 ARCUEIL",
|
|
||||||
email: "matoz@wanadoo.fr",
|
email: "matoz@wanadoo.fr",
|
||||||
website: "http://www.arcueil-chessland.fr/",
|
website: "http://www.arcueil-chessland.fr/",
|
||||||
coordinates: [48.79920260000001, 2.3391093],
|
coordinates: [48.79920260000001, 2.3391093],
|
||||||
@@ -458,8 +452,7 @@ export const clubData = [
|
|||||||
_id: new ObjectId("690586c9e06ce80de6cd726a"),
|
_id: new ObjectId("690586c9e06ce80de6cd726a"),
|
||||||
name: "Aubenas Vals Echiquier Cévenol",
|
name: "Aubenas Vals Echiquier Cévenol",
|
||||||
url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=505",
|
url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=505",
|
||||||
address:
|
address: "Centre Socio Culturel Le palabre 6 rue Albert Seibel 07200 AUBENAS",
|
||||||
"Centre Socio Culturel Le palabre 6 rue Albert Seibel 07200 AUBENAS",
|
|
||||||
email: "jean.louis.bourquard@free.fr",
|
email: "jean.louis.bourquard@free.fr",
|
||||||
website: "http://aubenasvals-echecs.fr",
|
website: "http://aubenasvals-echecs.fr",
|
||||||
coordinates: [44.6173697, 4.388114],
|
coordinates: [44.6173697, 4.388114],
|
||||||
@@ -522,8 +515,7 @@ export const clubData = [
|
|||||||
_id: new ObjectId("690586c9e06ce80de6cd7262"),
|
_id: new ObjectId("690586c9e06ce80de6cd7262"),
|
||||||
name: "Azur Chess Club",
|
name: "Azur Chess Club",
|
||||||
url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=2680",
|
url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=2680",
|
||||||
address:
|
address: "Res le Marco Polo Ketch D 2e Etage 312 Bld des Ecureuils 06210 MANDELIEU LA NAPOULE",
|
||||||
"Res le Marco Polo Ketch D 2e Etage 312 Bld des Ecureuils 06210 MANDELIEU LA NAPOULE",
|
|
||||||
email: "eric.sighirdjian@sfr.fr",
|
email: "eric.sighirdjian@sfr.fr",
|
||||||
website: "http://azurchessclub.fr",
|
website: "http://azurchessclub.fr",
|
||||||
coordinates: [43.5420528, 6.9443551],
|
coordinates: [43.5420528, 6.9443551],
|
||||||
@@ -749,8 +741,7 @@ export const clubData = [
|
|||||||
_id: new ObjectId("690586c9e06ce80de6cd7524"),
|
_id: new ObjectId("690586c9e06ce80de6cd7524"),
|
||||||
name: 'C.E. Fontenay le Fleury "Les Fous Furieux"',
|
name: 'C.E. Fontenay le Fleury "Les Fous Furieux"',
|
||||||
url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=819",
|
url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=819",
|
||||||
address:
|
address: "Maison des Associations 5 rue Jean Jaures 78330 FONTENAY LE FLEURY",
|
||||||
"Maison des Associations 5 rue Jean Jaures 78330 FONTENAY LE FLEURY",
|
|
||||||
email: "poutoune@club-internet.fr",
|
email: "poutoune@club-internet.fr",
|
||||||
website: "https://echecs-fontenaylefleury.org",
|
website: "https://echecs-fontenaylefleury.org",
|
||||||
coordinates: [48.8147484, 2.048536],
|
coordinates: [48.8147484, 2.048536],
|
||||||
@@ -804,8 +795,7 @@ export const clubData = [
|
|||||||
_id: new ObjectId("690586c9e06ce80de6cd7594"),
|
_id: new ObjectId("690586c9e06ce80de6cd7594"),
|
||||||
name: "C.E. de Bois-Colombes",
|
name: "C.E. de Bois-Colombes",
|
||||||
url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=689",
|
url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=689",
|
||||||
address:
|
address: "Espace Associations 26 rue d'Estienne d'Orves 92270 BOIS COLOMBES",
|
||||||
"Espace Associations 26 rue d'Estienne d'Orves 92270 BOIS COLOMBES",
|
|
||||||
email: "contact@bois-colombes-echecs.com",
|
email: "contact@bois-colombes-echecs.com",
|
||||||
website: "https://www.bois-colombes-echecs.com",
|
website: "https://www.bois-colombes-echecs.com",
|
||||||
coordinates: [48.9156126, 2.2716207],
|
coordinates: [48.9156126, 2.2716207],
|
||||||
@@ -896,8 +886,7 @@ export const clubData = [
|
|||||||
_id: new ObjectId("690586c9e06ce80de6cd7312"),
|
_id: new ObjectId("690586c9e06ce80de6cd7312"),
|
||||||
name: "C.L. Léo Lagrange - Colomiers",
|
name: "C.L. Léo Lagrange - Colomiers",
|
||||||
url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=1239",
|
url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=1239",
|
||||||
address:
|
address: "Salle Municipale 1 place Leo Lagrange ex place du Val d'Aran 31770 COLOMIERS",
|
||||||
"Salle Municipale 1 place Leo Lagrange ex place du Val d'Aran 31770 COLOMIERS",
|
|
||||||
email: "colomiersclubdechecs@gmail.com",
|
email: "colomiersclubdechecs@gmail.com",
|
||||||
website: "http://colomiers.chess.free.fr",
|
website: "http://colomiers.chess.free.fr",
|
||||||
coordinates: [43.6117764, 1.3285075],
|
coordinates: [43.6117764, 1.3285075],
|
||||||
@@ -906,8 +895,7 @@ export const clubData = [
|
|||||||
_id: new ObjectId("690586c9e06ce80de6cd759f"),
|
_id: new ObjectId("690586c9e06ce80de6cd759f"),
|
||||||
name: "C.S.M. Puteaux Echecs",
|
name: "C.S.M. Puteaux Echecs",
|
||||||
url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=928",
|
url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=928",
|
||||||
address:
|
address: "Palais des Sports ile de Puteaux 2 Voie Georges Hassoux 92800 PUTEAUX",
|
||||||
"Palais des Sports ile de Puteaux 2 Voie Georges Hassoux 92800 PUTEAUX",
|
|
||||||
email: "csmpe@free.fr",
|
email: "csmpe@free.fr",
|
||||||
website: "http://csmpe.free.fr",
|
website: "http://csmpe.free.fr",
|
||||||
coordinates: [48.8788229, 2.2457232],
|
coordinates: [48.8788229, 2.2457232],
|
||||||
|
|||||||
@@ -7,7 +7,9 @@ export default function AddClubPage() {
|
|||||||
return (
|
return (
|
||||||
<section className="grid place-items-center bg-white pb-20 dark:bg-gray-800">
|
<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">
|
<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">
|
<p className="mb-8 text-center font-light text-gray-500 dark:text-gray-400 sm:text-xl lg:mb-16">
|
||||||
{t("info")}
|
{t("info")}
|
||||||
@@ -16,5 +18,5 @@ export default function AddClubPage() {
|
|||||||
<ClubForm />
|
<ClubForm />
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
@@ -101,11 +101,7 @@ const TournamentForm = () => {
|
|||||||
name="tournament.time_control"
|
name="tournament.time_control"
|
||||||
control={form.control}
|
control={form.control}
|
||||||
label={t("tcLabel")}
|
label={t("tcLabel")}
|
||||||
options={[
|
options={[TimeControl.Classic, TimeControl.Rapid, TimeControl.Blitz].map((tc) => ({
|
||||||
TimeControl.Classic,
|
|
||||||
TimeControl.Rapid,
|
|
||||||
TimeControl.Blitz,
|
|
||||||
].map((tc) => ({
|
|
||||||
value: tc,
|
value: tc,
|
||||||
label: at("timeControlEnum", { tc }),
|
label: at("timeControlEnum", { tc }),
|
||||||
}))}
|
}))}
|
||||||
|
|||||||
@@ -11,10 +11,7 @@ export async function generateMetadata({
|
|||||||
const { locale } = await params;
|
const { locale } = await params;
|
||||||
return {
|
return {
|
||||||
alternates: {
|
alternates: {
|
||||||
canonical:
|
canonical: locale === "fr" ? `${baseUrl}/auth/sign-in` : `${baseUrl}/${locale}/auth/sign-in`,
|
||||||
locale === "fr"
|
|
||||||
? `${baseUrl}/auth/sign-in`
|
|
||||||
: `${baseUrl}/${locale}/auth/sign-in`,
|
|
||||||
languages: {
|
languages: {
|
||||||
fr: `${baseUrl}/auth/sign-in`,
|
fr: `${baseUrl}/auth/sign-in`,
|
||||||
en: `${baseUrl}/en/auth/sign-in`,
|
en: `${baseUrl}/en/auth/sign-in`,
|
||||||
|
|||||||
@@ -94,10 +94,7 @@ export const ClubMarker = forwardRef<MarkerRef, ClubMarkerProps>(
|
|||||||
)}
|
)}
|
||||||
{club.email && (
|
{club.email && (
|
||||||
<div>
|
<div>
|
||||||
<a
|
<a href={`mailto:${club.email}`} className="text-primary hover:text-primary-800">
|
||||||
href={`mailto:${club.email}`}
|
|
||||||
className="text-primary hover:text-primary-800"
|
|
||||||
>
|
|
||||||
{club.email}
|
{club.email}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -29,9 +29,7 @@ const ClubTable = () => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!isLg || debouncedHoveredMapId === null) return;
|
if (!isLg || debouncedHoveredMapId === null) return;
|
||||||
const clubRow = document.querySelector(
|
const clubRow = document.querySelector(`[data-group-id="${debouncedHoveredMapId}"]`);
|
||||||
`[data-group-id="${debouncedHoveredMapId}"]`,
|
|
||||||
);
|
|
||||||
|
|
||||||
clubRow?.scrollIntoView({ behavior: "smooth" });
|
clubRow?.scrollIntoView({ behavior: "smooth" });
|
||||||
}, [debouncedHoveredMapId, isLg]);
|
}, [debouncedHoveredMapId, isLg]);
|
||||||
@@ -87,9 +85,7 @@ const ClubTable = () => {
|
|||||||
hoveredMapId === club.id && "bg-gray-200 dark:bg-gray-900",
|
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">
|
<td className="px-1 py-2 sm:px-3 sm:py-3 lg:px-3 lg:py-3">{club.name}</td>
|
||||||
{club.name}
|
|
||||||
</td>
|
|
||||||
<td className="px-1 py-2 text-left sm:px-3 sm:py-3 lg:px-3 lg:py-3">
|
<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.address && <div>{club.address}</div>}
|
||||||
{club.website && (
|
{club.website && (
|
||||||
|
|||||||
@@ -44,14 +44,10 @@ export default function ClubsDisplay({ clubs }: ClubsDisplayProps) {
|
|||||||
.replace(/[\u0300-\u036f]/g, "") === regionSearchParam.toLowerCase(),
|
.replace(/[\u0300-\u036f]/g, "") === regionSearchParam.toLowerCase(),
|
||||||
);
|
);
|
||||||
|
|
||||||
const regionData = regionGeoJson.features.find(
|
const regionData = regionGeoJson.features.find((f) => f.properties.nom === matchedRegion);
|
||||||
(f) => f.properties.nom === matchedRegion,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (regionData) {
|
if (regionData) {
|
||||||
setRegionFilter(
|
setRegionFilter(regionData as Feature<Polygon | MultiPolygon, GeoJsonProperties>);
|
||||||
regionData as Feature<Polygon | MultiPolygon, GeoJsonProperties>,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,8 +19,7 @@ export async function generateMetadata({
|
|||||||
const { locale } = await params;
|
const { locale } = await params;
|
||||||
return {
|
return {
|
||||||
alternates: {
|
alternates: {
|
||||||
canonical:
|
canonical: locale === "fr" ? `${baseUrl}/clubs` : `${baseUrl}/${locale}/clubs`,
|
||||||
locale === "fr" ? `${baseUrl}/clubs` : `${baseUrl}/${locale}/clubs`,
|
|
||||||
languages: {
|
languages: {
|
||||||
fr: `${baseUrl}/clubs`,
|
fr: `${baseUrl}/clubs`,
|
||||||
en: `${baseUrl}/en/clubs`,
|
en: `${baseUrl}/en/clubs`,
|
||||||
|
|||||||
@@ -49,11 +49,7 @@ export default function Footer() {
|
|||||||
<Link href="/contact-us" aria-label={t("contactAria")} className="mr-4">
|
<Link href="/contact-us" aria-label={t("contactAria")} className="mr-4">
|
||||||
<FaRegEnvelope />
|
<FaRegEnvelope />
|
||||||
</Link>
|
</Link>
|
||||||
<Link
|
<Link href="/privacy" aria-label={t("privacyPolicyAria")} className="mr-4">
|
||||||
href="/privacy"
|
|
||||||
aria-label={t("privacyPolicyAria")}
|
|
||||||
className="mr-4"
|
|
||||||
>
|
|
||||||
<MdOutlinePrivacyTip />
|
<MdOutlinePrivacyTip />
|
||||||
</Link>
|
</Link>
|
||||||
<div className="mr-4 space-x-2 text-xs">
|
<div className="mr-4 space-x-2 text-xs">
|
||||||
|
|||||||
@@ -20,8 +20,7 @@ const Hamburger = () => {
|
|||||||
<div
|
<div
|
||||||
className={twMerge(
|
className={twMerge(
|
||||||
"h-0.5 w-8 bg-gray-600 transition-all duration-300 ease-in-out dark:bg-white",
|
"h-0.5 w-8 bg-gray-600 transition-all duration-300 ease-in-out dark:bg-white",
|
||||||
burgerMenuIsOpen &&
|
burgerMenuIsOpen && "translate-x-[1px] translate-y-2.5 rotate-45 bg-white",
|
||||||
"translate-x-[1px] translate-y-2.5 rotate-45 bg-white",
|
|
||||||
)}
|
)}
|
||||||
></div>
|
></div>
|
||||||
<div
|
<div
|
||||||
|
|||||||
@@ -21,9 +21,7 @@ export default function Navbar() {
|
|||||||
className="font-extrabold text-gray-900 no-underline hover:no-underline dark:text-white"
|
className="font-extrabold text-gray-900 no-underline hover:no-underline dark:text-white"
|
||||||
href="/"
|
href="/"
|
||||||
>
|
>
|
||||||
<span className="font-title text-2xl text-gray-800 dark:text-white">
|
<span className="font-title text-2xl text-gray-800 dark:text-white">{t("title")}</span>
|
||||||
{t("title")}
|
|
||||||
</span>
|
|
||||||
</Link>
|
</Link>
|
||||||
|
|
||||||
<div className="md:hidden" data-test="mobile-menu">
|
<div className="md:hidden" data-test="mobile-menu">
|
||||||
|
|||||||
@@ -57,28 +57,14 @@ export default function Contact() {
|
|||||||
{t("info")}
|
{t("info")}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
{error && (
|
{error && <InfoMessage className="mb-8" type="error" message={t("failure")} />}
|
||||||
<InfoMessage
|
|
||||||
className="mb-8"
|
|
||||||
type="error"
|
|
||||||
message={t("failure")}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<div className="flex items-center justify-center space-x-4 text-sm font-bold">
|
<div className="flex items-center justify-center space-x-4 text-sm font-bold">
|
||||||
<Button
|
<Button type="button" onClick={() => router.back()} intent="secondary">
|
||||||
type="button"
|
|
||||||
onClick={() => router.back()}
|
|
||||||
intent="secondary"
|
|
||||||
>
|
|
||||||
{at("cancelButton")}
|
{at("cancelButton")}
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
<Button
|
<Button onClick={() => onDeleteAccount()} disabled={deleting} intent="primary">
|
||||||
onClick={() => onDeleteAccount()}
|
|
||||||
disabled={deleting}
|
|
||||||
intent="primary"
|
|
||||||
>
|
|
||||||
{t("deleteButton")}
|
{t("deleteButton")}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -53,8 +53,7 @@ export default function EloClient() {
|
|||||||
const kFactorParam = searchParams.get("k");
|
const kFactorParam = searchParams.get("k");
|
||||||
const player = searchParams.get("player") ?? "";
|
const player = searchParams.get("player") ?? "";
|
||||||
|
|
||||||
const kFactor =
|
const kFactor = kFactorParam && kFactors.includes(kFactorParam) ? kFactorParam : "20";
|
||||||
kFactorParam && kFactors.includes(kFactorParam) ? kFactorParam : "20";
|
|
||||||
|
|
||||||
const hasTournamentId = !isEmpty(tournamentId.trim());
|
const hasTournamentId = !isEmpty(tournamentId.trim());
|
||||||
|
|
||||||
@@ -109,11 +108,7 @@ export default function EloClient() {
|
|||||||
const subscription = form.watch((value, { name, type }) => {
|
const subscription = form.watch((value, { name, type }) => {
|
||||||
let update = false;
|
let update = false;
|
||||||
if (type === "change") {
|
if (type === "change") {
|
||||||
if (
|
if (name === "tournamentId" && value.tournamentId !== tournamentId && value.tournamentId) {
|
||||||
name === "tournamentId" &&
|
|
||||||
value.tournamentId !== tournamentId &&
|
|
||||||
value.tournamentId
|
|
||||||
) {
|
|
||||||
current.set("tId", value.tournamentId);
|
current.set("tId", value.tournamentId);
|
||||||
update = true;
|
update = true;
|
||||||
} else if (
|
} else if (
|
||||||
@@ -122,18 +117,10 @@ export default function EloClient() {
|
|||||||
value.tournamentId === null
|
value.tournamentId === null
|
||||||
) {
|
) {
|
||||||
clearForm();
|
clearForm();
|
||||||
} else if (
|
} else if (name === "player" && value.player !== player && value.player) {
|
||||||
name === "player" &&
|
|
||||||
value.player !== player &&
|
|
||||||
value.player
|
|
||||||
) {
|
|
||||||
current.set("player", value.player);
|
current.set("player", value.player);
|
||||||
update = true;
|
update = true;
|
||||||
} else if (
|
} else if (name === "kFactor" && value.kFactor !== kFactor && value.kFactor) {
|
||||||
name === "kFactor" &&
|
|
||||||
value.kFactor !== kFactor &&
|
|
||||||
value.kFactor
|
|
||||||
) {
|
|
||||||
current.set("k", value.kFactor);
|
current.set("k", value.kFactor);
|
||||||
update = true;
|
update = true;
|
||||||
}
|
}
|
||||||
@@ -146,17 +133,7 @@ export default function EloClient() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
return () => subscription.unsubscribe();
|
return () => subscription.unsubscribe();
|
||||||
}, [
|
}, [clearForm, current, form, form.watch, kFactor, pathname, player, router, tournamentId]);
|
||||||
clearForm,
|
|
||||||
current,
|
|
||||||
form,
|
|
||||||
form.watch,
|
|
||||||
kFactor,
|
|
||||||
pathname,
|
|
||||||
player,
|
|
||||||
router,
|
|
||||||
tournamentId,
|
|
||||||
]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// When the URL changes, we update the form values
|
// When the URL changes, we update the form values
|
||||||
@@ -184,9 +161,7 @@ export default function EloClient() {
|
|||||||
>
|
>
|
||||||
{t("title")}
|
{t("title")}
|
||||||
</h2>
|
</h2>
|
||||||
<p className="mb-8 text-center font-light text-gray-500 dark:text-gray-400">
|
<p className="mb-8 text-center font-light text-gray-500 dark:text-gray-400">{t("info")}</p>
|
||||||
{t("info")}
|
|
||||||
</p>
|
|
||||||
|
|
||||||
{hasTournamentId && !isFetching && !error && (
|
{hasTournamentId && !isFetching && !error && (
|
||||||
<div className="mx-auto mb-8 flex justify-center">
|
<div className="mx-auto mb-8 flex justify-center">
|
||||||
@@ -251,11 +226,7 @@ export default function EloClient() {
|
|||||||
</form>
|
</form>
|
||||||
</FormProvider>
|
</FormProvider>
|
||||||
|
|
||||||
{hasTournamentId &&
|
{hasTournamentId && !isFetching && player && playerResults && !error && (
|
||||||
!isFetching &&
|
|
||||||
player &&
|
|
||||||
playerResults &&
|
|
||||||
!error && (
|
|
||||||
<TournamentResults
|
<TournamentResults
|
||||||
playerId={player}
|
playerId={player}
|
||||||
kFactor={parseInt(kFactor)}
|
kFactor={parseInt(kFactor)}
|
||||||
@@ -265,9 +236,7 @@ export default function EloClient() {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
{(!!error || allResults?.serverError) && (
|
{(!!error || allResults?.serverError) && (
|
||||||
<ErrorBox
|
<ErrorBox error={<TranslatedError err={error ?? allResults?.serverError} />} />
|
||||||
error={<TranslatedError err={error ?? allResults?.serverError} />}
|
|
||||||
/>
|
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{((!hasTournamentId && !isFetching) || !!error) && (
|
{((!hasTournamentId && !isFetching) || !!error) && (
|
||||||
|
|||||||
@@ -23,29 +23,17 @@ export const KFactor = ({ className }: KFactorProps) => {
|
|||||||
</Disclosure.Button>
|
</Disclosure.Button>
|
||||||
|
|
||||||
<Disclosure.Panel className="mt-4">
|
<Disclosure.Panel className="mt-4">
|
||||||
<p className="text-sm text-gray-500 dark:text-neutral-400">
|
<p className="text-sm text-gray-500 dark:text-neutral-400">{t("kFactorInfo1")}</p>
|
||||||
{t("kFactorInfo1")}
|
<p className="mt-4 text-sm text-gray-500 dark:text-neutral-400">{t("kFactorInfo2")}</p>
|
||||||
</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">
|
<ul className="mb-8 ml-4 mt-3 list-outside list-disc">
|
||||||
{(
|
{(["kFactorInfo3", "kFactorInfo4", "kFactorInfo5", "kFactorInfo6"] as const).map(
|
||||||
[
|
(key) => (
|
||||||
"kFactorInfo3",
|
<li key={key} className="mt-2 text-sm text-gray-500 dark:text-neutral-400">
|
||||||
"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> })}
|
{t.rich(key, { b: (str) => <b>{str}</b> })}
|
||||||
</li>
|
</li>
|
||||||
))}
|
),
|
||||||
|
)}
|
||||||
</ul>
|
</ul>
|
||||||
</Disclosure.Panel>
|
</Disclosure.Panel>
|
||||||
</Disclosure>
|
</Disclosure>
|
||||||
|
|||||||
@@ -63,20 +63,16 @@ 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([
|
const [currentElo, kFactor, games] = form.watch(["currentElo", "kFactor", "games"]);
|
||||||
"currentElo",
|
|
||||||
"kFactor",
|
|
||||||
"games",
|
|
||||||
]);
|
|
||||||
|
|
||||||
const isDefault =
|
const isDefault =
|
||||||
isEmpty(currentElo) &&
|
isEmpty(currentElo) &&
|
||||||
kFactor === "20" &&
|
kFactor === "20" &&
|
||||||
games?.length === 1 &&
|
games?.length === 1 &&
|
||||||
(isEmpty(games[0]) ||
|
(isEmpty(games[0]) || (isEmpty(games[0]?.opponentElo) && isEmpty(games[0]?.result)));
|
||||||
(isEmpty(games[0]?.opponentElo) && isEmpty(games[0]?.result)));
|
|
||||||
|
|
||||||
type Deltas = {
|
type Deltas = {
|
||||||
rating: number;
|
rating: number;
|
||||||
@@ -86,13 +82,8 @@ export const ManualEloForm = () => {
|
|||||||
const calculations = !Number.isNaN(currentElo)
|
const calculations = !Number.isNaN(currentElo)
|
||||||
? (games ?? []).reduce<Deltas>(
|
? (games ?? []).reduce<Deltas>(
|
||||||
(acc, game) => {
|
(acc, game) => {
|
||||||
if (
|
if (!isNil(game?.opponentElo) && !Number.isNaN(game?.opponentElo) && game?.result) {
|
||||||
!isNil(game?.opponentElo) &&
|
const result = game?.result === "win" ? 1 : game?.result === "loss" ? 0 : 0.5;
|
||||||
!Number.isNaN(game?.opponentElo) &&
|
|
||||||
game?.result
|
|
||||||
) {
|
|
||||||
const result =
|
|
||||||
game?.result === "win" ? 1 : game?.result === "loss" ? 0 : 0.5;
|
|
||||||
|
|
||||||
const { delta } = getNewRating(
|
const { delta } = getNewRating(
|
||||||
currentElo!,
|
currentElo!,
|
||||||
@@ -117,9 +108,7 @@ export const ManualEloForm = () => {
|
|||||||
|
|
||||||
const deltas = calculations.deltas;
|
const deltas = calculations.deltas;
|
||||||
const hasDeltas = deltas.some((d) => d.delta !== undefined);
|
const hasDeltas = deltas.some((d) => d.delta !== undefined);
|
||||||
const totalDelta = Math.round(
|
const totalDelta = Math.round(deltas.reduce((acc, delta) => acc + (delta.delta ?? 0), 0));
|
||||||
deltas.reduce((acc, delta) => acc + (delta.delta ?? 0), 0),
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<FormProvider {...form}>
|
<FormProvider {...form}>
|
||||||
@@ -149,9 +138,7 @@ export const ManualEloForm = () => {
|
|||||||
|
|
||||||
<KFactor className="mt-2" />
|
<KFactor className="mt-2" />
|
||||||
|
|
||||||
<h3 className="my-4 text-lg text-gray-900 dark:text-white">
|
<h3 className="my-4 text-lg text-gray-900 dark:text-white">{t("resultsTitle")}</h3>
|
||||||
{t("resultsTitle")}
|
|
||||||
</h3>
|
|
||||||
|
|
||||||
<div className="flex w-full flex-col gap-6 sm:gap-2">
|
<div className="flex w-full flex-col gap-6 sm:gap-2">
|
||||||
{gameFields.map((game, i) => {
|
{gameFields.map((game, i) => {
|
||||||
|
|||||||
@@ -78,19 +78,13 @@ export const TournamentResults = ({
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
rating: acc.rating + delta,
|
rating: acc.rating + delta,
|
||||||
deltas: [
|
deltas: [...acc.deltas, { rating: acc.rating + delta, delta, ...info }],
|
||||||
...acc.deltas,
|
|
||||||
{ rating: acc.rating + delta, delta, ...info },
|
|
||||||
],
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
rating: acc.rating,
|
rating: acc.rating,
|
||||||
deltas: [
|
deltas: [...acc.deltas, { rating: acc.rating, delta: undefined, ...info }],
|
||||||
...acc.deltas,
|
|
||||||
{ rating: acc.rating, delta: undefined, ...info },
|
|
||||||
],
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
{ rating: currentElo!, deltas: [] },
|
{ rating: currentElo!, deltas: [] },
|
||||||
@@ -98,9 +92,7 @@ export const TournamentResults = ({
|
|||||||
: { rating: currentElo!, deltas: [] };
|
: { rating: currentElo!, deltas: [] };
|
||||||
|
|
||||||
const deltas = calculations.deltas;
|
const deltas = calculations.deltas;
|
||||||
const totalDelta = Math.round(
|
const totalDelta = Math.round(deltas.reduce((acc, delta) => acc + (delta.delta ?? 0), 0));
|
||||||
deltas.reduce((acc, delta) => acc + (delta.delta ?? 0), 0),
|
|
||||||
);
|
|
||||||
|
|
||||||
const noChangeCount = (deltas ?? []).filter(
|
const noChangeCount = (deltas ?? []).filter(
|
||||||
({ wonByForfeit, lostByForfeit, estimated, national }) =>
|
({ wonByForfeit, lostByForfeit, estimated, national }) =>
|
||||||
@@ -121,16 +113,12 @@ export const TournamentResults = ({
|
|||||||
{deltas.map((delta, i) => {
|
{deltas.map((delta, i) => {
|
||||||
const { estimated, national, lostByForfeit, wonByForfeit } = delta;
|
const { estimated, national, lostByForfeit, wonByForfeit } = delta;
|
||||||
const opponentElo = delta.opponentElo
|
const opponentElo = delta.opponentElo
|
||||||
? ` (${delta.opponentElo} ${
|
? ` (${delta.opponentElo} ${estimated ? "E" : national ? "N" : "F"})`
|
||||||
estimated ? "E" : national ? "N" : "F"
|
|
||||||
})`
|
|
||||||
: "";
|
: "";
|
||||||
|
|
||||||
const opponentName = delta.opponentName ? (
|
const opponentName = delta.opponentName ? (
|
||||||
<span>
|
<span>
|
||||||
<span className="whitespace-nowrap font-bold">
|
<span className="whitespace-nowrap font-bold">{delta.opponentName}</span>
|
||||||
{delta.opponentName}
|
|
||||||
</span>
|
|
||||||
{opponentElo}
|
{opponentElo}
|
||||||
</span>
|
</span>
|
||||||
) : (
|
) : (
|
||||||
@@ -140,11 +128,8 @@ export const TournamentResults = ({
|
|||||||
const playedWhite = delta.colour === "white";
|
const playedWhite = delta.colour === "white";
|
||||||
|
|
||||||
const whitePlayer = playedWhite ? playerResults.name : opponentName;
|
const whitePlayer = playedWhite ? playerResults.name : opponentName;
|
||||||
const blackPlayer = !playedWhite
|
const blackPlayer = !playedWhite ? playerResults.name : opponentName;
|
||||||
? playerResults.name
|
const noChange = wonByForfeit || lostByForfeit || estimated || national;
|
||||||
: opponentName;
|
|
||||||
const noChange =
|
|
||||||
wonByForfeit || lostByForfeit || estimated || national;
|
|
||||||
|
|
||||||
const forfeit = delta.opponentName === null;
|
const forfeit = delta.opponentName === null;
|
||||||
|
|
||||||
@@ -173,9 +158,7 @@ export const TournamentResults = ({
|
|||||||
{blackPlayer}
|
{blackPlayer}
|
||||||
</td>
|
</td>
|
||||||
)}
|
)}
|
||||||
<td className="whitespace-nowrap px-2 pb-2 text-center">
|
<td className="whitespace-nowrap px-2 pb-2 text-center">{!forfeit && result}</td>
|
||||||
{!forfeit && result}
|
|
||||||
</td>
|
|
||||||
<td className="pb-2 text-right">
|
<td className="pb-2 text-right">
|
||||||
{noChange ? (
|
{noChange ? (
|
||||||
"-"
|
"-"
|
||||||
|
|||||||
@@ -11,8 +11,7 @@ export async function generateMetadata({
|
|||||||
const { locale } = await params;
|
const { locale } = await params;
|
||||||
return {
|
return {
|
||||||
alternates: {
|
alternates: {
|
||||||
canonical:
|
canonical: locale === "fr" ? `${baseUrl}/elo` : `${baseUrl}/${locale}/elo`,
|
||||||
locale === "fr" ? `${baseUrl}/elo` : `${baseUrl}/${locale}/elo`,
|
|
||||||
languages: {
|
languages: {
|
||||||
fr: `${baseUrl}/elo`,
|
fr: `${baseUrl}/elo`,
|
||||||
en: `${baseUrl}/en/elo`,
|
en: `${baseUrl}/en/elo`,
|
||||||
|
|||||||
@@ -3,11 +3,7 @@ import { ReactNode } from "react";
|
|||||||
import Footer from "./components/Footer";
|
import Footer from "./components/Footer";
|
||||||
import Navbar from "./components/Navbar";
|
import Navbar from "./components/Navbar";
|
||||||
|
|
||||||
export default async function MainLayout({
|
export default async function MainLayout({ children }: { children: ReactNode }) {
|
||||||
children,
|
|
||||||
}: {
|
|
||||||
children: ReactNode;
|
|
||||||
}) {
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Navbar />
|
<Navbar />
|
||||||
|
|||||||
@@ -33,11 +33,7 @@ export default function Contact() {
|
|||||||
<p>
|
<p>
|
||||||
{t.rich("cookiesInfo", {
|
{t.rich("cookiesInfo", {
|
||||||
link: (str) => (
|
link: (str) => (
|
||||||
<a
|
<a href="https://matomo.org" target="_blank" rel="noopener noreferrer">
|
||||||
href="https://tinyanalytics.io"
|
|
||||||
target="_blank"
|
|
||||||
rel="noopener noreferrer"
|
|
||||||
>
|
|
||||||
{str}
|
{str}
|
||||||
</a>
|
</a>
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -8,11 +8,7 @@ import "react-date-range/dist/theme/default.css";
|
|||||||
import { dateRangeAtom, maxDateAtom } from "@/atoms";
|
import { dateRangeAtom, maxDateAtom } from "@/atoms";
|
||||||
import { DatePickerDirection } from "@/types";
|
import { DatePickerDirection } from "@/types";
|
||||||
|
|
||||||
const DatePicker = ({
|
const DatePicker = ({ datePickerDirection }: { datePickerDirection: DatePickerDirection }) => {
|
||||||
datePickerDirection,
|
|
||||||
}: {
|
|
||||||
datePickerDirection: DatePickerDirection;
|
|
||||||
}) => {
|
|
||||||
const [dateRange, setDateRange] = useAtom(dateRangeAtom);
|
const [dateRange, setDateRange] = useAtom(dateRangeAtom);
|
||||||
const maxDate = useAtomValue(maxDateAtom);
|
const maxDate = useAtomValue(maxDateAtom);
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
||||||
@@ -16,12 +16,9 @@ const Legend = () => {
|
|||||||
|
|
||||||
const timeControls = useMemo(
|
const timeControls = useMemo(
|
||||||
() =>
|
() =>
|
||||||
[
|
[TimeControl.Classic, TimeControl.Rapid, TimeControl.Blitz, TimeControl.Other].filter((tc) =>
|
||||||
TimeControl.Classic,
|
tournaments.some((t) => t.timeControl === tc),
|
||||||
TimeControl.Rapid,
|
),
|
||||||
TimeControl.Blitz,
|
|
||||||
TimeControl.Other,
|
|
||||||
].filter((tc) => tournaments.some((t) => t.timeControl === tc)),
|
|
||||||
[tournaments],
|
[tournaments],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,7 @@
|
|||||||
import { useAtom, useAtomValue } from "jotai";
|
import { useAtom, useAtomValue } from "jotai";
|
||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
|
|
||||||
import {
|
import { blitzAtom, classicAtom, otherAtom, rapidAtom, tournamentsAtom } from "@/atoms";
|
||||||
blitzAtom,
|
|
||||||
classicAtom,
|
|
||||||
otherAtom,
|
|
||||||
rapidAtom,
|
|
||||||
tournamentsAtom,
|
|
||||||
} from "@/atoms";
|
|
||||||
import { TimeControl } from "@/types";
|
import { TimeControl } from "@/types";
|
||||||
|
|
||||||
const TimeControlFilters = () => {
|
const TimeControlFilters = () => {
|
||||||
|
|||||||
@@ -10,10 +10,7 @@ import "leaflet.smooth_marker_bouncing";
|
|||||||
import "leaflet/dist/leaflet.css";
|
import "leaflet/dist/leaflet.css";
|
||||||
import { countBy, groupBy } from "lodash";
|
import { countBy, groupBy } from "lodash";
|
||||||
|
|
||||||
import {
|
import { filteredTournamentsByTimeControlAndZoneAtom, normsOnlyAtom } from "@/atoms";
|
||||||
filteredTournamentsByTimeControlAndZoneAtom,
|
|
||||||
normsOnlyAtom,
|
|
||||||
} from "@/atoms";
|
|
||||||
import { Map, MapMarker } from "@/components/Map";
|
import { Map, MapMarker } from "@/components/Map";
|
||||||
import { TimeControlColours } from "@/constants";
|
import { TimeControlColours } from "@/constants";
|
||||||
import { TimeControl } from "@/types";
|
import { TimeControl } from "@/types";
|
||||||
@@ -49,15 +46,12 @@ const TournamentMap = () => {
|
|||||||
${generatePieSVG(
|
${generatePieSVG(
|
||||||
"absolute w-[30px]",
|
"absolute w-[30px]",
|
||||||
15,
|
15,
|
||||||
[
|
[TimeControl.Classic, TimeControl.Rapid, TimeControl.Blitz, TimeControl.Other].map(
|
||||||
TimeControl.Classic,
|
(tc) => ({
|
||||||
TimeControl.Rapid,
|
|
||||||
TimeControl.Blitz,
|
|
||||||
TimeControl.Other,
|
|
||||||
].map((tc) => ({
|
|
||||||
value: timeControlCounts[tc] ?? 0,
|
value: timeControlCounts[tc] ?? 0,
|
||||||
colour: TimeControlColours[tc],
|
colour: TimeControlColours[tc],
|
||||||
})),
|
}),
|
||||||
|
),
|
||||||
)}
|
)}
|
||||||
<span class="text-white font-semibold relative z-[300]">${childCount}</span>
|
<span class="text-white font-semibold relative z-[300]">${childCount}</span>
|
||||||
</div>
|
</div>
|
||||||
@@ -77,9 +71,7 @@ const TournamentMap = () => {
|
|||||||
return {
|
return {
|
||||||
markerId: groupId,
|
markerId: groupId,
|
||||||
tableIds: tournamentGroup.map((t) => t.id),
|
tableIds: tournamentGroup.map((t) => t.id),
|
||||||
component: (
|
component: <TournamentMarker key={groupId} tournamentGroup={tournamentGroup} />,
|
||||||
<TournamentMarker key={groupId} tournamentGroup={tournamentGroup} />
|
|
||||||
),
|
|
||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
[groupedTournaments],
|
[groupedTournaments],
|
||||||
|
|||||||
@@ -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 = () => {
|
||||||
@@ -43,19 +44,14 @@ const TournamentTable = () => {
|
|||||||
|
|
||||||
const setDateRange = useSetAtom(dateRangeAtom);
|
const setDateRange = useSetAtom(dateRangeAtom);
|
||||||
const [datePickerIsOpen, setDatePickerIsOpen] = useAtom(datePickerIsOpenAtom);
|
const [datePickerIsOpen, setDatePickerIsOpen] = useAtom(datePickerIsOpenAtom);
|
||||||
const [dateDirectionState, setDateDirectionState] =
|
const [dateDirectionState, setDateDirectionState] = useState<DatePickerDirection>("horizontal");
|
||||||
useState<DatePickerDirection>("horizontal");
|
const datePickerColour = datePickerIsOpen ? "text-primary-600" : "text-gray-500";
|
||||||
const datePickerColour = datePickerIsOpen
|
|
||||||
? "text-primary-600"
|
|
||||||
: "text-gray-500";
|
|
||||||
|
|
||||||
useDatePickerWidth({ datePickerRef, setDateDirectionState });
|
useDatePickerWidth({ datePickerRef, setDateDirectionState });
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!isLg || debouncedHoveredMapId === null) return;
|
if (!isLg || debouncedHoveredMapId === null) return;
|
||||||
const tournamentRow = document.querySelector(
|
const tournamentRow = document.querySelector(`[data-group-id="${debouncedHoveredMapId}"]`);
|
||||||
`[data-group-id="${debouncedHoveredMapId}"]`,
|
|
||||||
);
|
|
||||||
|
|
||||||
tournamentRow?.scrollIntoView({ behavior: "smooth" });
|
tournamentRow?.scrollIntoView({ behavior: "smooth" });
|
||||||
}, [debouncedHoveredMapId, isLg]);
|
}, [debouncedHoveredMapId, isLg]);
|
||||||
@@ -80,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={{
|
||||||
@@ -94,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
|
||||||
@@ -112,9 +111,7 @@ const TournamentTable = () => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex justify-center" ref={datePickerRef}>
|
<div className="flex justify-center" ref={datePickerRef}>
|
||||||
{datePickerIsOpen && (
|
{datePickerIsOpen && <DatePicker datePickerDirection={dateDirectionState} />}
|
||||||
<DatePicker datePickerDirection={dateDirectionState} />
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="overflow-x-scroll">
|
<div className="overflow-x-scroll">
|
||||||
@@ -156,23 +153,15 @@ const TournamentTable = () => {
|
|||||||
onMouseLeave={() => setHoveredListId(null)}
|
onMouseLeave={() => setHoveredListId(null)}
|
||||||
className={twMerge(
|
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",
|
"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 &&
|
hoveredMapId === tournament.groupId && "bg-gray-200 dark:bg-gray-900",
|
||||||
"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">
|
<td className="px-1 py-2 sm:px-3 sm:py-3 lg:px-3 lg:py-3">{tournament.date}</td>
|
||||||
{tournament.date}
|
<td className="px-1 py-2 sm:px-3 sm:py-3 lg:px-3 lg:py-3">{tournament.town}</td>
|
||||||
</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">
|
<td className="px-1 py-2 text-left sm:px-3 sm:py-3 lg:px-3 lg:py-3">
|
||||||
<span>
|
<span>
|
||||||
{tournament.norm && (
|
{tournament.norm && (
|
||||||
<FaTrophy
|
<FaTrophy className="mr-2 inline-block h-4 w-4" data-norm="norm" />
|
||||||
className="mr-2 inline-block h-4 w-4"
|
|
||||||
data-norm="norm"
|
|
||||||
/>
|
|
||||||
)}
|
)}
|
||||||
{tournament.tournament}
|
{tournament.tournament}
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
@@ -22,9 +22,7 @@ const TournamentMap = dynamic(() => import("./TournamentMap"), {
|
|||||||
loading: LoadingMap,
|
loading: LoadingMap,
|
||||||
});
|
});
|
||||||
|
|
||||||
export default function TournamentsDisplay({
|
export default function TournamentsDisplay({ tournaments }: TournamentsDisplayProps) {
|
||||||
tournaments,
|
|
||||||
}: TournamentsDisplayProps) {
|
|
||||||
useHydrateAtoms([[tournamentsAtom, tournaments]]);
|
useHydrateAtoms([[tournamentsAtom, tournaments]]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,9 +1,4 @@
|
|||||||
import {
|
import { differenceInDays, isSameDay, parse, setDefaultOptions } from "date-fns";
|
||||||
differenceInDays,
|
|
||||||
isSameDay,
|
|
||||||
parse,
|
|
||||||
setDefaultOptions,
|
|
||||||
} from "date-fns";
|
|
||||||
import { fr } from "date-fns/locale";
|
import { fr } from "date-fns/locale";
|
||||||
import { groupBy } from "lodash";
|
import { groupBy } from "lodash";
|
||||||
import { Metadata } from "next";
|
import { Metadata } from "next";
|
||||||
@@ -12,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";
|
||||||
@@ -27,10 +22,7 @@ export async function generateMetadata({
|
|||||||
const { locale } = await params;
|
const { locale } = await params;
|
||||||
return {
|
return {
|
||||||
alternates: {
|
alternates: {
|
||||||
canonical:
|
canonical: locale === "fr" ? `${baseUrl}/tournois` : `${baseUrl}/${locale}/tournaments`,
|
||||||
locale === "fr"
|
|
||||||
? `${baseUrl}/tournois`
|
|
||||||
: `${baseUrl}/${locale}/tournaments`,
|
|
||||||
languages: {
|
languages: {
|
||||||
fr: `${baseUrl}/tournois`,
|
fr: `${baseUrl}/tournois`,
|
||||||
en: `${baseUrl}/en/tournaments`,
|
en: `${baseUrl}/en/tournaments`,
|
||||||
@@ -73,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));
|
||||||
|
|
||||||
@@ -101,17 +93,14 @@ 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());
|
||||||
const goodData = data.filter((t) => !badIds.includes(t._id.toString()));
|
const goodData = data.filter((t) => !badIds.includes(t._id.toString()));
|
||||||
|
|
||||||
// Group the tournaments by their location
|
// Group the tournaments by their location
|
||||||
const groupedByLocation = groupBy(
|
const groupedByLocation = groupBy(goodData, (t) => `${t.coordinates[0]}_${t.coordinates[1]}`);
|
||||||
goodData,
|
|
||||||
(t) => `${t.coordinates[0]}_${t.coordinates[1]}`,
|
|
||||||
);
|
|
||||||
|
|
||||||
// For each location, create an array of arrays of contiguous dates for this location
|
// For each location, create an array of arrays of contiguous dates for this location
|
||||||
const dateRangesByLocation: Record<string, Date[][]> = {};
|
const dateRangesByLocation: Record<string, Date[][]> = {};
|
||||||
@@ -119,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());
|
||||||
@@ -133,23 +122,24 @@ const getTournaments = async () => {
|
|||||||
},
|
},
|
||||||
[[]],
|
[[]],
|
||||||
);
|
);
|
||||||
|
|
||||||
dateRangesByLocation[location] = dateRanges;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return goodData.map<Tournament>((t) => {
|
return goodData.map<Tournament>((t) => {
|
||||||
const location = `${t.coordinates[0]}_${t.coordinates[1]}`;
|
const location = `${t.coordinates[0]}_${t.coordinates[1]}`;
|
||||||
const date = parse(t.date, "dd/MM/yyyy", new Date());
|
const date = parse(t.date, "dd/MM/yyyy", new Date());
|
||||||
const dateRanges = dateRangesByLocation[location];
|
const dateRanges = dateRangesByLocation[location];
|
||||||
const rangeIndex = dateRanges.findIndex((ranges) =>
|
const rangeIndex = dateRanges.findIndex((ranges) => ranges.some((d) => isSameDay(d, date)));
|
||||||
ranges.some((d) => isSameDay(d, date)),
|
|
||||||
);
|
|
||||||
|
|
||||||
// We place each tournament into a group based on location and date and time control, so that
|
// We place each tournament into a group based on location and date and time control, so that
|
||||||
// we can display a single map marker.
|
// we can display a single map marker.
|
||||||
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,
|
||||||
@@ -164,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) {
|
||||||
@@ -175,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}
|
||||||
|
|||||||
@@ -46,11 +46,7 @@ const CreateZone = () => {
|
|||||||
{t("createTitle")}
|
{t("createTitle")}
|
||||||
</h2>
|
</h2>
|
||||||
|
|
||||||
<ZoneForm
|
<ZoneForm withInfo onSubmit={onSubmit} onCancel={() => router.push("/zones")} />
|
||||||
withInfo
|
|
||||||
onSubmit={onSubmit}
|
|
||||||
onCancel={() => router.push("/zones")}
|
|
||||||
/>
|
|
||||||
|
|
||||||
{responseMessage && (
|
{responseMessage && (
|
||||||
<InfoMessage
|
<InfoMessage
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ const EditZone = () => {
|
|||||||
|
|
||||||
await refetch();
|
await refetch();
|
||||||
router.push("/zones");
|
router.push("/zones");
|
||||||
} catch (error) {
|
} catch {
|
||||||
setResponseMessage({
|
setResponseMessage({
|
||||||
type: "error",
|
type: "error",
|
||||||
message: t("createFailure"),
|
message: t("createFailure"),
|
||||||
@@ -66,11 +66,7 @@ const EditZone = () => {
|
|||||||
{t("editTitle")}
|
{t("editTitle")}
|
||||||
</h2>
|
</h2>
|
||||||
|
|
||||||
<ZoneForm
|
<ZoneForm onSubmit={onSubmit} onCancel={() => router.push("/zones")} zone={zone} />
|
||||||
onSubmit={onSubmit}
|
|
||||||
onCancel={() => router.push("/zones")}
|
|
||||||
zone={zone}
|
|
||||||
/>
|
|
||||||
|
|
||||||
{responseMessage && (
|
{responseMessage && (
|
||||||
<InfoMessage
|
<InfoMessage
|
||||||
|
|||||||
@@ -160,11 +160,7 @@ const Zones = () => {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
<div className="flex items-center justify-between space-x-4 text-sm font-bold">
|
<div className="flex items-center justify-between space-x-4 text-sm font-bold">
|
||||||
<Button
|
<Button intent="secondary" type="button" onClick={() => setDeletingZoneId(null)}>
|
||||||
intent="secondary"
|
|
||||||
type="button"
|
|
||||||
onClick={() => setDeletingZoneId(null)}
|
|
||||||
>
|
|
||||||
{at("cancelButton")}
|
{at("cancelButton")}
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
|
|||||||
@@ -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";
|
||||||
@@ -20,11 +20,7 @@ const title = Julius_Sans_One({
|
|||||||
variable: "--font-title",
|
variable: "--font-title",
|
||||||
});
|
});
|
||||||
|
|
||||||
export async function generateMetadata({
|
export async function generateMetadata({ params }: { params: Promise<{ locale?: string }> }) {
|
||||||
params,
|
|
||||||
}: {
|
|
||||||
params: Promise<{ locale?: string }>;
|
|
||||||
}) {
|
|
||||||
// While the `locale` is required, the namespace is optional and
|
// While the `locale` is required, the namespace is optional and
|
||||||
// identical to the parameter that `useTranslations` accepts.
|
// identical to the parameter that `useTranslations` accepts.
|
||||||
const { locale } = await params;
|
const { locale } = await params;
|
||||||
@@ -58,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();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,18 +45,11 @@ export default function Home() {
|
|||||||
>
|
>
|
||||||
{t("title")}
|
{t("title")}
|
||||||
</h1>
|
</h1>
|
||||||
<p className={twMerge("text-sm", "sm:text-lg", "md:text-xl")}>
|
<p className={twMerge("text-sm", "sm:text-lg", "md:text-xl")}>{t("purpose")}</p>
|
||||||
{t("purpose")}
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="absolute -bottom-[2px] w-full text-white dark:text-gray-800">
|
<div className="absolute -bottom-[2px] w-full text-white dark:text-gray-800">
|
||||||
<svg
|
<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="auto" viewBox="0 0 1440 128">
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
width="100%"
|
|
||||||
height="auto"
|
|
||||||
viewBox="0 0 1440 128"
|
|
||||||
>
|
|
||||||
<path
|
<path
|
||||||
fill="currentColor"
|
fill="currentColor"
|
||||||
d="M0,471 L1440,471 L1440,386.338583 C1331.33333,357.446194 1239,343 1163,343 C821.995497,343 821.995497,463.944882 426,463.944882 C262.447846,463.944882 120.447846,438.076115 0,386.338583 L0,471 Z"
|
d="M0,471 L1440,471 L1440,386.338583 C1331.33333,357.446194 1239,343 1163,343 C821.995497,343 821.995497,463.944882 426,463.944882 C262.447846,463.944882 120.447846,438.076115 0,386.338583 L0,471 Z"
|
||||||
@@ -85,9 +78,7 @@ export default function Home() {
|
|||||||
<div className="flex items-center justify-center text-5xl">
|
<div className="flex items-center justify-center text-5xl">
|
||||||
<GiTrophyCup />
|
<GiTrophyCup />
|
||||||
</div>
|
</div>
|
||||||
<h2 className="text-center text-2xl font-semibold">
|
<h2 className="text-center text-2xl font-semibold">{t("tournamentsTitle")}</h2>
|
||||||
{t("tournamentsTitle")}
|
|
||||||
</h2>
|
|
||||||
|
|
||||||
<p className="">{t("tournamentsInfo")}</p>
|
<p className="">{t("tournamentsInfo")}</p>
|
||||||
|
|
||||||
@@ -110,9 +101,7 @@ export default function Home() {
|
|||||||
<div className="flex items-center justify-center text-5xl">
|
<div className="flex items-center justify-center text-5xl">
|
||||||
<HiUserGroup />
|
<HiUserGroup />
|
||||||
</div>
|
</div>
|
||||||
<h2 className="text-center text-2xl font-semibold">
|
<h2 className="text-center text-2xl font-semibold">{t("clubsTitle")}</h2>
|
||||||
{t("clubsTitle")}
|
|
||||||
</h2>
|
|
||||||
<p className="">{t("clubsInfo")}</p>
|
<p className="">{t("clubsInfo")}</p>
|
||||||
|
|
||||||
<Link
|
<Link
|
||||||
@@ -134,9 +123,7 @@ export default function Home() {
|
|||||||
<div className="flex items-center justify-center text-5xl">
|
<div className="flex items-center justify-center text-5xl">
|
||||||
<GrLineChart />
|
<GrLineChart />
|
||||||
</div>
|
</div>
|
||||||
<h2 className="text-center text-2xl font-semibold">
|
<h2 className="text-center text-2xl font-semibold">{t("eloTitle")}</h2>
|
||||||
{t("eloTitle")}
|
|
||||||
</h2>
|
|
||||||
<p className="">{t("eloInfo")}</p>
|
<p className="">{t("eloInfo")}</p>
|
||||||
|
|
||||||
<Link
|
<Link
|
||||||
|
|||||||
+1
-3
@@ -4,9 +4,7 @@ import { Pathnames, routing } from "@/utils/routing";
|
|||||||
|
|
||||||
export default function sitemap(): MetadataRoute.Sitemap {
|
export default function sitemap(): MetadataRoute.Sitemap {
|
||||||
return routing.locales.flatMap((locale) => {
|
return routing.locales.flatMap((locale) => {
|
||||||
const prefix = `https://echecsfrance.com${
|
const prefix = `https://echecsfrance.com${locale === "fr" ? "" : `/${locale}`}`;
|
||||||
locale === "fr" ? "" : `/${locale}`
|
|
||||||
}`;
|
|
||||||
|
|
||||||
const paths = Object.keys(routing.pathnames) as Array<Pathnames>;
|
const paths = Object.keys(routing.pathnames) as Array<Pathnames>;
|
||||||
|
|
||||||
|
|||||||
+30
-55
@@ -1,20 +1,7 @@
|
|||||||
import booleanPointInPolygon from "@turf/boolean-point-in-polygon";
|
import booleanPointInPolygon from "@turf/boolean-point-in-polygon";
|
||||||
import {
|
import { endOfDay, isAfter, isBefore, parse, setDefaultOptions, startOfDay } from "date-fns";
|
||||||
endOfDay,
|
|
||||||
isAfter,
|
|
||||||
isBefore,
|
|
||||||
parse,
|
|
||||||
setDefaultOptions,
|
|
||||||
startOfDay,
|
|
||||||
} from "date-fns";
|
|
||||||
import { fr } from "date-fns/locale";
|
import { fr } from "date-fns/locale";
|
||||||
import {
|
import { Feature, FeatureCollection, GeoJsonProperties, MultiPolygon, Polygon } from "geojson";
|
||||||
Feature,
|
|
||||||
FeatureCollection,
|
|
||||||
GeoJsonProperties,
|
|
||||||
MultiPolygon,
|
|
||||||
Polygon,
|
|
||||||
} from "geojson";
|
|
||||||
import { atom } from "jotai";
|
import { atom } from "jotai";
|
||||||
import { LatLngBounds } from "leaflet";
|
import { LatLngBounds } from "leaflet";
|
||||||
|
|
||||||
@@ -54,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);
|
||||||
@@ -61,13 +51,14 @@ export const otherAtom = atom(true);
|
|||||||
|
|
||||||
export const clubsAtom = atom<Club[]>([]);
|
export const clubsAtom = atom<Club[]>([]);
|
||||||
|
|
||||||
export const {
|
export const { currentValueAtom: hoveredMapIdAtom, debouncedValueAtom: debouncedHoveredMapIdAtom } =
|
||||||
currentValueAtom: hoveredMapIdAtom,
|
atomWithDebounce<string | null>(null);
|
||||||
debouncedValueAtom: debouncedHoveredMapIdAtom,
|
|
||||||
} = atomWithDebounce<string | null>(null);
|
|
||||||
|
|
||||||
export const { debouncedValueAtom: debouncedHoveredListIdAtom } =
|
export const { debouncedValueAtom: debouncedHoveredListIdAtom } = atomWithDebounce<string | null>(
|
||||||
atomWithDebounce<string | null>(null, 1000, 100);
|
null,
|
||||||
|
1000,
|
||||||
|
100,
|
||||||
|
);
|
||||||
|
|
||||||
export const filteredTournamentsByTimeControlAndZoneAtom = atom((get) => {
|
export const filteredTournamentsByTimeControlAndZoneAtom = atom((get) => {
|
||||||
const tournaments = get(tournamentsAtom);
|
const tournaments = get(tournamentsAtom);
|
||||||
@@ -81,16 +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(
|
const tournamentDate = startOfDay(parse(tournament.date, "dd/MM/yyyy", new Date()));
|
||||||
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) ||
|
||||||
@@ -98,11 +96,7 @@ export const filteredTournamentsByTimeControlAndZoneAtom = atom((get) => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (
|
if (regionFilter === "all" || regionFilter === "map" || regionFilter === "region")
|
||||||
regionFilter === "all" ||
|
|
||||||
regionFilter === "map" ||
|
|
||||||
regionFilter === "region"
|
|
||||||
)
|
|
||||||
return filterByTimeControl;
|
return filterByTimeControl;
|
||||||
|
|
||||||
if (isFeature(regionFilter)) {
|
if (isFeature(regionFilter)) {
|
||||||
@@ -118,10 +112,7 @@ export const filteredTournamentsByTimeControlAndZoneAtom = atom((get) => {
|
|||||||
return regionFilter.features?.features?.some(
|
return regionFilter.features?.features?.some(
|
||||||
(feature) =>
|
(feature) =>
|
||||||
feature.geometry.type === "Polygon" &&
|
feature.geometry.type === "Polygon" &&
|
||||||
booleanPointInPolygon(
|
booleanPointInPolygon([tournament.latLng.lng, tournament.latLng.lat], feature.geometry),
|
||||||
[tournament.latLng.lng, tournament.latLng.lat],
|
|
||||||
feature.geometry,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -133,16 +124,13 @@ export const filteredTournamentsListAtom = atom((get) => {
|
|||||||
const normsOnly = get(normsOnlyAtom);
|
const normsOnly = get(normsOnlyAtom);
|
||||||
const searchString = get(searchStringAtom).trim();
|
const searchString = get(searchStringAtom).trim();
|
||||||
|
|
||||||
const filteredByNorm = normsOnly
|
const filteredByNorm = normsOnly ? tournaments.filter((t) => t.norm) : tournaments;
|
||||||
? tournaments.filter((t) => t.norm)
|
|
||||||
: tournaments;
|
|
||||||
|
|
||||||
// When searching, we search all the tournament, regardless of the map display
|
// When searching, we search all the tournament, regardless of the map display
|
||||||
if (searchString !== "") {
|
if (searchString !== "") {
|
||||||
return filteredByNorm.filter(
|
return filteredByNorm.filter(
|
||||||
(t) =>
|
(t) =>
|
||||||
normalizedContains(t.town, searchString) ||
|
normalizedContains(t.town, searchString) || normalizedContains(t.tournament, searchString),
|
||||||
normalizedContains(t.tournament, searchString),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -150,28 +138,18 @@ export const filteredTournamentsListAtom = atom((get) => {
|
|||||||
if (mapBounds === null || regionFilter !== "map") return filteredByNorm;
|
if (mapBounds === null || regionFilter !== "map") return filteredByNorm;
|
||||||
|
|
||||||
// Filter by the map bounds
|
// Filter by the map bounds
|
||||||
return filteredByNorm.filter((tournament) =>
|
return filteredByNorm.filter((tournament) => mapBounds.contains(tournament.latLng));
|
||||||
mapBounds.contains(tournament.latLng),
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export const filteredClubsByZoneAtom = atom((get) => {
|
export const filteredClubsByZoneAtom = atom((get) => {
|
||||||
const clubs = get(clubsAtom);
|
const clubs = get(clubsAtom);
|
||||||
const regionFilter = get(regionFilterAtom);
|
const regionFilter = get(regionFilterAtom);
|
||||||
|
|
||||||
if (
|
if (regionFilter === "all" || regionFilter === "map" || regionFilter === "region") return clubs;
|
||||||
regionFilter === "all" ||
|
|
||||||
regionFilter === "map" ||
|
|
||||||
regionFilter === "region"
|
|
||||||
)
|
|
||||||
return clubs;
|
|
||||||
|
|
||||||
if (isFeature(regionFilter)) {
|
if (isFeature(regionFilter)) {
|
||||||
return clubs.filter((club) => {
|
return clubs.filter((club) => {
|
||||||
return booleanPointInPolygon(
|
return booleanPointInPolygon([club.latLng.lng, club.latLng.lat], regionFilter.geometry);
|
||||||
[club.latLng.lng, club.latLng.lat],
|
|
||||||
regionFilter.geometry,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -179,10 +157,7 @@ export const filteredClubsByZoneAtom = atom((get) => {
|
|||||||
return regionFilter.features?.features?.some(
|
return regionFilter.features?.features?.some(
|
||||||
(feature) =>
|
(feature) =>
|
||||||
feature.geometry.type === "Polygon" &&
|
feature.geometry.type === "Polygon" &&
|
||||||
booleanPointInPolygon(
|
booleanPointInPolygon([club.latLng.lng, club.latLng.lat], feature.geometry),
|
||||||
[club.latLng.lng, club.latLng.lat],
|
|
||||||
feature.geometry,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
|
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";
|
||||||
|
|
||||||
export const buttonVariants = cva(
|
export const buttonVariants = cva("flex items-center justify-center transition-all duration-200", {
|
||||||
"flex items-center justify-center transition-all duration-200",
|
|
||||||
{
|
|
||||||
variants: {
|
variants: {
|
||||||
intent: {
|
intent: {
|
||||||
primary: [
|
primary: [
|
||||||
@@ -42,11 +41,10 @@ export const buttonVariants = cva(
|
|||||||
intent: "primary",
|
intent: "primary",
|
||||||
size: "medium",
|
size: "medium",
|
||||||
},
|
},
|
||||||
},
|
});
|
||||||
);
|
|
||||||
|
|
||||||
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,
|
||||||
@@ -54,8 +52,5 @@ export const Button = ({
|
|||||||
size,
|
size,
|
||||||
...props
|
...props
|
||||||
}: ButtonProps & { className?: string }) => (
|
}: ButtonProps & { className?: string }) => (
|
||||||
<button
|
<button className={twMerge(buttonVariants({ intent, size, className }))} {...props} />
|
||||||
className={twMerge(buttonVariants({ intent, size, className }))}
|
|
||||||
{...props}
|
|
||||||
/>
|
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -17,11 +17,7 @@ type DropdownMenuProps = {
|
|||||||
containerClassName?: string;
|
containerClassName?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const DropdownMenu = ({
|
export const DropdownMenu = ({ items, buttonComponent, containerClassName }: DropdownMenuProps) => {
|
||||||
items,
|
|
||||||
buttonComponent,
|
|
||||||
containerClassName,
|
|
||||||
}: DropdownMenuProps) => {
|
|
||||||
return (
|
return (
|
||||||
<Menu as="div" className={twMerge("relative", containerClassName)}>
|
<Menu as="div" className={twMerge("relative", containerClassName)}>
|
||||||
{buttonComponent ?? (
|
{buttonComponent ?? (
|
||||||
|
|||||||
@@ -1,11 +1,6 @@
|
|||||||
import { type ReactNode } from "react";
|
import { type ReactNode } from "react";
|
||||||
|
|
||||||
import {
|
import { HiCheckCircle, HiInformationCircle, HiXCircle, HiXMark } from "react-icons/hi2";
|
||||||
HiCheckCircle,
|
|
||||||
HiInformationCircle,
|
|
||||||
HiXCircle,
|
|
||||||
HiXMark,
|
|
||||||
} from "react-icons/hi2";
|
|
||||||
import { twMerge } from "tailwind-merge";
|
import { twMerge } from "tailwind-merge";
|
||||||
|
|
||||||
export type InfoMessageType = "success" | "error" | "info";
|
export type InfoMessageType = "success" | "error" | "info";
|
||||||
@@ -74,11 +69,7 @@ const InfoMessage = ({
|
|||||||
button,
|
button,
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<HiXMark
|
<HiXMark aria-hidden="true" className="h-5 w-5" onClick={onDismiss} />
|
||||||
aria-hidden="true"
|
|
||||||
className="h-5 w-5"
|
|
||||||
onClick={onDismiss}
|
|
||||||
/>
|
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -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 />
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useEffect } from "react";
|
import { useEffect, type ReactNode } from "react";
|
||||||
|
|
||||||
import { useSession } from "next-auth/react";
|
import { useSession } from "next-auth/react";
|
||||||
import { useLocale } from "next-intl";
|
import { useLocale } from "next-intl";
|
||||||
@@ -10,11 +10,11 @@ import { setUserLocale } from "@/server/setUserLocale";
|
|||||||
import { usePathname, useRouter } from "@/utils/routing";
|
import { usePathname, useRouter } from "@/utils/routing";
|
||||||
|
|
||||||
type LocaleCheckerProps = {
|
type LocaleCheckerProps = {
|
||||||
children?: React.ReactNode;
|
children?: ReactNode;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const LocaleChecker = ({ children }: LocaleCheckerProps) => {
|
export const LocaleChecker = ({ children }: LocaleCheckerProps) => {
|
||||||
const { data: sessionData, status, update } = useSession();
|
const { data: sessionData, status } = useSession();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const pathname = usePathname();
|
const pathname = usePathname();
|
||||||
const params = useParams();
|
const params = useParams();
|
||||||
@@ -30,23 +30,14 @@ export const LocaleChecker = ({ children }: LocaleCheckerProps) => {
|
|||||||
|
|
||||||
// If the user is authenticated and has a preferred locale that is different from the user's locale,
|
// If the user is authenticated and has a preferred locale that is different from the user's locale,
|
||||||
// then we update redirect to the user's preference
|
// then we update redirect to the user's preference
|
||||||
if (
|
if (status === "authenticated" && userLocale !== undefined && userLocale !== locale) {
|
||||||
status === "authenticated" &&
|
|
||||||
userLocale !== undefined &&
|
|
||||||
userLocale !== locale
|
|
||||||
) {
|
|
||||||
router.push({ pathname, params: params as any }, { locale: userLocale });
|
router.push({ pathname, params: params as any }, { locale: userLocale });
|
||||||
}
|
}
|
||||||
}, [locale, sessionData, status, params, pathname, router, userLocale]);
|
}, [locale, sessionData, status, params, pathname, router, userLocale]);
|
||||||
|
|
||||||
// To avoid flickering, we don't render the children until we have the user's locale
|
// To avoid flickering, we don't render the children until we have the user's locale
|
||||||
if (status === "loading") return null;
|
if (status === "loading") return null;
|
||||||
if (
|
if (status === "authenticated" && userLocale !== undefined && userLocale !== locale) return null;
|
||||||
status === "authenticated" &&
|
|
||||||
userLocale !== undefined &&
|
|
||||||
userLocale !== locale
|
|
||||||
)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return children;
|
return children;
|
||||||
};
|
};
|
||||||
|
|||||||
+7
-25
@@ -59,12 +59,7 @@ type MapProps = {
|
|||||||
iconCreateFunction?: L.MarkerClusterGroupOptions["iconCreateFunction"];
|
iconCreateFunction?: L.MarkerClusterGroupOptions["iconCreateFunction"];
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Map = ({
|
export const Map = ({ filters, legend, markers, iconCreateFunction }: MapProps) => {
|
||||||
filters,
|
|
||||||
legend,
|
|
||||||
markers,
|
|
||||||
iconCreateFunction,
|
|
||||||
}: MapProps) => {
|
|
||||||
const setMapBounds = useSetAtom(mapBoundsAtom);
|
const setMapBounds = useSetAtom(mapBoundsAtom);
|
||||||
|
|
||||||
const hoveredListTournamentId = useAtomValue(debouncedHoveredListIdAtom);
|
const hoveredListTournamentId = useAtomValue(debouncedHoveredListIdAtom);
|
||||||
@@ -82,17 +77,13 @@ export const Map = ({
|
|||||||
|
|
||||||
const expandAndBounceIfNeeded = useCallback(() => {
|
const expandAndBounceIfNeeded = useCallback(() => {
|
||||||
if (hoveredListTournamentId) {
|
if (hoveredListTournamentId) {
|
||||||
const marker = markers.find((m) =>
|
const marker = markers.find((m) => m.tableIds.includes(hoveredListTournamentId));
|
||||||
m.tableIds.includes(hoveredListTournamentId),
|
|
||||||
);
|
|
||||||
|
|
||||||
if (marker) {
|
if (marker) {
|
||||||
const markerRef = markerRefs.current[marker.markerId];
|
const markerRef = markerRefs.current[marker.markerId];
|
||||||
if (markerRef) {
|
if (markerRef) {
|
||||||
if (clusterRef.current) {
|
if (clusterRef.current) {
|
||||||
const visibleMarker = clusterRef.current.getVisibleParent(
|
const visibleMarker = clusterRef.current.getVisibleParent(markerRef.getMarker());
|
||||||
markerRef.getMarker(),
|
|
||||||
);
|
|
||||||
if (!visibleMarker) return;
|
if (!visibleMarker) return;
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
@@ -140,9 +131,7 @@ export const Map = ({
|
|||||||
// Once expanded, bounce the appropriate marker
|
// Once expanded, bounce the appropriate marker
|
||||||
|
|
||||||
if (hoveredListTournamentId) {
|
if (hoveredListTournamentId) {
|
||||||
const marker = markers.find((m) =>
|
const marker = markers.find((m) => m.tableIds.includes(hoveredListTournamentId));
|
||||||
m.tableIds.includes(hoveredListTournamentId),
|
|
||||||
);
|
|
||||||
if (!marker) return;
|
if (!marker) return;
|
||||||
|
|
||||||
expandedClusterMarkerRef.current = e.cluster;
|
expandedClusterMarkerRef.current = e.cluster;
|
||||||
@@ -159,8 +148,7 @@ export const Map = ({
|
|||||||
|
|
||||||
const onUnSpiderified = useCallback(
|
const onUnSpiderified = useCallback(
|
||||||
(e: L.MarkerClusterSpiderfyEvent) => {
|
(e: L.MarkerClusterSpiderfyEvent) => {
|
||||||
if (expandedClusterMarkerRef.current === e.cluster)
|
if (expandedClusterMarkerRef.current === e.cluster) expandedClusterMarkerRef.current = null;
|
||||||
expandedClusterMarkerRef.current = null;
|
|
||||||
|
|
||||||
// Once closed, we can expand the next group if needed
|
// Once closed, we can expand the next group if needed
|
||||||
expandAndBounceIfNeeded();
|
expandAndBounceIfNeeded();
|
||||||
@@ -188,8 +176,7 @@ export const Map = ({
|
|||||||
// Expand/contract as hoveredListTournamentId changes
|
// Expand/contract as hoveredListTournamentId changes
|
||||||
if (expandAndBounceIfNeeded()) return;
|
if (expandAndBounceIfNeeded()) return;
|
||||||
|
|
||||||
if (expandedClusterMarkerRef.current)
|
if (expandedClusterMarkerRef.current) expandedClusterMarkerRef.current.unspiderfy();
|
||||||
expandedClusterMarkerRef.current.unspiderfy();
|
|
||||||
}, [expandAndBounceIfNeeded, hoveredListTournamentId]);
|
}, [expandAndBounceIfNeeded, hoveredListTournamentId]);
|
||||||
|
|
||||||
const referencedMarkers = useMemo(
|
const referencedMarkers = useMemo(
|
||||||
@@ -247,12 +234,7 @@ export const Map = ({
|
|||||||
</MapContainer>
|
</MapContainer>
|
||||||
|
|
||||||
<div className="flex items-center justify-center lg:hidden">
|
<div className="flex items-center justify-center lg:hidden">
|
||||||
<Button
|
<Button intent="tertiary" size="compacted" className="p-3" onClick={onScrollToTable}>
|
||||||
intent="tertiary"
|
|
||||||
size="compacted"
|
|
||||||
className="p-3"
|
|
||||||
onClick={onScrollToTable}
|
|
||||||
>
|
|
||||||
<FaAngleDoubleDown />
|
<FaAngleDoubleDown />
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -14,10 +14,7 @@ import { mapBoundsAtom } from "@/atoms";
|
|||||||
L.Map.addInitHook("addHandler", "gestureHandling", GestureHandling);
|
L.Map.addInitHook("addHandler", "gestureHandling", GestureHandling);
|
||||||
|
|
||||||
const worldBounds = L.latLngBounds(L.latLng(-90, -180), L.latLng(90, 180));
|
const worldBounds = L.latLngBounds(L.latLng(-90, -180), L.latLng(90, 180));
|
||||||
const franceBounds = L.latLngBounds(
|
const franceBounds = L.latLngBounds(L.latLng(42.08, -5.12), L.latLng(51.17, 9.53));
|
||||||
L.latLng(42.08, -5.12),
|
|
||||||
L.latLng(51.17, 9.53),
|
|
||||||
);
|
|
||||||
|
|
||||||
type MapEventsProps = {
|
type MapEventsProps = {
|
||||||
bounds?: L.LatLngBounds;
|
bounds?: L.LatLngBounds;
|
||||||
@@ -32,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;
|
||||||
@@ -49,17 +46,12 @@ 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]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (
|
if ("gestureHandlingOptions" in map.options && map.options.gestureHandlingOptions) {
|
||||||
"gestureHandlingOptions" in map.options &&
|
|
||||||
map.options.gestureHandlingOptions
|
|
||||||
) {
|
|
||||||
map.options.gestureHandlingOptions.text = {
|
map.options.gestureHandlingOptions.text = {
|
||||||
touch: t("touch"),
|
touch: t("touch"),
|
||||||
scroll: t("scroll"),
|
scroll: t("scroll"),
|
||||||
|
|||||||
@@ -30,12 +30,7 @@ export const Modal = ({
|
|||||||
...dialogProps
|
...dialogProps
|
||||||
}: ModalProps) => (
|
}: ModalProps) => (
|
||||||
<Transition appear show={open} as={Fragment}>
|
<Transition appear show={open} as={Fragment}>
|
||||||
<Dialog
|
<Dialog as="div" className="relative z-[2000]" onClose={onClose} {...dialogProps}>
|
||||||
as="div"
|
|
||||||
className="relative z-[2000]"
|
|
||||||
onClose={onClose}
|
|
||||||
{...dialogProps}
|
|
||||||
>
|
|
||||||
<Transition.Child
|
<Transition.Child
|
||||||
as={Fragment}
|
as={Fragment}
|
||||||
enter="ease-out duration-300"
|
enter="ease-out duration-300"
|
||||||
@@ -45,9 +40,7 @@ export const Modal = ({
|
|||||||
leaveFrom="opacity-100"
|
leaveFrom="opacity-100"
|
||||||
leaveTo="opacity-0"
|
leaveTo="opacity-0"
|
||||||
>
|
>
|
||||||
<div
|
<div className={twMerge("fixed inset-0 bg-neutral-900/50", overlayClass)} />
|
||||||
className={twMerge("fixed inset-0 bg-neutral-900/50", overlayClass)}
|
|
||||||
/>
|
|
||||||
</Transition.Child>
|
</Transition.Child>
|
||||||
|
|
||||||
<div className="fixed inset-0 overflow-y-auto">
|
<div className="fixed inset-0 overflow-y-auto">
|
||||||
|
|||||||
@@ -22,10 +22,7 @@ type RegionSelectProps = Omit<
|
|||||||
type RegionOption = BaseOption<string, Zone | null>;
|
type RegionOption = BaseOption<string, Zone | null>;
|
||||||
type GroupedOption = GroupBase<RegionOption>;
|
type GroupedOption = GroupBase<RegionOption>;
|
||||||
|
|
||||||
export const RegionSelect = ({
|
export const RegionSelect = ({ syncTitle, ...selectProps }: RegionSelectProps) => {
|
||||||
syncTitle,
|
|
||||||
...selectProps
|
|
||||||
}: RegionSelectProps) => {
|
|
||||||
const t = useTranslations("Zones");
|
const t = useTranslations("Zones");
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const [regionFilter, setRegionFilter] = useAtom(regionFilterAtom);
|
const [regionFilter, setRegionFilter] = useAtom(regionFilterAtom);
|
||||||
@@ -67,9 +64,7 @@ export const RegionSelect = ({
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const onChange = (
|
const onChange = (option: OnChangeValue<BaseOption<string, Zone | null>, false>) => {
|
||||||
option: OnChangeValue<BaseOption<string, Zone | null>, false>,
|
|
||||||
) => {
|
|
||||||
if (!option) return;
|
if (!option) return;
|
||||||
|
|
||||||
if (option.value === "create") {
|
if (option.value === "create") {
|
||||||
@@ -114,11 +109,7 @@ export const RegionSelect = ({
|
|||||||
);
|
);
|
||||||
|
|
||||||
const getValue = () => {
|
const getValue = () => {
|
||||||
if (
|
if (regionFilter === "all" || regionFilter === "map" || regionFilter === "region") {
|
||||||
regionFilter === "all" ||
|
|
||||||
regionFilter === "map" ||
|
|
||||||
regionFilter === "region"
|
|
||||||
) {
|
|
||||||
return allOptions.find((o) => o.value === regionFilter);
|
return allOptions.find((o) => o.value === regionFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,6 @@
|
|||||||
import type { Dispatch, SetStateAction } from "react";
|
import type { Dispatch, SetStateAction } from "react";
|
||||||
|
|
||||||
import {
|
import { type Feature, GeoJsonProperties, MultiPolygon, Polygon } from "geojson";
|
||||||
type Feature,
|
|
||||||
GeoJsonProperties,
|
|
||||||
MultiPolygon,
|
|
||||||
Polygon,
|
|
||||||
} from "geojson";
|
|
||||||
import { useSetAtom } from "jotai";
|
import { useSetAtom } from "jotai";
|
||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
import { IoClose } from "react-icons/io5";
|
import { IoClose } from "react-icons/io5";
|
||||||
@@ -20,10 +15,7 @@ interface IProps {
|
|||||||
setIsRegionModalOpen: Dispatch<SetStateAction<boolean>>;
|
setIsRegionModalOpen: Dispatch<SetStateAction<boolean>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const RegionSelectModal = ({
|
export const RegionSelectModal = ({ isRegionModalOpen, setIsRegionModalOpen }: IProps) => {
|
||||||
isRegionModalOpen,
|
|
||||||
setIsRegionModalOpen,
|
|
||||||
}: IProps) => {
|
|
||||||
const t = useTranslations("Zones");
|
const t = useTranslations("Zones");
|
||||||
const setRegionFilter = useSetAtom(regionFilterAtom);
|
const setRegionFilter = useSetAtom(regionFilterAtom);
|
||||||
|
|
||||||
@@ -32,13 +24,9 @@ export const RegionSelectModal = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleRegionSelect = (region: string) => {
|
const handleRegionSelect = (region: string) => {
|
||||||
const regionData = regionGeoJson.features.find(
|
const regionData = regionGeoJson.features.find((f) => f.properties.nom === region);
|
||||||
(f) => f.properties.nom === region,
|
|
||||||
);
|
|
||||||
if (regionData) {
|
if (regionData) {
|
||||||
setRegionFilter(
|
setRegionFilter(regionData as Feature<Polygon | MultiPolygon, GeoJsonProperties>);
|
||||||
regionData as Feature<Polygon | MultiPolygon, GeoJsonProperties>,
|
|
||||||
);
|
|
||||||
handleCloseModal();
|
handleCloseModal();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -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(() => {
|
||||||
@@ -53,11 +53,7 @@ const SearchBar = ({ className }: SearchBarProps) => {
|
|||||||
}
|
}
|
||||||
endIcon={
|
endIcon={
|
||||||
searchString !== "" && (
|
searchString !== "" && (
|
||||||
<Button
|
<Button intent="tertiary" size="compacted" onClick={() => setSearchString("")}>
|
||||||
intent="tertiary"
|
|
||||||
size="compacted"
|
|
||||||
onClick={() => setSearchString("")}
|
|
||||||
>
|
|
||||||
<IoCloseOutline className="h-5 w-5" />
|
<IoCloseOutline className="h-5 w-5" />
|
||||||
</Button>
|
</Button>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -97,10 +97,7 @@ export const SignInForm = ({ callbackPath }: SignInFormProps) => {
|
|||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
{responseMessage && (
|
{responseMessage && (
|
||||||
<InfoMessage
|
<InfoMessage message={responseMessage.message} type={responseMessage.type} />
|
||||||
message={responseMessage.message}
|
|
||||||
type={responseMessage.type}
|
|
||||||
/>
|
|
||||||
)}
|
)}
|
||||||
</form>
|
</form>
|
||||||
</FormProvider>
|
</FormProvider>
|
||||||
|
|||||||
@@ -2,13 +2,7 @@ import React, { useEffect, useRef, useState } from "react";
|
|||||||
|
|
||||||
import { get, isArray, isNil } from "lodash";
|
import { get, isArray, isNil } from "lodash";
|
||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
import {
|
import { Controller, FieldPath, FieldValues, useFormContext, useWatch } from "react-hook-form";
|
||||||
Controller,
|
|
||||||
FieldPath,
|
|
||||||
FieldValues,
|
|
||||||
useFormContext,
|
|
||||||
useWatch,
|
|
||||||
} from "react-hook-form";
|
|
||||||
import { ActionMeta, GroupBase, OnChangeValue, Props } from "react-select";
|
import { ActionMeta, GroupBase, OnChangeValue, Props } from "react-select";
|
||||||
import AsyncSelect from "react-select/async";
|
import AsyncSelect from "react-select/async";
|
||||||
|
|
||||||
@@ -52,19 +46,16 @@ export const AsyncSelectField = <
|
|||||||
hideErrorMessage,
|
hideErrorMessage,
|
||||||
required,
|
required,
|
||||||
size,
|
size,
|
||||||
|
|
||||||
loadOption,
|
loadOption,
|
||||||
loadOptions,
|
loadOptions,
|
||||||
onInformChange,
|
onInformChange,
|
||||||
|
|
||||||
placeholder,
|
placeholder,
|
||||||
separators,
|
separators,
|
||||||
|
|
||||||
...selectProps
|
...selectProps
|
||||||
}: 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>[]>([]);
|
||||||
@@ -78,8 +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) {
|
||||||
@@ -98,9 +88,10 @@ export const AsyncSelectField = <
|
|||||||
setLoadingValues(false);
|
setLoadingValues(false);
|
||||||
|
|
||||||
onInformChange?.(
|
onInformChange?.(
|
||||||
values.map(
|
values.map((v) => valueOptions.current.find((o) => o.value === v)!) as BaseOption<
|
||||||
(v) => valueOptions.current.find((o) => o.value === v)!,
|
T,
|
||||||
) as BaseOption<T, D>[],
|
D
|
||||||
|
>[],
|
||||||
);
|
);
|
||||||
|
|
||||||
// This forced a state update, which enures that the select is updated once the query has finished
|
// 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 hasError = !!get(errors, name)?.message;
|
||||||
|
|
||||||
const valueToOption = (value: T) =>
|
const valueToOption = (value: T) =>
|
||||||
[...valueOptions.current, ...searchOptions.current].find(
|
[...valueOptions.current, ...searchOptions.current].find((o) => o.value === value) ?? {
|
||||||
(o) => o.value === value,
|
value,
|
||||||
) ?? { value, label: "" };
|
label: "",
|
||||||
|
};
|
||||||
|
|
||||||
const fetchOptions = async (searchString?: string) => {
|
const fetchOptions = async (searchString?: string) => {
|
||||||
setLoadingOptions(true);
|
setLoadingOptions(true);
|
||||||
|
|||||||
@@ -12,10 +12,7 @@ interface InputProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type AllProps = Omit<
|
type AllProps = Omit<
|
||||||
React.DetailedHTMLProps<
|
React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>,
|
||||||
React.InputHTMLAttributes<HTMLInputElement>,
|
|
||||||
HTMLInputElement
|
|
||||||
>,
|
|
||||||
"ref"
|
"ref"
|
||||||
> &
|
> &
|
||||||
InputProps;
|
InputProps;
|
||||||
@@ -24,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,16 +1,11 @@
|
|||||||
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";
|
||||||
import { get } from "lodash";
|
import { get } from "lodash";
|
||||||
import { useLocale, useTranslations } from "next-intl";
|
import { useLocale, useTranslations } from "next-intl";
|
||||||
import DatePicker, { registerLocale } from "react-datepicker";
|
import DatePicker, { registerLocale } from "react-datepicker";
|
||||||
import {
|
import { Controller, FieldPath, FieldValues, useFormContext } from "react-hook-form";
|
||||||
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";
|
||||||
@@ -45,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();
|
||||||
@@ -93,11 +86,7 @@ export const DateField = <
|
|||||||
// Called when the user types in the input
|
// Called when the user types in the input
|
||||||
if (e?.currentTarget && "value" in e.currentTarget) {
|
if (e?.currentTarget && "value" in e.currentTarget) {
|
||||||
const value = e.currentTarget.value;
|
const value = e.currentTarget.value;
|
||||||
const date = parse(
|
const date = parse(value as string, at("dateParseFormat"), new Date());
|
||||||
value as string,
|
|
||||||
at("dateParseFormat"),
|
|
||||||
new Date(),
|
|
||||||
);
|
|
||||||
if (
|
if (
|
||||||
isValid(date) &&
|
isValid(date) &&
|
||||||
date.getFullYear() >= min &&
|
date.getFullYear() >= min &&
|
||||||
@@ -124,9 +113,7 @@ export const DateField = <
|
|||||||
minDate={minDate}
|
minDate={minDate}
|
||||||
showFullMonthYearPicker
|
showFullMonthYearPicker
|
||||||
maxDate={maxDate}
|
maxDate={maxDate}
|
||||||
renderCustomHeader={(props) => (
|
renderCustomHeader={(props) => <DatePickerCustomHeader {...props} />}
|
||||||
<DatePickerCustomHeader {...props} />
|
|
||||||
)}
|
|
||||||
customInput={
|
customInput={
|
||||||
<InputDatePicker
|
<InputDatePicker
|
||||||
mask={at("dateMask")}
|
mask={at("dateMask")}
|
||||||
|
|||||||
@@ -1,12 +1,7 @@
|
|||||||
import { ReactNode } from "react";
|
import { ReactNode } from "react";
|
||||||
|
|
||||||
import { get } from "lodash";
|
import { get } from "lodash";
|
||||||
import {
|
import { Control, FieldPath, FieldValues, useFormContext } from "react-hook-form";
|
||||||
Control,
|
|
||||||
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";
|
||||||
@@ -70,13 +65,7 @@ export const Field = <
|
|||||||
</Label>
|
</Label>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
<div
|
<div className={twMerge("flex w-full", label && "mt-2", childrenWrapperClassName)}>
|
||||||
className={twMerge(
|
|
||||||
"flex w-full",
|
|
||||||
label && "mt-2",
|
|
||||||
childrenWrapperClassName,
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
{children}
|
{children}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -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,18 +1,12 @@
|
|||||||
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<
|
||||||
TFieldValues extends FieldValues = FieldValues,
|
TFieldValues extends FieldValues = FieldValues,
|
||||||
TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
|
TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
|
||||||
> = GenericFieldProps<TFieldValues, TFieldName> &
|
> = GenericFieldProps<TFieldValues, TFieldName> & Omit<SwitchProps<"button">, "name">;
|
||||||
Omit<SwitchProps<"button">, "name">;
|
|
||||||
|
|
||||||
export const InlineSwitchField = <
|
export const InlineSwitchField = <
|
||||||
TFieldValues extends FieldValues = FieldValues,
|
TFieldValues extends FieldValues = FieldValues,
|
||||||
|
|||||||
@@ -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,25 +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<
|
DetailedHTMLProps<LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement> & {
|
||||||
React.LabelHTMLAttributes<HTMLLabelElement>,
|
|
||||||
HTMLLabelElement
|
|
||||||
> & {
|
|
||||||
required?: boolean;
|
required?: boolean;
|
||||||
className?: string;
|
className?: string;
|
||||||
tooltip?: React.ReactNode;
|
tooltip?: ReactNode;
|
||||||
}
|
}
|
||||||
>;
|
>;
|
||||||
|
|
||||||
export const Label = ({
|
export const Label = ({ required, className, children, ...labelProps }: LabelProps) => {
|
||||||
required,
|
|
||||||
className,
|
|
||||||
children,
|
|
||||||
tooltip,
|
|
||||||
...labelProps
|
|
||||||
}: LabelProps) => {
|
|
||||||
return (
|
return (
|
||||||
<label
|
<label
|
||||||
{...labelProps}
|
{...labelProps}
|
||||||
|
|||||||
@@ -1,21 +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 { Controller, FieldPath, FieldValues, useFormContext } from "react-hook-form";
|
||||||
import { useTranslations } from "next-intl";
|
|
||||||
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;
|
||||||
@@ -51,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
|
||||||
{...{
|
{...{
|
||||||
@@ -78,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}
|
||||||
|
|||||||
@@ -14,11 +14,7 @@ export type BaseOption<T = string, D = unknown> = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const createSelectClassNamesFn =
|
export const createSelectClassNamesFn =
|
||||||
<Option, IsMulti extends boolean = false>({
|
<Option, IsMulti extends boolean = false>({ size }: { size?: "small" | "medium" }) =>
|
||||||
size,
|
|
||||||
}: {
|
|
||||||
size?: "small" | "medium";
|
|
||||||
}) =>
|
|
||||||
(
|
(
|
||||||
hasError: boolean,
|
hasError: boolean,
|
||||||
separators: boolean,
|
separators: boolean,
|
||||||
@@ -26,8 +22,7 @@ export const createSelectClassNamesFn =
|
|||||||
container: () => "w-full",
|
container: () => "w-full",
|
||||||
valueContainer: () => "text-gray-900 dark:text-white",
|
valueContainer: () => "text-gray-900 dark:text-white",
|
||||||
indicatorsContainer: () => "flex items-center self-stretch shrink-0",
|
indicatorsContainer: () => "flex items-center self-stretch shrink-0",
|
||||||
clearIndicator: () =>
|
clearIndicator: () => "flex items-center pr-2 text-gray-900 dark:text-white",
|
||||||
"flex items-center pr-2 text-gray-900 dark:text-white",
|
|
||||||
dropdownIndicator: () =>
|
dropdownIndicator: () =>
|
||||||
"pointer-events-none flex items-center pr-2 text-gray-900 dark:text-white",
|
"pointer-events-none flex items-center pr-2 text-gray-900 dark:text-white",
|
||||||
indicatorSeparator: () => "w-px 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",
|
multiValue: () => "bg-fieldGray border rounded-lg flex space-x-1 pl-1 m-1",
|
||||||
multiValueLabel: () => "",
|
multiValueLabel: () => "",
|
||||||
multiValueRemove: () => "items-center px-1 hover:text-primary",
|
multiValueRemove: () => "items-center px-1 hover:text-primary",
|
||||||
placeholder: () =>
|
placeholder: () => "block truncate pr-2 placeholder-gray dark:placeholder-gray-400",
|
||||||
"block truncate pr-2 placeholder-gray dark:placeholder-gray-400",
|
|
||||||
menu: () =>
|
menu: () =>
|
||||||
twMerge(
|
twMerge(
|
||||||
"!z-30 mt-2 rounded-lg border border-gray-200 bg-white p-1",
|
"!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",
|
"text-textGray p-2 bg-gray-50 border border-dashed border-gray-200 rounded-sm",
|
||||||
});
|
});
|
||||||
|
|
||||||
export type SelectProps<
|
export type SelectProps<IsMulti extends boolean = false, T = string, D = unknown> = Prettify<
|
||||||
IsMulti extends boolean = false,
|
|
||||||
T = string,
|
|
||||||
D = unknown,
|
|
||||||
> = Prettify<
|
|
||||||
Omit<Props<BaseOption<T, D>, IsMulti>, "classNames"> & {
|
Omit<Props<BaseOption<T, D>, IsMulti>, "classNames"> & {
|
||||||
required?: boolean;
|
required?: boolean;
|
||||||
separators?: boolean;
|
separators?: boolean;
|
||||||
hasError?: boolean;
|
hasError?: boolean;
|
||||||
size?: "small" | "medium";
|
size?: "small" | "medium";
|
||||||
classNameOverrides?: ClassNamesConfig<
|
classNameOverrides?: ClassNamesConfig<BaseOption<T, D>, IsMulti, GroupBase<BaseOption<T, D>>>;
|
||||||
BaseOption<T, D>,
|
|
||||||
IsMulti,
|
|
||||||
GroupBase<BaseOption<T, D>>
|
|
||||||
>;
|
|
||||||
}
|
}
|
||||||
>;
|
>;
|
||||||
|
|
||||||
export const Select = <
|
export const Select = <IsMulti extends boolean = false, T = string, D = unknown>({
|
||||||
IsMulti extends boolean = false,
|
|
||||||
T = string,
|
|
||||||
D = unknown,
|
|
||||||
>({
|
|
||||||
className,
|
|
||||||
required,
|
|
||||||
size,
|
size,
|
||||||
|
|
||||||
placeholder,
|
placeholder,
|
||||||
separators,
|
separators,
|
||||||
hasError,
|
hasError,
|
||||||
@@ -121,7 +100,7 @@ export const Select = <
|
|||||||
}}
|
}}
|
||||||
classNames={{
|
classNames={{
|
||||||
...classNames(hasError ?? false, separators ?? false),
|
...classNames(hasError ?? false, separators ?? false),
|
||||||
...(classNameOverrides ?? {}),
|
...classNameOverrides,
|
||||||
}}
|
}}
|
||||||
{...selectProps}
|
{...selectProps}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -1,13 +1,5 @@
|
|||||||
import React from "react";
|
|
||||||
|
|
||||||
import { flatMap, get, isArray, isNil, isObject } from "lodash";
|
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 { GroupBase, OnChangeValue } from "react-select";
|
||||||
|
|
||||||
import { BaseOption, Select, SelectProps } from "@/components/form/Select";
|
import { BaseOption, Select, SelectProps } from "@/components/form/Select";
|
||||||
@@ -23,10 +15,7 @@ export type SelectFieldProps<
|
|||||||
D = unknown,
|
D = unknown,
|
||||||
> = Prettify<
|
> = Prettify<
|
||||||
GenericFieldProps<TFieldValues, TFieldName> &
|
GenericFieldProps<TFieldValues, TFieldName> &
|
||||||
Omit<
|
Omit<SelectProps<IsMulti, T, D>, "onChange" | "value" | "classNames" | "name"> & {
|
||||||
SelectProps<IsMulti, T, D>,
|
|
||||||
"onChange" | "value" | "classNames" | "name"
|
|
||||||
> & {
|
|
||||||
required?: boolean;
|
required?: boolean;
|
||||||
separators?: boolean;
|
separators?: boolean;
|
||||||
}
|
}
|
||||||
@@ -47,13 +36,9 @@ export const SelectField = <
|
|||||||
label,
|
label,
|
||||||
hideErrorMessage,
|
hideErrorMessage,
|
||||||
required,
|
required,
|
||||||
|
|
||||||
placeholder,
|
|
||||||
separators,
|
|
||||||
options,
|
options,
|
||||||
...selectProps
|
...selectProps
|
||||||
}: SelectFieldProps<TFieldValues, TFieldName, IsMulti, T, D>) => {
|
}: SelectFieldProps<TFieldValues, TFieldName, IsMulti, T, D>) => {
|
||||||
const t = useTranslations("App");
|
|
||||||
const form = useFormContext<TFieldValues>();
|
const form = useFormContext<TFieldValues>();
|
||||||
|
|
||||||
const {
|
const {
|
||||||
@@ -64,8 +49,7 @@ export const SelectField = <
|
|||||||
|
|
||||||
const isGroup = (
|
const isGroup = (
|
||||||
option: BaseOption<T, D> | GroupBase<BaseOption<T, D>>,
|
option: BaseOption<T, D> | GroupBase<BaseOption<T, D>>,
|
||||||
): option is GroupBase<BaseOption<T, D>> =>
|
): option is GroupBase<BaseOption<T, D>> => isObject(option) && "options" in option;
|
||||||
isObject(option) && "options" in option;
|
|
||||||
|
|
||||||
const flattenedOptions = flatMap(options, (option) => {
|
const flattenedOptions = flatMap(options, (option) => {
|
||||||
return isGroup(option) ? option.options : option;
|
return isGroup(option) ? option.options : option;
|
||||||
@@ -91,9 +75,7 @@ export const SelectField = <
|
|||||||
name={name}
|
name={name}
|
||||||
control={control}
|
control={control}
|
||||||
render={({ field: { onChange, value } }) => {
|
render={({ field: { onChange, value } }) => {
|
||||||
const onSelectChange = (
|
const onSelectChange = (newValue: OnChangeValue<BaseOption<T, D>, IsMulti>) => {
|
||||||
newValue: OnChangeValue<BaseOption<T, D>, IsMulti>,
|
|
||||||
) => {
|
|
||||||
if (isNil(newValue)) onChange(null);
|
if (isNil(newValue)) onChange(null);
|
||||||
else if (isArray(newValue)) {
|
else if (isArray(newValue)) {
|
||||||
onChange(newValue.map((option) => option.value));
|
onChange(newValue.map((option) => option.value));
|
||||||
|
|||||||
@@ -1,12 +1,7 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
import { Switch, SwitchProps } from "@headlessui/react";
|
import { Switch, SwitchProps } from "@headlessui/react";
|
||||||
import {
|
import { Controller, FieldPath, FieldValues } from "react-hook-form";
|
||||||
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";
|
||||||
@@ -16,10 +11,7 @@ import { Field, GenericFieldProps } from "./Field";
|
|||||||
type SwitchFieldProps<
|
type SwitchFieldProps<
|
||||||
TFieldValues extends FieldValues = FieldValues,
|
TFieldValues extends FieldValues = FieldValues,
|
||||||
TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
|
TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
|
||||||
> = Prettify<
|
> = Prettify<GenericFieldProps<TFieldValues, TFieldName> & Omit<SwitchProps<"button">, "name">>;
|
||||||
GenericFieldProps<TFieldValues, TFieldName> &
|
|
||||||
Omit<SwitchProps<"button">, "name">
|
|
||||||
>;
|
|
||||||
|
|
||||||
export const SwitchField = <
|
export const SwitchField = <
|
||||||
TFieldValues extends FieldValues = FieldValues,
|
TFieldValues extends FieldValues = FieldValues,
|
||||||
@@ -27,21 +19,7 @@ export const SwitchField = <
|
|||||||
>(
|
>(
|
||||||
props: SwitchFieldProps<TFieldValues, TFieldName>,
|
props: SwitchFieldProps<TFieldValues, TFieldName>,
|
||||||
) => {
|
) => {
|
||||||
const {
|
const { name, control, label, disabled, className, labelClassName, ...rest } = props;
|
||||||
name,
|
|
||||||
control,
|
|
||||||
label,
|
|
||||||
disabled,
|
|
||||||
className,
|
|
||||||
labelClassName,
|
|
||||||
|
|
||||||
childrenWrapperClassName,
|
|
||||||
hideErrorMessage,
|
|
||||||
|
|
||||||
...rest
|
|
||||||
} = props;
|
|
||||||
const form = useFormContext<TFieldValues>();
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Field
|
<Field
|
||||||
{...{
|
{...{
|
||||||
|
|||||||
@@ -1,12 +1,7 @@
|
|||||||
import React from "react";
|
import type { HTMLProps, ReactNode } from "react";
|
||||||
|
|
||||||
import { get } from "lodash";
|
import { get } from "lodash";
|
||||||
import {
|
import { Controller, FieldPath, FieldValues, useFormContext } from "react-hook-form";
|
||||||
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";
|
||||||
@@ -19,9 +14,9 @@ type TextAreaFieldProps<
|
|||||||
TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
|
TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
|
||||||
> = Prettify<
|
> = Prettify<
|
||||||
GenericFieldProps<TFieldValues, TFieldName> &
|
GenericFieldProps<TFieldValues, TFieldName> &
|
||||||
Omit<React.HTMLProps<HTMLTextAreaElement>, "ref" | "name"> & {
|
Omit<HTMLProps<HTMLTextAreaElement>, "ref" | "name"> & {
|
||||||
handleChanged?: (props: { name: string }) => void;
|
handleChanged?: (props: { name: string }) => void;
|
||||||
startIcon?: React.ReactNode;
|
startIcon?: ReactNode;
|
||||||
required?: boolean;
|
required?: boolean;
|
||||||
}
|
}
|
||||||
>;
|
>;
|
||||||
@@ -40,11 +35,7 @@ export const TextAreaField = <
|
|||||||
labelClassName,
|
labelClassName,
|
||||||
childrenWrapperClassName,
|
childrenWrapperClassName,
|
||||||
hideErrorMessage = false,
|
hideErrorMessage = false,
|
||||||
|
|
||||||
startIcon,
|
|
||||||
handleChanged,
|
|
||||||
required,
|
required,
|
||||||
|
|
||||||
disabled,
|
disabled,
|
||||||
...rest
|
...rest
|
||||||
} = props;
|
} = props;
|
||||||
|
|||||||
@@ -1,12 +1,7 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
import { get } from "lodash";
|
import { get } from "lodash";
|
||||||
import {
|
import { Controller, FieldPath, FieldValues, useFormContext } from "react-hook-form";
|
||||||
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";
|
||||||
@@ -57,11 +52,7 @@ export const TextField = <
|
|||||||
const hasError = !!get(errors, name)?.message;
|
const hasError = !!get(errors, name)?.message;
|
||||||
|
|
||||||
const input = (value: string | number) => {
|
const input = (value: string | number) => {
|
||||||
return typeof value === "number"
|
return typeof value === "number" ? (isNaN(value) ? "" : value.toString()) : (value ?? "");
|
||||||
? isNaN(value)
|
|
||||||
? ""
|
|
||||||
: value.toString()
|
|
||||||
: (value ?? "");
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const output =
|
const output =
|
||||||
|
|||||||
@@ -1,16 +1,12 @@
|
|||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
|
||||||
import { on } from "events";
|
|
||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
import { FieldPath, FieldValues } from "react-hook-form";
|
import { FieldPath, FieldValues } from "react-hook-form";
|
||||||
import { FaExternalLinkAlt } from "react-icons/fa";
|
import { FaExternalLinkAlt } from "react-icons/fa";
|
||||||
|
|
||||||
import { TimeControlColours } from "@/constants";
|
import { TimeControlColours } from "@/constants";
|
||||||
import { getTournamentDetails } from "@/server/getTournamentDetails";
|
import { getTournamentDetails } from "@/server/getTournamentDetails";
|
||||||
import {
|
import { SearchedTournament, searchTournaments } from "@/server/searchTournaments";
|
||||||
SearchedTournament,
|
|
||||||
searchTournaments,
|
|
||||||
} from "@/server/searchTournaments";
|
|
||||||
|
|
||||||
import { AsyncSelectField, AsyncSelectFieldProps } from "./AsyncSelectField";
|
import { AsyncSelectField, AsyncSelectFieldProps } from "./AsyncSelectField";
|
||||||
|
|
||||||
@@ -18,13 +14,7 @@ type TournamentSelectFieldProps<
|
|||||||
TFieldValues extends FieldValues = FieldValues,
|
TFieldValues extends FieldValues = FieldValues,
|
||||||
TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
|
TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
|
||||||
> = Omit<
|
> = Omit<
|
||||||
AsyncSelectFieldProps<
|
AsyncSelectFieldProps<TFieldValues, TFieldName, false, string, SearchedTournament>,
|
||||||
TFieldValues,
|
|
||||||
TFieldName,
|
|
||||||
false,
|
|
||||||
string,
|
|
||||||
SearchedTournament
|
|
||||||
>,
|
|
||||||
"loadOptions" | "loadOption" | "separators"
|
"loadOptions" | "loadOption" | "separators"
|
||||||
>;
|
>;
|
||||||
|
|
||||||
@@ -36,8 +26,7 @@ export const TournamentSelectField = <
|
|||||||
...rest
|
...rest
|
||||||
}: TournamentSelectFieldProps<TFieldValues, TFieldName>) => {
|
}: TournamentSelectFieldProps<TFieldValues, TFieldName>) => {
|
||||||
const at = useTranslations("App");
|
const at = useTranslations("App");
|
||||||
const [selectedTournament, setSelectedTournament] =
|
const [selectedTournament, setSelectedTournament] = useState<SearchedTournament | null>(null);
|
||||||
useState<SearchedTournament | null>(null);
|
|
||||||
|
|
||||||
const loadOption = async (ffeId: string) => {
|
const loadOption = async (ffeId: string) => {
|
||||||
const result = await getTournamentDetails({ ffeId });
|
const result = await getTournamentDetails({ ffeId });
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|
||||||
@@ -52,11 +52,7 @@ export const ZoneEditor = ({ value, onChange }: ZoneEditorProps) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<MapContainer
|
<MapContainer center={center} zoom={5} style={{ height: "600px", flexGrow: 1 }}>
|
||||||
center={center}
|
|
||||||
zoom={5}
|
|
||||||
style={{ height: "600px", flexGrow: 1 }}
|
|
||||||
>
|
|
||||||
<MapEvents
|
<MapEvents
|
||||||
bounds={
|
bounds={
|
||||||
(initialFeatures.current ?? []).length > 0
|
(initialFeatures.current ?? []).length > 0
|
||||||
|
|||||||
@@ -20,8 +20,7 @@ type ZoneEditorFieldProps<
|
|||||||
TFieldValues extends FieldValues = FieldValues,
|
TFieldValues extends FieldValues = FieldValues,
|
||||||
TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
|
TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
|
||||||
> = Prettify<
|
> = Prettify<
|
||||||
GenericFieldProps<TFieldValues, TFieldName> &
|
GenericFieldProps<TFieldValues, TFieldName> & Omit<ZoneEditorProps, "value" | "onChange">
|
||||||
Omit<ZoneEditorProps, "value" | "onChange">
|
|
||||||
>;
|
>;
|
||||||
|
|
||||||
export const ZoneEditorField = <
|
export const ZoneEditorField = <
|
||||||
|
|||||||
+1
-5
@@ -18,11 +18,7 @@
|
|||||||
|
|
||||||
body {
|
body {
|
||||||
color: rgb(var(--foreground-rgb));
|
color: rgb(var(--foreground-rgb));
|
||||||
background: linear-gradient(
|
background: linear-gradient(to bottom, transparent, rgb(var(--background-end-rgb)))
|
||||||
to bottom,
|
|
||||||
transparent,
|
|
||||||
rgb(var(--background-end-rgb))
|
|
||||||
)
|
|
||||||
rgb(var(--background-start-rgb));
|
rgb(var(--background-start-rgb));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-10
@@ -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;
|
||||||
@@ -22,9 +22,7 @@ export type CreatorReturnType = {
|
|||||||
|
|
||||||
function create(screens: object | undefined) {
|
function create(screens: object | undefined) {
|
||||||
if (!screens) {
|
if (!screens) {
|
||||||
throw new Error(
|
throw new Error("Failed to create breakpoint hooks, given `screens` value is invalid.");
|
||||||
"Failed to create breakpoint hooks, given `screens` value is invalid.",
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function useBreakpoint(breakpoint: string, defaultValue: boolean = false) {
|
function useBreakpoint(breakpoint: string, defaultValue: boolean = false) {
|
||||||
@@ -67,10 +65,7 @@ function create(screens: object | undefined) {
|
|||||||
invalid: U,
|
invalid: U,
|
||||||
) {
|
) {
|
||||||
const match = useBreakpoint(breakpoint);
|
const match = useBreakpoint(breakpoint);
|
||||||
const value = useMemo(
|
const value = useMemo(() => (match ? valid : invalid), [invalid, match, valid]);
|
||||||
() => (match ? valid : invalid),
|
|
||||||
[invalid, match, valid],
|
|
||||||
);
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,5 +76,4 @@ function create(screens: object | undefined) {
|
|||||||
} as CreatorReturnType;
|
} as CreatorReturnType;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const { useBreakpoint, useBreakpointEffect, useBreakpointValue } =
|
export const { useBreakpoint } = create(config.theme!.screens);
|
||||||
create(config.theme!.screens);
|
|
||||||
|
|||||||
@@ -2,8 +2,7 @@ import { Dispatch, SetStateAction, useEffect, useState } from "react";
|
|||||||
|
|
||||||
function useDarkMode(): [string, Dispatch<SetStateAction<string>>] {
|
function useDarkMode(): [string, Dispatch<SetStateAction<string>>] {
|
||||||
const prefersDarkMode =
|
const prefersDarkMode =
|
||||||
typeof window !== "undefined" &&
|
typeof window !== "undefined" && window.matchMedia("(prefers-color-scheme: dark)").matches;
|
||||||
window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
||||||
|
|
||||||
const [theme, setTheme] = useState(
|
const [theme, setTheme] = useState(
|
||||||
typeof window !== "undefined"
|
typeof window !== "undefined"
|
||||||
|
|||||||
@@ -13,9 +13,8 @@ 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;
|
||||||
isLg
|
// oxlint-disable-next-line no-unused-expressions
|
||||||
? setDateDirectionState("horizontal")
|
isLg ? setDateDirectionState("horizontal") : setDateDirectionState("vertical");
|
||||||
: setDateDirectionState("vertical");
|
|
||||||
};
|
};
|
||||||
updateDatePickerDirection();
|
updateDatePickerDirection();
|
||||||
|
|
||||||
|
|||||||
@@ -9,9 +9,7 @@ export const useDynamicViewportUnits = () => {
|
|||||||
const isMobile = function () {
|
const isMobile = function () {
|
||||||
if (
|
if (
|
||||||
/Android|iPhone|iPad|iPod/i.test(navigator.userAgent) ||
|
/Android|iPhone|iPad|iPod/i.test(navigator.userAgent) ||
|
||||||
(navigator.userAgent.match(/Mac/) &&
|
(navigator.userAgent.match(/Mac/) && navigator.maxTouchPoints && navigator.maxTouchPoints > 2)
|
||||||
navigator.maxTouchPoints &&
|
|
||||||
navigator.maxTouchPoints > 2)
|
|
||||||
) {
|
) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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>;
|
||||||
@@ -26,15 +26,9 @@ const useFormPersist = (
|
|||||||
) => {
|
) => {
|
||||||
const watchedValues = watch();
|
const watchedValues = watch();
|
||||||
|
|
||||||
const getStorage = useCallback(
|
const getStorage = useCallback(() => storage || window.sessionStorage, [storage]);
|
||||||
() => storage || window.sessionStorage,
|
|
||||||
[storage],
|
|
||||||
);
|
|
||||||
|
|
||||||
const clearStorage = useCallback(
|
const clearStorage = useCallback(() => getStorage().removeItem(name), [getStorage, name]);
|
||||||
() => getStorage().removeItem(name),
|
|
||||||
[getStorage, name],
|
|
||||||
);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const storedValuesJSON = getStorage().getItem(name);
|
const storedValuesJSON = getStorage().getItem(name);
|
||||||
@@ -58,17 +52,7 @@ const useFormPersist = (
|
|||||||
|
|
||||||
return () => getStorage().setItem(name, JSON.stringify(dataRestored));
|
return () => getStorage().setItem(name, JSON.stringify(dataRestored));
|
||||||
}
|
}
|
||||||
}, [
|
}, [storage, name, setValue, clearStorage, dirty, exclude, touch, validate, getStorage]);
|
||||||
storage,
|
|
||||||
name,
|
|
||||||
setValue,
|
|
||||||
clearStorage,
|
|
||||||
dirty,
|
|
||||||
exclude,
|
|
||||||
touch,
|
|
||||||
validate,
|
|
||||||
getStorage,
|
|
||||||
]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const values =
|
const values =
|
||||||
|
|||||||
@@ -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."
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,9 +14,7 @@ export default function Providers({ children }: { children: React.ReactNode }) {
|
|||||||
return (
|
return (
|
||||||
<SessionProvider>
|
<SessionProvider>
|
||||||
<JotaiProvider>
|
<JotaiProvider>
|
||||||
<QueryClientProvider client={queryClient}>
|
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
|
||||||
{children}
|
|
||||||
</QueryClientProvider>
|
|
||||||
</JotaiProvider>
|
</JotaiProvider>
|
||||||
</SessionProvider>
|
</SessionProvider>
|
||||||
);
|
);
|
||||||
|
|||||||
+14556
-1
File diff suppressed because one or more lines are too long
+9
-9
@@ -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),
|
||||||
|
|||||||
@@ -5,9 +5,7 @@ import { collections, dbConnect } from "@/server/mongodb";
|
|||||||
import { actionClient } from "@/server/safeAction";
|
import { actionClient } from "@/server/safeAction";
|
||||||
import { errorLog } from "@/utils/logger";
|
import { errorLog } from "@/utils/logger";
|
||||||
|
|
||||||
export const addClub = actionClient
|
export const addClub = actionClient.schema(addClubSchema).action(async (input) => {
|
||||||
.schema(addClubSchema)
|
|
||||||
.action(async (input) => {
|
|
||||||
try {
|
try {
|
||||||
const { name, email, message, club } = input.parsedInput;
|
const { name, email, message, club } = input.parsedInput;
|
||||||
|
|
||||||
|
|||||||
@@ -17,9 +17,7 @@ const tcMap: Record<TimeControl, TournamentModel["time_control"]> = {
|
|||||||
[TimeControl.Other]: "Other",
|
[TimeControl.Other]: "Other",
|
||||||
};
|
};
|
||||||
|
|
||||||
export const addTournament = actionClient
|
export const addTournament = actionClient.schema(addTournamentSchema).action(async (input) => {
|
||||||
.schema(addTournamentSchema)
|
|
||||||
.action(async (input) => {
|
|
||||||
try {
|
try {
|
||||||
await dbConnect();
|
await dbConnect();
|
||||||
|
|
||||||
@@ -42,12 +40,8 @@ export const addTournament = actionClient
|
|||||||
if (result.insertedId) {
|
if (result.insertedId) {
|
||||||
const { tournament, country, date, time_control } = tournamentData;
|
const { tournament, country, date, time_control } = tournamentData;
|
||||||
|
|
||||||
if (
|
if (typeof process.env.DISCORD_WEBHOOK_ADD_TOURNAMENT_URL === "string") {
|
||||||
typeof process.env.DISCORD_WEBHOOK_ADD_TOURNAMENT_URL === "string"
|
await fetch(process.env.DISCORD_WEBHOOK_ADD_TOURNAMENT_URL as string, {
|
||||||
) {
|
|
||||||
await fetch(
|
|
||||||
process.env.DISCORD_WEBHOOK_ADD_TOURNAMENT_URL as string,
|
|
||||||
{
|
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
@@ -71,8 +65,7 @@ export const addTournament = actionClient
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
},
|
});
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -5,9 +5,7 @@ import { errorLog } from "@/utils/logger";
|
|||||||
|
|
||||||
import { actionClient } from "./safeAction";
|
import { actionClient } from "./safeAction";
|
||||||
|
|
||||||
export const contactUs = actionClient
|
export const contactUs = actionClient.schema(contactUsSchema).action(async (input) => {
|
||||||
.schema(contactUsSchema)
|
|
||||||
.action(async (input) => {
|
|
||||||
try {
|
try {
|
||||||
const { email, subject, message } = input.parsedInput;
|
const { email, subject, message } = input.parsedInput;
|
||||||
await fetch(process.env.DISCORD_WEBHOOK_CONTACT_URL as string, {
|
await fetch(process.env.DISCORD_WEBHOOK_CONTACT_URL as string, {
|
||||||
|
|||||||
@@ -10,9 +10,7 @@ import { errorLog } from "@/utils/logger";
|
|||||||
import { ZoneModel } from "./models/zoneModel";
|
import { ZoneModel } from "./models/zoneModel";
|
||||||
import { actionClient } from "./safeAction";
|
import { actionClient } from "./safeAction";
|
||||||
|
|
||||||
export const createZone = actionClient
|
export const createZone = actionClient.schema(zoneSchema).action(async (input) => {
|
||||||
.schema(zoneSchema)
|
|
||||||
.action(async (input) => {
|
|
||||||
try {
|
try {
|
||||||
await dbConnect();
|
await dbConnect();
|
||||||
|
|
||||||
|
|||||||
@@ -13,9 +13,7 @@ const deleteZoneSchema = z.object({
|
|||||||
id: z.string(),
|
id: z.string(),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const deleteZone = actionClient
|
export const deleteZone = actionClient.schema(deleteZoneSchema).action(async (input) => {
|
||||||
.schema(deleteZoneSchema)
|
|
||||||
.action(async (input) => {
|
|
||||||
const { id } = input.parsedInput;
|
const { id } = input.parsedInput;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -17,9 +17,7 @@ const editZoneSchema = z.object({
|
|||||||
zone: zoneSchema,
|
zone: zoneSchema,
|
||||||
});
|
});
|
||||||
|
|
||||||
export const editZone = actionClient
|
export const editZone = actionClient.schema(editZoneSchema).action(async (input) => {
|
||||||
.schema(editZoneSchema)
|
|
||||||
.action(async (input) => {
|
|
||||||
const { id, zone } = input.parsedInput;
|
const { id, zone } = input.parsedInput;
|
||||||
try {
|
try {
|
||||||
await dbConnect();
|
await dbConnect();
|
||||||
|
|||||||
@@ -58,9 +58,7 @@ const getEloDetails = (elo: string | null) => {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
const getResultDetails = (
|
const getResultDetails = (results: z.infer<typeof dbSchema>[number]["results"][number]) => {
|
||||||
results: z.infer<typeof dbSchema>[number]["results"][number],
|
|
||||||
) => {
|
|
||||||
if (results.opponent_name === null) {
|
if (results.opponent_name === null) {
|
||||||
return { result: 0, lostByForfeit: true, wonByForfeit: false };
|
return { result: 0, lostByForfeit: true, wonByForfeit: false };
|
||||||
}
|
}
|
||||||
@@ -118,12 +116,9 @@ export const fetchTournamentResults = actionClient
|
|||||||
headers.append("api-key", apiKey);
|
headers.append("api-key", apiKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
const rawResults = await fetch(
|
const rawResults = await fetch(`${process.env.RESULTS_SCRAPER_URL}${id}`, {
|
||||||
`${process.env.RESULTS_SCRAPER_URL}${id}`,
|
|
||||||
{
|
|
||||||
headers: headers,
|
headers: headers,
|
||||||
},
|
});
|
||||||
);
|
|
||||||
|
|
||||||
if (rawResults.status >= 500) {
|
if (rawResults.status >= 500) {
|
||||||
throw new Error("ERR_TOURNAMENT_RESULTS_NOT_AVAILABLE");
|
throw new Error("ERR_TOURNAMENT_RESULTS_NOT_AVAILABLE");
|
||||||
@@ -143,12 +138,7 @@ export const fetchTournamentResults = actionClient
|
|||||||
name: player.name,
|
name: player.name,
|
||||||
...getEloDetails(player.elo),
|
...getEloDetails(player.elo),
|
||||||
results: player.results.map((result) => ({
|
results: player.results.map((result) => ({
|
||||||
colour:
|
colour: result.colour === "B" ? "white" : result.colour === "N" ? "black" : "",
|
||||||
result.colour === "B"
|
|
||||||
? "white"
|
|
||||||
: result.colour === "N"
|
|
||||||
? "black"
|
|
||||||
: "",
|
|
||||||
opponent: result.opponent_name,
|
opponent: result.opponent_name,
|
||||||
...getResultDetails(result),
|
...getResultDetails(result),
|
||||||
...getEloDetails(result.opponent_elo),
|
...getEloDetails(result.opponent_elo),
|
||||||
@@ -156,10 +146,7 @@ export const fetchTournamentResults = actionClient
|
|||||||
})),
|
})),
|
||||||
);
|
);
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
if (
|
if (!("message" in error) || error.message !== "ERR_TOURNAMENT_NOT_FOUND") {
|
||||||
!("message" in error) ||
|
|
||||||
error.message !== "ERR_TOURNAMENT_NOT_FOUND"
|
|
||||||
) {
|
|
||||||
reportFetchError(id, error);
|
reportFetchError(id, error);
|
||||||
errorLog(JSON.stringify(error, null, 2));
|
errorLog(JSON.stringify(error, null, 2));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,9 +12,7 @@ const inputSchema = z.object({
|
|||||||
ffeId: z.string(),
|
ffeId: z.string(),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const getTournamentDetails = actionClient
|
export const getTournamentDetails = actionClient.schema(inputSchema).action(async (input) => {
|
||||||
.schema(inputSchema)
|
|
||||||
.action(async (input) => {
|
|
||||||
const { ffeId } = input.parsedInput;
|
const { ffeId } = input.parsedInput;
|
||||||
try {
|
try {
|
||||||
await dbConnect();
|
await dbConnect();
|
||||||
|
|||||||
@@ -23,9 +23,7 @@ export const myZones = actionClient.action(async () => {
|
|||||||
throw new Error("You must be logged in to fetch your zones");
|
throw new Error("You must be logged in to fetch your zones");
|
||||||
}
|
}
|
||||||
|
|
||||||
const zones = await collections
|
const zones = await collections.zones!.find({ userId: new ObjectId(user.user!.id!) }).toArray();
|
||||||
.zones!.find({ userId: new ObjectId(user.user!.id!) })
|
|
||||||
.toArray();
|
|
||||||
|
|
||||||
const result: Zone[] = zones.map((zone) => ({
|
const result: Zone[] = zones.map((zone) => ({
|
||||||
...omit(zone, ["_id", "userId"]),
|
...omit(zone, ["_id", "userId"]),
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user