added badge for unconfirmed bookings (#4912)

* added badge for unconfirmed bookings

* added link to unconfirmed bookings

* added rounded prop to badge, added unconfirmed badge to botto nav

* Supporting recurring events + bug fix

* Tooltip and hover style

Co-authored-by: Joe Au-Yeung <[email protected]>
Co-authored-by: Leo Giovanetti <[email protected]>
This commit is contained in:
authored and GitHub committed 2022-10-10 17:00:09 +00:00
1 parent 2a0a293f8c
commit 4fcdc7bf5c
6 files changed
+65 -3

No files matched your search

+29
View File
@@ -587,6 +587,7 @@ const loggedInViewerRouter = createProtectedRouter()
status: {
notIn: [BookingStatus.CANCELLED],
},
userId: user.id,
},
});
@@ -1437,6 +1438,34 @@ const loggedInViewerRouter = createProtectedRouter()
},
});
},
})
.query("bookingUnconfirmedCount", {
async resolve({ ctx }) {
const { prisma, user } = ctx;
const count = await prisma.booking.count({
where: {
status: BookingStatus.PENDING,
userId: user.id,
endTime: { gt: new Date() },
},
});
const recurringGrouping = await prisma.booking.groupBy({
by: ["recurringEventId"],
_count: {
recurringEventId: true,
},
where: {
recurringEventId: { not: { equals: null } },
status: { equals: "PENDING" },
userId: user.id,
},
});
return recurringGrouping.reduce((prev, current) => {
// recurringEventId is the total number of recurring instances for a booking
// we need to substract all but one, to represent a single recurring booking
return prev - (current._count?.recurringEventId - 1);
}, count);
},
});
export const viewerRouter = createRouter()
@@ -20,6 +20,7 @@ import getWebhooks from "@calcom/features/webhooks/utils/getWebhooks";
import { isPrismaObjOrUndefined, parseRecurringEvent } from "@calcom/lib";
import logger from "@calcom/lib/logger";
import { getTranslation } from "@calcom/lib/server";
import prisma from "@calcom/prisma";
import { bookingConfirmPatchBodySchema } from "@calcom/prisma/zod-utils";
import type { AdditionalInformation, CalendarEvent } from "@calcom/types/Calendar";