diff --git a/.env.example b/.env.example index 4dd29be..91a7d9d 100644 --- a/.env.example +++ b/.env.example @@ -1,6 +1,7 @@ MONGODB_URI= DISCORD_WEBHOOK_ADD_TOURNAMENT_URL= +DISCORD_WEBHOOK_ADD_CLUB_URL= DISCORD_WEBHOOK_ERROR_LOGS_URL= DISCORD_WEBHOOK_CONTACT_URL= diff --git a/.gitignore b/.gitignore index dc8f696..7520252 100644 --- a/.gitignore +++ b/.gitignore @@ -35,7 +35,7 @@ yarn-debug.log* yarn-error.log* # local env files -.env*.local +.env.development.local # vercel .vercel diff --git a/package.json b/package.json index d1a71fd..3fdc525 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "version": "0.1.0", "private": true, "scripts": { + "test": "vitest --config vitetest.config.ts", "dev": "next dev", "build": "next build", "start": "next start", @@ -61,6 +62,7 @@ "tailwind-merge": "^2.0.0", "tailwindcss": "^3.3.5", "typescript": "^5.3.3", + "vitest": "^4.0.12", "zod": "^3.22.4" }, "devDependencies": { diff --git a/public/worker-qB-wrzOf6Q9yVujDcM83S.js b/public/worker-8UPo2bE_k5RZTZQmUKKyz.js similarity index 100% rename from public/worker-qB-wrzOf6Q9yVujDcM83S.js rename to public/worker-8UPo2bE_k5RZTZQmUKKyz.js diff --git a/src/__tests__/clubs/clubs.test.ts b/src/__tests__/clubs/clubs.test.ts new file mode 100644 index 0000000..f88a345 --- /dev/null +++ b/src/__tests__/clubs/clubs.test.ts @@ -0,0 +1,47 @@ +import { describe, expect, test } from "vitest"; + +import { IClub, filterClubsByManualEntry } from "@/utils/clubFilters"; + +import { clubData } from "./helpers/clubData"; + +describe("clubs", () => { + test("club data is unique", () => { + const clubDataIds = clubData.map((club) => club._id); + const originalLength = clubDataIds.length; + const filteredLength = new Set(clubDataIds).size; + 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 = new Set( + clubData.map((club) => club.name), + ); + + for (const club of clubData) { + if (duplicateClubNames.has(club.name)) { + duplicateClubNames.delete(club.name); + } else { + duplicateClubNames.add(club.name); + } + } + + 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; + }); +}); diff --git a/src/__tests__/clubs/helpers/clubData.ts b/src/__tests__/clubs/helpers/clubData.ts new file mode 100644 index 0000000..7c10097 --- /dev/null +++ b/src/__tests__/clubs/helpers/clubData.ts @@ -0,0 +1,933 @@ +import { ObjectId } from "mongodb"; + +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", + email: "gambitdemuret@gmail.com", + website: "http://www.gambit-de-muret.webou.net", + coordinates: [43.46106289999999, 1.3218611], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd7490"), + name: `"cle" Club Lutterbachois d'Echecs`, + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=41", + address: "50 rue Aristide Briand 68460 LUTTERBACH", + email: "merlojeanpierre11@gmail.com", + website: "", + coordinates: [47.760706, 7.2824232], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd73f9"), + name: "1 Plateau 2 Fous", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=3282", + address: "6 Residence Coet Bihan 56660 ST JEAN BREVELAY", + email: "1plateau2fous@gmail.com", + website: "https://www.1plateau2fous.fr/", + coordinates: [47.8487638, -2.7180808], + }, + { + _id: new ObjectId("691586c9e06ce80de6cd73f9"), + name: "1 Plateau 2 Fous", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=3282", + address: "6 Residence Coet Bihan 56660 ST JEAN BREVELAY", + email: "1plateau2fous@gmail.com", + website: "https://www.1plateau2fous.fr/", + coordinates: [47.8687638, -2.7180808], + manual_entry: true, + pending: false, + }, + { + _id: new ObjectId("690586c9e06ce80de6cd74ef"), + name: "7 Echecs Club", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=2981", + address: "115 rue Saint Dominique 75007 PARIS", + email: "yveslamorelle@hotmail.com", + website: "www.elan-paris-echecs.fr", + coordinates: [48.8590876, 2.3047594], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd738b"), + name: "A.A.J. Blois", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=440", + address: "41000 BLOIS", + email: "rprevot56@gmail.com", + website: "http://aajbechecs.over-blog.com/contact", + coordinates: [47.5866694, 1.3351561], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd749d"), + name: "A.C.E.L. Couzon", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=2278", + address: "106 Av du General de Gaulle 69270 COUZON AU MONT D OR", + email: "acel.couzon@hotmail.fr", + website: "www acelcouzon.com", + coordinates: [45.845596, 4.831502], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd746e"), + name: "A.C.S. Dettwiller", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=18", + address: "Foyer St Jacques 29 rue des Vosges 67490 DETTWILLER", + email: "mathisjeanmichel@aol.com", + website: "http://acs-dettwiller.000webhostapp.com/", + coordinates: [48.75788439999999, 7.463797899999999], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd7436"), + name: "A.J.E. Noyon", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=1513", + address: + "Mairie de Noyon place Bertrand Labarre courrier a Carton328 rue de Montdidier 60400 Larbroye 60400 NOYON 60150 VILLERS SUR CO", + email: "Philechec@gmail.com", + website: "", + coordinates: [49.573906, 2.963432], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd7501"), + name: "A.L.B.C.S. Grand Quevilly", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=638", + address: "Centre Socio-Culturel avenue J. Kennedy 76120 LE GRAND QUEVILLY", + email: "lealna@hotmail.fr", + website: "", + coordinates: [49.4073006, 1.0534999], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd75d5"), + name: "A.S.C.A. Ermont", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=796", + address: "Stade Raoul Dautry 105 rue de St Gratien 95120 ERMONT", + email: "braja_christine@yahoo.fr", + website: "", + coordinates: [48.9790868, 2.2624101], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd74d7"), + name: "A.S.C.E.-S.E. Paris Est", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=911", + address: "C O eric Brebant 3 rue du Pressoir 02200 BELLEU", + email: "eric.brebant@orange.fr", + website: "", + coordinates: [49.3579842, 3.3379834], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd7405"), + name: "A.S.P.T.T. Metz", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=1139", + address: "1 rue des Hauts Peupliers 57070 METZ", + email: "christianymarco@wanadoo.fr", + website: "http://aspttechecs.free.fr", + coordinates: [49.1073304, 6.2043988], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd74d9"), + name: "A.T.S.C.A.F. Paris Echecs", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=683", + address: "143 rue de Bercy teledoc 801 75012 PARIS", + email: "", + website: "https://atscaf-paris-echecs.fr/", + coordinates: [48.8412587, 2.3772843], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd72bb"), + name: "AAB Saint Porchaire", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=3210", + address: "Mairie 83 rue Nationale 17250 ST PORCHAIRE", + email: "contact@ateliersartistiquesbruant.fr", + website: "https://www.ateliersartistiquesbruant.fr", + coordinates: [45.8216792, -0.7864717999999999], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd7326"), + name: "AGJA-Echiquier Aquitaine", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=105", + address: "Agja 8 rue Gambetta 33200 BORDEAUX", + email: "echiquier-aquitaine@agja.org", + website: "www.agja.org", + coordinates: [44.8494531, -0.6144533], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd757e"), + name: "AJA - Echiquier Auxerrois", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=3076", + address: "83 avenue Yver 89000 AUXERRE", + email: "echiquier.auxerrois@hotmail.com", + website: "https://aja-echiquierauxerrois.weebly.com/", + coordinates: [47.7896203, 3.5879196], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd72e9"), + name: "ALCHESS Châteaudun", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=2016", + address: + "Amicale Laique de Chateaudun 71 rue de la Republique Alchess 4 le Menard 28160 Yevres 28200 CHATEAUDUN", + email: "j.descamps@wanadoo.fr", + website: "http://echecs-chateaudun.blogspot.fr/", + coordinates: [48.070998, 1.3358119], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd7307"), + name: "ASBM Echiquier Bagnols Tresques", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=993", + address: + "Maison des Associations 95 avenue Francois Mitterrand batiment A 30200 BAGNOLS SUR CEZE", + email: "l.christian30@orange.fr", + website: "http://club-ebt.fr", + coordinates: [44.1719284, 4.6196155], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd7351"), + name: "ASC Echecs", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=3371", + address: "Mairie 44 avenue Andre Bonnin 35135 CHANTEPIE", + email: "presidence.echecs@as-chantepie.fr", + website: "", + coordinates: [48.08840470000001, -1.6203833], + }, + { + _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", + email: "stephane.bastin1805@gmail.com", + website: "", + coordinates: [44.8839858, -0.7063288999999999], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd72c5"), + name: "Academie d'Echecs Philidor", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=2636", + address: "84 bd de l'Europe 21800 QUETIGNY", + email: "yannlh@philidor.fr", + website: "http://www.academie-echecs-philidor.fr/", + coordinates: [47.3185937, 5.1012641], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd74c4"), + name: "Academie d'Echecs d'Aix les bains", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=2624", + address: "15 avenue d'Annecy 73100 AIX LES BAINS", + email: "aixlesbains.echecs@gmail.com", + website: "https://aixlesbainsechecs.org/", + coordinates: [45.6952367, 5.9117241], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd73ce"), + name: "Agneaux Saint-Lô", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=219", + address: "Salle Charles de Gaulle place de la Paliere 50180 AGNEAUX", + email: "webmaster@echecsaglo.fr", + website: "https://www.echecsaglo.fr", + coordinates: [49.11626709999999, -1.1139482], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd743d"), + name: "Aiglechecs", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=179", + address: "Hotel de Ville - place Fulbert de Beina 61300 L AIGLE", + email: "schebat.gilles@orange.fr", + website: "http://aiglechecs.clubeo.com", + coordinates: [48.7647285, 0.6289707999999999], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd72e5"), + name: "Aile Roi Louviers", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=649", + address: "Mairie de Louviers rue Pierre Mendes France 27400 LOUVIERS", + email: "aileroi.louviers@gmail.com", + website: "http://www.aileroi-louviers.fr", + coordinates: [49.2144786, 1.1689218], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd72e1"), + name: "Aile dame de Beaumont le Roger", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=1830", + address: "Mairie de Beaumont le Roger 27170 BEAUMONT LE ROGER", + email: "clartenucale@free.fr", + website: "", + coordinates: [49.0805595, 0.7767493], + }, + { + _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", + email: "albertville.savoie.echecs@gmail.com", + website: "https://www.albertville-savoie-echecs.fr", + coordinates: [45.6680374, 6.377434999999999], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd75b0"), + name: "Alekhine Noisy Le Grand", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=896", + address: "9 allee du Bataillon Hildevert 93160 NOISY LE GRAND", + email: "contact@cerclealekhine.fr", + website: "https://cerclealekhine.fr/", + coordinates: [48.8433017, 2.578255], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd74c9"), + name: "Alex Echecs", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=3213", + address: "105 Chemin de la Pierre 74290 ALEX", + email: "contact@alexechecs.fr", + website: "www.alexechecs.fr", + coordinates: [45.8888904, 6.2123178], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd7517"), + name: "Alionouchka Echecs", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=3054", + address: + "Vie Associative 107 avenue de la Republique hotel de Ville 77340 Pontault-Combault 77340 PONTAULT COMBAULT", + email: "echecs.pontault@gmail.com", + website: "http://www.echecspontault.asso-web.com", + coordinates: [48.8018983, 2.6068965], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd7242"), + name: "Amicale Echecs", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=2725", + address: "410 avenue des Alpes 74100", + email: "opf@lalieu.com", + website: "http://amicale-echecs.com", + coordinates: [46.1829563, 6.2372305], + }, + { + _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", + email: "echecs@lalieu.com", + website: "", + coordinates: [46.3464497, 6.1342244], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd7369"), + name: "Apprentissage Echecs Chanceaux", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=3303", + address: "19 rue de la Mairie 37390 CHANCEAUX SUR CHOISILLE", + email: "apprentissageechecschanceaux@gmail.com", + website: "https://apprentissageechec.wixsite.com/apprentissage-echecs", + coordinates: [47.4727386, 0.7020364], + }, + { + _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", + email: "regislegendre@free.fr", + website: "http://www.ncarcachon.fr/", + coordinates: [44.6626304, -1.1692262], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd7432"), + name: "Arcole Echecs Compiegne", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=1504", + address: "2 a rue de la Surveillance 60200", + email: "bart.varin@orange.fr", + website: "", + coordinates: [49.41775639999999, 2.8268517], + }, + { + _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", + email: "matoz@wanadoo.fr", + website: "http://www.arcueil-chessland.fr/", + coordinates: [48.79920260000001, 2.3391093], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd7411"), + name: "Armentieres Mat 88", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=1373", + address: "Maison des Associations 57 rue Paul Bert 59280 ARMENTIERES", + email: "nicolas.torrez@gmail.com", + website: "", + coordinates: [50.6868035, 2.8877895], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd7600"), + name: "Arsenal", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=1215", + address: "Plateau Sportif de Mansarde Catalogne 97231 LE ROBERT", + email: "arsenalechecs@hotmail.fr", + website: "", + coordinates: [14.6716129, -60.947015], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd74bb"), + name: "Arçonnay Echecs Le Roi s'amuse", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=2266", + address: "Mairie 72610 ARCONNAY", + email: "pascal.personeni@neuf.fr", + website: "http://echecs-arconnay.fr", + coordinates: [48.39691, 0.087244], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd7592"), + name: "Asnières - Le Grand Echiquier", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=2460", + address: "16 place de l'Hotel de Ville 92600 ASNIERES SUR SEINE", + email: "y.marek@hotmail.fr", + website: "http://www.legrandechiquier.fr", + coordinates: [48.9109178, 2.2896992], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd72e3"), + name: "Ass Familliale d Evreux Section Echecs Evreux Gambit Club", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=1973", + address: "23 rue Saint Pierre 27000 EVREUX", + email: "x.vappereau@orange.fr", + website: "http://www.evreuxgambitclub.ovh/", + coordinates: [49.0282075, 1.1499633], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd75ba"), + name: "Ass des Joueurs d'Echecs du Groupe Renault - AJEGRE", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=3133", + address: "5 allee Ronsard 94220 CHARENTON LE PONT", + email: "cyrildaghigh@gmail.com", + website: "", + coordinates: [48.82260309999999, 2.4071111], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd744c"), + name: "Association Echephile Vendinoise", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=2027", + address: "313 rue Nationale appt 89 62290 NOEUX LES MINES", + email: "sylvie.verslype@orange.fr", + website: "", + coordinates: [50.4742256, 2.6687953], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd759b"), + name: "Association Gennevilloise des Echecs", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=3014", + address: "Club Agir 19 rue Louis Calmel 92230 GENNEVILLIERS", + email: "age.echecs@9online.fr", + website: "https://age-echecs.sportsregions.fr/", + coordinates: [48.9262488, 2.2923556], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd7303"), + name: "Associu di i Scacchi di U Centru", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=2030", + address: "Chez M. Sauveur Giannoni 3 Cours Paoli 20250 Corte 20250 CORTE", + email: "scacchidiucentru@gmail.com", + website: "https://www.facebook.com/Scacchidiucentru", + coordinates: [42.306067, 9.1507969], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd72dc"), + name: "Atelier Echecs de Crest", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=3139", + address: "14 rue Sadi Carnot 26400 CREST", + email: "alexisrodriguez@sfr.fr", + website: "", + coordinates: [44.73000070000001, 5.019104899999999], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd726b"), + name: "Atelier Echecs des Assions", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=3269", + address: "Mairie le Village 07140 LES ASSIONS", + email: "le-deuff.frederic@orange.fr", + website: "https://assions-echecs.assoconnect.com/", + coordinates: [44.421387, 4.1740449], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd73a9"), + name: "Atlantique Herblinois Chessboxing Club", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=3325", + address: "15 rue de la Johardiere 44800 ST HERBLAIN", + email: "chessboxing@proton.me", + website: "https://atlantique-chessboxing.fr/", + coordinates: [47.2270586, -1.6501785], + }, + { + _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", + email: "jean.louis.bourquard@free.fr", + website: "http://aubenasvals-echecs.fr", + coordinates: [44.6173697, 4.388114], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd73ee"), + name: "Auray Pat ou Mat !? Club Echecs Alreen", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=3287", + address: "6 impasse du Pere Bonnaud 56400 AURAY", + email: "auray.patoumat@gmail.com", + website: "https://patoumat.fr", + coordinates: [47.6616977, -2.9898842], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd72d4"), + name: "Aux Tours de Domme", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=3435", + address: "648 Chemin de la Burague 24250 DOMME", + email: "24atdd@gmail.com", + website: "", + coordinates: [44.79202, 1.217554], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd75da"), + name: "Aux Tours de Magny", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=874", + address: "Hotel de Ville 20 rue de Crosne 95420 MAGNY EN VEXIN", + email: "atdm95@gmail.com", + website: "http://aux-tours-de-magny.assoconnect.com/", + coordinates: [49.1517087, 1.7873798], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd72a4"), + name: "Avant-Garde-Caennaise", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=185", + address: "6 rue du Petit Clos St-Marc 14000 CAEN", + email: "david.deman@commeett.fr", + website: "http://www.agcaen.com/sport/echecs/7", + coordinates: [49.2115145, -0.3746491], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd74ab"), + name: "Avinkha Club d'Echecs", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=2570", + address: "Bat G allee 3 rue Andre Werth 69120 VAULX EN VELIN", + email: "vinhduc@hotmail.com", + website: "http://avinkha-echecs.e-monsite.com/", + coordinates: [45.788263, 4.9133813], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd7454"), + name: "Aviron Bayonnais Echecs", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=2129", + address: "Club House Maurice Celhay 1 rue Harry Owen Roe 64100 BAYONNE", + email: "aviron.bayonnais.echecs@gmail.com", + website: "https://www.avironbayonnais-echecs.fr/", + coordinates: [43.48666, -1.4760448], + }, + { + _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", + email: "eric.sighirdjian@sfr.fr", + website: "http://azurchessclub.fr", + coordinates: [43.5420528, 6.9443551], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd7593"), + name: "Bagneux", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=688", + address: "74 rue Jean Marin Naudin 92220 BAGNEUX", + email: "echecsbagneux@gmail.com", + website: "http://echecs-bagneux.fr", + coordinates: [48.805125, 2.3205486], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd7302"), + name: "Balagna Chess Club", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=1875", + address: "Cyrille Paris immeuble des Douanes route du Stade 20260 CALVI", + email: "info@balagnachessclub.fr", + website: "https://www.facebook.com/balagnachessclub/", + coordinates: [42.5368416, 8.7811645], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd74d5"), + name: "Banque de France", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=690", + address: "Aabf 33 rue de Radziwill 75001 PARIS", + email: "", + website: "", + coordinates: [48.86583520000001, 2.3394427], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd73eb"), + name: "Bar-Le-Duc C.S.L.B.", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=1102", + address: "Centre Social de la Ville Haute 55000 BAR LE DUC", + email: "echecsbarleduc@gmail.com", + website: "https://www.facebook.com/profile.php?id=100086892967381", + coordinates: [48.7514589, 5.171067], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd74f2"), + name: "Barreau de Paris Echecs", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=3075", + address: "91 boulevard Bessieres 75017 PARIS", + email: "joelgautier.avocat@yahoo.fr", + website: "", + coordinates: [48.8961178, 2.3188243], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd726f"), + name: "Bayard Monge Echecs", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=404", + address: "11rue des Chalets 08000 CHARLEVILLE MEZIERES", + email: "jihered@sfr.fr", + website: "http://club.quomodo.com/bme08", + coordinates: [49.780334, 4.7280547], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd72c3"), + name: "Beaune Echecs", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=1664", + address: "17 impasse de la Gouzotte 21200 BEAUNE", + email: "emmanuel.fara@u-bourgogne.fr", + website: "https://beaune-echecs-1.jimdosite.com/", + coordinates: [47.0151431, 4.8218619], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd7583"), + name: "BelfortEchecs-AEAU", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=550", + address: "34 bis rue Andre Parant 90000 BELFORT", + email: "president@belfort-echecs.fr", + website: "http://www.belfort-echecs.org", + coordinates: [47.6377347, 6.872601], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd753d"), + name: "Belloy Echecs", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=1499", + address: "15 rue du Marechal Leclerc 80310 BELLOY SUR SOMME", + email: "regiscourtois@sfr.fr", + website: "https://www.belloy-echecs.fr/", + coordinates: [49.9672603, 2.1334583], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd7350"), + name: "Betton Echecs Club", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=2134", + address: "11 allee du Champ Huby 35520 LA CHAPELLE DES FOUGERETZ", + email: "bettonechecs@gmail.com", + website: "http://betton.echecs35.fr", + coordinates: [48.1802747, -1.725364], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd746d"), + name: "Bischwiller", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=7", + address: "M.A.C. 1 rue du Stade 67240 BISCHWILLER", + email: "savignonyannis@gmail.com", + website: "http://bischwiller-echecs.com", + coordinates: [48.7775574, 7.845359999999999], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd7311"), + name: "Blagnac Echecs", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=2569", + address: "4 Cheminement des Saules 31700 BLAGNAC", + email: "blagnac-echecs@echecs-blagnac.org", + website: "http://www.echecs-blagnac.org/", + coordinates: [43.636819, 1.378467], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd7543"), + name: "Blaye Echiquier Club", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=1674", + address: "Ancienne Mairie de Blaye village 81400 BLAYE LES MINES", + email: "quentin.maury@univ-jfc.fr", + website: "", + coordinates: [44.030913, 2.1316], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd74f7"), + name: "Blitz Academie", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=3299", + address: "28 avenue D. Eylau 75116 PARIS", + email: "", + website: "", + coordinates: [48.8649847, 2.2843654], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd751f"), + name: "Blitz Masters 77", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=3408", + address: "8 rue du Pont de Couilly 77174 VILLENEUVE LE COMTE", + email: "blitzmasters77@gmail.com", + website: "https://www.valdeuropeechecs.fr/", + coordinates: [48.815073, 2.8301745], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd7414"), + name: "Bondues Echecs", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=3304", + address: "Mairie de Bondues 16 place de l'Abbe Bonpain 59910 BONDUES", + email: "jean.michel.lebret@gmail.com", + website: "https://www.facebook.com/BonduesEchecs", + coordinates: [50.7032619, 3.0920996], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd74fb"), + name: "Bonsecours A.S.C.", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=602", + address: "Ferme du Plan rue Armand Requier 76240 BONSECOURS", + email: "kevinpeignon@hotmail.fr", + website: "https://asc-bonsecours-echecs.fr/", + coordinates: [49.4255589, 1.1260986], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd7327"), + name: "Bordeaux ASPOM Echecs", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=106", + address: "130 bis Amedee St Germain 33800 BORDEAUX", + email: "president.aspom@gmail.com", + website: "http://www.aspomechecs.fr", + coordinates: [44.8177208, -0.5640065000000001], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd73cf"), + name: "Brehal Echecs et Maths", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=3145", + address: "74 rue de Langlade 50290 BREHAL", + email: "brehalechecsetmaths@gmail.com", + website: "https://www.brehalechecsetmaths.fr", + coordinates: [48.8985129, -1.512843], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd72c1"), + name: "Brive Le Cavalier Gaillard", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=2017", + address: "13 rue Jacques Daguerre 19100 BRIVE LA GAILLARDE", + email: "brive.clubechecs@gmail.com", + website: "https://sites.google.com/view/brivelecavaliergaillard/", + coordinates: [45.1625233, 1.5091968], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd746f"), + name: "C E Bruche- Ergersheim- Molsheim", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=23", + address: "48 rue Principale 67120 MOLSHEIM", + email: "echecs.bruche@gmail.com", + website: "https://www.echecsbruche.fr/", + coordinates: [48.5708497, 7.5278701], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd72e8"), + name: "C'Chartres Echecs", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=475", + address: "4 rue du Tertre 28300 ST PREST", + email: "francois.gilles@wanadoo.fr", + website: "https://c-chartres-echecs.com/", + coordinates: [48.4909286, 1.5293645], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd743e"), + name: "C'Chess - Club d'Echecs de Sées", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=3370", + address: "20 rue de la Republique 61500 SEES", + email: "", + website: "", + coordinates: [48.60452610000001, 0.1720279], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd7599"), + name: "C.E. Colombes", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=745", + address: + "Club d'Echecs de Colombes maison des Associations 4 place du General Leclerc 92700 COLOMBES", + email: "contact@colombes-echecs.fr", + website: "https://colombes-echecs.fr/", + coordinates: [48.9222463, 2.2528161], + }, + { + _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", + email: "poutoune@club-internet.fr", + website: "https://echecs-fontenaylefleury.org", + coordinates: [48.8147484, 2.048536], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd754a"), + name: "C.E. Moissac-Castelsarrasin", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=1261", + address: "Cercle Culturel 2 rue du Soleil 82100 CASTELSARRASIN", + email: "castelmoissac.echecs@free.fr", + website: "http://castelmoissac-echecs.fr/", + coordinates: [44.03667739999999, 1.109957], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd7428"), + name: "C.E. Neuville-en-Ferrain", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=1356", + address: "Espace Schumann 93 rue de Tourcoing 59960 NEUVILLE EN FERRAIN", + email: "president@neuville-echecs.fr", + website: "https://www.neuville-echecs.fr", + coordinates: [50.7478564, 3.1564851], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd7481"), + name: "C.E. Selestat", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=76", + address: "Chez Delphine Bergmann 7 rue des Marchands 67600 SELESTAT", + email: "delphine.bergmann@sfr.fr", + website: "https://ceselestat.fr/", + coordinates: [48.2599404, 7.453945699999999], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd7483"), + name: "C.E. Strasbourg", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=84", + address: "6 rue d'Ingwiller 67000 STRASBOURG", + email: "echecs.strasbourg@orange.fr", + website: "http://www.cercledechecsdestrasbourg.net", + coordinates: [48.5881456, 7.7426506], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd7486"), + name: "C.E. Wissembourg", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=90", + address: "24 rue du Sel 67160 WISSEMBOURG", + email: "adilyavuz@hotmail.fr", + website: "", + coordinates: [49.0378823, 7.945100399999999], + }, + { + _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", + email: "contact@bois-colombes-echecs.com", + website: "https://www.bois-colombes-echecs.com", + coordinates: [48.9156126, 2.2716207], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd7473"), + name: "C.E. de Haguenau", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=32", + address: "M.L.C. C.S.C. Centre Ville 6 place Robert Schuman 67500 HAGUENAU", + email: "", + website: "", + coordinates: [48.8116938, 7.795276499999999], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd75e2"), + name: "C.E. de L'Etang Sale", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=2116", + address: "13 bis rue du Cimetiere 97427 L ETANG SALE LES HAUTS", + email: "despres.pierre2@orange.fr", + website: "https://cees-etangsale.clubeo.com", + coordinates: [-21.2694981, 55.372362], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd7531"), + name: "C.E. de Rambouillet - Le Roi de Rome", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=929", + address: "11 place de l'Europe 78120 RAMBOUILLET", + email: "echecs.rambouillet@gmail.com", + website: "", + coordinates: [48.64805519999999, 1.8565883], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd75b3"), + name: "C.E. de Rosny Sous Bois", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=936", + address: + "Cercle d'Echecs de Rosny-Sous-Bois 9-11 Mail Jean-Pierre Timbaud 93110 ROSNY SOUS BOIS", + email: "jean.steinfeld@wanadoo.fr", + website: "http://rosny93-echecs.com/", + coordinates: [48.87220019999999, 2.4828322], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd75a0"), + name: "C.E. de Rueil Malmaison", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=937", + address: "94 rue d'Estienne d'Orves 92500 RUEIL MALMAISON", + email: "president@rueil-echecs.com", + website: "http://www.rueil-echecs.com", + coordinates: [48.8886779, 2.1795955], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd747f"), + name: "C.E. de la Mossig", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=74", + address: "20 rue de l'Eglise 67310 SCHARRACHBERGHEIM IRMSTETT", + email: "cemossig@yahoo.fr", + website: "http://cemossig.fr.nf", + coordinates: [48.5931988, 7.498377199999999], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd731c"), + name: "C.E.I. Toulouse", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=1284", + address: "5 rue Michel-Ange 31200 TOULOUSE", + email: "contact@ceitoulouse.fr", + website: "https://ceitoulouse.fr", + coordinates: [43.6205185, 1.4512881], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd7264"), + name: "C.E.M.C. Monaco", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=353", + address: "5 rue des Oliviers 98000 MONACO", + email: "cemc@libello.com", + website: "https://www.monaco-echecs.mc", + coordinates: [43.7428681, 7.4291682], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd7439"), + name: "C.E.de St Just - Les Tours Infernales", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=1808", + address: "Mairie place Rene Benoist 60130 ST JUST EN CHAUSSEE", + email: "gervais.maupin@orange.fr", + website: "https://www.lestoursinfernales.fr", + coordinates: [49.5055539, 2.434972], + }, + { + _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", + email: "colomiersclubdechecs@gmail.com", + website: "http://colomiers.chess.free.fr", + coordinates: [43.6117764, 1.3285075], + }, + { + _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", + email: "csmpe@free.fr", + website: "http://csmpe.free.fr", + coordinates: [48.8788229, 2.2457232], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd734b"), + name: "CAPECHECS", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=3420", + address: "47 avenue de la Peche 34410 SERIGNAN", + email: "capechecs@gmail.com", + website: "", + coordinates: [43.24320030000001, 3.2603074], + }, + { + _id: new ObjectId("690586c9e06ce80de6cd7527"), + name: "CE Le Roi Soleil - Le Chesnay - Versailles", + url: "http://www.echecs.asso.fr/FicheClub.aspx?Ref=730", + address: "7 rue Pottier 78150 LE CHESNAY", + email: "club.roisoleil@gmail.com", + website: "https://ce-le-roi-soleil-le-chesnay-versailles.webnode.fr/", + coordinates: [48.8254229, 2.1253681], + }, +]; diff --git a/src/app/[locale]/(main)/add-club/ClubForm.tsx b/src/app/[locale]/(main)/add-club/ClubForm.tsx new file mode 100644 index 0000000..4067ead --- /dev/null +++ b/src/app/[locale]/(main)/add-club/ClubForm.tsx @@ -0,0 +1,179 @@ +"use client"; + +import { useState } from "react"; + +import { zodResolver } from "@hookform/resolvers/zod"; +import { useTranslations } from "next-intl"; +import dynamic from "next/dynamic"; +import { FormProvider, useForm } from "react-hook-form"; +import { z } from "zod"; + +import { Button } from "@/components/Button"; +import InfoMessage, { InfoMessageType } from "@/components/InfoMessage"; +import LoadingMap from "@/components/LoadingMap"; +import { TextAreaField } from "@/components/form/TextAreaField"; +import { TextField } from "@/components/form/TextField"; +import { addClubSchema } from "@/schemas"; +import { addClub } from "@/server/addClub"; +import { errorLog } from "@/utils/logger"; + +type ClubFormValues = z.infer; + +const Map = dynamic(() => import("../components/MapCoordinateSelection"), { + ssr: false, + loading: LoadingMap, +}); + +const ClubForm = () => { + const t = useTranslations("AddClub"); + + const [responseMessage, setResponseMessage] = useState<{ + type: InfoMessageType; + message: string; + } | null>(null); + + const form = useForm({ + resolver: zodResolver(addClubSchema), + defaultValues: { + club: { + coordinates: [47.0844, 2.3964], + }, + }, + }); + + const onSubmit = async (data: ClubFormValues) => { + try { + await addClub(data); + + setResponseMessage({ + type: "success", + message: t("success"), + }); + + form.reset(); + } catch (err: unknown) { + errorLog(err); + setResponseMessage({ + type: "error", + message: t("failure"), + }); + } + }; + + return ( + +
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+ +
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ + + +
+ + {responseMessage && ( + setResponseMessage(null)} + /> + )} + +
+ ); +}; + +export default ClubForm; diff --git a/src/app/[locale]/(main)/add-club/page.tsx b/src/app/[locale]/(main)/add-club/page.tsx new file mode 100644 index 0000000..46fd710 --- /dev/null +++ b/src/app/[locale]/(main)/add-club/page.tsx @@ -0,0 +1,20 @@ +import ClubForm from "@/app/[locale]/(main)/add-club/ClubForm"; +import { useTranslations } from "next-intl"; + +export default function AddClubPage() { + const t = useTranslations("AddClub"); + + return ( +
+
+

{t("title")}

+ +

+ {t("info")} +

+ + +
+
+ ) +} \ No newline at end of file diff --git a/src/app/[locale]/(main)/add-tournament/TournamentForm.tsx b/src/app/[locale]/(main)/add-tournament/TournamentForm.tsx index b684f62..60b2be7 100644 --- a/src/app/[locale]/(main)/add-tournament/TournamentForm.tsx +++ b/src/app/[locale]/(main)/add-tournament/TournamentForm.tsx @@ -23,7 +23,7 @@ import { TimeControl } from "@/types"; type TournamentFormValues = z.infer; -const Map = dynamic(() => import("./Map"), { +const Map = dynamic(() => import("../components/MapCoordinateSelection"), { ssr: false, loading: LoadingMap, }); @@ -205,7 +205,7 @@ const TournamentForm = () => {
- +
diff --git a/src/app/[locale]/(main)/clubs/page.tsx b/src/app/[locale]/(main)/clubs/page.tsx index 68a60aa..cba6a83 100644 --- a/src/app/[locale]/(main)/clubs/page.tsx +++ b/src/app/[locale]/(main)/clubs/page.tsx @@ -2,6 +2,7 @@ import { unstable_cache } from "next/cache"; import { collections, dbConnect } from "@/server/mongodb"; import { Club } from "@/types"; +import { filterClubsByManualEntry } from "@/utils/clubFilters"; import { errorLog } from "@/utils/logger"; import ClubsDisplay from "./ClubsDisplay"; @@ -11,9 +12,12 @@ export const revalidate = 3600; // Revalidate cache every 6 hours const getClubs = async () => { try { await dbConnect(); - const data = await collections.clubs!.find({}).sort({ name: 1 }).toArray(); + const data = await collections + .clubs!.find({ pending: { $ne: true } }) + .sort({ name: 1 }) + .toArray(); - return data + return filterClubsByManualEntry(data) .filter((c) => !!c.coordinates) .map((club) => { return { diff --git a/src/app/[locale]/(main)/add-tournament/Map.tsx b/src/app/[locale]/(main)/components/MapCoordinateSelection.tsx similarity index 83% rename from src/app/[locale]/(main)/add-tournament/Map.tsx rename to src/app/[locale]/(main)/components/MapCoordinateSelection.tsx index 67cf849..abc4b68 100644 --- a/src/app/[locale]/(main)/add-tournament/Map.tsx +++ b/src/app/[locale]/(main)/components/MapCoordinateSelection.tsx @@ -15,11 +15,11 @@ import { MapEvents } from "@/components/MapEvents"; const center: LatLngLiteral = { lat: 47.0844, lng: 2.3964 }; -const Map = () => { +const MapCoordinateSelection = ( { page }: {page: "club" | "tournament"}) => { const { control, setValue } = useFormContext(); - const latValue = useWatch({ control, name: "tournament.coordinates.0" }); - const lngValue = useWatch({ control, name: "tournament.coordinates.1" }); + const latValue = useWatch({ control, name: `${page}.coordinates.0` }); + const lngValue = useWatch({ control, name: `${page}.coordinates.1` }); const setMapBounds = useSetAtom(mapBoundsAtom); const markerRef = useRef(null); @@ -31,17 +31,17 @@ const Map = () => { if (marker != null) { const position = marker.getLatLng(); setValue( - "tournament.coordinates.0", + `${page}.coordinates.0`, Math.round((position.lat + Number.EPSILON) * 10000) / 10000, ); setValue( - "tournament.coordinates.1", + `${page}.coordinates.1`, Math.round((position.lng + Number.EPSILON) * 10000) / 10000, ); } }, }), - [setValue], + [setValue, page], ); return ( @@ -71,4 +71,4 @@ const Map = () => { ); }; -export default Map; +export default MapCoordinateSelection; diff --git a/src/components/InfoMessage.tsx b/src/components/InfoMessage.tsx index 34d17db..0e9c8f1 100644 --- a/src/components/InfoMessage.tsx +++ b/src/components/InfoMessage.tsx @@ -1,3 +1,5 @@ +import { type ReactNode } from "react"; + import { HiCheckCircle, HiInformationCircle, @@ -14,7 +16,7 @@ const InfoMessage = ({ className, onDismiss, }: { - message: React.ReactNode; + message: ReactNode; type: "success" | "error" | "info"; onDismiss?: () => void; className?: string; @@ -72,7 +74,11 @@ const InfoMessage = ({ button, )} > -