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
+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),
);
});