From eb93e778bd0acbdb3007b8b167121d64798fedac Mon Sep 17 00:00:00 2001 From: Alex Johansson Date: Sat, 2 Oct 2021 14:29:26 +0100 Subject: [PATCH] simplify `/bookings/[status]` logic (#845) --- pages/bookings/[status].tsx | 20 ++++++++------------ server/routers/viewer.tsx | 4 ++-- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/pages/bookings/[status].tsx b/pages/bookings/[status].tsx index 02ec6841..cae178ca 100644 --- a/pages/bookings/[status].tsx +++ b/pages/bookings/[status].tsx @@ -11,7 +11,7 @@ import BookingListItem from "@components/booking/BookingListItem"; type BookingListingStatus = inferQueryInput<"viewer.bookings">["status"]; -const descriptionByStatus = { +const descriptionByStatus: Record = { upcoming: "As soon as someone books a time with you it will show up here.", past: "Your past bookings will show up here.", cancelled: "Your cancelled bookings will show up here.", @@ -41,17 +41,13 @@ export default function Bookings() { )} - empty={ - status - ? () => ( - - ) - : undefined - } + empty={() => ( + + )} /> diff --git a/server/routers/viewer.tsx b/server/routers/viewer.tsx index aba98e98..3196cad3 100644 --- a/server/routers/viewer.tsx +++ b/server/routers/viewer.tsx @@ -22,11 +22,11 @@ export const viewerRouter = createProtectedRouter() }) .query("bookings", { input: z.object({ - status: z.enum(["upcoming", "past", "cancelled"]).optional(), + status: z.enum(["upcoming", "past", "cancelled"]), }), async resolve({ ctx, input }) { const { prisma, user } = ctx; - const bookingListingByStatus = input.status || "upcoming"; + const bookingListingByStatus = input.status; const bookingListingFilters: Record = { upcoming: [{ endTime: { gte: new Date() } }], past: [{ endTime: { lte: new Date() } }],