Skip to content

Commit

Permalink
Filter out pickup events that start in less than 2 days (#246)
Browse files Browse the repository at this point in the history
* filtered events

* added by ms instead of days

* new constant
  • Loading branch information
nik-dange authored May 5, 2024
1 parent edcb3bc commit 958f5e5
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/pages/store/cart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,14 @@ const getServerSidePropsFunc: GetServerSideProps = async ({ req, res }) => {
.filter(
event => !(event.orders && event.orderLimit && event.orders.length > event.orderLimit)
)
// filter out events that have a start time less than 2 days from now
.filter(event => {
const startTime = new Date(event.start);
const now = Date.now();
const twoDaysInMs = 2 * 24 * 60 * 60 * 1000;
const twoDaysFromNow = new Date(now + twoDaysInMs);
return startTime >= twoDaysFromNow;
})
);
const userPromise = getCurrentUserAndRefreshCookie(AUTH_TOKEN, { req, res });

Expand Down

0 comments on commit 958f5e5

Please sign in to comment.