filtered out old tournaments from front page

This commit is contained in:
Kristoffer Longva Eriksen 2022-04-09 11:05:11 +02:00
parent 6774868dfc
commit 7849f8c0ca
1 changed files with 7 additions and 2 deletions

View File

@ -110,13 +110,18 @@ function TournamentList() {
return; return;
} }
let today = new Date()
let currenttournaments = []
let tournaments = Object.values(data.data); let tournaments = Object.values(data.data);
for (let i = 0; i < tournaments.length; i++) { for (let i = 0; i < tournaments.length; i++) {
tournaments[i].startTime = new Date(tournaments[i].startTime); tournaments[i].startTime = new Date(tournaments[i].startTime);
tournaments[i].endTime = new Date(tournaments[i].endTime); tournaments[i].endTime = new Date(tournaments[i].endTime);
if(today - tournaments[i].endTime <= 24*60*60*1000) {
currenttournaments.push(tournaments[i])
}
} }
// tournaments.filter((tournament) => today - tournament.endTime < 24*60*60*1000)
setTournamentList(tournaments); setTournamentList(currenttournaments);
}) })
.catch((err) => console.log(err.message)); .catch((err) => console.log(err.message));
}, []); }, []);