Prettify all files

This commit is contained in:
Timothy Armes
2023-07-17 11:49:07 +02:00
parent 95118b32e2
commit d3afc1d1f4
34 changed files with 152 additions and 135 deletions
+1 -1
View File
@@ -31,7 +31,7 @@ export default function Footer() {
>
<FaRegEnvelope />
</Link>
<div className="space-x-2 mr-4 text-xs">
<div className="mr-4 space-x-2 text-xs">
<Link href="/" locale="fr">
FR
</Link>
+6 -6
View File
@@ -20,7 +20,7 @@ const Legend = () => {
{ tc: TimeControl.Blitz, colour: "#cec348" },
{ tc: TimeControl.Other, colour: "#d10c3e" },
].filter(({ tc }) => tournaments.some((t) => t.timeControl === tc)),
[tournaments]
[tournaments],
);
useEffect(() => {
@@ -32,7 +32,7 @@ const Legend = () => {
const div = L.DomUtil.create("div", "map-legend");
div.setAttribute(
"style",
"background: white; color: black; border: 2px solid grey; border-radius: 6px; padding: 10px;"
"background: white; color: black; border: 2px solid grey; border-radius: 6px; padding: 10px;",
);
div.innerHTML = `
@@ -42,11 +42,11 @@ const Legend = () => {
({ tc, colour }) => `
<li>
<span class="block h-4 w-7 border border-[#999] float-left mr-1" style="background: ${colour}"></span>${t(
"timeControlEnum",
{ tc }
)}
"timeControlEnum",
{ tc },
)}
</li>
`
`,
)
.join("")}
</ul>`;
+1 -1
View File
@@ -5,7 +5,7 @@ import { ScrollableElement } from "@/types";
import { FaArrowUp } from "react-icons/fa";
import { handleScrollToTop } from "@/handlers/scrollHandlers";
import { useEffect, useRef, useState } from "react";
import {useBreakpoint} from "@/hooks/tailwind";
import { useBreakpoint } from "@/hooks/tailwind";
const ScrollToTopButton = () => {
const scrollToTopElementRef = useRef<ScrollableElement | null>(null);
+7 -7
View File
@@ -99,11 +99,11 @@ const TimeControlGroup = ({ timeControl, colour }: TimeControlGroupProps) => {
const filteredTournaments = useMemo(
() => tournaments.filter((t) => t.timeControl === timeControl),
[timeControl, tournaments]
[timeControl, tournaments],
);
const hoveredListTournamentId = useAtomValue(
debouncedHoveredListTournamentIdAtom
debouncedHoveredListTournamentIdAtom,
);
const expandAndBounceIfNeeded = useCallback(() => {
@@ -167,7 +167,7 @@ const TimeControlGroup = ({ timeControl, colour }: TimeControlGroupProps) => {
}
}
},
[hoveredListTournamentId]
[hoveredListTournamentId],
);
const onUnSpiderified = useCallback(
@@ -178,7 +178,7 @@ const TimeControlGroup = ({ timeControl, colour }: TimeControlGroupProps) => {
// Once closed, we can expand the next group if needed
expandAndBounceIfNeeded();
},
[expandAndBounceIfNeeded]
[expandAndBounceIfNeeded],
);
useEffect(() => {
@@ -215,7 +215,7 @@ const TimeControlGroup = ({ timeControl, colour }: TimeControlGroupProps) => {
iconSize: new L.Point(40, 40),
});
},
[timeControl]
[timeControl],
);
const markers = filteredTournaments.map((tournament) => {
@@ -242,7 +242,7 @@ const TimeControlGroup = ({ timeControl, colour }: TimeControlGroupProps) => {
</MarkerClusterGroup>
</LayerGroup>
),
[createClusterCustomIcon, markers]
[createClusterCustomIcon, markers],
);
return group;
@@ -251,7 +251,7 @@ const TimeControlGroup = ({ timeControl, colour }: TimeControlGroupProps) => {
export default function TournamentMap() {
const setMapBounds = useSetAtom(mapBoundsAtom);
const hoveredListTournamentId = useAtomValue(
debouncedHoveredListTournamentIdAtom
debouncedHoveredListTournamentIdAtom,
);
const classic = useAtomValue(classicAtom);
+2 -2
View File
@@ -35,7 +35,7 @@ export const TournamentMarker = forwardRef<
});
const setHoveredMapTournamentId = useSetAtom(
debouncedHoveredMapTournamentIdAtom
debouncedHoveredMapTournamentIdAtom,
);
const iconOptions = useMemo(
@@ -48,7 +48,7 @@ export const TournamentMarker = forwardRef<
popupAnchor: [1, -34],
shadowSize: [41, 41],
}),
[colour]
[colour],
);
return (
+4 -4
View File
@@ -26,10 +26,10 @@ export default function TournamentTable() {
const [syncVisible, setSyncVisible] = useAtom(syncVisibleAtom);
const hoveredMapTournamentId = useAtomValue(hoveredMapTournamentIdAtom);
const debouncedHoveredMapTournamentId = useAtomValue(
debouncedHoveredMapTournamentIdAtom
debouncedHoveredMapTournamentIdAtom,
);
const setHoveredListTournamentId = useSetAtom(
debouncedHoveredListTournamentIdAtom
debouncedHoveredListTournamentIdAtom,
);
const isLg = useBreakpoint("lg");
@@ -38,7 +38,7 @@ export default function TournamentTable() {
if (!isLg || debouncedHoveredMapTournamentId === null) return;
const tournamentRow = document.getElementById(
debouncedHoveredMapTournamentId
debouncedHoveredMapTournamentId,
);
tournamentRow?.scrollIntoView({ behavior: "smooth" });
@@ -110,7 +110,7 @@ export default function TournamentTable() {
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",
hoveredMapTournamentId === tournament._id &&
"bg-gray-200 dark:bg-gray-900"
"bg-gray-200 dark:bg-gray-900",
)}
>
<td className="p-3">{tournament.date}</td>
+1 -1
View File
@@ -27,7 +27,7 @@ export async function POST(req: Request) {
return NextResponse.json(
{ success: `Message delivered to ${mailInfo.accepted}` },
{ status: 250 }
{ status: 250 },
);
} catch (error) {
errorLog(error);
+21 -17
View File
@@ -1,6 +1,6 @@
import { TimeControl, Tournament } from '@/types';
import { atom } from 'jotai';
import { LatLngBounds } from 'leaflet';
import { TimeControl, Tournament } from "@/types";
import { atom } from "jotai";
import { LatLngBounds } from "leaflet";
import atomWithDebounce from "@/utils/atomWithDebounce";
@@ -8,7 +8,7 @@ export const tournamentsAtom = atom<Tournament[]>([]);
export const mapBoundsAtom = atom<LatLngBounds | null>(null);
export const syncVisibleAtom = atom(true);
export const searchStringAtom = atom('');
export const searchStringAtom = atom("");
export const classicAtom = atom(true);
export const rapidAtom = atom(true);
export const blitzAtom = atom(true);
@@ -19,9 +19,8 @@ export const {
debouncedValueAtom: debouncedHoveredMapTournamentIdAtom,
} = atomWithDebounce<string | null>(null);
export const {
debouncedValueAtom: debouncedHoveredListTournamentIdAtom,
} = atomWithDebounce<string | null>(null, 300, true);
export const { debouncedValueAtom: debouncedHoveredListTournamentIdAtom } =
atomWithDebounce<string | null>(null, 300, true);
export const filteredTournamentsByTimeControlAtom = atom((get) => {
const tournaments = get(tournamentsAtom);
@@ -31,11 +30,13 @@ export const filteredTournamentsByTimeControlAtom = atom((get) => {
const blitz = get(blitzAtom);
const other = get(otherAtom);
return tournaments.filter(tournament =>
(tournament.timeControl === TimeControl.Classic && classic) ||
(tournament.timeControl === TimeControl.Rapid && rapid) ||
(tournament.timeControl === TimeControl.Blitz && blitz) ||
(tournament.timeControl === TimeControl.Other && other));
return tournaments.filter(
(tournament) =>
(tournament.timeControl === TimeControl.Classic && classic) ||
(tournament.timeControl === TimeControl.Rapid && rapid) ||
(tournament.timeControl === TimeControl.Blitz && blitz) ||
(tournament.timeControl === TimeControl.Other && other),
);
});
export const filteredTournamentsListAtom = atom((get) => {
@@ -45,14 +46,17 @@ export const filteredTournamentsListAtom = atom((get) => {
const searchString = get(searchStringAtom).trim();
// When searching, we search all the tournament, regardless of the map display
if (searchString !== '')
return tournaments.filter((t) => t.town.includes(searchString.toUpperCase()))
if (searchString !== "")
return tournaments.filter((t) =>
t.town.includes(searchString.toUpperCase()),
);
// If we not syncing to the map, return all tournaments
if (mapBounds === null || !syncVisible) return tournaments;
// Filter by those in the current map bounds
return tournaments.filter(tournament => mapBounds.contains(tournament.latLng))
})
return tournaments.filter((tournament) =>
mapBounds.contains(tournament.latLng),
);
});
+22 -19
View File
@@ -1,24 +1,27 @@
import { MetadataRoute } from "next";
export default function sitemap(): MetadataRoute.Sitemap {
return ['fr', 'en'].flatMap(locale => {
const prefix = `https://echecsfrance.com/${locale === 'fr' ? '' : `${locale}/`}`
return ["fr", "en"].flatMap((locale) => {
const prefix = `https://echecsfrance.com/${
locale === "fr" ? "" : `${locale}/`
}`;
return [
{
url: prefix,
lastModified: new Date(),
},
{
url: `${prefix}tournois`,
lastModified: new Date(),
},
{
url: `${prefix}qui-sommes-nous`,
lastModified: new Date(),
},
{
url: `${prefix}contactez-nous`,
lastModified: new Date(),
},
]});
{
url: prefix,
lastModified: new Date(),
},
{
url: `${prefix}tournois`,
lastModified: new Date(),
},
{
url: `${prefix}qui-sommes-nous`,
lastModified: new Date(),
},
{
url: `${prefix}contactez-nous`,
lastModified: new Date(),
},
];
});
}