From ba7585ba54cd4495533a0efb64f2abdeaa4c541f Mon Sep 17 00:00:00 2001 From: Joonatan Kuosa Date: Thu, 22 Feb 2024 10:45:52 +0200 Subject: [PATCH] fix: remove todays reservastions from past list --- apps/ui/pages/reservations/index.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/ui/pages/reservations/index.tsx b/apps/ui/pages/reservations/index.tsx index b73b2803c9..ea2c2b5a9d 100644 --- a/apps/ui/pages/reservations/index.tsx +++ b/apps/ui/pages/reservations/index.tsx @@ -23,6 +23,7 @@ import Head from "@/components/reservations/Head"; import { CenterSpinner } from "@/components/common/common"; import { getCommonServerSideProps } from "@/modules/serverUtils"; import { toApiDate } from "common/src/common/util"; +import { addDays } from "date-fns"; export const getServerSideProps = async (ctx: GetServerSidePropsContext) => { const { locale } = ctx; @@ -106,8 +107,9 @@ const Reservations = (): JSX.Element | null => { ], orderBy: tab === "upcoming" ? "begin" : "-begin", user: currentUser?.pk?.toString(), + // NOTE today's reservations are always shown in upcoming (even when they are in the past) beginDate: tab === "upcoming" ? toApiDate(today) : undefined, - endDate: tab === "past" ? toApiDate(today) : undefined, + endDate: tab === "past" ? toApiDate(addDays(today, -1)) : undefined, }, });