mirror of
https://github.com/TheRealOwenRees/echecsfrance.git
synced 2026-11-18 07:22:06 +00:00
upgrade Nodemailer to v10
fix dead code with knip upgrade TS to v6 and fix linting errors auto apply oxfmt rules fix linting errors - unused deps etc ignore file remove all ignored files in knip add knip - dead code analysis tool swap prettier and eslint of oxfmt and oxlint fix: fix map rendering in react strict mode fix: headlessUI float replace fix: disable Matomo if not URL and SITE ID exist upgrade: 1st pass upgrade to Next.js v16 deps: upgrade react to v19
This commit is contained in:
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"extends": ["next", "next/core-web-vitals", "prettier"],
|
||||
"globals": {
|
||||
"React": "readonly"
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,8 @@
|
||||
# pwa
|
||||
sw.*
|
||||
workbox*.*
|
||||
swe-worker*.*
|
||||
!src/app/sw.ts
|
||||
|
||||
# testing
|
||||
/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
-1
@@ -5,10 +5,12 @@ When contributing to this repository, please first discuss the change you wish t
|
||||
## Development Environment Setup
|
||||
|
||||
### Prerequisites
|
||||
|
||||
- [Yarn](https://classic.yarnpkg.com/lang/en/docs/install/#debian-stable)
|
||||
- [Docker](https://docs.docker.com/engine/install/)
|
||||
|
||||
### Setup
|
||||
|
||||
1. Fork the repository
|
||||
2. Clone your fork locally
|
||||
3. Run `yarn` to install dependencies
|
||||
@@ -18,12 +20,14 @@ 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.
|
||||
|
||||
### Branching
|
||||
|
||||
- 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.
|
||||
- Non-feature branches are allowed, but please give a clear name to your branch such as `hotfix/fix-bug`
|
||||
|
||||
## Pull Request Process
|
||||
|
||||
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
|
||||
3. When opening a PR, give a clear overview of what your changes are and why
|
||||
4. Wait for review and approval
|
||||
4. Wait for review and approval
|
||||
|
||||
+1
-1
@@ -6,4 +6,4 @@ services:
|
||||
ports:
|
||||
- "27017:27017"
|
||||
volumes:
|
||||
- ./mongo/init:/docker-entrypoint-initdb.d
|
||||
- ./mongo/init:/docker-entrypoint-initdb.d
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"$schema": "https://unpkg.com/knip@6/schema.json",
|
||||
"ignore": [
|
||||
"src/app/sw.ts",
|
||||
"src/i18n.ts",
|
||||
"src/__tests__/clubs/helpers/clubData.ts"
|
||||
],
|
||||
"ignoreDependencies": [
|
||||
"leaflet.markercluster",
|
||||
"serwist",
|
||||
"sharp",
|
||||
"superjson",
|
||||
"@swc-jotai/react-refresh",
|
||||
"@testing-library/jest-dom",
|
||||
"@headlessui/tailwindcss",
|
||||
"@next/bundle-analyzer",
|
||||
"@serwist/next",
|
||||
"oxfmt",
|
||||
"oxlint",
|
||||
"vitest"
|
||||
],
|
||||
"tags": ["-lintignore"]
|
||||
}
|
||||
+10650
-13552
File diff suppressed because it is too large
Load Diff
+11002
-12500
File diff suppressed because it is too large
Load Diff
+18
-7
@@ -1,5 +1,10 @@
|
||||
/** @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")({
|
||||
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 withPWA = require("next-pwa")({
|
||||
dest: "public",
|
||||
disable: process.env.NODE_ENV === "development",
|
||||
});
|
||||
// PWA service worker, generated with Serwist. It hooks into webpack, so it is
|
||||
// only enabled for production builds (`next build --webpack`) and disabled for
|
||||
// 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(withPWA({})));
|
||||
module.exports = withBundleAnalyzer(withNextIntl(withSerwist(nextConfig)));
|
||||
|
||||
+26
-26
@@ -5,31 +5,34 @@
|
||||
"scripts": {
|
||||
"test": "vitest --config vitetest.config.ts",
|
||||
"dev": "next dev",
|
||||
"build": "next build",
|
||||
"build": "next build --webpack",
|
||||
"start": "next start",
|
||||
"lint": "next lint",
|
||||
"lint": "oxlint",
|
||||
"typeCheck": "tsc -p ./tsconfig.json",
|
||||
"format": "prettier --check \"**/*.{js,jsx,ts,tsx}\"",
|
||||
"format:fix": "prettier --write \"**/*.{js,jsx,ts,tsx}\""
|
||||
"postinstall": "patch-package",
|
||||
"format": "oxfmt --check",
|
||||
"format:fix": "oxfmt",
|
||||
"knip": "knip",
|
||||
"knip:prod": "knip --production",
|
||||
"knip:ci": "knip --production --cache"
|
||||
},
|
||||
"dependencies": {
|
||||
"@auth/mongodb-adapter": "^3.5.2",
|
||||
"@headlessui-float/react": "^0.15.0",
|
||||
"@headlessui/react": "^2.1.8",
|
||||
"@headlessui/tailwindcss": "^0.2.1",
|
||||
"@hookform/resolvers": "^3.9.0",
|
||||
"@infra-blocks/zod-utils": "^0.4.2",
|
||||
"@next/bundle-analyzer": "^14.0.4",
|
||||
"@socialgouv/matomo-next": "^1.10.0",
|
||||
"@next/bundle-analyzer": "^16.3.6",
|
||||
"@serwist/next": "^9.5.12",
|
||||
"@socialgouv/matomo-next": "^1.14.2",
|
||||
"@tanstack/react-query": "^5.29.0",
|
||||
"@trivago/prettier-plugin-sort-imports": "^4.2.0",
|
||||
"@turf/boolean-point-in-polygon": "^7.0.0-alpha.114",
|
||||
"@types/node": "^22.7.2",
|
||||
"autoprefixer": "^10.4.16",
|
||||
"class-variance-authority": "^0.7.0",
|
||||
"date-fns": "^4.1.0",
|
||||
"geojson": "^0.5.0",
|
||||
"jotai": "^2.6.1",
|
||||
"knip": "^6.38.0",
|
||||
"leaflet": "^1.9.4",
|
||||
"leaflet-defaulticon-compatibility": "^0.1.2",
|
||||
"leaflet-draw": "^1.0.4",
|
||||
@@ -38,17 +41,18 @@
|
||||
"leaflet.smooth_marker_bouncing": "3.0.3",
|
||||
"lodash": "^4.17.21",
|
||||
"mongodb": "^7.0.0",
|
||||
"next": "^14.2.3",
|
||||
"next-auth": "^5.0.0-beta.16",
|
||||
"next-intl": "^3.3.2",
|
||||
"next-pwa": "^5.6.0",
|
||||
"next": "^16.3.6",
|
||||
"next-auth": "^5.0.0-beta.32",
|
||||
"next-intl": "^4.14.7",
|
||||
"next-safe-action": "^7.9.3",
|
||||
"nodemailer": "^6.9.12",
|
||||
"nodemailer": "^10.0.12",
|
||||
"oxfmt": "^0.71.0",
|
||||
"oxlint": "^1.86.0",
|
||||
"postcss": "^8.4.47",
|
||||
"react": "^18.2.0",
|
||||
"react": "^19.3.0",
|
||||
"react-date-range": "^2.0.1",
|
||||
"react-datepicker": "^7.4.0",
|
||||
"react-dom": "^18.2.0",
|
||||
"react-dom": "^19.3.0",
|
||||
"react-hook-form": "^7.46.1",
|
||||
"react-icons": "^5.3.0",
|
||||
"react-input-mask": "^2.0.4",
|
||||
@@ -57,11 +61,12 @@
|
||||
"react-leaflet-draw": "^0.20.4",
|
||||
"react-select": "^5.7.4",
|
||||
"react-tooltip": "^5.18.0",
|
||||
"serwist": "^9.5.12",
|
||||
"sharp": "^0.33.0",
|
||||
"superjson": "^2.2.1",
|
||||
"tailwind-merge": "^2.0.0",
|
||||
"tailwindcss": "^3.3.5",
|
||||
"typescript": "^5.3.3",
|
||||
"typescript": "^6.0.3",
|
||||
"vitest": "^4.0.12",
|
||||
"zod": "^3.22.4"
|
||||
},
|
||||
@@ -72,17 +77,12 @@
|
||||
"@testing-library/jest-dom": "^6.1.2",
|
||||
"@types/leaflet": "^1.9.12",
|
||||
"@types/lodash": "^4.14.195",
|
||||
"@types/nodemailer": "^6.4.8",
|
||||
"@types/react": "^18.2.27",
|
||||
"@types/node": "^24.19.0",
|
||||
"@types/react": "^19.3.0",
|
||||
"@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",
|
||||
"eslint": "8",
|
||||
"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"
|
||||
"patch-package": "^8.0.1"
|
||||
},
|
||||
"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 = {};
|
||||
+30
-30
@@ -1,31 +1,31 @@
|
||||
{
|
||||
"theme_color": "#00A1F0",
|
||||
"background_color": "#00A1F0",
|
||||
"display": "standalone",
|
||||
"scope": "/",
|
||||
"start_url": "/",
|
||||
"name": "Echecs France",
|
||||
"short_name": "Echecs France",
|
||||
"icons": [
|
||||
{
|
||||
"src": "/icon-192x192.png",
|
||||
"sizes": "192x192",
|
||||
"type": "image/png"
|
||||
},
|
||||
{
|
||||
"src": "/icon-256x256.png",
|
||||
"sizes": "256x256",
|
||||
"type": "image/png"
|
||||
},
|
||||
{
|
||||
"src": "/icon-384x384.png",
|
||||
"sizes": "384x384",
|
||||
"type": "image/png"
|
||||
},
|
||||
{
|
||||
"src": "/icon-512x512.png",
|
||||
"sizes": "512x512",
|
||||
"type": "image/png"
|
||||
}
|
||||
]
|
||||
}
|
||||
"theme_color": "#00A1F0",
|
||||
"background_color": "#00A1F0",
|
||||
"display": "standalone",
|
||||
"scope": "/",
|
||||
"start_url": "/",
|
||||
"name": "Echecs France",
|
||||
"short_name": "Echecs France",
|
||||
"icons": [
|
||||
{
|
||||
"src": "/icon-192x192.png",
|
||||
"sizes": "192x192",
|
||||
"type": "image/png"
|
||||
},
|
||||
{
|
||||
"src": "/icon-256x256.png",
|
||||
"sizes": "256x256",
|
||||
"type": "image/png"
|
||||
},
|
||||
{
|
||||
"src": "/icon-384x384.png",
|
||||
"sizes": "384x384",
|
||||
"type": "image/png"
|
||||
},
|
||||
{
|
||||
"src": "/icon-512x512.png",
|
||||
"sizes": "512x512",
|
||||
"type": "image/png"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
self.__WB_DISABLE_DEV_LOGS=!0;
|
||||
@@ -1,7 +1,5 @@
|
||||
import { describe, expect, test } from "vitest";
|
||||
|
||||
import { IClub, filterClubsByManualEntry } from "@/utils/clubFilters";
|
||||
|
||||
import { clubData } from "./helpers/clubData";
|
||||
|
||||
describe("clubs", () => {
|
||||
@@ -12,17 +10,8 @@ describe("clubs", () => {
|
||||
expect(originalLength).toEqual(filteredLength);
|
||||
});
|
||||
|
||||
test("contains manually entered club non-pending", () => {
|
||||
const containsManuallyEnteredClub = clubData.some(
|
||||
(club) => club.manual_entry,
|
||||
);
|
||||
expect(containsManuallyEnteredClub).toBeTruthy;
|
||||
});
|
||||
|
||||
test("manual entered club filters out auto-generated club of same name", () => {
|
||||
const duplicateClubNames: Set<string> = new Set(
|
||||
clubData.map((club) => club.name),
|
||||
);
|
||||
const duplicateClubNames: Set<string> = new Set(clubData.map((club) => club.name));
|
||||
|
||||
for (const club of clubData) {
|
||||
if (duplicateClubNames.has(club.name)) {
|
||||
@@ -33,15 +22,6 @@ describe("clubs", () => {
|
||||
}
|
||||
|
||||
const filteredData: IClub[] = filterClubsByManualEntry(clubData);
|
||||
|
||||
const hasManualEnteredClubs = filteredData.some(
|
||||
(club) => club.manual_entry && !club.pending,
|
||||
);
|
||||
|
||||
expect(filteredData.length).toEqual(
|
||||
clubData.length - duplicateClubNames.size,
|
||||
);
|
||||
|
||||
expect(hasManualEnteredClubs).toBeTruthy;
|
||||
expect(filteredData.length).toEqual(clubData.length - duplicateClubNames.size);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -5,8 +5,7 @@ export const clubData = [
|
||||
_id: new ObjectId("690586c9e06ce80de6cd7315"),
|
||||
name: '"Le Gambit "de Muret',
|
||||
url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=1264",
|
||||
address:
|
||||
"Maison des Associations 5 Sq des Combattants d'Afrique du Nord Salle B3 31600 MURET",
|
||||
address: "Maison des Associations 5 Sq des Combattants d'Afrique du Nord Salle B3 31600 MURET",
|
||||
email: "gambitdemuret@gmail.com",
|
||||
website: "http://www.gambit-de-muret.webou.net",
|
||||
coordinates: [43.46106289999999, 1.3218611],
|
||||
@@ -191,8 +190,7 @@ export const clubData = [
|
||||
_id: new ObjectId("690586c9e06ce80de6cd7336"),
|
||||
name: "ASSM - Ass sportive St Medard en Jalles",
|
||||
url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=3104",
|
||||
address:
|
||||
"Complexe Sportif R. Monseau rue Charles Capsec 33160 ST MEDARD EN JALLES",
|
||||
address: "Complexe Sportif R. Monseau rue Charles Capsec 33160 ST MEDARD EN JALLES",
|
||||
email: "stephane.bastin1805@gmail.com",
|
||||
website: "",
|
||||
coordinates: [44.8839858, -0.7063288999999999],
|
||||
@@ -255,8 +253,7 @@ export const clubData = [
|
||||
_id: new ObjectId("690586c9e06ce80de6cd74c5"),
|
||||
name: "Albertville Savoie Echecs",
|
||||
url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=3200",
|
||||
address:
|
||||
"Maison des Associations 21 rue Georges Lamarque 73200 ALBERTVILLE",
|
||||
address: "Maison des Associations 21 rue Georges Lamarque 73200 ALBERTVILLE",
|
||||
email: "albertville.savoie.echecs@gmail.com",
|
||||
website: "https://www.albertville-savoie-echecs.fr",
|
||||
coordinates: [45.6680374, 6.377434999999999],
|
||||
@@ -302,8 +299,7 @@ export const clubData = [
|
||||
_id: new ObjectId("690586c9e06ce80de6cd7241"),
|
||||
name: "Amicale Echecs de Divonne les Bains",
|
||||
url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=3410",
|
||||
address:
|
||||
"Bet Adonide Res Divona Park 268 Bld des Epinettes 01220 DIVONNE LES BAINS",
|
||||
address: "Bet Adonide Res Divona Park 268 Bld des Epinettes 01220 DIVONNE LES BAINS",
|
||||
email: "echecs@lalieu.com",
|
||||
website: "",
|
||||
coordinates: [46.3464497, 6.1342244],
|
||||
@@ -321,8 +317,7 @@ export const clubData = [
|
||||
_id: new ObjectId("690586c9e06ce80de6cd7324"),
|
||||
name: "Arcachon Echecs",
|
||||
url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=98",
|
||||
address:
|
||||
"Nouveau Cercle Arcachonnais 195 boulevard de la Plage 33120 ARCACHON",
|
||||
address: "Nouveau Cercle Arcachonnais 195 boulevard de la Plage 33120 ARCACHON",
|
||||
email: "regislegendre@free.fr",
|
||||
website: "http://www.ncarcachon.fr/",
|
||||
coordinates: [44.6626304, -1.1692262],
|
||||
@@ -340,8 +335,7 @@ export const clubData = [
|
||||
_id: new ObjectId("690586c9e06ce80de6cd75b8"),
|
||||
name: "Arcueil Chessland",
|
||||
url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=678",
|
||||
address:
|
||||
"1-2 rue Fernand Forest groupe Scolaire Jean Mace Cote Gardienne 94110 ARCUEIL",
|
||||
address: "1-2 rue Fernand Forest groupe Scolaire Jean Mace Cote Gardienne 94110 ARCUEIL",
|
||||
email: "matoz@wanadoo.fr",
|
||||
website: "http://www.arcueil-chessland.fr/",
|
||||
coordinates: [48.79920260000001, 2.3391093],
|
||||
@@ -458,8 +452,7 @@ export const clubData = [
|
||||
_id: new ObjectId("690586c9e06ce80de6cd726a"),
|
||||
name: "Aubenas Vals Echiquier Cévenol",
|
||||
url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=505",
|
||||
address:
|
||||
"Centre Socio Culturel Le palabre 6 rue Albert Seibel 07200 AUBENAS",
|
||||
address: "Centre Socio Culturel Le palabre 6 rue Albert Seibel 07200 AUBENAS",
|
||||
email: "jean.louis.bourquard@free.fr",
|
||||
website: "http://aubenasvals-echecs.fr",
|
||||
coordinates: [44.6173697, 4.388114],
|
||||
@@ -522,8 +515,7 @@ export const clubData = [
|
||||
_id: new ObjectId("690586c9e06ce80de6cd7262"),
|
||||
name: "Azur Chess Club",
|
||||
url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=2680",
|
||||
address:
|
||||
"Res le Marco Polo Ketch D 2e Etage 312 Bld des Ecureuils 06210 MANDELIEU LA NAPOULE",
|
||||
address: "Res le Marco Polo Ketch D 2e Etage 312 Bld des Ecureuils 06210 MANDELIEU LA NAPOULE",
|
||||
email: "eric.sighirdjian@sfr.fr",
|
||||
website: "http://azurchessclub.fr",
|
||||
coordinates: [43.5420528, 6.9443551],
|
||||
@@ -749,8 +741,7 @@ export const clubData = [
|
||||
_id: new ObjectId("690586c9e06ce80de6cd7524"),
|
||||
name: 'C.E. Fontenay le Fleury "Les Fous Furieux"',
|
||||
url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=819",
|
||||
address:
|
||||
"Maison des Associations 5 rue Jean Jaures 78330 FONTENAY LE FLEURY",
|
||||
address: "Maison des Associations 5 rue Jean Jaures 78330 FONTENAY LE FLEURY",
|
||||
email: "poutoune@club-internet.fr",
|
||||
website: "https://echecs-fontenaylefleury.org",
|
||||
coordinates: [48.8147484, 2.048536],
|
||||
@@ -804,8 +795,7 @@ export const clubData = [
|
||||
_id: new ObjectId("690586c9e06ce80de6cd7594"),
|
||||
name: "C.E. de Bois-Colombes",
|
||||
url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=689",
|
||||
address:
|
||||
"Espace Associations 26 rue d'Estienne d'Orves 92270 BOIS COLOMBES",
|
||||
address: "Espace Associations 26 rue d'Estienne d'Orves 92270 BOIS COLOMBES",
|
||||
email: "contact@bois-colombes-echecs.com",
|
||||
website: "https://www.bois-colombes-echecs.com",
|
||||
coordinates: [48.9156126, 2.2716207],
|
||||
@@ -896,8 +886,7 @@ export const clubData = [
|
||||
_id: new ObjectId("690586c9e06ce80de6cd7312"),
|
||||
name: "C.L. Léo Lagrange - Colomiers",
|
||||
url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=1239",
|
||||
address:
|
||||
"Salle Municipale 1 place Leo Lagrange ex place du Val d'Aran 31770 COLOMIERS",
|
||||
address: "Salle Municipale 1 place Leo Lagrange ex place du Val d'Aran 31770 COLOMIERS",
|
||||
email: "colomiersclubdechecs@gmail.com",
|
||||
website: "http://colomiers.chess.free.fr",
|
||||
coordinates: [43.6117764, 1.3285075],
|
||||
@@ -906,8 +895,7 @@ export const clubData = [
|
||||
_id: new ObjectId("690586c9e06ce80de6cd759f"),
|
||||
name: "C.S.M. Puteaux Echecs",
|
||||
url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=928",
|
||||
address:
|
||||
"Palais des Sports ile de Puteaux 2 Voie Georges Hassoux 92800 PUTEAUX",
|
||||
address: "Palais des Sports ile de Puteaux 2 Voie Georges Hassoux 92800 PUTEAUX",
|
||||
email: "csmpe@free.fr",
|
||||
website: "http://csmpe.free.fr",
|
||||
coordinates: [48.8788229, 2.2457232],
|
||||
|
||||
@@ -7,7 +7,9 @@ export default function AddClubPage() {
|
||||
return (
|
||||
<section className="grid place-items-center bg-white pb-20 dark:bg-gray-800">
|
||||
<div className="mx-auto max-w-screen-md px-4 py-8 lg:py-16">
|
||||
<h2 className="mb-4 text-center text-4xl font-extrabold tracking-tight text-gray-900 dark:text-white">{t("title")}</h2>
|
||||
<h2 className="mb-4 text-center text-4xl font-extrabold tracking-tight text-gray-900 dark:text-white">
|
||||
{t("title")}
|
||||
</h2>
|
||||
|
||||
<p className="mb-8 text-center font-light text-gray-500 dark:text-gray-400 sm:text-xl lg:mb-16">
|
||||
{t("info")}
|
||||
@@ -16,5 +18,5 @@ export default function AddClubPage() {
|
||||
<ClubForm />
|
||||
</div>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -101,11 +101,7 @@ const TournamentForm = () => {
|
||||
name="tournament.time_control"
|
||||
control={form.control}
|
||||
label={t("tcLabel")}
|
||||
options={[
|
||||
TimeControl.Classic,
|
||||
TimeControl.Rapid,
|
||||
TimeControl.Blitz,
|
||||
].map((tc) => ({
|
||||
options={[TimeControl.Classic, TimeControl.Rapid, TimeControl.Blitz].map((tc) => ({
|
||||
value: tc,
|
||||
label: at("timeControlEnum", { tc }),
|
||||
}))}
|
||||
|
||||
@@ -4,16 +4,14 @@ import SignInClient from "@/app/[locale]/(main)/auth/sign-in/SignInClient";
|
||||
import { baseUrl } from "@/constants";
|
||||
|
||||
export async function generateMetadata({
|
||||
params: { locale },
|
||||
params,
|
||||
}: {
|
||||
params: { locale?: string };
|
||||
params: Promise<{ locale?: string }>;
|
||||
}): Promise<Metadata> {
|
||||
const { locale } = await params;
|
||||
return {
|
||||
alternates: {
|
||||
canonical:
|
||||
locale === "fr"
|
||||
? `${baseUrl}/auth/sign-in`
|
||||
: `${baseUrl}/${locale}/auth/sign-in`,
|
||||
canonical: locale === "fr" ? `${baseUrl}/auth/sign-in` : `${baseUrl}/${locale}/auth/sign-in`,
|
||||
languages: {
|
||||
fr: `${baseUrl}/auth/sign-in`,
|
||||
en: `${baseUrl}/en/auth/sign-in`,
|
||||
|
||||
@@ -94,10 +94,7 @@ export const ClubMarker = forwardRef<MarkerRef, ClubMarkerProps>(
|
||||
)}
|
||||
{club.email && (
|
||||
<div>
|
||||
<a
|
||||
href={`mailto:${club.email}`}
|
||||
className="text-primary hover:text-primary-800"
|
||||
>
|
||||
<a href={`mailto:${club.email}`} className="text-primary hover:text-primary-800">
|
||||
{club.email}
|
||||
</a>
|
||||
</div>
|
||||
|
||||
@@ -29,9 +29,7 @@ const ClubTable = () => {
|
||||
|
||||
useEffect(() => {
|
||||
if (!isLg || debouncedHoveredMapId === null) return;
|
||||
const clubRow = document.querySelector(
|
||||
`[data-group-id="${debouncedHoveredMapId}"]`,
|
||||
);
|
||||
const clubRow = document.querySelector(`[data-group-id="${debouncedHoveredMapId}"]`);
|
||||
|
||||
clubRow?.scrollIntoView({ behavior: "smooth" });
|
||||
}, [debouncedHoveredMapId, isLg]);
|
||||
@@ -87,9 +85,7 @@ const ClubTable = () => {
|
||||
hoveredMapId === club.id && "bg-gray-200 dark:bg-gray-900",
|
||||
)}
|
||||
>
|
||||
<td className="px-1 py-2 sm:px-3 sm:py-3 lg:px-3 lg:py-3">
|
||||
{club.name}
|
||||
</td>
|
||||
<td className="px-1 py-2 sm:px-3 sm:py-3 lg:px-3 lg:py-3">{club.name}</td>
|
||||
<td className="px-1 py-2 text-left sm:px-3 sm:py-3 lg:px-3 lg:py-3">
|
||||
{club.address && <div>{club.address}</div>}
|
||||
{club.website && (
|
||||
|
||||
@@ -44,14 +44,10 @@ export default function ClubsDisplay({ clubs }: ClubsDisplayProps) {
|
||||
.replace(/[\u0300-\u036f]/g, "") === regionSearchParam.toLowerCase(),
|
||||
);
|
||||
|
||||
const regionData = regionGeoJson.features.find(
|
||||
(f) => f.properties.nom === matchedRegion,
|
||||
);
|
||||
const regionData = regionGeoJson.features.find((f) => f.properties.nom === matchedRegion);
|
||||
|
||||
if (regionData) {
|
||||
setRegionFilter(
|
||||
regionData as Feature<Polygon | MultiPolygon, GeoJsonProperties>,
|
||||
);
|
||||
setRegionFilter(regionData as Feature<Polygon | MultiPolygon, GeoJsonProperties>);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,14 +12,14 @@ import ClubsDisplay from "./ClubsDisplay";
|
||||
export const revalidate = 3600; // Revalidate cache every 6 hours
|
||||
|
||||
export async function generateMetadata({
|
||||
params: { locale },
|
||||
params,
|
||||
}: {
|
||||
params: { locale?: string };
|
||||
params: Promise<{ locale?: string }>;
|
||||
}): Promise<Metadata> {
|
||||
const { locale } = await params;
|
||||
return {
|
||||
alternates: {
|
||||
canonical:
|
||||
locale === "fr" ? `${baseUrl}/clubs` : `${baseUrl}/${locale}/clubs`,
|
||||
canonical: locale === "fr" ? `${baseUrl}/clubs` : `${baseUrl}/${locale}/clubs`,
|
||||
languages: {
|
||||
fr: `${baseUrl}/clubs`,
|
||||
en: `${baseUrl}/en/clubs`,
|
||||
|
||||
@@ -49,11 +49,7 @@ export default function Footer() {
|
||||
<Link href="/contact-us" aria-label={t("contactAria")} className="mr-4">
|
||||
<FaRegEnvelope />
|
||||
</Link>
|
||||
<Link
|
||||
href="/privacy"
|
||||
aria-label={t("privacyPolicyAria")}
|
||||
className="mr-4"
|
||||
>
|
||||
<Link href="/privacy" aria-label={t("privacyPolicyAria")} className="mr-4">
|
||||
<MdOutlinePrivacyTip />
|
||||
</Link>
|
||||
<div className="mr-4 space-x-2 text-xs">
|
||||
|
||||
@@ -20,8 +20,7 @@ const Hamburger = () => {
|
||||
<div
|
||||
className={twMerge(
|
||||
"h-0.5 w-8 bg-gray-600 transition-all duration-300 ease-in-out dark:bg-white",
|
||||
burgerMenuIsOpen &&
|
||||
"translate-x-[1px] translate-y-2.5 rotate-45 bg-white",
|
||||
burgerMenuIsOpen && "translate-x-[1px] translate-y-2.5 rotate-45 bg-white",
|
||||
)}
|
||||
></div>
|
||||
<div
|
||||
|
||||
@@ -15,7 +15,7 @@ import { MapEvents } from "@/components/MapEvents";
|
||||
|
||||
const center: LatLngLiteral = { lat: 47.0844, lng: 2.3964 };
|
||||
|
||||
const MapCoordinateSelection = ( { page }: {page: "club" | "tournament"}) => {
|
||||
const MapCoordinateSelection = ({ page }: { page: "club" | "tournament" }) => {
|
||||
const { control, setValue } = useFormContext();
|
||||
|
||||
const latValue = useWatch({ control, name: `${page}.coordinates.0` });
|
||||
|
||||
@@ -21,9 +21,7 @@ export default function Navbar() {
|
||||
className="font-extrabold text-gray-900 no-underline hover:no-underline dark:text-white"
|
||||
href="/"
|
||||
>
|
||||
<span className="font-title text-2xl text-gray-800 dark:text-white">
|
||||
{t("title")}
|
||||
</span>
|
||||
<span className="font-title text-2xl text-gray-800 dark:text-white">{t("title")}</span>
|
||||
</Link>
|
||||
|
||||
<div className="md:hidden" data-test="mobile-menu">
|
||||
|
||||
@@ -57,28 +57,14 @@ export default function Contact() {
|
||||
{t("info")}
|
||||
</p>
|
||||
|
||||
{error && (
|
||||
<InfoMessage
|
||||
className="mb-8"
|
||||
type="error"
|
||||
message={t("failure")}
|
||||
/>
|
||||
)}
|
||||
{error && <InfoMessage className="mb-8" type="error" message={t("failure")} />}
|
||||
|
||||
<div className="flex items-center justify-center space-x-4 text-sm font-bold">
|
||||
<Button
|
||||
type="button"
|
||||
onClick={() => router.back()}
|
||||
intent="secondary"
|
||||
>
|
||||
<Button type="button" onClick={() => router.back()} intent="secondary">
|
||||
{at("cancelButton")}
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
onClick={() => onDeleteAccount()}
|
||||
disabled={deleting}
|
||||
intent="primary"
|
||||
>
|
||||
<Button onClick={() => onDeleteAccount()} disabled={deleting} intent="primary">
|
||||
{t("deleteButton")}
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
@@ -53,8 +53,7 @@ export default function EloClient() {
|
||||
const kFactorParam = searchParams.get("k");
|
||||
const player = searchParams.get("player") ?? "";
|
||||
|
||||
const kFactor =
|
||||
kFactorParam && kFactors.includes(kFactorParam) ? kFactorParam : "20";
|
||||
const kFactor = kFactorParam && kFactors.includes(kFactorParam) ? kFactorParam : "20";
|
||||
|
||||
const hasTournamentId = !isEmpty(tournamentId.trim());
|
||||
|
||||
@@ -109,11 +108,7 @@ export default function EloClient() {
|
||||
const subscription = form.watch((value, { name, type }) => {
|
||||
let update = false;
|
||||
if (type === "change") {
|
||||
if (
|
||||
name === "tournamentId" &&
|
||||
value.tournamentId !== tournamentId &&
|
||||
value.tournamentId
|
||||
) {
|
||||
if (name === "tournamentId" && value.tournamentId !== tournamentId && value.tournamentId) {
|
||||
current.set("tId", value.tournamentId);
|
||||
update = true;
|
||||
} else if (
|
||||
@@ -122,18 +117,10 @@ export default function EloClient() {
|
||||
value.tournamentId === null
|
||||
) {
|
||||
clearForm();
|
||||
} else if (
|
||||
name === "player" &&
|
||||
value.player !== player &&
|
||||
value.player
|
||||
) {
|
||||
} else if (name === "player" && value.player !== player && value.player) {
|
||||
current.set("player", value.player);
|
||||
update = true;
|
||||
} else if (
|
||||
name === "kFactor" &&
|
||||
value.kFactor !== kFactor &&
|
||||
value.kFactor
|
||||
) {
|
||||
} else if (name === "kFactor" && value.kFactor !== kFactor && value.kFactor) {
|
||||
current.set("k", value.kFactor);
|
||||
update = true;
|
||||
}
|
||||
@@ -146,17 +133,7 @@ export default function EloClient() {
|
||||
}
|
||||
});
|
||||
return () => subscription.unsubscribe();
|
||||
}, [
|
||||
clearForm,
|
||||
current,
|
||||
form,
|
||||
form.watch,
|
||||
kFactor,
|
||||
pathname,
|
||||
player,
|
||||
router,
|
||||
tournamentId,
|
||||
]);
|
||||
}, [clearForm, current, form, form.watch, kFactor, pathname, player, router, tournamentId]);
|
||||
|
||||
useEffect(() => {
|
||||
// When the URL changes, we update the form values
|
||||
@@ -184,9 +161,7 @@ export default function EloClient() {
|
||||
>
|
||||
{t("title")}
|
||||
</h2>
|
||||
<p className="mb-8 text-center font-light text-gray-500 dark:text-gray-400">
|
||||
{t("info")}
|
||||
</p>
|
||||
<p className="mb-8 text-center font-light text-gray-500 dark:text-gray-400">{t("info")}</p>
|
||||
|
||||
{hasTournamentId && !isFetching && !error && (
|
||||
<div className="mx-auto mb-8 flex justify-center">
|
||||
@@ -251,23 +226,17 @@ export default function EloClient() {
|
||||
</form>
|
||||
</FormProvider>
|
||||
|
||||
{hasTournamentId &&
|
||||
!isFetching &&
|
||||
player &&
|
||||
playerResults &&
|
||||
!error && (
|
||||
<TournamentResults
|
||||
playerId={player}
|
||||
kFactor={parseInt(kFactor)}
|
||||
results={allResults?.data ?? []}
|
||||
tournament={tournament}
|
||||
/>
|
||||
)}
|
||||
{hasTournamentId && !isFetching && player && playerResults && !error && (
|
||||
<TournamentResults
|
||||
playerId={player}
|
||||
kFactor={parseInt(kFactor)}
|
||||
results={allResults?.data ?? []}
|
||||
tournament={tournament}
|
||||
/>
|
||||
)}
|
||||
|
||||
{(!!error || allResults?.serverError) && (
|
||||
<ErrorBox
|
||||
error={<TranslatedError err={error ?? allResults?.serverError} />}
|
||||
/>
|
||||
<ErrorBox error={<TranslatedError err={error ?? allResults?.serverError} />} />
|
||||
)}
|
||||
|
||||
{((!hasTournamentId && !isFetching) || !!error) && (
|
||||
|
||||
@@ -23,29 +23,17 @@ export const KFactor = ({ className }: KFactorProps) => {
|
||||
</Disclosure.Button>
|
||||
|
||||
<Disclosure.Panel className="mt-4">
|
||||
<p className="text-sm text-gray-500 dark:text-neutral-400">
|
||||
{t("kFactorInfo1")}
|
||||
</p>
|
||||
<p className="mt-4 text-sm text-gray-500 dark:text-neutral-400">
|
||||
{t("kFactorInfo2")}
|
||||
</p>
|
||||
<p className="text-sm text-gray-500 dark:text-neutral-400">{t("kFactorInfo1")}</p>
|
||||
<p className="mt-4 text-sm text-gray-500 dark:text-neutral-400">{t("kFactorInfo2")}</p>
|
||||
|
||||
<ul className="mb-8 ml-4 mt-3 list-outside list-disc">
|
||||
{(
|
||||
[
|
||||
"kFactorInfo3",
|
||||
"kFactorInfo4",
|
||||
"kFactorInfo5",
|
||||
"kFactorInfo6",
|
||||
] as const
|
||||
).map((key) => (
|
||||
<li
|
||||
key={key}
|
||||
className="mt-2 text-sm text-gray-500 dark:text-neutral-400"
|
||||
>
|
||||
{t.rich(key, { b: (str) => <b>{str}</b> })}
|
||||
</li>
|
||||
))}
|
||||
{(["kFactorInfo3", "kFactorInfo4", "kFactorInfo5", "kFactorInfo6"] as const).map(
|
||||
(key) => (
|
||||
<li key={key} className="mt-2 text-sm text-gray-500 dark:text-neutral-400">
|
||||
{t.rich(key, { b: (str) => <b>{str}</b> })}
|
||||
</li>
|
||||
),
|
||||
)}
|
||||
</ul>
|
||||
</Disclosure.Panel>
|
||||
</Disclosure>
|
||||
|
||||
@@ -63,20 +63,16 @@ export const ManualEloForm = () => {
|
||||
storage: window.localStorage,
|
||||
});
|
||||
|
||||
// oxlint-disable-next-line no-unused-vars
|
||||
const onSubmit = async (data: EloFormValues) => {};
|
||||
|
||||
const [currentElo, kFactor, games] = form.watch([
|
||||
"currentElo",
|
||||
"kFactor",
|
||||
"games",
|
||||
]);
|
||||
const [currentElo, kFactor, games] = form.watch(["currentElo", "kFactor", "games"]);
|
||||
|
||||
const isDefault =
|
||||
isEmpty(currentElo) &&
|
||||
kFactor === "20" &&
|
||||
games?.length === 1 &&
|
||||
(isEmpty(games[0]) ||
|
||||
(isEmpty(games[0]?.opponentElo) && isEmpty(games[0]?.result)));
|
||||
(isEmpty(games[0]) || (isEmpty(games[0]?.opponentElo) && isEmpty(games[0]?.result)));
|
||||
|
||||
type Deltas = {
|
||||
rating: number;
|
||||
@@ -86,13 +82,8 @@ export const ManualEloForm = () => {
|
||||
const calculations = !Number.isNaN(currentElo)
|
||||
? (games ?? []).reduce<Deltas>(
|
||||
(acc, game) => {
|
||||
if (
|
||||
!isNil(game?.opponentElo) &&
|
||||
!Number.isNaN(game?.opponentElo) &&
|
||||
game?.result
|
||||
) {
|
||||
const result =
|
||||
game?.result === "win" ? 1 : game?.result === "loss" ? 0 : 0.5;
|
||||
if (!isNil(game?.opponentElo) && !Number.isNaN(game?.opponentElo) && game?.result) {
|
||||
const result = game?.result === "win" ? 1 : game?.result === "loss" ? 0 : 0.5;
|
||||
|
||||
const { delta } = getNewRating(
|
||||
currentElo!,
|
||||
@@ -117,9 +108,7 @@ export const ManualEloForm = () => {
|
||||
|
||||
const deltas = calculations.deltas;
|
||||
const hasDeltas = deltas.some((d) => d.delta !== undefined);
|
||||
const totalDelta = Math.round(
|
||||
deltas.reduce((acc, delta) => acc + (delta.delta ?? 0), 0),
|
||||
);
|
||||
const totalDelta = Math.round(deltas.reduce((acc, delta) => acc + (delta.delta ?? 0), 0));
|
||||
|
||||
return (
|
||||
<FormProvider {...form}>
|
||||
@@ -149,9 +138,7 @@ export const ManualEloForm = () => {
|
||||
|
||||
<KFactor className="mt-2" />
|
||||
|
||||
<h3 className="my-4 text-lg text-gray-900 dark:text-white">
|
||||
{t("resultsTitle")}
|
||||
</h3>
|
||||
<h3 className="my-4 text-lg text-gray-900 dark:text-white">{t("resultsTitle")}</h3>
|
||||
|
||||
<div className="flex w-full flex-col gap-6 sm:gap-2">
|
||||
{gameFields.map((game, i) => {
|
||||
|
||||
@@ -78,19 +78,13 @@ export const TournamentResults = ({
|
||||
|
||||
return {
|
||||
rating: acc.rating + delta,
|
||||
deltas: [
|
||||
...acc.deltas,
|
||||
{ rating: acc.rating + delta, delta, ...info },
|
||||
],
|
||||
deltas: [...acc.deltas, { rating: acc.rating + delta, delta, ...info }],
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
rating: acc.rating,
|
||||
deltas: [
|
||||
...acc.deltas,
|
||||
{ rating: acc.rating, delta: undefined, ...info },
|
||||
],
|
||||
deltas: [...acc.deltas, { rating: acc.rating, delta: undefined, ...info }],
|
||||
};
|
||||
},
|
||||
{ rating: currentElo!, deltas: [] },
|
||||
@@ -98,9 +92,7 @@ export const TournamentResults = ({
|
||||
: { rating: currentElo!, deltas: [] };
|
||||
|
||||
const deltas = calculations.deltas;
|
||||
const totalDelta = Math.round(
|
||||
deltas.reduce((acc, delta) => acc + (delta.delta ?? 0), 0),
|
||||
);
|
||||
const totalDelta = Math.round(deltas.reduce((acc, delta) => acc + (delta.delta ?? 0), 0));
|
||||
|
||||
const noChangeCount = (deltas ?? []).filter(
|
||||
({ wonByForfeit, lostByForfeit, estimated, national }) =>
|
||||
@@ -121,16 +113,12 @@ export const TournamentResults = ({
|
||||
{deltas.map((delta, i) => {
|
||||
const { estimated, national, lostByForfeit, wonByForfeit } = delta;
|
||||
const opponentElo = delta.opponentElo
|
||||
? ` (${delta.opponentElo} ${
|
||||
estimated ? "E" : national ? "N" : "F"
|
||||
})`
|
||||
? ` (${delta.opponentElo} ${estimated ? "E" : national ? "N" : "F"})`
|
||||
: "";
|
||||
|
||||
const opponentName = delta.opponentName ? (
|
||||
<span>
|
||||
<span className="whitespace-nowrap font-bold">
|
||||
{delta.opponentName}
|
||||
</span>
|
||||
<span className="whitespace-nowrap font-bold">{delta.opponentName}</span>
|
||||
{opponentElo}
|
||||
</span>
|
||||
) : (
|
||||
@@ -140,11 +128,8 @@ export const TournamentResults = ({
|
||||
const playedWhite = delta.colour === "white";
|
||||
|
||||
const whitePlayer = playedWhite ? playerResults.name : opponentName;
|
||||
const blackPlayer = !playedWhite
|
||||
? playerResults.name
|
||||
: opponentName;
|
||||
const noChange =
|
||||
wonByForfeit || lostByForfeit || estimated || national;
|
||||
const blackPlayer = !playedWhite ? playerResults.name : opponentName;
|
||||
const noChange = wonByForfeit || lostByForfeit || estimated || national;
|
||||
|
||||
const forfeit = delta.opponentName === null;
|
||||
|
||||
@@ -173,9 +158,7 @@ export const TournamentResults = ({
|
||||
{blackPlayer}
|
||||
</td>
|
||||
)}
|
||||
<td className="whitespace-nowrap px-2 pb-2 text-center">
|
||||
{!forfeit && result}
|
||||
</td>
|
||||
<td className="whitespace-nowrap px-2 pb-2 text-center">{!forfeit && result}</td>
|
||||
<td className="pb-2 text-right">
|
||||
{noChange ? (
|
||||
"-"
|
||||
|
||||
@@ -4,14 +4,14 @@ import EloClient from "@/app/[locale]/(main)/elo/EloClient";
|
||||
import { baseUrl } from "@/constants";
|
||||
|
||||
export async function generateMetadata({
|
||||
params: { locale },
|
||||
params,
|
||||
}: {
|
||||
params: { locale?: string };
|
||||
params: Promise<{ locale?: string }>;
|
||||
}): Promise<Metadata> {
|
||||
const { locale } = await params;
|
||||
return {
|
||||
alternates: {
|
||||
canonical:
|
||||
locale === "fr" ? `${baseUrl}/elo` : `${baseUrl}/${locale}/elo`,
|
||||
canonical: locale === "fr" ? `${baseUrl}/elo` : `${baseUrl}/${locale}/elo`,
|
||||
languages: {
|
||||
fr: `${baseUrl}/elo`,
|
||||
en: `${baseUrl}/en/elo`,
|
||||
|
||||
@@ -3,11 +3,7 @@ import { ReactNode } from "react";
|
||||
import Footer from "./components/Footer";
|
||||
import Navbar from "./components/Navbar";
|
||||
|
||||
export default async function MainLayout({
|
||||
children,
|
||||
}: {
|
||||
children: ReactNode;
|
||||
}) {
|
||||
export default async function MainLayout({ children }: { children: ReactNode }) {
|
||||
return (
|
||||
<>
|
||||
<Navbar />
|
||||
|
||||
@@ -33,11 +33,7 @@ export default function Contact() {
|
||||
<p>
|
||||
{t.rich("cookiesInfo", {
|
||||
link: (str) => (
|
||||
<a
|
||||
href="https://tinyanalytics.io"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
<a href="https://tinyanalytics.io" target="_blank" rel="noopener noreferrer">
|
||||
{str}
|
||||
</a>
|
||||
),
|
||||
|
||||
@@ -8,11 +8,7 @@ import "react-date-range/dist/theme/default.css";
|
||||
import { dateRangeAtom, maxDateAtom } from "@/atoms";
|
||||
import { DatePickerDirection } from "@/types";
|
||||
|
||||
const DatePicker = ({
|
||||
datePickerDirection,
|
||||
}: {
|
||||
datePickerDirection: DatePickerDirection;
|
||||
}) => {
|
||||
const DatePicker = ({ datePickerDirection }: { datePickerDirection: DatePickerDirection }) => {
|
||||
const [dateRange, setDateRange] = useAtom(dateRangeAtom);
|
||||
const maxDate = useAtomValue(maxDateAtom);
|
||||
|
||||
|
||||
@@ -16,12 +16,9 @@ const Legend = () => {
|
||||
|
||||
const timeControls = useMemo(
|
||||
() =>
|
||||
[
|
||||
TimeControl.Classic,
|
||||
TimeControl.Rapid,
|
||||
TimeControl.Blitz,
|
||||
TimeControl.Other,
|
||||
].filter((tc) => tournaments.some((t) => t.timeControl === tc)),
|
||||
[TimeControl.Classic, TimeControl.Rapid, TimeControl.Blitz, TimeControl.Other].filter((tc) =>
|
||||
tournaments.some((t) => t.timeControl === tc),
|
||||
),
|
||||
[tournaments],
|
||||
);
|
||||
|
||||
|
||||
@@ -1,13 +1,7 @@
|
||||
import { useAtom, useAtomValue } from "jotai";
|
||||
import { useTranslations } from "next-intl";
|
||||
|
||||
import {
|
||||
blitzAtom,
|
||||
classicAtom,
|
||||
otherAtom,
|
||||
rapidAtom,
|
||||
tournamentsAtom,
|
||||
} from "@/atoms";
|
||||
import { blitzAtom, classicAtom, otherAtom, rapidAtom, tournamentsAtom } from "@/atoms";
|
||||
import { TimeControl } from "@/types";
|
||||
|
||||
const TimeControlFilters = () => {
|
||||
|
||||
@@ -3,17 +3,14 @@
|
||||
import { useCallback, useMemo } from "react";
|
||||
|
||||
import { useAtomValue } from "jotai";
|
||||
import L, { LatLngLiteral } from "leaflet";
|
||||
import L from "leaflet";
|
||||
import "leaflet-defaulticon-compatibility";
|
||||
import "leaflet-defaulticon-compatibility/dist/leaflet-defaulticon-compatibility.css";
|
||||
import "leaflet.smooth_marker_bouncing";
|
||||
import "leaflet/dist/leaflet.css";
|
||||
import { countBy, groupBy } from "lodash";
|
||||
|
||||
import {
|
||||
filteredTournamentsByTimeControlAndZoneAtom,
|
||||
normsOnlyAtom,
|
||||
} from "@/atoms";
|
||||
import { filteredTournamentsByTimeControlAndZoneAtom, normsOnlyAtom } from "@/atoms";
|
||||
import { Map, MapMarker } from "@/components/Map";
|
||||
import { TimeControlColours } from "@/constants";
|
||||
import { TimeControl } from "@/types";
|
||||
@@ -49,15 +46,12 @@ const TournamentMap = () => {
|
||||
${generatePieSVG(
|
||||
"absolute w-[30px]",
|
||||
15,
|
||||
[
|
||||
TimeControl.Classic,
|
||||
TimeControl.Rapid,
|
||||
TimeControl.Blitz,
|
||||
TimeControl.Other,
|
||||
].map((tc) => ({
|
||||
value: timeControlCounts[tc] ?? 0,
|
||||
colour: TimeControlColours[tc],
|
||||
})),
|
||||
[TimeControl.Classic, TimeControl.Rapid, TimeControl.Blitz, TimeControl.Other].map(
|
||||
(tc) => ({
|
||||
value: timeControlCounts[tc] ?? 0,
|
||||
colour: TimeControlColours[tc],
|
||||
}),
|
||||
),
|
||||
)}
|
||||
<span class="text-white font-semibold relative z-[300]">${childCount}</span>
|
||||
</div>
|
||||
@@ -77,9 +71,7 @@ const TournamentMap = () => {
|
||||
return {
|
||||
markerId: groupId,
|
||||
tableIds: tournamentGroup.map((t) => t.id),
|
||||
component: (
|
||||
<TournamentMarker key={groupId} tournamentGroup={tournamentGroup} />
|
||||
),
|
||||
component: <TournamentMarker key={groupId} tournamentGroup={tournamentGroup} />,
|
||||
};
|
||||
}),
|
||||
[groupedTournaments],
|
||||
|
||||
@@ -43,19 +43,14 @@ const TournamentTable = () => {
|
||||
|
||||
const setDateRange = useSetAtom(dateRangeAtom);
|
||||
const [datePickerIsOpen, setDatePickerIsOpen] = useAtom(datePickerIsOpenAtom);
|
||||
const [dateDirectionState, setDateDirectionState] =
|
||||
useState<DatePickerDirection>("horizontal");
|
||||
const datePickerColour = datePickerIsOpen
|
||||
? "text-primary-600"
|
||||
: "text-gray-500";
|
||||
const [dateDirectionState, setDateDirectionState] = useState<DatePickerDirection>("horizontal");
|
||||
const datePickerColour = datePickerIsOpen ? "text-primary-600" : "text-gray-500";
|
||||
|
||||
useDatePickerWidth({ datePickerRef, setDateDirectionState });
|
||||
|
||||
useEffect(() => {
|
||||
if (!isLg || debouncedHoveredMapId === null) return;
|
||||
const tournamentRow = document.querySelector(
|
||||
`[data-group-id="${debouncedHoveredMapId}"]`,
|
||||
);
|
||||
const tournamentRow = document.querySelector(`[data-group-id="${debouncedHoveredMapId}"]`);
|
||||
|
||||
tournamentRow?.scrollIntoView({ behavior: "smooth" });
|
||||
}, [debouncedHoveredMapId, isLg]);
|
||||
@@ -112,9 +107,7 @@ const TournamentTable = () => {
|
||||
</div>
|
||||
|
||||
<div className="flex justify-center" ref={datePickerRef}>
|
||||
{datePickerIsOpen && (
|
||||
<DatePicker datePickerDirection={dateDirectionState} />
|
||||
)}
|
||||
{datePickerIsOpen && <DatePicker datePickerDirection={dateDirectionState} />}
|
||||
</div>
|
||||
|
||||
<div className="overflow-x-scroll">
|
||||
@@ -156,23 +149,15 @@ const TournamentTable = () => {
|
||||
onMouseLeave={() => setHoveredListId(null)}
|
||||
className={twMerge(
|
||||
"scroll-m-20 bg-white text-gray-900 hover:bg-gray-200 dark:bg-gray-800 dark:text-white dark:hover:bg-gray-900",
|
||||
hoveredMapId === tournament.groupId &&
|
||||
"bg-gray-200 dark:bg-gray-900",
|
||||
hoveredMapId === tournament.groupId && "bg-gray-200 dark:bg-gray-900",
|
||||
)}
|
||||
>
|
||||
<td className="px-1 py-2 sm:px-3 sm:py-3 lg:px-3 lg:py-3">
|
||||
{tournament.date}
|
||||
</td>
|
||||
<td className="px-1 py-2 sm:px-3 sm:py-3 lg:px-3 lg:py-3">
|
||||
{tournament.town}
|
||||
</td>
|
||||
<td className="px-1 py-2 sm:px-3 sm:py-3 lg:px-3 lg:py-3">{tournament.date}</td>
|
||||
<td className="px-1 py-2 sm:px-3 sm:py-3 lg:px-3 lg:py-3">{tournament.town}</td>
|
||||
<td className="px-1 py-2 text-left sm:px-3 sm:py-3 lg:px-3 lg:py-3">
|
||||
<span>
|
||||
{tournament.norm && (
|
||||
<FaTrophy
|
||||
className="mr-2 inline-block h-4 w-4"
|
||||
data-norm="norm"
|
||||
/>
|
||||
<FaTrophy className="mr-2 inline-block h-4 w-4" data-norm="norm" />
|
||||
)}
|
||||
{tournament.tournament}
|
||||
</span>
|
||||
|
||||
@@ -22,9 +22,7 @@ const TournamentMap = dynamic(() => import("./TournamentMap"), {
|
||||
loading: LoadingMap,
|
||||
});
|
||||
|
||||
export default function TournamentsDisplay({
|
||||
tournaments,
|
||||
}: TournamentsDisplayProps) {
|
||||
export default function TournamentsDisplay({ tournaments }: TournamentsDisplayProps) {
|
||||
useHydrateAtoms([[tournamentsAtom, tournaments]]);
|
||||
|
||||
return (
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
import {
|
||||
differenceInDays,
|
||||
isSameDay,
|
||||
parse,
|
||||
setDefaultOptions,
|
||||
} from "date-fns";
|
||||
import { differenceInDays, isSameDay, parse, setDefaultOptions } from "date-fns";
|
||||
import { fr } from "date-fns/locale";
|
||||
import { groupBy } from "lodash";
|
||||
import { Metadata } from "next";
|
||||
@@ -20,16 +15,14 @@ import TournamentsDisplay from "./TournamentsDisplay";
|
||||
setDefaultOptions({ locale: fr });
|
||||
|
||||
export async function generateMetadata({
|
||||
params: { locale },
|
||||
params,
|
||||
}: {
|
||||
params: { locale?: string };
|
||||
params: Promise<{ locale?: string }>;
|
||||
}): Promise<Metadata> {
|
||||
const { locale } = await params;
|
||||
return {
|
||||
alternates: {
|
||||
canonical:
|
||||
locale === "fr"
|
||||
? `${baseUrl}/tournois`
|
||||
: `${baseUrl}/${locale}/tournaments`,
|
||||
canonical: locale === "fr" ? `${baseUrl}/tournois` : `${baseUrl}/${locale}/tournaments`,
|
||||
languages: {
|
||||
fr: `${baseUrl}/tournois`,
|
||||
en: `${baseUrl}/en/tournaments`,
|
||||
@@ -107,10 +100,7 @@ const getTournaments = async () => {
|
||||
const goodData = data.filter((t) => !badIds.includes(t._id.toString()));
|
||||
|
||||
// Group the tournaments by their location
|
||||
const groupedByLocation = groupBy(
|
||||
goodData,
|
||||
(t) => `${t.coordinates[0]}_${t.coordinates[1]}`,
|
||||
);
|
||||
const groupedByLocation = groupBy(goodData, (t) => `${t.coordinates[0]}_${t.coordinates[1]}`);
|
||||
|
||||
// For each location, create an array of arrays of contiguous dates for this location
|
||||
const dateRangesByLocation: Record<string, Date[][]> = {};
|
||||
@@ -140,9 +130,7 @@ const getTournaments = async () => {
|
||||
const location = `${t.coordinates[0]}_${t.coordinates[1]}`;
|
||||
const date = parse(t.date, "dd/MM/yyyy", new Date());
|
||||
const dateRanges = dateRangesByLocation[location];
|
||||
const rangeIndex = dateRanges.findIndex((ranges) =>
|
||||
ranges.some((d) => isSameDay(d, date)),
|
||||
);
|
||||
const rangeIndex = dateRanges.findIndex((ranges) => ranges.some((d) => isSameDay(d, date)));
|
||||
|
||||
// We place each tournament into a group based on location and date and time control, so that
|
||||
// we can display a single map marker.
|
||||
|
||||
@@ -12,12 +12,12 @@ import { Zone } from "@/server/myZones";
|
||||
|
||||
const center: LatLngLiteral = { lat: 47.0844, lng: 2.3964 };
|
||||
|
||||
export type ZoneThumbnailProps = {
|
||||
type ZoneThumbnailProps = {
|
||||
features: Zone["features"];
|
||||
className?: string;
|
||||
};
|
||||
|
||||
export const ZoneThumbnail = ({ features, className }: ZoneThumbnailProps) => {
|
||||
const ZoneThumbnail = ({ features, className }: ZoneThumbnailProps) => {
|
||||
return (
|
||||
<MapContainer
|
||||
center={center}
|
||||
|
||||
@@ -46,11 +46,7 @@ const CreateZone = () => {
|
||||
{t("createTitle")}
|
||||
</h2>
|
||||
|
||||
<ZoneForm
|
||||
withInfo
|
||||
onSubmit={onSubmit}
|
||||
onCancel={() => router.push("/zones")}
|
||||
/>
|
||||
<ZoneForm withInfo onSubmit={onSubmit} onCancel={() => router.push("/zones")} />
|
||||
|
||||
{responseMessage && (
|
||||
<InfoMessage
|
||||
|
||||
@@ -49,7 +49,7 @@ const EditZone = () => {
|
||||
|
||||
await refetch();
|
||||
router.push("/zones");
|
||||
} catch (error) {
|
||||
} catch {
|
||||
setResponseMessage({
|
||||
type: "error",
|
||||
message: t("createFailure"),
|
||||
@@ -66,11 +66,7 @@ const EditZone = () => {
|
||||
{t("editTitle")}
|
||||
</h2>
|
||||
|
||||
<ZoneForm
|
||||
onSubmit={onSubmit}
|
||||
onCancel={() => router.push("/zones")}
|
||||
zone={zone}
|
||||
/>
|
||||
<ZoneForm onSubmit={onSubmit} onCancel={() => router.push("/zones")} zone={zone} />
|
||||
|
||||
{responseMessage && (
|
||||
<InfoMessage
|
||||
|
||||
@@ -160,11 +160,7 @@ const Zones = () => {
|
||||
)}
|
||||
|
||||
<div className="flex items-center justify-between space-x-4 text-sm font-bold">
|
||||
<Button
|
||||
intent="secondary"
|
||||
type="button"
|
||||
onClick={() => setDeletingZoneId(null)}
|
||||
>
|
||||
<Button intent="secondary" type="button" onClick={() => setDeletingZoneId(null)}>
|
||||
{at("cancelButton")}
|
||||
</Button>
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 197 KiB After Width: | Height: | Size: 197 KiB |
@@ -1,4 +1,4 @@
|
||||
import { ReactNode, Suspense } from "react";
|
||||
import { type ReactNode, Suspense } from "react";
|
||||
|
||||
import { NextIntlClientProvider } from "next-intl";
|
||||
import { getTranslations } from "next-intl/server";
|
||||
@@ -20,13 +20,10 @@ const title = Julius_Sans_One({
|
||||
variable: "--font-title",
|
||||
});
|
||||
|
||||
export async function generateMetadata({
|
||||
params: { locale },
|
||||
}: {
|
||||
params: { locale?: string };
|
||||
}) {
|
||||
export async function generateMetadata({ params }: { params: Promise<{ locale?: string }> }) {
|
||||
// While the `locale` is required, the namespace is optional and
|
||||
// identical to the parameter that `useTranslations` accepts.
|
||||
const { locale } = await params;
|
||||
const t = await getTranslations({
|
||||
locale: locale ?? "fr",
|
||||
namespace: "Metadata",
|
||||
@@ -48,14 +45,16 @@ export async function generateMetadata({
|
||||
|
||||
export default async function RootLayout({
|
||||
children,
|
||||
params: { locale },
|
||||
params,
|
||||
}: {
|
||||
children: ReactNode;
|
||||
params: { locale?: string };
|
||||
params: Promise<{ locale?: string }>;
|
||||
}) {
|
||||
const { locale } = await params;
|
||||
let messages;
|
||||
try {
|
||||
messages = (await import(`@/messages/${locale}.json`)).default;
|
||||
// oxlint-disable-next-line no-unused-vars
|
||||
} catch (error) {
|
||||
notFound();
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import { GrLineChart } from "react-icons/gr";
|
||||
import { HiUserGroup } from "react-icons/hi2";
|
||||
import { twMerge } from "tailwind-merge";
|
||||
|
||||
import bannerImage from "/public/banner.jpeg";
|
||||
import bannerImage from "./banner.jpeg";
|
||||
import { Link } from "@/utils/routing";
|
||||
|
||||
export default function Home() {
|
||||
@@ -45,18 +45,11 @@ export default function Home() {
|
||||
>
|
||||
{t("title")}
|
||||
</h1>
|
||||
<p className={twMerge("text-sm", "sm:text-lg", "md:text-xl")}>
|
||||
{t("purpose")}
|
||||
</p>
|
||||
<p className={twMerge("text-sm", "sm:text-lg", "md:text-xl")}>{t("purpose")}</p>
|
||||
</div>
|
||||
|
||||
<div className="absolute -bottom-[2px] w-full text-white dark:text-gray-800">
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="100%"
|
||||
height="auto"
|
||||
viewBox="0 0 1440 128"
|
||||
>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="auto" viewBox="0 0 1440 128">
|
||||
<path
|
||||
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"
|
||||
@@ -85,9 +78,7 @@ export default function Home() {
|
||||
<div className="flex items-center justify-center text-5xl">
|
||||
<GiTrophyCup />
|
||||
</div>
|
||||
<h2 className="text-center text-2xl font-semibold">
|
||||
{t("tournamentsTitle")}
|
||||
</h2>
|
||||
<h2 className="text-center text-2xl font-semibold">{t("tournamentsTitle")}</h2>
|
||||
|
||||
<p className="">{t("tournamentsInfo")}</p>
|
||||
|
||||
@@ -110,9 +101,7 @@ export default function Home() {
|
||||
<div className="flex items-center justify-center text-5xl">
|
||||
<HiUserGroup />
|
||||
</div>
|
||||
<h2 className="text-center text-2xl font-semibold">
|
||||
{t("clubsTitle")}
|
||||
</h2>
|
||||
<h2 className="text-center text-2xl font-semibold">{t("clubsTitle")}</h2>
|
||||
<p className="">{t("clubsInfo")}</p>
|
||||
|
||||
<Link
|
||||
@@ -134,9 +123,7 @@ export default function Home() {
|
||||
<div className="flex items-center justify-center text-5xl">
|
||||
<GrLineChart />
|
||||
</div>
|
||||
<h2 className="text-center text-2xl font-semibold">
|
||||
{t("eloTitle")}
|
||||
</h2>
|
||||
<h2 className="text-center text-2xl font-semibold">{t("eloTitle")}</h2>
|
||||
<p className="">{t("eloInfo")}</p>
|
||||
|
||||
<Link
|
||||
|
||||
+1
-3
@@ -4,9 +4,7 @@ import { Pathnames, routing } from "@/utils/routing";
|
||||
|
||||
export default function sitemap(): MetadataRoute.Sitemap {
|
||||
return routing.locales.flatMap((locale) => {
|
||||
const prefix = `https://echecsfrance.com${
|
||||
locale === "fr" ? "" : `/${locale}`
|
||||
}`;
|
||||
const prefix = `https://echecsfrance.com${locale === "fr" ? "" : `/${locale}`}`;
|
||||
|
||||
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 {
|
||||
endOfDay,
|
||||
isAfter,
|
||||
isBefore,
|
||||
parse,
|
||||
setDefaultOptions,
|
||||
startOfDay,
|
||||
} from "date-fns";
|
||||
import { endOfDay, isAfter, isBefore, parse, setDefaultOptions, startOfDay } from "date-fns";
|
||||
import { fr } from "date-fns/locale";
|
||||
import {
|
||||
Feature,
|
||||
FeatureCollection,
|
||||
GeoJsonProperties,
|
||||
MultiPolygon,
|
||||
Polygon,
|
||||
} from "geojson";
|
||||
import { Feature, FeatureCollection, GeoJsonProperties, MultiPolygon, Polygon } from "geojson";
|
||||
import { atom } from "jotai";
|
||||
import { LatLngBounds } from "leaflet";
|
||||
|
||||
@@ -61,13 +48,14 @@ export const otherAtom = atom(true);
|
||||
|
||||
export const clubsAtom = atom<Club[]>([]);
|
||||
|
||||
export const {
|
||||
currentValueAtom: hoveredMapIdAtom,
|
||||
debouncedValueAtom: debouncedHoveredMapIdAtom,
|
||||
} = atomWithDebounce<string | null>(null);
|
||||
export const { currentValueAtom: hoveredMapIdAtom, debouncedValueAtom: debouncedHoveredMapIdAtom } =
|
||||
atomWithDebounce<string | null>(null);
|
||||
|
||||
export const { debouncedValueAtom: debouncedHoveredListIdAtom } =
|
||||
atomWithDebounce<string | null>(null, 1000, 100);
|
||||
export const { debouncedValueAtom: debouncedHoveredListIdAtom } = atomWithDebounce<string | null>(
|
||||
null,
|
||||
1000,
|
||||
100,
|
||||
);
|
||||
|
||||
export const filteredTournamentsByTimeControlAndZoneAtom = atom((get) => {
|
||||
const tournaments = get(tournamentsAtom);
|
||||
@@ -82,9 +70,7 @@ export const filteredTournamentsByTimeControlAndZoneAtom = atom((get) => {
|
||||
const { startDate, endDate } = dateRange[0];
|
||||
|
||||
const filterByTimeControl = tournaments.filter((tournament) => {
|
||||
const tournamentDate = startOfDay(
|
||||
parse(tournament.date, "dd/MM/yyyy", new Date()),
|
||||
);
|
||||
const tournamentDate = startOfDay(parse(tournament.date, "dd/MM/yyyy", new Date()));
|
||||
|
||||
return (
|
||||
!isBefore(tournamentDate, startDate) &&
|
||||
@@ -98,11 +84,7 @@ export const filteredTournamentsByTimeControlAndZoneAtom = atom((get) => {
|
||||
);
|
||||
});
|
||||
|
||||
if (
|
||||
regionFilter === "all" ||
|
||||
regionFilter === "map" ||
|
||||
regionFilter === "region"
|
||||
)
|
||||
if (regionFilter === "all" || regionFilter === "map" || regionFilter === "region")
|
||||
return filterByTimeControl;
|
||||
|
||||
if (isFeature(regionFilter)) {
|
||||
@@ -118,10 +100,7 @@ export const filteredTournamentsByTimeControlAndZoneAtom = atom((get) => {
|
||||
return regionFilter.features?.features?.some(
|
||||
(feature) =>
|
||||
feature.geometry.type === "Polygon" &&
|
||||
booleanPointInPolygon(
|
||||
[tournament.latLng.lng, tournament.latLng.lat],
|
||||
feature.geometry,
|
||||
),
|
||||
booleanPointInPolygon([tournament.latLng.lng, tournament.latLng.lat], feature.geometry),
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -133,16 +112,13 @@ export const filteredTournamentsListAtom = atom((get) => {
|
||||
const normsOnly = get(normsOnlyAtom);
|
||||
const searchString = get(searchStringAtom).trim();
|
||||
|
||||
const filteredByNorm = normsOnly
|
||||
? tournaments.filter((t) => t.norm)
|
||||
: tournaments;
|
||||
const filteredByNorm = normsOnly ? tournaments.filter((t) => t.norm) : tournaments;
|
||||
|
||||
// When searching, we search all the tournament, regardless of the map display
|
||||
if (searchString !== "") {
|
||||
return filteredByNorm.filter(
|
||||
(t) =>
|
||||
normalizedContains(t.town, searchString) ||
|
||||
normalizedContains(t.tournament, searchString),
|
||||
normalizedContains(t.town, searchString) || normalizedContains(t.tournament, searchString),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -150,28 +126,18 @@ export const filteredTournamentsListAtom = atom((get) => {
|
||||
if (mapBounds === null || regionFilter !== "map") return filteredByNorm;
|
||||
|
||||
// Filter by the map bounds
|
||||
return filteredByNorm.filter((tournament) =>
|
||||
mapBounds.contains(tournament.latLng),
|
||||
);
|
||||
return filteredByNorm.filter((tournament) => mapBounds.contains(tournament.latLng));
|
||||
});
|
||||
|
||||
export const filteredClubsByZoneAtom = atom((get) => {
|
||||
const clubs = get(clubsAtom);
|
||||
const regionFilter = get(regionFilterAtom);
|
||||
|
||||
if (
|
||||
regionFilter === "all" ||
|
||||
regionFilter === "map" ||
|
||||
regionFilter === "region"
|
||||
)
|
||||
return clubs;
|
||||
if (regionFilter === "all" || regionFilter === "map" || regionFilter === "region") return clubs;
|
||||
|
||||
if (isFeature(regionFilter)) {
|
||||
return clubs.filter((club) => {
|
||||
return booleanPointInPolygon(
|
||||
[club.latLng.lng, club.latLng.lat],
|
||||
regionFilter.geometry,
|
||||
);
|
||||
return booleanPointInPolygon([club.latLng.lng, club.latLng.lat], regionFilter.geometry);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -179,10 +145,7 @@ export const filteredClubsByZoneAtom = atom((get) => {
|
||||
return regionFilter.features?.features?.some(
|
||||
(feature) =>
|
||||
feature.geometry.type === "Polygon" &&
|
||||
booleanPointInPolygon(
|
||||
[club.latLng.lng, club.latLng.lat],
|
||||
feature.geometry,
|
||||
),
|
||||
booleanPointInPolygon([club.latLng.lng, club.latLng.lat], feature.geometry),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
+39
-44
@@ -1,52 +1,50 @@
|
||||
import { type ComponentProps } from 'react'
|
||||
import { type VariantProps, cva } from "class-variance-authority";
|
||||
import { twMerge } from "tailwind-merge";
|
||||
|
||||
export const buttonVariants = cva(
|
||||
"flex items-center justify-center transition-all duration-200",
|
||||
{
|
||||
variants: {
|
||||
intent: {
|
||||
primary: [
|
||||
"text-center",
|
||||
"text-white",
|
||||
"focus:outline-none focus:ring-2 focus:ring-primary-500",
|
||||
"bg-primary-600",
|
||||
"hover:bg-primary-800",
|
||||
"disabled:opacity-25",
|
||||
"dark:text-white dark:hover:bg-primary-700",
|
||||
],
|
||||
export const buttonVariants = cva("flex items-center justify-center transition-all duration-200", {
|
||||
variants: {
|
||||
intent: {
|
||||
primary: [
|
||||
"text-center",
|
||||
"text-white",
|
||||
"focus:outline-none focus:ring-2 focus:ring-primary-500",
|
||||
"bg-primary-600",
|
||||
"hover:bg-primary-800",
|
||||
"disabled:opacity-25",
|
||||
"dark:text-white dark:hover:bg-primary-700",
|
||||
],
|
||||
|
||||
secondary: [
|
||||
"text-primary dark:text-white",
|
||||
"hover:text-white dark:hover:text-white",
|
||||
"hover:bg-primary hover:text-white",
|
||||
"border border-primary",
|
||||
"focus:outline-none focus:ring-2 focus:ring-primary-500",
|
||||
"disabled:opacity-25",
|
||||
],
|
||||
secondary: [
|
||||
"text-primary dark:text-white",
|
||||
"hover:text-white dark:hover:text-white",
|
||||
"hover:bg-primary hover:text-white",
|
||||
"border border-primary",
|
||||
"focus:outline-none focus:ring-2 focus:ring-primary-500",
|
||||
"disabled:opacity-25",
|
||||
],
|
||||
|
||||
tertiary: [
|
||||
"text-gray-900 dark:text-neutral-400",
|
||||
"hover:text-primary dark:hover:text-white",
|
||||
"focus:outline-none focus:ring-2 focus:ring-primary-500",
|
||||
"disabled:opacity-25",
|
||||
],
|
||||
},
|
||||
size: {
|
||||
small: ["text-sm font-medium", "px-3 py-2", "sm:w-fit", "rounded-lg"],
|
||||
medium: ["text-sm font-medium", "px-5 py-3", "sm:w-fit", "rounded-lg"],
|
||||
compacted: ["rounded-none", "px-0 py-0"],
|
||||
},
|
||||
tertiary: [
|
||||
"text-gray-900 dark:text-neutral-400",
|
||||
"hover:text-primary dark:hover:text-white",
|
||||
"focus:outline-none focus:ring-2 focus:ring-primary-500",
|
||||
"disabled:opacity-25",
|
||||
],
|
||||
},
|
||||
defaultVariants: {
|
||||
intent: "primary",
|
||||
size: "medium",
|
||||
size: {
|
||||
small: ["text-sm font-medium", "px-3 py-2", "sm:w-fit", "rounded-lg"],
|
||||
medium: ["text-sm font-medium", "px-5 py-3", "sm:w-fit", "rounded-lg"],
|
||||
compacted: ["rounded-none", "px-0 py-0"],
|
||||
},
|
||||
},
|
||||
);
|
||||
defaultVariants: {
|
||||
intent: "primary",
|
||||
size: "medium",
|
||||
},
|
||||
});
|
||||
|
||||
export type ButtonVariants = VariantProps<typeof buttonVariants>;
|
||||
export type ButtonProps = React.ComponentProps<"button"> & ButtonVariants;
|
||||
type ButtonVariants = VariantProps<typeof buttonVariants>;
|
||||
export type ButtonProps = ComponentProps<"button"> & ButtonVariants;
|
||||
|
||||
export const Button = ({
|
||||
className,
|
||||
@@ -54,8 +52,5 @@ export const Button = ({
|
||||
size,
|
||||
...props
|
||||
}: ButtonProps & { className?: string }) => (
|
||||
<button
|
||||
className={twMerge(buttonVariants({ intent, size, className }))}
|
||||
{...props}
|
||||
/>
|
||||
<button className={twMerge(buttonVariants({ intent, size, className }))} {...props} />
|
||||
);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import React from "react";
|
||||
|
||||
import { Float } from "@headlessui-float/react";
|
||||
import { Menu, MenuButton, MenuItem, MenuItems } from "@headlessui/react";
|
||||
import { IoMdMore } from "react-icons/io";
|
||||
import { twMerge } from "tailwind-merge";
|
||||
@@ -18,54 +17,43 @@ type DropdownMenuProps = {
|
||||
containerClassName?: string;
|
||||
};
|
||||
|
||||
export const DropdownMenu = ({
|
||||
items,
|
||||
buttonComponent,
|
||||
containerClassName,
|
||||
}: DropdownMenuProps) => {
|
||||
export const DropdownMenu = ({ items, buttonComponent, containerClassName }: DropdownMenuProps) => {
|
||||
return (
|
||||
<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 ?? (
|
||||
<MenuButton>
|
||||
<IoMdMore />
|
||||
</MenuButton>
|
||||
)}
|
||||
{buttonComponent ?? (
|
||||
<MenuButton>
|
||||
<IoMdMore />
|
||||
</MenuButton>
|
||||
)}
|
||||
|
||||
<MenuItems className="z-20 flex w-auto items-start overflow-hidden rounded-md bg-neutral-200 focus:outline-none dark:bg-neutral-600">
|
||||
<div className="flex flex-col px-1 py-1">
|
||||
{items.map(({ title, onClick, className, disabled }, i) => (
|
||||
<MenuItem key={i}>
|
||||
<button
|
||||
type="button"
|
||||
className={twMerge(
|
||||
"w-full whitespace-nowrap rounded-md px-2.5 py-2 text-left text-sm text-black dark:text-white",
|
||||
!disabled && "hover:bg-white dark:hover:bg-neutral-700",
|
||||
disabled && "text-neutral-500 dark:text-neutral-500",
|
||||
className,
|
||||
)}
|
||||
disabled={disabled ?? false}
|
||||
onClick={() => {
|
||||
if (!disabled) onClick();
|
||||
}}
|
||||
>
|
||||
{title}
|
||||
</button>
|
||||
</MenuItem>
|
||||
))}
|
||||
</div>
|
||||
</MenuItems>
|
||||
</Float>
|
||||
<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">
|
||||
{items.map(({ title, onClick, className, disabled }, i) => (
|
||||
<MenuItem key={i}>
|
||||
<button
|
||||
type="button"
|
||||
className={twMerge(
|
||||
"w-full whitespace-nowrap rounded-md px-2.5 py-2 text-left text-sm text-black dark:text-white",
|
||||
!disabled && "hover:bg-white dark:hover:bg-neutral-700",
|
||||
disabled && "text-neutral-500 dark:text-neutral-500",
|
||||
className,
|
||||
)}
|
||||
disabled={disabled ?? false}
|
||||
onClick={() => {
|
||||
if (!disabled) onClick();
|
||||
}}
|
||||
>
|
||||
{title}
|
||||
</button>
|
||||
</MenuItem>
|
||||
))}
|
||||
</div>
|
||||
</MenuItems>
|
||||
</Menu>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
import { type ReactNode } from "react";
|
||||
|
||||
import {
|
||||
HiCheckCircle,
|
||||
HiInformationCircle,
|
||||
HiXCircle,
|
||||
HiXMark,
|
||||
} from "react-icons/hi2";
|
||||
import { HiCheckCircle, HiInformationCircle, HiXCircle, HiXMark } from "react-icons/hi2";
|
||||
import { twMerge } from "tailwind-merge";
|
||||
|
||||
export type InfoMessageType = "success" | "error" | "info";
|
||||
@@ -74,11 +69,7 @@ const InfoMessage = ({
|
||||
button,
|
||||
)}
|
||||
>
|
||||
<HiXMark
|
||||
aria-hidden="true"
|
||||
className="h-5 w-5"
|
||||
onClick={onDismiss}
|
||||
/>
|
||||
<HiXMark aria-hidden="true" className="h-5 w-5" onClick={onDismiss} />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
import { useTranslations } from "next-intl";
|
||||
|
||||
import { Spinner } from "./Spinner";
|
||||
|
||||
const LoadingMap = () => {
|
||||
const t = useTranslations("Tournaments");
|
||||
return (
|
||||
<div className="mt-20 flex h-content justify-center bg-white pt-20 text-center text-gray-900 dark:bg-gray-800 dark:text-white">
|
||||
<Spinner />
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect } from "react";
|
||||
import { useEffect, type ReactNode } from "react";
|
||||
|
||||
import { useSession } from "next-auth/react";
|
||||
import { useLocale } from "next-intl";
|
||||
@@ -10,11 +10,11 @@ import { setUserLocale } from "@/server/setUserLocale";
|
||||
import { usePathname, useRouter } from "@/utils/routing";
|
||||
|
||||
type LocaleCheckerProps = {
|
||||
children?: React.ReactNode;
|
||||
children?: ReactNode;
|
||||
};
|
||||
|
||||
export const LocaleChecker = ({ children }: LocaleCheckerProps) => {
|
||||
const { data: sessionData, status, update } = useSession();
|
||||
const { data: sessionData, status } = useSession();
|
||||
const router = useRouter();
|
||||
const pathname = usePathname();
|
||||
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,
|
||||
// then we update redirect to the user's preference
|
||||
if (
|
||||
status === "authenticated" &&
|
||||
userLocale !== undefined &&
|
||||
userLocale !== locale
|
||||
) {
|
||||
if (status === "authenticated" && userLocale !== undefined && userLocale !== locale) {
|
||||
router.push({ pathname, params: params as any }, { locale: userLocale });
|
||||
}
|
||||
}, [locale, sessionData, status, params, pathname, router, userLocale]);
|
||||
|
||||
// To avoid flickering, we don't render the children until we have the user's locale
|
||||
if (status === "loading") return null;
|
||||
if (
|
||||
status === "authenticated" &&
|
||||
userLocale !== undefined &&
|
||||
userLocale !== locale
|
||||
)
|
||||
return null;
|
||||
if (status === "authenticated" && userLocale !== undefined && userLocale !== locale) return null;
|
||||
|
||||
return children;
|
||||
};
|
||||
|
||||
+18
-29
@@ -12,6 +12,8 @@ import "leaflet/dist/leaflet.css";
|
||||
import { FaAngleDoubleDown } from "react-icons/fa";
|
||||
import { LayerGroup, MapContainer, TileLayer } from "react-leaflet";
|
||||
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 { MapEvents } from "@/components/MapEvents";
|
||||
@@ -57,12 +59,7 @@ type MapProps = {
|
||||
iconCreateFunction?: L.MarkerClusterGroupOptions["iconCreateFunction"];
|
||||
};
|
||||
|
||||
export const Map = ({
|
||||
filters,
|
||||
legend,
|
||||
markers: markers,
|
||||
iconCreateFunction,
|
||||
}: MapProps) => {
|
||||
export const Map = ({ filters, legend, markers, iconCreateFunction }: MapProps) => {
|
||||
const setMapBounds = useSetAtom(mapBoundsAtom);
|
||||
|
||||
const hoveredListTournamentId = useAtomValue(debouncedHoveredListIdAtom);
|
||||
@@ -80,17 +77,13 @@ export const Map = ({
|
||||
|
||||
const expandAndBounceIfNeeded = useCallback(() => {
|
||||
if (hoveredListTournamentId) {
|
||||
const marker = markers.find((m) =>
|
||||
m.tableIds.includes(hoveredListTournamentId),
|
||||
);
|
||||
const marker = markers.find((m) => m.tableIds.includes(hoveredListTournamentId));
|
||||
|
||||
if (marker) {
|
||||
const markerRef = markerRefs.current[marker.markerId];
|
||||
if (markerRef) {
|
||||
if (clusterRef.current) {
|
||||
const visibleMarker = clusterRef.current.getVisibleParent(
|
||||
markerRef.getMarker(),
|
||||
);
|
||||
const visibleMarker = clusterRef.current.getVisibleParent(markerRef.getMarker());
|
||||
if (!visibleMarker) return;
|
||||
|
||||
// @ts-ignore
|
||||
@@ -138,9 +131,7 @@ export const Map = ({
|
||||
// Once expanded, bounce the appropriate marker
|
||||
|
||||
if (hoveredListTournamentId) {
|
||||
const marker = markers.find((m) =>
|
||||
m.tableIds.includes(hoveredListTournamentId),
|
||||
);
|
||||
const marker = markers.find((m) => m.tableIds.includes(hoveredListTournamentId));
|
||||
if (!marker) return;
|
||||
|
||||
expandedClusterMarkerRef.current = e.cluster;
|
||||
@@ -157,8 +148,7 @@ export const Map = ({
|
||||
|
||||
const onUnSpiderified = useCallback(
|
||||
(e: L.MarkerClusterSpiderfyEvent) => {
|
||||
if (expandedClusterMarkerRef.current === e.cluster)
|
||||
expandedClusterMarkerRef.current = null;
|
||||
if (expandedClusterMarkerRef.current === e.cluster) expandedClusterMarkerRef.current = null;
|
||||
|
||||
// Once closed, we can expand the next group if needed
|
||||
expandAndBounceIfNeeded();
|
||||
@@ -186,18 +176,22 @@ export const Map = ({
|
||||
// Expand/contract as hoveredListTournamentId changes
|
||||
if (expandAndBounceIfNeeded()) return;
|
||||
|
||||
if (expandedClusterMarkerRef.current)
|
||||
expandedClusterMarkerRef.current.unspiderfy();
|
||||
if (expandedClusterMarkerRef.current) expandedClusterMarkerRef.current.unspiderfy();
|
||||
}, [expandAndBounceIfNeeded, hoveredListTournamentId]);
|
||||
|
||||
const referencedMarkers = useMemo(
|
||||
() =>
|
||||
markers.map((marker) =>
|
||||
React.cloneElement(marker.component, {
|
||||
ref: (ref: MarkerRef) => {
|
||||
markerRefs.current[marker.markerId] = ref;
|
||||
React.cloneElement(
|
||||
marker.component as React.ReactElement<{
|
||||
ref?: (ref: MarkerRef) => void;
|
||||
}>,
|
||||
{
|
||||
ref: (ref: MarkerRef) => {
|
||||
markerRefs.current[marker.markerId] = ref;
|
||||
},
|
||||
},
|
||||
}),
|
||||
),
|
||||
),
|
||||
[markers],
|
||||
);
|
||||
@@ -240,12 +234,7 @@ export const Map = ({
|
||||
</MapContainer>
|
||||
|
||||
<div className="flex items-center justify-center lg:hidden">
|
||||
<Button
|
||||
intent="tertiary"
|
||||
size="compacted"
|
||||
className="p-3"
|
||||
onClick={onScrollToTable}
|
||||
>
|
||||
<Button intent="tertiary" size="compacted" className="p-3" onClick={onScrollToTable}>
|
||||
<FaAngleDoubleDown />
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
@@ -14,10 +14,7 @@ import { mapBoundsAtom } from "@/atoms";
|
||||
L.Map.addInitHook("addHandler", "gestureHandling", GestureHandling);
|
||||
|
||||
const worldBounds = L.latLngBounds(L.latLng(-90, -180), L.latLng(90, 180));
|
||||
const franceBounds = L.latLngBounds(
|
||||
L.latLng(42.08, -5.12),
|
||||
L.latLng(51.17, 9.53),
|
||||
);
|
||||
const franceBounds = L.latLngBounds(L.latLng(42.08, -5.12), L.latLng(51.17, 9.53));
|
||||
|
||||
type MapEventsProps = {
|
||||
bounds?: L.LatLngBounds;
|
||||
@@ -32,7 +29,7 @@ export const MapEvents = ({
|
||||
const t = useTranslations("Map");
|
||||
const map = useMap();
|
||||
const setMapBounds = useSetAtom(mapBoundsAtom);
|
||||
const [isPending, startTransition] = useTransition();
|
||||
const [_isPending, startTransition] = useTransition();
|
||||
|
||||
useMapEvent("moveend", () => {
|
||||
if (!updateMapBoundsAtom) return;
|
||||
@@ -49,17 +46,12 @@ export const MapEvents = ({
|
||||
map.setView(bounds.getCenter(), zoom === Infinity ? 10 : zoom);
|
||||
map.setMaxBounds(worldBounds);
|
||||
map.options.maxBoundsViscosity = 1.0; // Prevents going past bounds while dragging
|
||||
|
||||
map.addHandler("gestureHandling", GestureHandling);
|
||||
|
||||
map.gestureHandling?.enable();
|
||||
}, [bounds, map]);
|
||||
|
||||
useEffect(() => {
|
||||
if (
|
||||
"gestureHandlingOptions" in map.options &&
|
||||
map.options.gestureHandlingOptions
|
||||
) {
|
||||
if ("gestureHandlingOptions" in map.options && map.options.gestureHandlingOptions) {
|
||||
map.options.gestureHandlingOptions.text = {
|
||||
touch: t("touch"),
|
||||
scroll: t("scroll"),
|
||||
|
||||
@@ -1,23 +1,26 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect } from "react";
|
||||
|
||||
import { trackAppRouter } from "@socialgouv/matomo-next";
|
||||
import { usePathname, useSearchParams } from "next/navigation";
|
||||
import { useEffect } from "react";
|
||||
|
||||
const MATOMO_URL = process.env.NEXT_PUBLIC_MATOMO_URL;
|
||||
const MATOMO_SITE_ID = process.env.NEXT_PUBLIC_MATOMO_SITE_ID;
|
||||
const isMatomoEnabled = Boolean(MATOMO_URL && MATOMO_SITE_ID);
|
||||
|
||||
export function MatomoAnalytics() {
|
||||
const pathname = usePathname();
|
||||
const searchParams = useSearchParams();
|
||||
|
||||
useEffect(() => {
|
||||
if (!isMatomoEnabled) return;
|
||||
|
||||
trackAppRouter({
|
||||
url: MATOMO_URL || "",
|
||||
siteId: MATOMO_SITE_ID || "",
|
||||
url: MATOMO_URL as string,
|
||||
siteId: MATOMO_SITE_ID as string,
|
||||
pathname,
|
||||
searchParams, // Pass URLSearchParams object directly
|
||||
// Optional: Enable additional features
|
||||
searchParams,
|
||||
enableHeatmapSessionRecording: false,
|
||||
enableHeartBeatTimer: true,
|
||||
cleanUrl: true,
|
||||
@@ -27,4 +30,4 @@ export function MatomoAnalytics() {
|
||||
}, [pathname, searchParams]);
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,12 +30,7 @@ export const Modal = ({
|
||||
...dialogProps
|
||||
}: ModalProps) => (
|
||||
<Transition appear show={open} as={Fragment}>
|
||||
<Dialog
|
||||
as="div"
|
||||
className="relative z-[2000]"
|
||||
onClose={onClose}
|
||||
{...dialogProps}
|
||||
>
|
||||
<Dialog as="div" className="relative z-[2000]" onClose={onClose} {...dialogProps}>
|
||||
<Transition.Child
|
||||
as={Fragment}
|
||||
enter="ease-out duration-300"
|
||||
@@ -45,9 +40,7 @@ export const Modal = ({
|
||||
leaveFrom="opacity-100"
|
||||
leaveTo="opacity-0"
|
||||
>
|
||||
<div
|
||||
className={twMerge("fixed inset-0 bg-neutral-900/50", overlayClass)}
|
||||
/>
|
||||
<div className={twMerge("fixed inset-0 bg-neutral-900/50", overlayClass)} />
|
||||
</Transition.Child>
|
||||
|
||||
<div className="fixed inset-0 overflow-y-auto">
|
||||
|
||||
@@ -22,10 +22,7 @@ type RegionSelectProps = Omit<
|
||||
type RegionOption = BaseOption<string, Zone | null>;
|
||||
type GroupedOption = GroupBase<RegionOption>;
|
||||
|
||||
export const RegionSelect = ({
|
||||
syncTitle,
|
||||
...selectProps
|
||||
}: RegionSelectProps) => {
|
||||
export const RegionSelect = ({ syncTitle, ...selectProps }: RegionSelectProps) => {
|
||||
const t = useTranslations("Zones");
|
||||
const router = useRouter();
|
||||
const [regionFilter, setRegionFilter] = useAtom(regionFilterAtom);
|
||||
@@ -67,9 +64,7 @@ export const RegionSelect = ({
|
||||
},
|
||||
];
|
||||
|
||||
const onChange = (
|
||||
option: OnChangeValue<BaseOption<string, Zone | null>, false>,
|
||||
) => {
|
||||
const onChange = (option: OnChangeValue<BaseOption<string, Zone | null>, false>) => {
|
||||
if (!option) return;
|
||||
|
||||
if (option.value === "create") {
|
||||
@@ -114,11 +109,7 @@ export const RegionSelect = ({
|
||||
);
|
||||
|
||||
const getValue = () => {
|
||||
if (
|
||||
regionFilter === "all" ||
|
||||
regionFilter === "map" ||
|
||||
regionFilter === "region"
|
||||
) {
|
||||
if (regionFilter === "all" || regionFilter === "map" || regionFilter === "region") {
|
||||
return allOptions.find((o) => o.value === regionFilter);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
import type { Dispatch, SetStateAction } from "react";
|
||||
|
||||
import {
|
||||
type Feature,
|
||||
GeoJsonProperties,
|
||||
MultiPolygon,
|
||||
Polygon,
|
||||
} from "geojson";
|
||||
import { type Feature, GeoJsonProperties, MultiPolygon, Polygon } from "geojson";
|
||||
import { useSetAtom } from "jotai";
|
||||
import { useTranslations } from "next-intl";
|
||||
import { IoClose } from "react-icons/io5";
|
||||
@@ -20,10 +15,7 @@ interface IProps {
|
||||
setIsRegionModalOpen: Dispatch<SetStateAction<boolean>>;
|
||||
}
|
||||
|
||||
export const RegionSelectModal = ({
|
||||
isRegionModalOpen,
|
||||
setIsRegionModalOpen,
|
||||
}: IProps) => {
|
||||
export const RegionSelectModal = ({ isRegionModalOpen, setIsRegionModalOpen }: IProps) => {
|
||||
const t = useTranslations("Zones");
|
||||
const setRegionFilter = useSetAtom(regionFilterAtom);
|
||||
|
||||
@@ -32,13 +24,9 @@ export const RegionSelectModal = ({
|
||||
};
|
||||
|
||||
const handleRegionSelect = (region: string) => {
|
||||
const regionData = regionGeoJson.features.find(
|
||||
(f) => f.properties.nom === region,
|
||||
);
|
||||
const regionData = regionGeoJson.features.find((f) => f.properties.nom === region);
|
||||
if (regionData) {
|
||||
setRegionFilter(
|
||||
regionData as Feature<Polygon | MultiPolygon, GeoJsonProperties>,
|
||||
);
|
||||
setRegionFilter(regionData as Feature<Polygon | MultiPolygon, GeoJsonProperties>);
|
||||
handleCloseModal();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -3,7 +3,6 @@ import { useTransition } from "react";
|
||||
import { useAtom } from "jotai/index";
|
||||
import { useTranslations } from "next-intl";
|
||||
import { IoCloseOutline } from "react-icons/io5";
|
||||
import { twMerge } from "tailwind-merge";
|
||||
|
||||
import { searchStringAtom } from "@/atoms";
|
||||
|
||||
@@ -14,10 +13,11 @@ type SearchBarProps = {
|
||||
className?: string;
|
||||
};
|
||||
|
||||
// oxlint-disable-next-line no-unused-vars
|
||||
const SearchBar = ({ className }: SearchBarProps) => {
|
||||
const t = useTranslations("Tournaments");
|
||||
const [searchString, setSearchString] = useAtom(searchStringAtom);
|
||||
const [isPending, startTransition] = useTransition();
|
||||
const [_isPending, startTransition] = useTransition();
|
||||
|
||||
const updateSearchString = (str: string) => {
|
||||
startTransition(() => {
|
||||
@@ -53,11 +53,7 @@ const SearchBar = ({ className }: SearchBarProps) => {
|
||||
}
|
||||
endIcon={
|
||||
searchString !== "" && (
|
||||
<Button
|
||||
intent="tertiary"
|
||||
size="compacted"
|
||||
onClick={() => setSearchString("")}
|
||||
>
|
||||
<Button intent="tertiary" size="compacted" onClick={() => setSearchString("")}>
|
||||
<IoCloseOutline className="h-5 w-5" />
|
||||
</Button>
|
||||
)
|
||||
|
||||
@@ -97,10 +97,7 @@ export const SignInForm = ({ callbackPath }: SignInFormProps) => {
|
||||
</Button>
|
||||
|
||||
{responseMessage && (
|
||||
<InfoMessage
|
||||
message={responseMessage.message}
|
||||
type={responseMessage.type}
|
||||
/>
|
||||
<InfoMessage message={responseMessage.message} type={responseMessage.type} />
|
||||
)}
|
||||
</form>
|
||||
</FormProvider>
|
||||
|
||||
@@ -2,13 +2,7 @@ import React, { useEffect, useRef, useState } from "react";
|
||||
|
||||
import { get, isArray, isNil } from "lodash";
|
||||
import { useTranslations } from "next-intl";
|
||||
import {
|
||||
Controller,
|
||||
FieldPath,
|
||||
FieldValues,
|
||||
useFormContext,
|
||||
useWatch,
|
||||
} from "react-hook-form";
|
||||
import { Controller, FieldPath, FieldValues, useFormContext, useWatch } from "react-hook-form";
|
||||
import { ActionMeta, GroupBase, OnChangeValue, Props } from "react-select";
|
||||
import AsyncSelect from "react-select/async";
|
||||
|
||||
@@ -52,19 +46,16 @@ export const AsyncSelectField = <
|
||||
hideErrorMessage,
|
||||
required,
|
||||
size,
|
||||
|
||||
loadOption,
|
||||
loadOptions,
|
||||
onInformChange,
|
||||
|
||||
placeholder,
|
||||
separators,
|
||||
|
||||
...selectProps
|
||||
}: AsyncSelectFieldProps<TFieldValues, TFieldName, IsMulti, T, D>) => {
|
||||
const t = useTranslations("App");
|
||||
const [loadingValues, setLoadingValues] = useState(false);
|
||||
const [loadedInitialValues, setLoadedInitialValues] = useState(false);
|
||||
const [_loadedInitialValues, setLoadedInitialValues] = useState(false);
|
||||
const [loadingOptions, setLoadingOptions] = useState(false);
|
||||
const valueOptions = useRef<BaseOption<T, D>[]>([]);
|
||||
const searchOptions = useRef<BaseOption<T, D>[]>([]);
|
||||
@@ -78,8 +69,7 @@ export const AsyncSelectField = <
|
||||
const values = !value ? [] : isArray(value) ? value : [value];
|
||||
|
||||
const unFetchedValues = values.filter(
|
||||
(v) =>
|
||||
valueOptions.current.find((o) => o.value === value) === undefined,
|
||||
() => valueOptions.current.find((o) => o.value === value) === undefined,
|
||||
);
|
||||
|
||||
if (unFetchedValues.length > 0) {
|
||||
@@ -98,9 +88,10 @@ export const AsyncSelectField = <
|
||||
setLoadingValues(false);
|
||||
|
||||
onInformChange?.(
|
||||
values.map(
|
||||
(v) => valueOptions.current.find((o) => o.value === v)!,
|
||||
) as BaseOption<T, D>[],
|
||||
values.map((v) => valueOptions.current.find((o) => o.value === v)!) as BaseOption<
|
||||
T,
|
||||
D
|
||||
>[],
|
||||
);
|
||||
|
||||
// This forced a state update, which enures that the select is updated once the query has finished
|
||||
@@ -122,9 +113,10 @@ export const AsyncSelectField = <
|
||||
const hasError = !!get(errors, name)?.message;
|
||||
|
||||
const valueToOption = (value: T) =>
|
||||
[...valueOptions.current, ...searchOptions.current].find(
|
||||
(o) => o.value === value,
|
||||
) ?? { value, label: "" };
|
||||
[...valueOptions.current, ...searchOptions.current].find((o) => o.value === value) ?? {
|
||||
value,
|
||||
label: "",
|
||||
};
|
||||
|
||||
const fetchOptions = async (searchString?: string) => {
|
||||
setLoadingOptions(true);
|
||||
|
||||
@@ -12,10 +12,7 @@ interface InputProps {
|
||||
}
|
||||
|
||||
type AllProps = Omit<
|
||||
React.DetailedHTMLProps<
|
||||
React.InputHTMLAttributes<HTMLInputElement>,
|
||||
HTMLInputElement
|
||||
>,
|
||||
React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>,
|
||||
"ref"
|
||||
> &
|
||||
InputProps;
|
||||
@@ -24,12 +21,13 @@ export const InputDatePicker = forwardRef<HTMLInputElement, AllProps>(
|
||||
(
|
||||
{
|
||||
error,
|
||||
// oxlint-disable-next-line no-unused-vars
|
||||
className,
|
||||
// oxlint-disable-next-line no-unused-vars
|
||||
children,
|
||||
inputContainerClass,
|
||||
inputClass,
|
||||
mask,
|
||||
|
||||
...props
|
||||
},
|
||||
inputRef,
|
||||
|
||||
@@ -1,16 +1,11 @@
|
||||
import React, { useRef } from "react";
|
||||
import { useRef } from "react";
|
||||
|
||||
import { getYear, isValid, parse } from "date-fns";
|
||||
import fr from "date-fns/locale/fr";
|
||||
import { get } from "lodash";
|
||||
import { useLocale, useTranslations } from "next-intl";
|
||||
import DatePicker, { registerLocale } from "react-datepicker";
|
||||
import {
|
||||
Controller,
|
||||
FieldPath,
|
||||
FieldValues,
|
||||
useFormContext,
|
||||
} from "react-hook-form";
|
||||
import { Controller, FieldPath, FieldValues, useFormContext } from "react-hook-form";
|
||||
import { twMerge } from "tailwind-merge";
|
||||
|
||||
import { Prettify } from "@/types";
|
||||
@@ -45,10 +40,8 @@ export const DateField = <
|
||||
dateFormat = "dd/MM/yyyy",
|
||||
className,
|
||||
datePickerPopperClass,
|
||||
|
||||
name,
|
||||
control,
|
||||
required,
|
||||
...otherFieldProps
|
||||
}: DateFieldProps<TFieldValues, TFieldName>) => {
|
||||
const locale = useLocale();
|
||||
@@ -93,11 +86,7 @@ export const DateField = <
|
||||
// Called when the user types in the input
|
||||
if (e?.currentTarget && "value" in e.currentTarget) {
|
||||
const value = e.currentTarget.value;
|
||||
const date = parse(
|
||||
value as string,
|
||||
at("dateParseFormat"),
|
||||
new Date(),
|
||||
);
|
||||
const date = parse(value as string, at("dateParseFormat"), new Date());
|
||||
if (
|
||||
isValid(date) &&
|
||||
date.getFullYear() >= min &&
|
||||
@@ -124,9 +113,7 @@ export const DateField = <
|
||||
minDate={minDate}
|
||||
showFullMonthYearPicker
|
||||
maxDate={maxDate}
|
||||
renderCustomHeader={(props) => (
|
||||
<DatePickerCustomHeader {...props} />
|
||||
)}
|
||||
renderCustomHeader={(props) => <DatePickerCustomHeader {...props} />}
|
||||
customInput={
|
||||
<InputDatePicker
|
||||
mask={at("dateMask")}
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
import { ReactNode } from "react";
|
||||
|
||||
import { get } from "lodash";
|
||||
import {
|
||||
Control,
|
||||
FieldPath,
|
||||
FieldValues,
|
||||
useFormContext,
|
||||
} from "react-hook-form";
|
||||
import { Control, FieldPath, FieldValues, useFormContext } from "react-hook-form";
|
||||
import { twMerge } from "tailwind-merge";
|
||||
|
||||
import { Prettify } from "@/types";
|
||||
@@ -70,13 +65,7 @@ export const Field = <
|
||||
</Label>
|
||||
) : null}
|
||||
|
||||
<div
|
||||
className={twMerge(
|
||||
"flex w-full",
|
||||
label && "mt-2",
|
||||
childrenWrapperClassName,
|
||||
)}
|
||||
>
|
||||
<div className={twMerge("flex w-full", label && "mt-2", childrenWrapperClassName)}>
|
||||
{children}
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,21 +1,17 @@
|
||||
import React from "react";
|
||||
|
||||
import type { ReactNode } from 'react'
|
||||
import { Switch, SwitchProps } from "@headlessui/react";
|
||||
import { twMerge } from "tailwind-merge";
|
||||
|
||||
export const InlineSwitch = (
|
||||
props: {
|
||||
label?: React.ReactNode;
|
||||
label?: ReactNode;
|
||||
tooltip?: string;
|
||||
tooltipId?: string;
|
||||
} & SwitchProps<"button">,
|
||||
) => {
|
||||
const {
|
||||
label,
|
||||
tooltip,
|
||||
tooltipId,
|
||||
disabled,
|
||||
|
||||
...rest
|
||||
} = props;
|
||||
|
||||
|
||||
@@ -1,18 +1,12 @@
|
||||
import React from "react";
|
||||
|
||||
import { SwitchProps } from "@headlessui/react";
|
||||
import { Controller, FieldPath, FieldValues } from "react-hook-form";
|
||||
import { twMerge } from "tailwind-merge";
|
||||
|
||||
import { Field, GenericFieldProps } from "@/components/form/Field";
|
||||
|
||||
import { InlineSwitch } from "./InlineSwitch";
|
||||
|
||||
type InlineSwitchFieldProps<
|
||||
TFieldValues extends FieldValues = FieldValues,
|
||||
TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
|
||||
> = GenericFieldProps<TFieldValues, TFieldName> &
|
||||
Omit<SwitchProps<"button">, "name">;
|
||||
> = GenericFieldProps<TFieldValues, TFieldName> & Omit<SwitchProps<"button">, "name">;
|
||||
|
||||
export const InlineSwitchField = <
|
||||
TFieldValues extends FieldValues = FieldValues,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import type { ComponentProps, ReactNode } from 'react'
|
||||
import { VariantProps, cva } from "class-variance-authority";
|
||||
import { twMerge } from "tailwind-merge";
|
||||
|
||||
@@ -26,12 +27,12 @@ export const inputVariants = cva(
|
||||
},
|
||||
);
|
||||
|
||||
export type InputVariants = VariantProps<typeof inputVariants>;
|
||||
export type InputProps = Omit<React.ComponentProps<"input">, "size"> &
|
||||
type InputVariants = VariantProps<typeof inputVariants>;
|
||||
export type InputProps = Omit<ComponentProps<"input">, "size"> &
|
||||
Omit<InputVariants, "state"> & {
|
||||
hasError?: boolean;
|
||||
startIcon?: React.ReactNode;
|
||||
endIcon?: React.ReactNode;
|
||||
startIcon?: ReactNode;
|
||||
endIcon?: ReactNode;
|
||||
};
|
||||
|
||||
export const Input = ({
|
||||
|
||||
@@ -1,25 +1,16 @@
|
||||
import type { LabelHTMLAttributes, ReactNode, DetailedHTMLProps } from "react";
|
||||
import { twMerge } from "tailwind-merge";
|
||||
|
||||
import { Prettify } from "@/types";
|
||||
|
||||
type LabelProps = Prettify<
|
||||
React.DetailedHTMLProps<
|
||||
React.LabelHTMLAttributes<HTMLLabelElement>,
|
||||
HTMLLabelElement
|
||||
> & {
|
||||
DetailedHTMLProps<LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement> & {
|
||||
required?: boolean;
|
||||
className?: string;
|
||||
tooltip?: React.ReactNode;
|
||||
tooltip?: ReactNode;
|
||||
}
|
||||
>;
|
||||
|
||||
export const Label = ({
|
||||
required,
|
||||
className,
|
||||
children,
|
||||
tooltip,
|
||||
...labelProps
|
||||
}: LabelProps) => {
|
||||
export const Label = ({ required, className, children, ...labelProps }: LabelProps) => {
|
||||
return (
|
||||
<label
|
||||
{...labelProps}
|
||||
|
||||
@@ -1,23 +1,14 @@
|
||||
import React from "react";
|
||||
|
||||
import { RadioGroup } from "@headlessui/react";
|
||||
import { isNil } from "lodash";
|
||||
import { useTranslations } from "next-intl";
|
||||
import {
|
||||
Controller,
|
||||
FieldPath,
|
||||
FieldValues,
|
||||
useFormContext,
|
||||
} from "react-hook-form";
|
||||
import { Controller, FieldPath, FieldValues, useFormContext } from "react-hook-form";
|
||||
import { twMerge } from "tailwind-merge";
|
||||
|
||||
import { Prettify } from "@/types";
|
||||
|
||||
import { Field, GenericFieldProps } from "./Field";
|
||||
|
||||
export type BaseOption<T = string, D = unknown> = {
|
||||
type BaseOption<T = string, D = unknown> = {
|
||||
value: T;
|
||||
label: string | JSX.Element;
|
||||
label: string | React.JSX.Element;
|
||||
disabled?: boolean;
|
||||
data?: D;
|
||||
};
|
||||
@@ -51,16 +42,13 @@ export const RadioGroupField = <
|
||||
|
||||
options,
|
||||
}: RadioGroupFieldProps<TFieldValues, TFieldName, T, D>) => {
|
||||
const t = useTranslations("App");
|
||||
const form = useFormContext<TFieldValues>();
|
||||
|
||||
const {
|
||||
// oxlint-disable-next-line no-unused-vars
|
||||
formState: { errors },
|
||||
} = form;
|
||||
|
||||
const valueToOption = (value: T): BaseOption<T, D> =>
|
||||
options.find((o) => o.value === value) ?? { value, label: "" };
|
||||
|
||||
return (
|
||||
<Field
|
||||
{...{
|
||||
@@ -78,8 +66,6 @@ export const RadioGroupField = <
|
||||
name={name}
|
||||
control={control}
|
||||
render={({ field: { onChange, value } }) => {
|
||||
const optionValue = isNil(value) ? null : valueToOption(value);
|
||||
|
||||
return (
|
||||
<RadioGroup
|
||||
value={value}
|
||||
|
||||
@@ -8,17 +8,13 @@ import { Prettify } from "@/types";
|
||||
|
||||
export type BaseOption<T = string, D = unknown> = {
|
||||
value: T;
|
||||
label: string | JSX.Element;
|
||||
label: string | React.JSX.Element;
|
||||
disabled?: boolean;
|
||||
data?: D;
|
||||
};
|
||||
|
||||
export const createSelectClassNamesFn =
|
||||
<Option, IsMulti extends boolean = false>({
|
||||
size,
|
||||
}: {
|
||||
size?: "small" | "medium";
|
||||
}) =>
|
||||
<Option, IsMulti extends boolean = false>({ size }: { size?: "small" | "medium" }) =>
|
||||
(
|
||||
hasError: boolean,
|
||||
separators: boolean,
|
||||
@@ -26,8 +22,7 @@ export const createSelectClassNamesFn =
|
||||
container: () => "w-full",
|
||||
valueContainer: () => "text-gray-900 dark:text-white",
|
||||
indicatorsContainer: () => "flex items-center self-stretch shrink-0",
|
||||
clearIndicator: () =>
|
||||
"flex items-center pr-2 text-gray-900 dark:text-white",
|
||||
clearIndicator: () => "flex items-center pr-2 text-gray-900 dark:text-white",
|
||||
dropdownIndicator: () =>
|
||||
"pointer-events-none flex items-center pr-2 text-gray-900 dark:text-white",
|
||||
indicatorSeparator: () => "w-px text-gray-900 dark:text-white",
|
||||
@@ -45,8 +40,7 @@ export const createSelectClassNamesFn =
|
||||
multiValue: () => "bg-fieldGray border rounded-lg flex space-x-1 pl-1 m-1",
|
||||
multiValueLabel: () => "",
|
||||
multiValueRemove: () => "items-center px-1 hover:text-primary",
|
||||
placeholder: () =>
|
||||
"block truncate pr-2 placeholder-gray dark:placeholder-gray-400",
|
||||
placeholder: () => "block truncate pr-2 placeholder-gray dark:placeholder-gray-400",
|
||||
menu: () =>
|
||||
twMerge(
|
||||
"!z-30 mt-2 rounded-lg border border-gray-200 bg-white p-1",
|
||||
@@ -65,33 +59,18 @@ export const createSelectClassNamesFn =
|
||||
"text-textGray p-2 bg-gray-50 border border-dashed border-gray-200 rounded-sm",
|
||||
});
|
||||
|
||||
export type SelectProps<
|
||||
IsMulti extends boolean = false,
|
||||
T = string,
|
||||
D = unknown,
|
||||
> = Prettify<
|
||||
export type SelectProps<IsMulti extends boolean = false, T = string, D = unknown> = Prettify<
|
||||
Omit<Props<BaseOption<T, D>, IsMulti>, "classNames"> & {
|
||||
required?: boolean;
|
||||
separators?: boolean;
|
||||
hasError?: boolean;
|
||||
size?: "small" | "medium";
|
||||
classNameOverrides?: ClassNamesConfig<
|
||||
BaseOption<T, D>,
|
||||
IsMulti,
|
||||
GroupBase<BaseOption<T, D>>
|
||||
>;
|
||||
classNameOverrides?: ClassNamesConfig<BaseOption<T, D>, IsMulti, GroupBase<BaseOption<T, D>>>;
|
||||
}
|
||||
>;
|
||||
|
||||
export const Select = <
|
||||
IsMulti extends boolean = false,
|
||||
T = string,
|
||||
D = unknown,
|
||||
>({
|
||||
className,
|
||||
required,
|
||||
export const Select = <IsMulti extends boolean = false, T = string, D = unknown>({
|
||||
size,
|
||||
|
||||
placeholder,
|
||||
separators,
|
||||
hasError,
|
||||
@@ -121,7 +100,7 @@ export const Select = <
|
||||
}}
|
||||
classNames={{
|
||||
...classNames(hasError ?? false, separators ?? false),
|
||||
...(classNameOverrides ?? {}),
|
||||
...classNameOverrides,
|
||||
}}
|
||||
{...selectProps}
|
||||
/>
|
||||
|
||||
@@ -1,13 +1,5 @@
|
||||
import React from "react";
|
||||
|
||||
import { flatMap, get, isArray, isNil, isObject } from "lodash";
|
||||
import { useTranslations } from "next-intl";
|
||||
import {
|
||||
Controller,
|
||||
FieldPath,
|
||||
FieldValues,
|
||||
useFormContext,
|
||||
} from "react-hook-form";
|
||||
import { Controller, FieldPath, FieldValues, useFormContext } from "react-hook-form";
|
||||
import { GroupBase, OnChangeValue } from "react-select";
|
||||
|
||||
import { BaseOption, Select, SelectProps } from "@/components/form/Select";
|
||||
@@ -23,10 +15,7 @@ export type SelectFieldProps<
|
||||
D = unknown,
|
||||
> = Prettify<
|
||||
GenericFieldProps<TFieldValues, TFieldName> &
|
||||
Omit<
|
||||
SelectProps<IsMulti, T, D>,
|
||||
"onChange" | "value" | "classNames" | "name"
|
||||
> & {
|
||||
Omit<SelectProps<IsMulti, T, D>, "onChange" | "value" | "classNames" | "name"> & {
|
||||
required?: boolean;
|
||||
separators?: boolean;
|
||||
}
|
||||
@@ -47,13 +36,9 @@ export const SelectField = <
|
||||
label,
|
||||
hideErrorMessage,
|
||||
required,
|
||||
|
||||
placeholder,
|
||||
separators,
|
||||
options,
|
||||
...selectProps
|
||||
}: SelectFieldProps<TFieldValues, TFieldName, IsMulti, T, D>) => {
|
||||
const t = useTranslations("App");
|
||||
const form = useFormContext<TFieldValues>();
|
||||
|
||||
const {
|
||||
@@ -64,8 +49,7 @@ export const SelectField = <
|
||||
|
||||
const isGroup = (
|
||||
option: BaseOption<T, D> | GroupBase<BaseOption<T, D>>,
|
||||
): option is GroupBase<BaseOption<T, D>> =>
|
||||
isObject(option) && "options" in option;
|
||||
): option is GroupBase<BaseOption<T, D>> => isObject(option) && "options" in option;
|
||||
|
||||
const flattenedOptions = flatMap(options, (option) => {
|
||||
return isGroup(option) ? option.options : option;
|
||||
@@ -91,9 +75,7 @@ export const SelectField = <
|
||||
name={name}
|
||||
control={control}
|
||||
render={({ field: { onChange, value } }) => {
|
||||
const onSelectChange = (
|
||||
newValue: OnChangeValue<BaseOption<T, D>, IsMulti>,
|
||||
) => {
|
||||
const onSelectChange = (newValue: OnChangeValue<BaseOption<T, D>, IsMulti>) => {
|
||||
if (isNil(newValue)) onChange(null);
|
||||
else if (isArray(newValue)) {
|
||||
onChange(newValue.map((option) => option.value));
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
import React from "react";
|
||||
|
||||
import { Switch, SwitchProps } from "@headlessui/react";
|
||||
import {
|
||||
Controller,
|
||||
FieldPath,
|
||||
FieldValues,
|
||||
useFormContext,
|
||||
} from "react-hook-form";
|
||||
import { Controller, FieldPath, FieldValues } from "react-hook-form";
|
||||
import { twMerge } from "tailwind-merge";
|
||||
|
||||
import { Prettify } from "@/types";
|
||||
@@ -16,10 +11,7 @@ import { Field, GenericFieldProps } from "./Field";
|
||||
type SwitchFieldProps<
|
||||
TFieldValues extends FieldValues = FieldValues,
|
||||
TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
|
||||
> = Prettify<
|
||||
GenericFieldProps<TFieldValues, TFieldName> &
|
||||
Omit<SwitchProps<"button">, "name">
|
||||
>;
|
||||
> = Prettify<GenericFieldProps<TFieldValues, TFieldName> & Omit<SwitchProps<"button">, "name">>;
|
||||
|
||||
export const SwitchField = <
|
||||
TFieldValues extends FieldValues = FieldValues,
|
||||
@@ -27,21 +19,7 @@ export const SwitchField = <
|
||||
>(
|
||||
props: SwitchFieldProps<TFieldValues, TFieldName>,
|
||||
) => {
|
||||
const {
|
||||
name,
|
||||
control,
|
||||
label,
|
||||
disabled,
|
||||
className,
|
||||
labelClassName,
|
||||
|
||||
childrenWrapperClassName,
|
||||
hideErrorMessage,
|
||||
|
||||
...rest
|
||||
} = props;
|
||||
const form = useFormContext<TFieldValues>();
|
||||
|
||||
const { name, control, label, disabled, className, labelClassName, ...rest } = props;
|
||||
return (
|
||||
<Field
|
||||
{...{
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
import React from "react";
|
||||
import type { HTMLProps, ReactNode } from "react";
|
||||
|
||||
import { get } from "lodash";
|
||||
import {
|
||||
Controller,
|
||||
FieldPath,
|
||||
FieldValues,
|
||||
useFormContext,
|
||||
} from "react-hook-form";
|
||||
import { Controller, FieldPath, FieldValues, useFormContext } from "react-hook-form";
|
||||
import { twMerge } from "tailwind-merge";
|
||||
|
||||
import { Prettify } from "@/types";
|
||||
@@ -19,9 +14,9 @@ type TextAreaFieldProps<
|
||||
TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
|
||||
> = Prettify<
|
||||
GenericFieldProps<TFieldValues, TFieldName> &
|
||||
Omit<React.HTMLProps<HTMLTextAreaElement>, "ref" | "name"> & {
|
||||
Omit<HTMLProps<HTMLTextAreaElement>, "ref" | "name"> & {
|
||||
handleChanged?: (props: { name: string }) => void;
|
||||
startIcon?: React.ReactNode;
|
||||
startIcon?: ReactNode;
|
||||
required?: boolean;
|
||||
}
|
||||
>;
|
||||
@@ -40,11 +35,7 @@ export const TextAreaField = <
|
||||
labelClassName,
|
||||
childrenWrapperClassName,
|
||||
hideErrorMessage = false,
|
||||
|
||||
startIcon,
|
||||
handleChanged,
|
||||
required,
|
||||
|
||||
disabled,
|
||||
...rest
|
||||
} = props;
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
import React from "react";
|
||||
|
||||
import { get } from "lodash";
|
||||
import {
|
||||
Controller,
|
||||
FieldPath,
|
||||
FieldValues,
|
||||
useFormContext,
|
||||
} from "react-hook-form";
|
||||
import { Controller, FieldPath, FieldValues, useFormContext } from "react-hook-form";
|
||||
import { twMerge } from "tailwind-merge";
|
||||
|
||||
import { Prettify } from "@/types";
|
||||
@@ -57,11 +52,7 @@ export const TextField = <
|
||||
const hasError = !!get(errors, name)?.message;
|
||||
|
||||
const input = (value: string | number) => {
|
||||
return typeof value === "number"
|
||||
? isNaN(value)
|
||||
? ""
|
||||
: value.toString()
|
||||
: (value ?? "");
|
||||
return typeof value === "number" ? (isNaN(value) ? "" : value.toString()) : (value ?? "");
|
||||
};
|
||||
|
||||
const output =
|
||||
|
||||
@@ -1,16 +1,12 @@
|
||||
import { useState } from "react";
|
||||
|
||||
import { on } from "events";
|
||||
import { useTranslations } from "next-intl";
|
||||
import { FieldPath, FieldValues } from "react-hook-form";
|
||||
import { FaExternalLinkAlt } from "react-icons/fa";
|
||||
|
||||
import { TimeControlColours } from "@/constants";
|
||||
import { getTournamentDetails } from "@/server/getTournamentDetails";
|
||||
import {
|
||||
SearchedTournament,
|
||||
searchTournaments,
|
||||
} from "@/server/searchTournaments";
|
||||
import { SearchedTournament, searchTournaments } from "@/server/searchTournaments";
|
||||
|
||||
import { AsyncSelectField, AsyncSelectFieldProps } from "./AsyncSelectField";
|
||||
|
||||
@@ -18,13 +14,7 @@ type TournamentSelectFieldProps<
|
||||
TFieldValues extends FieldValues = FieldValues,
|
||||
TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
|
||||
> = Omit<
|
||||
AsyncSelectFieldProps<
|
||||
TFieldValues,
|
||||
TFieldName,
|
||||
false,
|
||||
string,
|
||||
SearchedTournament
|
||||
>,
|
||||
AsyncSelectFieldProps<TFieldValues, TFieldName, false, string, SearchedTournament>,
|
||||
"loadOptions" | "loadOption" | "separators"
|
||||
>;
|
||||
|
||||
@@ -36,8 +26,7 @@ export const TournamentSelectField = <
|
||||
...rest
|
||||
}: TournamentSelectFieldProps<TFieldValues, TFieldName>) => {
|
||||
const at = useTranslations("App");
|
||||
const [selectedTournament, setSelectedTournament] =
|
||||
useState<SearchedTournament | null>(null);
|
||||
const [selectedTournament, setSelectedTournament] = useState<SearchedTournament | null>(null);
|
||||
|
||||
const loadOption = async (ffeId: string) => {
|
||||
const result = await getTournamentDetails({ ffeId });
|
||||
@@ -91,7 +80,7 @@ export const TournamentSelectField = <
|
||||
background: `${TimeControlColours[option.data!.timeControl]}`,
|
||||
}}
|
||||
>
|
||||
{at("timeControlEnum", { tc: option.data?.timeControl })}
|
||||
{at("timeControlEnum", { tc: option.data!.timeControl })}
|
||||
</div>
|
||||
<div className="text-xs">{option.data?.date}</div>
|
||||
</div>
|
||||
|
||||
@@ -18,9 +18,9 @@ export type ZoneEditorProps = {
|
||||
onChange: (geoJson: FeatureCollection) => void;
|
||||
};
|
||||
|
||||
export const ZoneEditor = ({ value, onChange }: ZoneEditorProps) => {
|
||||
const ZoneEditor = ({ value, onChange }: ZoneEditorProps) => {
|
||||
const initialFeatures = React.useRef(value?.features);
|
||||
const featureGroup = React.useRef<L.FeatureGroup>();
|
||||
const featureGroup = React.useRef<L.FeatureGroup | null>(null);
|
||||
|
||||
const setFeatureCollectionRef = (element: L.FeatureGroup) => {
|
||||
featureGroup.current = element;
|
||||
@@ -52,11 +52,7 @@ export const ZoneEditor = ({ value, onChange }: ZoneEditorProps) => {
|
||||
};
|
||||
|
||||
return (
|
||||
<MapContainer
|
||||
center={center}
|
||||
zoom={5}
|
||||
style={{ height: "600px", flexGrow: 1 }}
|
||||
>
|
||||
<MapContainer center={center} zoom={5} style={{ height: "600px", flexGrow: 1 }}>
|
||||
<MapEvents
|
||||
bounds={
|
||||
(initialFeatures.current ?? []).length > 0
|
||||
|
||||
@@ -20,8 +20,7 @@ type ZoneEditorFieldProps<
|
||||
TFieldValues extends FieldValues = FieldValues,
|
||||
TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
|
||||
> = Prettify<
|
||||
GenericFieldProps<TFieldValues, TFieldName> &
|
||||
Omit<ZoneEditorProps, "value" | "onChange">
|
||||
GenericFieldProps<TFieldValues, TFieldName> & Omit<ZoneEditorProps, "value" | "onChange">
|
||||
>;
|
||||
|
||||
export const ZoneEditorField = <
|
||||
|
||||
+1
-5
@@ -18,11 +18,7 @@
|
||||
|
||||
body {
|
||||
color: rgb(var(--foreground-rgb));
|
||||
background: linear-gradient(
|
||||
to bottom,
|
||||
transparent,
|
||||
rgb(var(--background-end-rgb))
|
||||
)
|
||||
background: linear-gradient(to bottom, transparent, rgb(var(--background-end-rgb)))
|
||||
rgb(var(--background-start-rgb));
|
||||
}
|
||||
|
||||
|
||||
+6
-10
@@ -14,7 +14,7 @@ const isSSR =
|
||||
const isBrowser = !isSSR;
|
||||
const useIsomorphicEffect = isBrowser ? useLayoutEffect : useEffect;
|
||||
|
||||
export type CreatorReturnType = {
|
||||
type CreatorReturnType = {
|
||||
useBreakpoint<B>(breakpoint: B, defaultValue?: boolean): boolean;
|
||||
useBreakpointEffect<B>(breakpoint: B, effect: (match: boolean) => void): void;
|
||||
useBreakpointValue<B, T, U>(breakpoint: B, valid: T, invalid: U): T | U;
|
||||
@@ -22,9 +22,7 @@ export type CreatorReturnType = {
|
||||
|
||||
function create(screens: object | undefined) {
|
||||
if (!screens) {
|
||||
throw new Error(
|
||||
"Failed to create breakpoint hooks, given `screens` value is invalid.",
|
||||
);
|
||||
throw new Error("Failed to create breakpoint hooks, given `screens` value is invalid.");
|
||||
}
|
||||
|
||||
function useBreakpoint(breakpoint: string, defaultValue: boolean = false) {
|
||||
@@ -67,10 +65,7 @@ function create(screens: object | undefined) {
|
||||
invalid: U,
|
||||
) {
|
||||
const match = useBreakpoint(breakpoint);
|
||||
const value = useMemo(
|
||||
() => (match ? valid : invalid),
|
||||
[invalid, match, valid],
|
||||
);
|
||||
const value = useMemo(() => (match ? valid : invalid), [invalid, match, valid]);
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -81,5 +76,6 @@ function create(screens: object | undefined) {
|
||||
} as CreatorReturnType;
|
||||
}
|
||||
|
||||
export const { useBreakpoint, useBreakpointEffect, useBreakpointValue } =
|
||||
create(config.theme!.screens);
|
||||
export const { useBreakpoint } = create(
|
||||
config.theme!.screens,
|
||||
);
|
||||
|
||||
@@ -2,8 +2,7 @@ import { Dispatch, SetStateAction, useEffect, useState } from "react";
|
||||
|
||||
function useDarkMode(): [string, Dispatch<SetStateAction<string>>] {
|
||||
const prefersDarkMode =
|
||||
typeof window !== "undefined" &&
|
||||
window.matchMedia("(prefers-color-scheme: dark)").matches;
|
||||
typeof window !== "undefined" && window.matchMedia("(prefers-color-scheme: dark)").matches;
|
||||
|
||||
const [theme, setTheme] = useState(
|
||||
typeof window !== "undefined"
|
||||
|
||||
@@ -6,16 +6,15 @@ const useDatePickerWidth = ({
|
||||
datePickerRef,
|
||||
setDateDirectionState,
|
||||
}: {
|
||||
datePickerRef: RefObject<HTMLDivElement>;
|
||||
datePickerRef: RefObject<HTMLDivElement | null>;
|
||||
setDateDirectionState: Dispatch<SetStateAction<DatePickerDirection>>;
|
||||
}) => {
|
||||
useEffect(() => {
|
||||
const updateDatePickerDirection = () => {
|
||||
const datePickerWidth = datePickerRef.current?.offsetWidth ?? 0;
|
||||
const isLg = datePickerWidth >= 680;
|
||||
isLg
|
||||
? setDateDirectionState("horizontal")
|
||||
: setDateDirectionState("vertical");
|
||||
// oxlint-disable-next-line no-unused-expressions
|
||||
isLg ? setDateDirectionState("horizontal") : setDateDirectionState("vertical");
|
||||
};
|
||||
updateDatePickerDirection();
|
||||
|
||||
|
||||
@@ -9,9 +9,7 @@ export const useDynamicViewportUnits = () => {
|
||||
const isMobile = function () {
|
||||
if (
|
||||
/Android|iPhone|iPad|iPod/i.test(navigator.userAgent) ||
|
||||
(navigator.userAgent.match(/Mac/) &&
|
||||
navigator.maxTouchPoints &&
|
||||
navigator.maxTouchPoints > 2)
|
||||
(navigator.userAgent.match(/Mac/) && navigator.maxTouchPoints && navigator.maxTouchPoints > 2)
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { useCallback, useEffect } from "react";
|
||||
|
||||
import { SetFieldValue } from "react-hook-form";
|
||||
|
||||
export interface FormPersistConfig {
|
||||
interface FormPersistConfig {
|
||||
storage?: Storage;
|
||||
watch: (names?: string | string[]) => any;
|
||||
setValue: SetFieldValue<any>;
|
||||
@@ -26,15 +26,9 @@ const useFormPersist = (
|
||||
) => {
|
||||
const watchedValues = watch();
|
||||
|
||||
const getStorage = useCallback(
|
||||
() => storage || window.sessionStorage,
|
||||
[storage],
|
||||
);
|
||||
const getStorage = useCallback(() => storage || window.sessionStorage, [storage]);
|
||||
|
||||
const clearStorage = useCallback(
|
||||
() => getStorage().removeItem(name),
|
||||
[getStorage, name],
|
||||
);
|
||||
const clearStorage = useCallback(() => getStorage().removeItem(name), [getStorage, name]);
|
||||
|
||||
useEffect(() => {
|
||||
const storedValuesJSON = getStorage().getItem(name);
|
||||
@@ -58,17 +52,7 @@ const useFormPersist = (
|
||||
|
||||
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(() => {
|
||||
const values =
|
||||
|
||||
+4
-2
@@ -3,11 +3,13 @@ import { notFound } from "next/navigation";
|
||||
|
||||
import { routing } from "./utils/routing";
|
||||
|
||||
export default getRequestConfig(async ({ locale }) => {
|
||||
export default getRequestConfig(async ({ requestLocale }) => {
|
||||
// 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 {
|
||||
locale,
|
||||
messages: (
|
||||
await (locale === "en"
|
||||
? // When using Turbopack, this will enable HMR for `en`
|
||||
|
||||
@@ -14,9 +14,7 @@ export default function Providers({ children }: { children: React.ReactNode }) {
|
||||
return (
|
||||
<SessionProvider>
|
||||
<JotaiProvider>
|
||||
<QueryClientProvider client={queryClient}>
|
||||
{children}
|
||||
</QueryClientProvider>
|
||||
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
|
||||
</JotaiProvider>
|
||||
</SessionProvider>
|
||||
);
|
||||
|
||||
@@ -14,4 +14,4 @@
|
||||
"Pays de la Loire",
|
||||
"Provence-Alpes-Côte d’Azur"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
+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" }),
|
||||
website: z.string().url({ message: "FormValidation.url" }).optional(),
|
||||
coordinates: z.array(z.number()).length(2),
|
||||
})
|
||||
})
|
||||
}),
|
||||
});
|
||||
|
||||
export const addTournamentSchema = z.object({
|
||||
name: z.string().min(1, { message: "FormValidation.required" }),
|
||||
|
||||
+44
-46
@@ -5,55 +5,53 @@ import { collections, dbConnect } from "@/server/mongodb";
|
||||
import { actionClient } from "@/server/safeAction";
|
||||
import { errorLog } from "@/utils/logger";
|
||||
|
||||
export const addClub = actionClient
|
||||
.schema(addClubSchema)
|
||||
.action(async (input) => {
|
||||
try {
|
||||
const { name, email, message, club } = input.parsedInput;
|
||||
export const addClub = actionClient.schema(addClubSchema).action(async (input) => {
|
||||
try {
|
||||
const { name, email, message, club } = input.parsedInput;
|
||||
|
||||
console.log(club);
|
||||
console.log(club);
|
||||
|
||||
const clubData = {
|
||||
name: club.name ?? "",
|
||||
address: club.address ?? "",
|
||||
email: club.email ?? "",
|
||||
website: club.website ?? "",
|
||||
coordinates: club.coordinates as [number, number],
|
||||
manual_entry: true,
|
||||
pending: true,
|
||||
};
|
||||
const clubData = {
|
||||
name: club.name ?? "",
|
||||
address: club.address ?? "",
|
||||
email: club.email ?? "",
|
||||
website: club.website ?? "",
|
||||
coordinates: club.coordinates as [number, number],
|
||||
manual_entry: true,
|
||||
pending: true,
|
||||
};
|
||||
|
||||
await dbConnect();
|
||||
await dbConnect();
|
||||
|
||||
const result = await collections.clubs!.insertOne(clubData);
|
||||
const result = await collections.clubs!.insertOne(clubData);
|
||||
|
||||
if (result.insertedId) {
|
||||
await fetch(process.env.DISCORD_WEBHOOK_ADD_CLUB_URL as string, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
embeds: [
|
||||
{
|
||||
title: "Club Submitted",
|
||||
fields: [
|
||||
{ name: "Name", value: club.name ?? "" },
|
||||
{ name: "Email", value: club.email ?? "" },
|
||||
{ name: "Address", value: club.address ?? "" },
|
||||
{ name: "Website", value: club.website ?? "" },
|
||||
{ name: "Sender", value: name ?? "" },
|
||||
{ name: "Sender Email", value: email ?? "" },
|
||||
{ name: "Message", value: message ?? "" },
|
||||
{ name: "ID", value: result.insertedId ?? "" },
|
||||
],
|
||||
},
|
||||
],
|
||||
}),
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
errorLog(error);
|
||||
throw error;
|
||||
if (result.insertedId) {
|
||||
await fetch(process.env.DISCORD_WEBHOOK_ADD_CLUB_URL as string, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
embeds: [
|
||||
{
|
||||
title: "Club Submitted",
|
||||
fields: [
|
||||
{ name: "Name", value: club.name ?? "" },
|
||||
{ name: "Email", value: club.email ?? "" },
|
||||
{ name: "Address", value: club.address ?? "" },
|
||||
{ name: "Website", value: club.website ?? "" },
|
||||
{ name: "Sender", value: name ?? "" },
|
||||
{ name: "Sender Email", value: email ?? "" },
|
||||
{ name: "Message", value: message ?? "" },
|
||||
{ name: "ID", value: result.insertedId ?? "" },
|
||||
],
|
||||
},
|
||||
],
|
||||
}),
|
||||
});
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
errorLog(error);
|
||||
throw error;
|
||||
}
|
||||
});
|
||||
|
||||
+48
-55
@@ -17,68 +17,61 @@ const tcMap: Record<TimeControl, TournamentModel["time_control"]> = {
|
||||
[TimeControl.Other]: "Other",
|
||||
};
|
||||
|
||||
export const addTournament = actionClient
|
||||
.schema(addTournamentSchema)
|
||||
.action(async (input) => {
|
||||
try {
|
||||
await dbConnect();
|
||||
export const addTournament = actionClient.schema(addTournamentSchema).action(async (input) => {
|
||||
try {
|
||||
await dbConnect();
|
||||
|
||||
const { name, email, message, tournament } = input.parsedInput;
|
||||
const { name, email, message, tournament } = input.parsedInput;
|
||||
|
||||
const tournamentData: Omit<TournamentModel, "_id" | "tournament_id"> = {
|
||||
...tournament,
|
||||
date: format(tournament.date, "dd/MM/yyyy"),
|
||||
start_date: format(tournament.date, "dd/MM/yyyy"),
|
||||
end_date: format(tournament.date, "dd/MM/yyyy"),
|
||||
time_control: tcMap[tournament.time_control],
|
||||
coordinates: tournament.coordinates as [number, number],
|
||||
entry_method: "manual",
|
||||
pending: true,
|
||||
status: "scheduled",
|
||||
};
|
||||
const tournamentData: Omit<TournamentModel, "_id" | "tournament_id"> = {
|
||||
...tournament,
|
||||
date: format(tournament.date, "dd/MM/yyyy"),
|
||||
start_date: format(tournament.date, "dd/MM/yyyy"),
|
||||
end_date: format(tournament.date, "dd/MM/yyyy"),
|
||||
time_control: tcMap[tournament.time_control],
|
||||
coordinates: tournament.coordinates as [number, number],
|
||||
entry_method: "manual",
|
||||
pending: true,
|
||||
status: "scheduled",
|
||||
};
|
||||
|
||||
const result = await collections.tournaments!.insertOne(tournamentData);
|
||||
const result = await collections.tournaments!.insertOne(tournamentData);
|
||||
|
||||
if (result.insertedId) {
|
||||
const { tournament, country, date, time_control } = tournamentData;
|
||||
if (result.insertedId) {
|
||||
const { tournament, country, date, time_control } = tournamentData;
|
||||
|
||||
if (
|
||||
typeof process.env.DISCORD_WEBHOOK_ADD_TOURNAMENT_URL === "string"
|
||||
) {
|
||||
await fetch(
|
||||
process.env.DISCORD_WEBHOOK_ADD_TOURNAMENT_URL as string,
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
embeds: [
|
||||
if (typeof process.env.DISCORD_WEBHOOK_ADD_TOURNAMENT_URL === "string") {
|
||||
await fetch(process.env.DISCORD_WEBHOOK_ADD_TOURNAMENT_URL as string, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
embeds: [
|
||||
{
|
||||
title: "Tournament Submitted",
|
||||
fields: [
|
||||
{ name: "Tournament", value: tournament },
|
||||
{ name: "Country", value: country },
|
||||
{ name: "Date", value: date },
|
||||
{
|
||||
title: "Tournament Submitted",
|
||||
fields: [
|
||||
{ name: "Tournament", value: tournament },
|
||||
{ name: "Country", value: country },
|
||||
{ name: "Date", value: date },
|
||||
{
|
||||
name: "Time Control",
|
||||
value: time_control,
|
||||
},
|
||||
{ name: "Sender", value: name },
|
||||
{ name: "Sender Email", value: email },
|
||||
{ name: "Message", value: message ?? "" },
|
||||
],
|
||||
name: "Time Control",
|
||||
value: time_control,
|
||||
},
|
||||
{ name: "Sender", value: name },
|
||||
{ name: "Sender Email", value: email },
|
||||
{ name: "Message", value: message ?? "" },
|
||||
],
|
||||
}),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
},
|
||||
],
|
||||
}),
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
errorLog(error);
|
||||
throw error;
|
||||
|
||||
return true;
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
errorLog(error);
|
||||
throw error;
|
||||
}
|
||||
});
|
||||
|
||||
+27
-31
@@ -1,38 +1,34 @@
|
||||
"use server";
|
||||
|
||||
import { z } from "zod";
|
||||
|
||||
import { contactUsSchema } from "@/schemas";
|
||||
import { errorLog } from "@/utils/logger";
|
||||
|
||||
import { actionClient } from "./safeAction";
|
||||
|
||||
export const contactUs = actionClient
|
||||
.schema(contactUsSchema)
|
||||
.action(async (input) => {
|
||||
try {
|
||||
const { email, subject, message } = input.parsedInput;
|
||||
await fetch(process.env.DISCORD_WEBHOOK_CONTACT_URL as string, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
embeds: [
|
||||
{
|
||||
title: "Contact",
|
||||
fields: [
|
||||
{ name: "Email", value: email },
|
||||
{ name: "Subject", value: subject },
|
||||
{ name: "Message", value: message },
|
||||
],
|
||||
},
|
||||
],
|
||||
}),
|
||||
});
|
||||
return true;
|
||||
} catch (error) {
|
||||
errorLog(error);
|
||||
throw error;
|
||||
}
|
||||
});
|
||||
export const contactUs = actionClient.schema(contactUsSchema).action(async (input) => {
|
||||
try {
|
||||
const { email, subject, message } = input.parsedInput;
|
||||
await fetch(process.env.DISCORD_WEBHOOK_CONTACT_URL as string, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
embeds: [
|
||||
{
|
||||
title: "Contact",
|
||||
fields: [
|
||||
{ name: "Email", value: email },
|
||||
{ name: "Subject", value: subject },
|
||||
{ name: "Message", value: message },
|
||||
],
|
||||
},
|
||||
],
|
||||
}),
|
||||
});
|
||||
return true;
|
||||
} catch (error) {
|
||||
errorLog(error);
|
||||
throw error;
|
||||
}
|
||||
});
|
||||
|
||||
+24
-26
@@ -10,31 +10,29 @@ import { errorLog } from "@/utils/logger";
|
||||
import { ZoneModel } from "./models/zoneModel";
|
||||
import { actionClient } from "./safeAction";
|
||||
|
||||
export const createZone = actionClient
|
||||
.schema(zoneSchema)
|
||||
.action(async (input) => {
|
||||
try {
|
||||
await dbConnect();
|
||||
export const createZone = actionClient.schema(zoneSchema).action(async (input) => {
|
||||
try {
|
||||
await dbConnect();
|
||||
|
||||
const user = await auth();
|
||||
if (!user?.user) {
|
||||
throw new Error("You must be logged in to create a zone");
|
||||
}
|
||||
|
||||
const zoneData: ZoneModel = {
|
||||
...input.parsedInput,
|
||||
userId: new ObjectId(user.user!.id!),
|
||||
};
|
||||
|
||||
const result = await collections.zones!.insertOne(zoneData);
|
||||
|
||||
if (!result.acknowledged) {
|
||||
throw new Error("ERR_ZONE_INSERT_FAILED");
|
||||
}
|
||||
|
||||
return true;
|
||||
} catch (error) {
|
||||
errorLog(error);
|
||||
throw error;
|
||||
const user = await auth();
|
||||
if (!user?.user) {
|
||||
throw new Error("You must be logged in to create a zone");
|
||||
}
|
||||
});
|
||||
|
||||
const zoneData: ZoneModel = {
|
||||
...input.parsedInput,
|
||||
userId: new ObjectId(user.user!.id!),
|
||||
};
|
||||
|
||||
const result = await collections.zones!.insertOne(zoneData);
|
||||
|
||||
if (!result.acknowledged) {
|
||||
throw new Error("ERR_ZONE_INSERT_FAILED");
|
||||
}
|
||||
|
||||
return true;
|
||||
} catch (error) {
|
||||
errorLog(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