mirror of
https://github.com/TheRealOwenRees/echecsfrance.git
synced 2026-11-18 07:22:06 +00:00
add tournament duration filter
remove expired tournaments from test data apply auto formatting rules condense norm tournament text revert duration to pill buttons use select for duration filter duration filter show date range on map marker return start/end dates and calculated duration for tournaments inline returns etc new seed data for dev
This commit is contained in:
@@ -41,6 +41,9 @@ export const searchStringAtom = atom("");
|
||||
export const tournamentsAtom = atom<Tournament[]>([]);
|
||||
export const normsOnlyAtom = atom(false);
|
||||
|
||||
export type DurationFilter = "any" | "1" | "2" | "3+";
|
||||
export const durationFilterAtom = atom<DurationFilter>("any");
|
||||
|
||||
export const classicAtom = atom(true);
|
||||
export const rapidAtom = atom(true);
|
||||
export const blitzAtom = atom(true);
|
||||
@@ -69,14 +72,23 @@ export const filteredTournamentsByTimeControlAndZoneAtom = atom((get) => {
|
||||
const dateRange = get(dateRangeAtom);
|
||||
const { startDate, endDate } = dateRange[0];
|
||||
|
||||
const durationFilter = get(durationFilterAtom);
|
||||
|
||||
const filterByTimeControl = tournaments.filter((tournament) => {
|
||||
const tournamentDate = startOfDay(parse(tournament.date, "dd/MM/yyyy", new Date()));
|
||||
|
||||
const durationMatch =
|
||||
durationFilter === "any" ||
|
||||
(durationFilter === "1" && tournament.durationDays === 1) ||
|
||||
(durationFilter === "2" && tournament.durationDays === 2) ||
|
||||
(durationFilter === "3+" && tournament.durationDays >= 3);
|
||||
|
||||
return (
|
||||
!isBefore(tournamentDate, startDate) &&
|
||||
(endDate === undefined || !isAfter(tournamentDate, endDate)) &&
|
||||
!tournament.pending &&
|
||||
tournament.status === "scheduled" &&
|
||||
durationMatch &&
|
||||
((tournament.timeControl === TimeControl.Classic && classic) ||
|
||||
(tournament.timeControl === TimeControl.Rapid && rapid) ||
|
||||
(tournament.timeControl === TimeControl.Blitz && blitz) ||
|
||||
|
||||
Reference in New Issue
Block a user