From 7849f8c0ca23be1f2bb4af07d83f555e2885fb75 Mon Sep 17 00:00:00 2001 From: Kristoffer Longva Eriksen Date: Sat, 9 Apr 2022 11:05:11 +0200 Subject: [PATCH] filtered out old tournaments from front page --- src/client/src/FrontPage.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/client/src/FrontPage.js b/src/client/src/FrontPage.js index 67b0682..ebe1da4 100644 --- a/src/client/src/FrontPage.js +++ b/src/client/src/FrontPage.js @@ -110,13 +110,18 @@ function TournamentList() { return; } + let today = new Date() + let currenttournaments = [] let tournaments = Object.values(data.data); for (let i = 0; i < tournaments.length; i++) { tournaments[i].startTime = new Date(tournaments[i].startTime); tournaments[i].endTime = new Date(tournaments[i].endTime); + if(today - tournaments[i].endTime <= 24*60*60*1000) { + currenttournaments.push(tournaments[i]) + } } - - setTournamentList(tournaments); + // tournaments.filter((tournament) => today - tournament.endTime < 24*60*60*1000) + setTournamentList(currenttournaments); }) .catch((err) => console.log(err.message)); }, []);