mirror of
https://github.com/TheRealOwenRees/echecsfrance.git
synced 2026-11-18 15:32:07 +00:00
Compare commits
12
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
216dc70605
|
||
|
|
3fde18106d
|
||
|
|
29e3173d80
|
||
|
|
eef456938a
|
||
|
|
dc7621ea57
|
||
|
|
5ac3dc3ad5
|
||
|
|
33f6bf12b0
|
||
|
|
ac3db34079
|
||
|
|
ba7ae10c31
|
||
|
|
9eeca7b64c
|
||
|
|
d57fa83aca
|
||
|
|
abb766c2ae
|
@@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
"extends": ["next", "next/core-web-vitals", "prettier"],
|
|
||||||
"globals": {
|
|
||||||
"React": "readonly"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -12,6 +12,8 @@
|
|||||||
# pwa
|
# pwa
|
||||||
sw.*
|
sw.*
|
||||||
workbox*.*
|
workbox*.*
|
||||||
|
swe-worker*.*
|
||||||
|
!src/app/sw.ts
|
||||||
|
|
||||||
# testing
|
# testing
|
||||||
/coverage
|
/coverage
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"$schema": "./node_modules/oxfmt/configuration_schema.json",
|
||||||
|
"ignorePatterns": ["**/leaflet.d.ts"]
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"$schema": "./node_modules/oxlint/configuration_schema.json",
|
||||||
|
"ignorePatterns": ["**/leaflet.d.ts"],
|
||||||
|
"plugins": ["typescript", "unicorn", "oxc"],
|
||||||
|
"categories": {
|
||||||
|
"correctness": "error"
|
||||||
|
},
|
||||||
|
"rules": {},
|
||||||
|
"env": {
|
||||||
|
"builtin": true
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
{
|
|
||||||
"trailingComma": "all",
|
|
||||||
"bracketSpacing": true,
|
|
||||||
"plugins": ["@trivago/prettier-plugin-sort-imports", "prettier-plugin-tailwindcss"],
|
|
||||||
"importOrder": ["^react$", "^@?\\w", "^@\\\\", "<THIRD_PARTY_MODULES>", "^\\.\\.", "^\\."],
|
|
||||||
"importOrderSeparation": true,
|
|
||||||
"importOrderSortSpecifiers": true,
|
|
||||||
"tailwindFunctions": ["twMerge"]
|
|
||||||
}
|
|
||||||
@@ -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
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://unpkg.com/knip@6/schema.json",
|
||||||
|
"ignore": [],
|
||||||
|
"ignoreDependencies": [],
|
||||||
|
"tags": ["-lintignore"]
|
||||||
|
}
|
||||||
+2906
-5808
File diff suppressed because it is too large
Load Diff
+1502
-3000
File diff suppressed because it is too large
Load Diff
+18
-7
@@ -1,5 +1,10 @@
|
|||||||
/** @type {import('next').NextConfig} */
|
/** @type {import('next').NextConfig} */
|
||||||
const nextConfig = {};
|
const nextConfig = {
|
||||||
|
// react-leaflet v4 creates maps in a render-phase ref callback, which breaks
|
||||||
|
// under React dev StrictMode's double-mount ("Map container is already
|
||||||
|
// initialized"). StrictMode only runs in dev, so production is unaffected.
|
||||||
|
reactStrictMode: false,
|
||||||
|
};
|
||||||
|
|
||||||
const withBundleAnalyzer = require("@next/bundle-analyzer")({
|
const withBundleAnalyzer = require("@next/bundle-analyzer")({
|
||||||
enabled: process.env.ANALYZE === "true",
|
enabled: process.env.ANALYZE === "true",
|
||||||
@@ -7,10 +12,16 @@ const withBundleAnalyzer = require("@next/bundle-analyzer")({
|
|||||||
|
|
||||||
const withNextIntl = require("next-intl/plugin")("./src/i18n.ts");
|
const withNextIntl = require("next-intl/plugin")("./src/i18n.ts");
|
||||||
|
|
||||||
const withPWA = require("next-pwa")({
|
// PWA service worker, generated with Serwist. It hooks into webpack, so it is
|
||||||
dest: "public",
|
// only enabled for production builds (`next build --webpack`) and disabled for
|
||||||
disable: process.env.NODE_ENV === "development",
|
// development, letting `next dev` keep running on Turbopack.
|
||||||
});
|
const withSerwist =
|
||||||
|
process.env.NODE_ENV === "production"
|
||||||
|
? require("@serwist/next").default({
|
||||||
|
swSrc: "src/app/sw.ts",
|
||||||
|
swDest: "public/sw.js",
|
||||||
|
disable: process.env.NODE_ENV !== "production",
|
||||||
|
})
|
||||||
|
: (config) => config;
|
||||||
|
|
||||||
module.exports = nextConfig;
|
module.exports = withBundleAnalyzer(withNextIntl(withSerwist(nextConfig)));
|
||||||
module.exports = withBundleAnalyzer(withNextIntl(withPWA({})));
|
|
||||||
|
|||||||
+23
-22
@@ -5,24 +5,27 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "vitest --config vitetest.config.ts",
|
"test": "vitest --config vitetest.config.ts",
|
||||||
"dev": "next dev",
|
"dev": "next dev",
|
||||||
"build": "next build",
|
"build": "next build --webpack",
|
||||||
"start": "next start",
|
"start": "next start",
|
||||||
"lint": "next lint",
|
"lint": "oxlint",
|
||||||
"typeCheck": "tsc -p ./tsconfig.json",
|
"typeCheck": "tsc -p ./tsconfig.json",
|
||||||
"format": "prettier --check \"**/*.{js,jsx,ts,tsx}\"",
|
"postinstall": "patch-package",
|
||||||
"format:fix": "prettier --write \"**/*.{js,jsx,ts,tsx}\""
|
"format": "oxfmt --check",
|
||||||
|
"format:fix": "oxfmt",
|
||||||
|
"knip": "knip",
|
||||||
|
"knip:prod": "knip --production",
|
||||||
|
"knip:ci": "knip --production --cache"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@auth/mongodb-adapter": "^3.5.2",
|
"@auth/mongodb-adapter": "^3.5.2",
|
||||||
"@headlessui-float/react": "^0.15.0",
|
|
||||||
"@headlessui/react": "^2.1.8",
|
"@headlessui/react": "^2.1.8",
|
||||||
"@headlessui/tailwindcss": "^0.2.1",
|
"@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.4.2",
|
||||||
"@next/bundle-analyzer": "^14.0.4",
|
"@next/bundle-analyzer": "^16.3.6",
|
||||||
"@socialgouv/matomo-next": "^1.10.0",
|
"@serwist/next": "^9.5.12",
|
||||||
|
"@socialgouv/matomo-next": "^1.14.2",
|
||||||
"@tanstack/react-query": "^5.29.0",
|
"@tanstack/react-query": "^5.29.0",
|
||||||
"@trivago/prettier-plugin-sort-imports": "^4.2.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",
|
"@types/node": "^22.7.2",
|
||||||
"autoprefixer": "^10.4.16",
|
"autoprefixer": "^10.4.16",
|
||||||
@@ -30,6 +33,7 @@
|
|||||||
"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",
|
||||||
@@ -38,17 +42,18 @@
|
|||||||
"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": "^14.2.3",
|
"next": "^16.3.6",
|
||||||
"next-auth": "^5.0.0-beta.16",
|
"next-auth": "^5.0.0-beta.32",
|
||||||
"next-intl": "^3.3.2",
|
"next-intl": "^4.14.7",
|
||||||
"next-pwa": "^5.6.0",
|
|
||||||
"next-safe-action": "^7.9.3",
|
"next-safe-action": "^7.9.3",
|
||||||
"nodemailer": "^6.9.12",
|
"nodemailer": "^6.9.12",
|
||||||
|
"oxfmt": "^0.71.0",
|
||||||
|
"oxlint": "^1.86.0",
|
||||||
"postcss": "^8.4.47",
|
"postcss": "^8.4.47",
|
||||||
"react": "^18.2.0",
|
"react": "^19.3.0",
|
||||||
"react-date-range": "^2.0.1",
|
"react-date-range": "^2.0.1",
|
||||||
"react-datepicker": "^7.4.0",
|
"react-datepicker": "^7.4.0",
|
||||||
"react-dom": "^18.2.0",
|
"react-dom": "^19.3.0",
|
||||||
"react-hook-form": "^7.46.1",
|
"react-hook-form": "^7.46.1",
|
||||||
"react-icons": "^5.3.0",
|
"react-icons": "^5.3.0",
|
||||||
"react-input-mask": "^2.0.4",
|
"react-input-mask": "^2.0.4",
|
||||||
@@ -57,6 +62,7 @@
|
|||||||
"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",
|
||||||
"sharp": "^0.33.0",
|
"sharp": "^0.33.0",
|
||||||
"superjson": "^2.2.1",
|
"superjson": "^2.2.1",
|
||||||
"tailwind-merge": "^2.0.0",
|
"tailwind-merge": "^2.0.0",
|
||||||
@@ -73,16 +79,11 @@
|
|||||||
"@types/leaflet": "^1.9.12",
|
"@types/leaflet": "^1.9.12",
|
||||||
"@types/lodash": "^4.14.195",
|
"@types/lodash": "^4.14.195",
|
||||||
"@types/nodemailer": "^6.4.8",
|
"@types/nodemailer": "^6.4.8",
|
||||||
"@types/react": "^18.2.27",
|
"@types/react": "^19.3.0",
|
||||||
"@types/react-date-range": "^1.4.9",
|
"@types/react-date-range": "^1.4.9",
|
||||||
"@types/react-dom": "^18.2.18",
|
"@types/react-dom": "^19.3.0",
|
||||||
"@types/react-input-mask": "^3.0.2",
|
"@types/react-input-mask": "^3.0.2",
|
||||||
"eslint": "8",
|
"patch-package": "^8.0.1"
|
||||||
"eslint-config-next": "^14.0.4",
|
|
||||||
"eslint-config-prettier": "^9.0.0",
|
|
||||||
"eslint-plugin-react-hooks": "^5.0.0-canary-7118f5dd7-20230705",
|
|
||||||
"prettier": "^3.1.1",
|
|
||||||
"prettier-plugin-tailwindcss": "^0.6.8"
|
|
||||||
},
|
},
|
||||||
"packageManager": "yarn@1.22.22+sha1.ac34549e6aa8e7ead463a7407e1c7390f61a6610"
|
"packageManager": "yarn@1.22.22+sha1.ac34549e6aa8e7ead463a7407e1c7390f61a6610"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
diff --git a/node_modules/react-leaflet-cluster/lib/index.js b/node_modules/react-leaflet-cluster/lib/index.js
|
||||||
|
index 36ab0c1..ba2ae92 100644
|
||||||
|
--- a/node_modules/react-leaflet-cluster/lib/index.js
|
||||||
|
+++ b/node_modules/react-leaflet-cluster/lib/index.js
|
||||||
|
@@ -28,14 +28,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
var core_1 = require("@react-leaflet/core");
|
||||||
|
var leaflet_1 = __importDefault(require("leaflet"));
|
||||||
|
require("leaflet.markercluster");
|
||||||
|
-require("./assets/MarkerCluster.css");
|
||||||
|
-require("./assets/MarkerCluster.Default.css");
|
||||||
|
-delete leaflet_1.default.Icon.Default.prototype._getIconUrl;
|
||||||
|
-leaflet_1.default.Icon.Default.mergeOptions({
|
||||||
|
- iconRetinaUrl: require('./assets/marker-icon-2x.png').default,
|
||||||
|
- iconUrl: require('./assets/marker-icon.png').default,
|
||||||
|
- shadowUrl: require('./assets/marker-shadow.png').default,
|
||||||
|
-});
|
||||||
|
function getPropsAndEvents(props) {
|
||||||
|
var clusterProps = {};
|
||||||
|
var clusterEvents = {};
|
||||||
@@ -1 +0,0 @@
|
|||||||
self.__WB_DISABLE_DEV_LOGS=!0;
|
|
||||||
@@ -13,16 +13,12 @@ describe("clubs", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("contains manually entered club non-pending", () => {
|
test("contains manually entered club non-pending", () => {
|
||||||
const containsManuallyEnteredClub = clubData.some(
|
const containsManuallyEnteredClub = clubData.some((club) => club.manual_entry);
|
||||||
(club) => club.manual_entry,
|
|
||||||
);
|
|
||||||
expect(containsManuallyEnteredClub).toBeTruthy;
|
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)) {
|
||||||
@@ -34,13 +30,9 @@ describe("clubs", () => {
|
|||||||
|
|
||||||
const filteredData: IClub[] = filterClubsByManualEntry(clubData);
|
const filteredData: IClub[] = filterClubsByManualEntry(clubData);
|
||||||
|
|
||||||
const hasManualEnteredClubs = filteredData.some(
|
const hasManualEnteredClubs = filteredData.some((club) => club.manual_entry && !club.pending);
|
||||||
(club) => club.manual_entry && !club.pending,
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(filteredData.length).toEqual(
|
expect(filteredData.length).toEqual(clubData.length - duplicateClubNames.size);
|
||||||
clubData.length - duplicateClubNames.size,
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(hasManualEnteredClubs).toBeTruthy;
|
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 }),
|
||||||
}))}
|
}))}
|
||||||
|
|||||||
@@ -4,16 +4,14 @@ import SignInClient from "@/app/[locale]/(main)/auth/sign-in/SignInClient";
|
|||||||
import { baseUrl } from "@/constants";
|
import { baseUrl } from "@/constants";
|
||||||
|
|
||||||
export async function generateMetadata({
|
export async function generateMetadata({
|
||||||
params: { locale },
|
params,
|
||||||
}: {
|
}: {
|
||||||
params: { locale?: string };
|
params: Promise<{ locale?: string }>;
|
||||||
}): Promise<Metadata> {
|
}): Promise<Metadata> {
|
||||||
|
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>,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,14 +12,14 @@ import ClubsDisplay from "./ClubsDisplay";
|
|||||||
export const revalidate = 3600; // Revalidate cache every 6 hours
|
export const revalidate = 3600; // Revalidate cache every 6 hours
|
||||||
|
|
||||||
export async function generateMetadata({
|
export async function generateMetadata({
|
||||||
params: { locale },
|
params,
|
||||||
}: {
|
}: {
|
||||||
params: { locale?: string };
|
params: Promise<{ locale?: string }>;
|
||||||
}): Promise<Metadata> {
|
}): Promise<Metadata> {
|
||||||
|
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
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import { MapEvents } from "@/components/MapEvents";
|
|||||||
|
|
||||||
const center: LatLngLiteral = { lat: 47.0844, lng: 2.3964 };
|
const center: LatLngLiteral = { lat: 47.0844, lng: 2.3964 };
|
||||||
|
|
||||||
const MapCoordinateSelection = ( { page }: {page: "club" | "tournament"}) => {
|
const MapCoordinateSelection = ({ page }: { page: "club" | "tournament" }) => {
|
||||||
const { control, setValue } = useFormContext();
|
const { control, setValue } = useFormContext();
|
||||||
|
|
||||||
const latValue = useWatch({ control, name: `${page}.coordinates.0` });
|
const latValue = useWatch({ control, name: `${page}.coordinates.0` });
|
||||||
|
|||||||
@@ -21,9 +21,7 @@ export default function Navbar() {
|
|||||||
className="font-extrabold text-gray-900 no-underline hover:no-underline dark:text-white"
|
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>
|
||||||
|
|||||||
@@ -65,18 +65,13 @@ export const ManualEloForm = () => {
|
|||||||
|
|
||||||
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 +81,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 +107,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 +137,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 ? (
|
||||||
"-"
|
"-"
|
||||||
|
|||||||
@@ -4,14 +4,14 @@ import EloClient from "@/app/[locale]/(main)/elo/EloClient";
|
|||||||
import { baseUrl } from "@/constants";
|
import { baseUrl } from "@/constants";
|
||||||
|
|
||||||
export async function generateMetadata({
|
export async function generateMetadata({
|
||||||
params: { locale },
|
params,
|
||||||
}: {
|
}: {
|
||||||
params: { locale?: string };
|
params: Promise<{ locale?: string }>;
|
||||||
}): Promise<Metadata> {
|
}): Promise<Metadata> {
|
||||||
|
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://tinyanalytics.io" 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);
|
||||||
|
|
||||||
|
|||||||
@@ -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 = () => {
|
||||||
|
|||||||
@@ -3,17 +3,14 @@
|
|||||||
import { useCallback, useMemo } from "react";
|
import { useCallback, useMemo } from "react";
|
||||||
|
|
||||||
import { useAtomValue } from "jotai";
|
import { useAtomValue } from "jotai";
|
||||||
import L, { LatLngLiteral } from "leaflet";
|
import L from "leaflet";
|
||||||
import "leaflet-defaulticon-compatibility";
|
import "leaflet-defaulticon-compatibility";
|
||||||
import "leaflet-defaulticon-compatibility/dist/leaflet-defaulticon-compatibility.css";
|
import "leaflet-defaulticon-compatibility/dist/leaflet-defaulticon-compatibility.css";
|
||||||
import "leaflet.smooth_marker_bouncing";
|
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],
|
||||||
|
|||||||
@@ -43,19 +43,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]);
|
||||||
@@ -112,9 +107,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 +149,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";
|
||||||
@@ -20,16 +15,14 @@ import TournamentsDisplay from "./TournamentsDisplay";
|
|||||||
setDefaultOptions({ locale: fr });
|
setDefaultOptions({ locale: fr });
|
||||||
|
|
||||||
export async function generateMetadata({
|
export async function generateMetadata({
|
||||||
params: { locale },
|
params,
|
||||||
}: {
|
}: {
|
||||||
params: { locale?: string };
|
params: Promise<{ locale?: string }>;
|
||||||
}): Promise<Metadata> {
|
}): Promise<Metadata> {
|
||||||
|
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`,
|
||||||
@@ -107,10 +100,7 @@ const getTournaments = async () => {
|
|||||||
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[][]> = {};
|
||||||
@@ -140,9 +130,7 @@ const getTournaments = async () => {
|
|||||||
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.
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 197 KiB After Width: | Height: | Size: 197 KiB |
@@ -20,13 +20,10 @@ 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: { locale },
|
|
||||||
}: {
|
|
||||||
params: { 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 t = await getTranslations({
|
const t = await getTranslations({
|
||||||
locale: locale ?? "fr",
|
locale: locale ?? "fr",
|
||||||
namespace: "Metadata",
|
namespace: "Metadata",
|
||||||
@@ -48,11 +45,12 @@ export async function generateMetadata({
|
|||||||
|
|
||||||
export default async function RootLayout({
|
export default async function RootLayout({
|
||||||
children,
|
children,
|
||||||
params: { locale },
|
params,
|
||||||
}: {
|
}: {
|
||||||
children: ReactNode;
|
children: ReactNode;
|
||||||
params: { locale?: string };
|
params: Promise<{ locale?: string }>;
|
||||||
}) {
|
}) {
|
||||||
|
const { locale } = await params;
|
||||||
let messages;
|
let messages;
|
||||||
try {
|
try {
|
||||||
messages = (await import(`@/messages/${locale}.json`)).default;
|
messages = (await import(`@/messages/${locale}.json`)).default;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { GrLineChart } from "react-icons/gr";
|
|||||||
import { HiUserGroup } from "react-icons/hi2";
|
import { HiUserGroup } from "react-icons/hi2";
|
||||||
import { twMerge } from "tailwind-merge";
|
import { twMerge } from "tailwind-merge";
|
||||||
|
|
||||||
import bannerImage from "/public/banner.jpeg";
|
import bannerImage from "./banner.jpeg";
|
||||||
import { Link } from "@/utils/routing";
|
import { Link } from "@/utils/routing";
|
||||||
|
|
||||||
export default function Home() {
|
export default function Home() {
|
||||||
@@ -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>;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
import { defaultCache } from "@serwist/next/worker";
|
||||||
|
import type { PrecacheEntry } from "serwist";
|
||||||
|
import { Serwist } from "serwist";
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
interface WorkerGlobalScope {
|
||||||
|
__SW_MANIFEST: (PrecacheEntry | string)[] | undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
declare const self: WorkerGlobalScope;
|
||||||
|
|
||||||
|
const serwist = new Serwist({
|
||||||
|
precacheEntries: self.__SW_MANIFEST,
|
||||||
|
skipWaiting: true,
|
||||||
|
clientsClaim: true,
|
||||||
|
navigationPreload: true,
|
||||||
|
runtimeCaching: defaultCache,
|
||||||
|
});
|
||||||
|
|
||||||
|
serwist.addEventListeners();
|
||||||
+18
-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";
|
||||||
|
|
||||||
@@ -61,13 +48,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);
|
||||||
@@ -82,9 +70,7 @@ export const filteredTournamentsByTimeControlAndZoneAtom = atom((get) => {
|
|||||||
const { startDate, endDate } = dateRange[0];
|
const { startDate, endDate } = dateRange[0];
|
||||||
|
|
||||||
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()),
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
!isBefore(tournamentDate, startDate) &&
|
!isBefore(tournamentDate, startDate) &&
|
||||||
@@ -98,11 +84,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 +100,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 +112,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 +126,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 +145,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,7 @@
|
|||||||
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,8 +40,7 @@ export const buttonVariants = cva(
|
|||||||
intent: "primary",
|
intent: "primary",
|
||||||
size: "medium",
|
size: "medium",
|
||||||
},
|
},
|
||||||
},
|
});
|
||||||
);
|
|
||||||
|
|
||||||
export type ButtonVariants = VariantProps<typeof buttonVariants>;
|
export type ButtonVariants = VariantProps<typeof buttonVariants>;
|
||||||
export type ButtonProps = React.ComponentProps<"button"> & ButtonVariants;
|
export type ButtonProps = React.ComponentProps<"button"> & ButtonVariants;
|
||||||
@@ -54,8 +51,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}
|
|
||||||
/>
|
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
import { Float } from "@headlessui-float/react";
|
|
||||||
import { Menu, MenuButton, MenuItem, MenuItems } from "@headlessui/react";
|
import { Menu, MenuButton, MenuItem, MenuItems } from "@headlessui/react";
|
||||||
import { IoMdMore } from "react-icons/io";
|
import { IoMdMore } from "react-icons/io";
|
||||||
import { twMerge } from "tailwind-merge";
|
import { twMerge } from "tailwind-merge";
|
||||||
@@ -18,31 +17,21 @@ 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)}>
|
||||||
<Float
|
|
||||||
portal
|
|
||||||
placement="bottom-end"
|
|
||||||
offset={15}
|
|
||||||
enter="transition ease-out duration-100"
|
|
||||||
enterFrom="transform opacity-0 scale-95"
|
|
||||||
enterTo="transform opacity-100 scale-100"
|
|
||||||
leave="transition ease-in duration-75"
|
|
||||||
leaveFrom="transform opacity-100 scale-100"
|
|
||||||
leaveTo="transform opacity-0 scale-95"
|
|
||||||
>
|
|
||||||
{buttonComponent ?? (
|
{buttonComponent ?? (
|
||||||
<MenuButton>
|
<MenuButton>
|
||||||
<IoMdMore />
|
<IoMdMore />
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<MenuItems className="z-20 flex w-auto items-start overflow-hidden rounded-md bg-neutral-200 focus:outline-none dark:bg-neutral-600">
|
<MenuItems
|
||||||
|
anchor={{ to: "bottom end", gap: 15 }}
|
||||||
|
portal
|
||||||
|
transition
|
||||||
|
className="z-20 flex w-auto items-start overflow-hidden rounded-md bg-neutral-200 transition ease-out data-[closed]:scale-95 data-[closed]:opacity-0 focus:outline-none dark:bg-neutral-600"
|
||||||
|
>
|
||||||
<div className="flex flex-col px-1 py-1">
|
<div className="flex flex-col px-1 py-1">
|
||||||
{items.map(({ title, onClick, className, disabled }, i) => (
|
{items.map(({ title, onClick, className, disabled }, i) => (
|
||||||
<MenuItem key={i}>
|
<MenuItem key={i}>
|
||||||
@@ -65,7 +54,6 @@ export const DropdownMenu = ({
|
|||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</MenuItems>
|
</MenuItems>
|
||||||
</Float>
|
|
||||||
</Menu>
|
</Menu>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -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,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;
|
||||||
};
|
};
|
||||||
|
|||||||
+16
-27
@@ -12,6 +12,8 @@ import "leaflet/dist/leaflet.css";
|
|||||||
import { FaAngleDoubleDown } from "react-icons/fa";
|
import { FaAngleDoubleDown } from "react-icons/fa";
|
||||||
import { LayerGroup, MapContainer, TileLayer } from "react-leaflet";
|
import { LayerGroup, MapContainer, TileLayer } from "react-leaflet";
|
||||||
import MarkerClusterGroup from "react-leaflet-cluster";
|
import MarkerClusterGroup from "react-leaflet-cluster";
|
||||||
|
import "react-leaflet-cluster/lib/assets/MarkerCluster.css";
|
||||||
|
import "react-leaflet-cluster/lib/assets/MarkerCluster.Default.css";
|
||||||
|
|
||||||
import { debouncedHoveredListIdAtom, mapBoundsAtom } from "@/atoms";
|
import { debouncedHoveredListIdAtom, mapBoundsAtom } from "@/atoms";
|
||||||
import { MapEvents } from "@/components/MapEvents";
|
import { MapEvents } from "@/components/MapEvents";
|
||||||
@@ -57,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: markers,
|
|
||||||
iconCreateFunction,
|
|
||||||
}: MapProps) => {
|
|
||||||
const setMapBounds = useSetAtom(mapBoundsAtom);
|
const setMapBounds = useSetAtom(mapBoundsAtom);
|
||||||
|
|
||||||
const hoveredListTournamentId = useAtomValue(debouncedHoveredListIdAtom);
|
const hoveredListTournamentId = useAtomValue(debouncedHoveredListIdAtom);
|
||||||
@@ -80,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
|
||||||
@@ -138,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;
|
||||||
@@ -157,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();
|
||||||
@@ -186,18 +176,22 @@ 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(
|
||||||
() =>
|
() =>
|
||||||
markers.map((marker) =>
|
markers.map((marker) =>
|
||||||
React.cloneElement(marker.component, {
|
React.cloneElement(
|
||||||
|
marker.component as React.ReactElement<{
|
||||||
|
ref?: (ref: MarkerRef) => void;
|
||||||
|
}>,
|
||||||
|
{
|
||||||
ref: (ref: MarkerRef) => {
|
ref: (ref: MarkerRef) => {
|
||||||
markerRefs.current[marker.markerId] = ref;
|
markerRefs.current[marker.markerId] = ref;
|
||||||
},
|
},
|
||||||
}),
|
},
|
||||||
|
),
|
||||||
),
|
),
|
||||||
[markers],
|
[markers],
|
||||||
);
|
);
|
||||||
@@ -240,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;
|
||||||
@@ -56,10 +53,7 @@ export const MapEvents = ({
|
|||||||
}, [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"),
|
||||||
|
|||||||
@@ -1,23 +1,26 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
|
import { useEffect } from "react";
|
||||||
|
|
||||||
import { trackAppRouter } from "@socialgouv/matomo-next";
|
import { trackAppRouter } from "@socialgouv/matomo-next";
|
||||||
import { usePathname, useSearchParams } from "next/navigation";
|
import { usePathname, useSearchParams } from "next/navigation";
|
||||||
import { useEffect } from "react";
|
|
||||||
|
|
||||||
const MATOMO_URL = process.env.NEXT_PUBLIC_MATOMO_URL;
|
const MATOMO_URL = process.env.NEXT_PUBLIC_MATOMO_URL;
|
||||||
const MATOMO_SITE_ID = process.env.NEXT_PUBLIC_MATOMO_SITE_ID;
|
const MATOMO_SITE_ID = process.env.NEXT_PUBLIC_MATOMO_SITE_ID;
|
||||||
|
const isMatomoEnabled = Boolean(MATOMO_URL && MATOMO_SITE_ID);
|
||||||
|
|
||||||
export function MatomoAnalytics() {
|
export function MatomoAnalytics() {
|
||||||
const pathname = usePathname();
|
const pathname = usePathname();
|
||||||
const searchParams = useSearchParams();
|
const searchParams = useSearchParams();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (!isMatomoEnabled) return;
|
||||||
|
|
||||||
trackAppRouter({
|
trackAppRouter({
|
||||||
url: MATOMO_URL || "",
|
url: MATOMO_URL as string,
|
||||||
siteId: MATOMO_SITE_ID || "",
|
siteId: MATOMO_SITE_ID as string,
|
||||||
pathname,
|
pathname,
|
||||||
searchParams, // Pass URLSearchParams object directly
|
searchParams,
|
||||||
// Optional: Enable additional features
|
|
||||||
enableHeatmapSessionRecording: false,
|
enableHeatmapSessionRecording: false,
|
||||||
enableHeartBeatTimer: true,
|
enableHeartBeatTimer: true,
|
||||||
cleanUrl: true,
|
cleanUrl: true,
|
||||||
|
|||||||
@@ -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();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -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,14 +46,11 @@ 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");
|
||||||
@@ -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) =>
|
(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;
|
||||||
|
|||||||
@@ -5,12 +5,7 @@ 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";
|
||||||
@@ -93,11 +88,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 +115,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>
|
||||||
|
|
||||||
|
|||||||
@@ -11,8 +11,7 @@ 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,
|
||||||
|
|||||||
@@ -3,23 +3,14 @@ import { twMerge } from "tailwind-merge";
|
|||||||
import { Prettify } from "@/types";
|
import { Prettify } from "@/types";
|
||||||
|
|
||||||
type LabelProps = Prettify<
|
type LabelProps = Prettify<
|
||||||
React.DetailedHTMLProps<
|
React.DetailedHTMLProps<React.LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement> & {
|
||||||
React.LabelHTMLAttributes<HTMLLabelElement>,
|
|
||||||
HTMLLabelElement
|
|
||||||
> & {
|
|
||||||
required?: boolean;
|
required?: boolean;
|
||||||
className?: string;
|
className?: string;
|
||||||
tooltip?: React.ReactNode;
|
tooltip?: React.ReactNode;
|
||||||
}
|
}
|
||||||
>;
|
>;
|
||||||
|
|
||||||
export const Label = ({
|
export const Label = ({ required, className, children, tooltip, ...labelProps }: LabelProps) => {
|
||||||
required,
|
|
||||||
className,
|
|
||||||
children,
|
|
||||||
tooltip,
|
|
||||||
...labelProps
|
|
||||||
}: LabelProps) => {
|
|
||||||
return (
|
return (
|
||||||
<label
|
<label
|
||||||
{...labelProps}
|
{...labelProps}
|
||||||
|
|||||||
@@ -3,12 +3,7 @@ import React from "react";
|
|||||||
import { RadioGroup } from "@headlessui/react";
|
import { RadioGroup } from "@headlessui/react";
|
||||||
import { isNil } from "lodash";
|
import { isNil } from "lodash";
|
||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
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";
|
||||||
@@ -17,7 +12,7 @@ import { Field, GenericFieldProps } from "./Field";
|
|||||||
|
|
||||||
export type BaseOption<T = string, D = unknown> = {
|
export type BaseOption<T = string, D = unknown> = {
|
||||||
value: T;
|
value: T;
|
||||||
label: string | JSX.Element;
|
label: string | React.JSX.Element;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
data?: D;
|
data?: D;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -8,17 +8,13 @@ import { Prettify } from "@/types";
|
|||||||
|
|
||||||
export type BaseOption<T = string, D = unknown> = {
|
export type BaseOption<T = string, D = unknown> = {
|
||||||
value: T;
|
value: T;
|
||||||
label: string | JSX.Element;
|
label: string | React.JSX.Element;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
data?: D;
|
data?: D;
|
||||||
};
|
};
|
||||||
|
|
||||||
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 });
|
||||||
@@ -91,7 +80,7 @@ export const TournamentSelectField = <
|
|||||||
background: `${TimeControlColours[option.data!.timeControl]}`,
|
background: `${TimeControlColours[option.data!.timeControl]}`,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{at("timeControlEnum", { tc: option.data?.timeControl })}
|
{at("timeControlEnum", { tc: option.data!.timeControl })}
|
||||||
</div>
|
</div>
|
||||||
<div className="text-xs">{option.data?.date}</div>
|
<div className="text-xs">{option.data?.date}</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ export type ZoneEditorProps = {
|
|||||||
|
|
||||||
export const ZoneEditor = ({ value, onChange }: ZoneEditorProps) => {
|
export const ZoneEditor = ({ value, onChange }: ZoneEditorProps) => {
|
||||||
const initialFeatures = React.useRef(value?.features);
|
const initialFeatures = React.useRef(value?.features);
|
||||||
const featureGroup = React.useRef<L.FeatureGroup>();
|
const featureGroup = React.useRef<L.FeatureGroup | null>(null);
|
||||||
|
|
||||||
const setFeatureCollectionRef = (element: L.FeatureGroup) => {
|
const setFeatureCollectionRef = (element: L.FeatureGroup) => {
|
||||||
featureGroup.current = element;
|
featureGroup.current = element;
|
||||||
@@ -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));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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,6 @@ function create(screens: object | undefined) {
|
|||||||
} as CreatorReturnType;
|
} as CreatorReturnType;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const { useBreakpoint, useBreakpointEffect, useBreakpointValue } =
|
export const { useBreakpoint, useBreakpointEffect, useBreakpointValue } = create(
|
||||||
create(config.theme!.screens);
|
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"
|
||||||
|
|||||||
@@ -6,16 +6,14 @@ const useDatePickerWidth = ({
|
|||||||
datePickerRef,
|
datePickerRef,
|
||||||
setDateDirectionState,
|
setDateDirectionState,
|
||||||
}: {
|
}: {
|
||||||
datePickerRef: RefObject<HTMLDivElement>;
|
datePickerRef: RefObject<HTMLDivElement | null>;
|
||||||
setDateDirectionState: Dispatch<SetStateAction<DatePickerDirection>>;
|
setDateDirectionState: Dispatch<SetStateAction<DatePickerDirection>>;
|
||||||
}) => {
|
}) => {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
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
|
isLg ? setDateDirectionState("horizontal") : setDateDirectionState("vertical");
|
||||||
? setDateDirectionState("horizontal")
|
|
||||||
: 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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 =
|
||||||
|
|||||||
+4
-2
@@ -3,11 +3,13 @@ import { notFound } from "next/navigation";
|
|||||||
|
|
||||||
import { routing } from "./utils/routing";
|
import { routing } from "./utils/routing";
|
||||||
|
|
||||||
export default getRequestConfig(async ({ locale }) => {
|
export default getRequestConfig(async ({ requestLocale }) => {
|
||||||
// Validate that the incoming `locale` parameter is valid
|
// Validate that the incoming `locale` parameter is valid
|
||||||
if (!routing.locales.includes(locale as any)) notFound();
|
const locale = await requestLocale;
|
||||||
|
if (!locale || !routing.locales.includes(locale as any)) notFound();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
locale,
|
||||||
messages: (
|
messages: (
|
||||||
await (locale === "en"
|
await (locale === "en"
|
||||||
? // When using Turbopack, this will enable HMR for `en`
|
? // When using Turbopack, this will enable HMR for `en`
|
||||||
|
|||||||
@@ -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
+2
-2
@@ -20,8 +20,8 @@ export const addClubSchema = z.object({
|
|||||||
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.string().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" }),
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|
||||||
@@ -56,4 +54,4 @@ export const addClub = actionClient
|
|||||||
errorLog(error);
|
errorLog(error);
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -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;
|
||||||
@@ -81,4 +74,4 @@ export const addTournament = actionClient
|
|||||||
errorLog(error);
|
errorLog(error);
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,15 +1,11 @@
|
|||||||
"use server";
|
"use server";
|
||||||
|
|
||||||
import { z } from "zod";
|
|
||||||
|
|
||||||
import { contactUsSchema } from "@/schemas";
|
import { contactUsSchema } from "@/schemas";
|
||||||
import { errorLog } from "@/utils/logger";
|
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, {
|
||||||
@@ -35,4 +31,4 @@ export const contactUs = actionClient
|
|||||||
errorLog(error);
|
errorLog(error);
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -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();
|
||||||
|
|
||||||
@@ -37,4 +35,4 @@ export const createZone = actionClient
|
|||||||
errorLog(error);
|
errorLog(error);
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
"use server";
|
"use server";
|
||||||
|
|
||||||
import { ObjectId } from "mongodb";
|
import { ObjectId } from "mongodb";
|
||||||
import { z } from "zod";
|
|
||||||
|
|
||||||
import { adapter, auth } from "@/auth";
|
import { adapter, auth } from "@/auth";
|
||||||
import { collections, dbConnect } from "@/server/mongodb";
|
import { collections, dbConnect } from "@/server/mongodb";
|
||||||
|
|||||||
@@ -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 {
|
||||||
@@ -40,4 +38,4 @@ export const deleteZone = actionClient
|
|||||||
errorLog(error);
|
errorLog(error);
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -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();
|
||||||
@@ -52,4 +50,4 @@ export const editZone = actionClient
|
|||||||
errorLog(error);
|
errorLog(error);
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -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();
|
||||||
@@ -43,4 +41,4 @@ export const getTournamentDetails = actionClient
|
|||||||
errorLog(JSON.stringify(error, null, 2));
|
errorLog(JSON.stringify(error, null, 2));
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -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"]),
|
||||||
|
|||||||
@@ -17,20 +17,10 @@ const inputSchema = z.object({
|
|||||||
|
|
||||||
export type SearchedTournament = Pick<
|
export type SearchedTournament = Pick<
|
||||||
Tournament,
|
Tournament,
|
||||||
| "id"
|
"id" | "ffeId" | "date" | "department" | "status" | "timeControl" | "tournament" | "town" | "url"
|
||||||
| "ffeId"
|
|
||||||
| "date"
|
|
||||||
| "department"
|
|
||||||
| "status"
|
|
||||||
| "timeControl"
|
|
||||||
| "tournament"
|
|
||||||
| "town"
|
|
||||||
| "url"
|
|
||||||
>;
|
>;
|
||||||
|
|
||||||
export const searchTournaments = actionClient
|
export const searchTournaments = actionClient.schema(inputSchema).action(async (input) => {
|
||||||
.schema(inputSchema)
|
|
||||||
.action(async (input) => {
|
|
||||||
const { searchValue, limit } = input.parsedInput;
|
const { searchValue, limit } = input.parsedInput;
|
||||||
try {
|
try {
|
||||||
await dbConnect();
|
await dbConnect();
|
||||||
@@ -93,4 +83,4 @@ export const searchTournaments = actionClient
|
|||||||
errorLog(JSON.stringify(error, null, 2));
|
errorLog(JSON.stringify(error, null, 2));
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -9,9 +9,7 @@ import { errorLog } from "@/utils/logger";
|
|||||||
|
|
||||||
import { actionClient } from "./safeAction";
|
import { actionClient } from "./safeAction";
|
||||||
|
|
||||||
export const setUserLocale = actionClient
|
export const setUserLocale = actionClient.schema(z.string()).action(async (input) => {
|
||||||
.schema(z.string())
|
|
||||||
.action(async (input) => {
|
|
||||||
try {
|
try {
|
||||||
await dbConnect();
|
await dbConnect();
|
||||||
|
|
||||||
@@ -30,4 +28,4 @@ export const setUserLocale = actionClient
|
|||||||
errorLog(error);
|
errorLog(error);
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user