-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Malcolm/current upcoming auctions (#58)
- Loading branch information
1 parent
c1b8521
commit 07d5b4d
Showing
4 changed files
with
137 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const sortAuctions = (auctionList) => { | ||
const upcomingList = [] | ||
const currentList = [] | ||
const pastList = [] | ||
|
||
const now = new Date(Date.now()); | ||
auctionList.forEach(auction => { | ||
if (new Date(auction.start_date) > now) { | ||
upcomingList.push(auction); | ||
} else if (new Date(auction.end_date) > now) { | ||
currentList.push(auction); | ||
} else { | ||
pastList.push(auction); | ||
} | ||
}); | ||
|
||
return ({"upcoming": upcomingList, "current": currentList, "past": pastList}); | ||
} | ||
|
||
|
||
|
||
export default sortAuctions; |