From 0098591a56bf7897c09d18a85951663a98aa5f52 Mon Sep 17 00:00:00 2001 From: Leo Giovanetti Date: Thu, 6 Oct 2022 17:38:50 -0300 Subject: [PATCH] Applying feedback from a merged PR (#4887) --- .../components/booking/BookingListItem.tsx | 20 ++++++++-------- packages/trpc/server/routers/viewer.tsx | 24 +++++-------------- 2 files changed, 16 insertions(+), 28 deletions(-) diff --git a/apps/web/components/booking/BookingListItem.tsx b/apps/web/components/booking/BookingListItem.tsx index 56ca8bf9fb..c376c4e88e 100644 --- a/apps/web/components/booking/BookingListItem.tsx +++ b/apps/web/components/booking/BookingListItem.tsx @@ -53,6 +53,16 @@ function BookingListItem(booking: BookingItemProps) { }, }); + const isUpcoming = new Date(booking.endTime) >= new Date(); + const isPast = new Date(booking.endTime) < new Date(); + const isCancelled = booking.status === BookingStatus.CANCELLED; + const isConfirmed = booking.status === BookingStatus.ACCEPTED; + const isRejected = booking.status === BookingStatus.REJECTED; + const isPending = booking.status === BookingStatus.PENDING; + const isRecurring = booking.recurringEventId !== null; + const isTabRecurring = booking.listingStatus === "recurring"; + const isTabUnconfirmed = booking.listingStatus === "unconfirmed"; + const bookingConfirm = async (confirm: boolean) => { let body = { bookingId: booking.id, @@ -69,16 +79,6 @@ function BookingListItem(booking: BookingItemProps) { mutation.mutate(body); }; - const isUpcoming = new Date(booking.endTime) >= new Date(); - const isPast = new Date(booking.endTime) < new Date(); - const isCancelled = booking.status === BookingStatus.CANCELLED; - const isConfirmed = booking.status === BookingStatus.ACCEPTED; - const isRejected = booking.status === BookingStatus.REJECTED; - const isPending = booking.status === BookingStatus.PENDING; - const isRecurring = booking.recurringEventId !== null; - const isTabRecurring = booking.listingStatus === "recurring"; - const isTabUnconfirmed = booking.listingStatus === "unconfirmed"; - const pendingActions: ActionType[] = [ { id: "reject", diff --git a/packages/trpc/server/routers/viewer.tsx b/packages/trpc/server/routers/viewer.tsx index 2eaf991fa7..00ff75643c 100644 --- a/packages/trpc/server/routers/viewer.tsx +++ b/packages/trpc/server/routers/viewer.tsx @@ -454,20 +454,12 @@ const loggedInViewerRouter = createProtectedRouter() // handled separately for each occurrence OR: [ { - AND: [ - { NOT: { recurringEventId: { equals: null } } }, - { - status: { - notIn: [BookingStatus.PENDING, BookingStatus.CANCELLED, BookingStatus.REJECTED], - }, - }, - ], + recurringEventId: { not: null }, + status: { notIn: [BookingStatus.PENDING, BookingStatus.CANCELLED, BookingStatus.REJECTED] }, }, { - AND: [ - { recurringEventId: { equals: null } }, - { status: { notIn: [BookingStatus.CANCELLED, BookingStatus.REJECTED] } }, - ], + recurringEventId: { equals: null }, + status: { notIn: [BookingStatus.CANCELLED, BookingStatus.REJECTED] }, }, ], }, @@ -495,12 +487,8 @@ const loggedInViewerRouter = createProtectedRouter() endTime: { gte: new Date() }, OR: [ { - AND: [ - { NOT: { recurringEventId: { equals: null } } }, - { - status: { equals: BookingStatus.PENDING }, - }, - ], + recurringEventId: { not: null }, + status: { equals: BookingStatus.PENDING }, }, { status: { equals: BookingStatus.PENDING },