fix: error because Seated slot reservations do not pass bookingUid (#22022)

* fixed query

* Update reserveSlot.handler.ts

---------

Co-authored-by: Benny Joo <sldisek783@gmail.com>
This commit is contained in:
Romit
2025-06-25 21:56:32 +00:00
committed by GitHub
co-authored by Benny Joo
parent 82d3b9d29d
commit 29aad2c535
2 changed files with 10 additions and 4 deletions
@@ -7,6 +7,7 @@ import { WEBAPP_URL } from "@calcom/lib/constants";
import { MINUTES_TO_BOOK } from "@calcom/lib/constants";
import { SelectedSlotsRepository } from "@calcom/lib/server/repository/selectedSlots";
import type { PrismaClient } from "@calcom/prisma";
import { BookingStatus } from "@calcom/prisma/enums";
import { TRPCError } from "@trpc/server";
@@ -23,7 +24,8 @@ interface ReserveSlotOptions {
export const reserveSlotHandler = async ({ ctx, input }: ReserveSlotOptions) => {
const { prisma, req, res } = ctx;
const uid = req?.cookies?.uid || uuid();
const { slotUtcStartDate, slotUtcEndDate, eventTypeId, bookingUid, _isDryRun } = input;
const { slotUtcStartDate, slotUtcEndDate, eventTypeId, _isDryRun } = input;
const releaseAt = dayjs.utc().add(parseInt(MINUTES_TO_BOOK), "minutes").format();
const eventType = await prisma.eventType.findUnique({
where: { id: eventTypeId },
@@ -42,8 +44,13 @@ export const reserveSlotHandler = async ({ ctx, input }: ReserveSlotOptions) =>
// If this is a seated event then don't reserve a slot
if (eventType.seatsPerTimeSlot) {
// Check to see if this is the last attendee
const bookingWithAttendees = await prisma.booking.findUnique({
where: { uid: bookingUid },
const bookingWithAttendees = await prisma.booking.findFirst({
where: {
eventTypeId,
startTime: slotUtcStartDate,
endTime: slotUtcEndDate,
status: BookingStatus.ACCEPTED,
},
select: { attendees: true },
});
const bookingAttendeesLength = bookingWithAttendees?.attendees?.length;
@@ -59,7 +59,6 @@ export const reserveSlotSchema = z
slotUtcStartDate: z.string(),
// endTime ISOString
slotUtcEndDate: z.string(),
bookingUid: z.string().optional(),
_isDryRun: z.boolean().optional(),
})
.refine(