fix: error because Seated slot reservations do not pass bookingUid (#22022)
* fixed query * Update reserveSlot.handler.ts --------- Co-authored-by: Benny Joo <[email protected]>
This commit is contained in:
1 parent
82d3b9d29d
commit
29aad2c535
2 files changed
+10
-4
No files matched your search
@@ -7,6 +7,7 @@ import { WEBAPP_URL } from "@calcom/lib/constants";
|
|||||||
import { MINUTES_TO_BOOK } from "@calcom/lib/constants";
|
import { MINUTES_TO_BOOK } from "@calcom/lib/constants";
|
||||||
import { SelectedSlotsRepository } from "@calcom/lib/server/repository/selectedSlots";
|
import { SelectedSlotsRepository } from "@calcom/lib/server/repository/selectedSlots";
|
||||||
import type { PrismaClient } from "@calcom/prisma";
|
import type { PrismaClient } from "@calcom/prisma";
|
||||||
|
import { BookingStatus } from "@calcom/prisma/enums";
|
||||||
|
|
||||||
import { TRPCError } from "@trpc/server";
|
import { TRPCError } from "@trpc/server";
|
||||||
|
|
||||||
@@ -23,7 +24,8 @@ interface ReserveSlotOptions {
|
|||||||
export const reserveSlotHandler = async ({ ctx, input }: ReserveSlotOptions) => {
|
export const reserveSlotHandler = async ({ ctx, input }: ReserveSlotOptions) => {
|
||||||
const { prisma, req, res } = ctx;
|
const { prisma, req, res } = ctx;
|
||||||
const uid = req?.cookies?.uid || uuid();
|
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 releaseAt = dayjs.utc().add(parseInt(MINUTES_TO_BOOK), "minutes").format();
|
||||||
const eventType = await prisma.eventType.findUnique({
|
const eventType = await prisma.eventType.findUnique({
|
||||||
where: { id: eventTypeId },
|
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 this is a seated event then don't reserve a slot
|
||||||
if (eventType.seatsPerTimeSlot) {
|
if (eventType.seatsPerTimeSlot) {
|
||||||
// Check to see if this is the last attendee
|
// Check to see if this is the last attendee
|
||||||
const bookingWithAttendees = await prisma.booking.findUnique({
|
const bookingWithAttendees = await prisma.booking.findFirst({
|
||||||
where: { uid: bookingUid },
|
where: {
|
||||||
|
eventTypeId,
|
||||||
|
startTime: slotUtcStartDate,
|
||||||
|
endTime: slotUtcEndDate,
|
||||||
|
status: BookingStatus.ACCEPTED,
|
||||||
|
},
|
||||||
select: { attendees: true },
|
select: { attendees: true },
|
||||||
});
|
});
|
||||||
const bookingAttendeesLength = bookingWithAttendees?.attendees?.length;
|
const bookingAttendeesLength = bookingWithAttendees?.attendees?.length;
|
||||||
|
|||||||
@@ -59,7 +59,6 @@ export const reserveSlotSchema = z
|
|||||||
slotUtcStartDate: z.string(),
|
slotUtcStartDate: z.string(),
|
||||||
// endTime ISOString
|
// endTime ISOString
|
||||||
slotUtcEndDate: z.string(),
|
slotUtcEndDate: z.string(),
|
||||||
bookingUid: z.string().optional(),
|
|
||||||
_isDryRun: z.boolean().optional(),
|
_isDryRun: z.boolean().optional(),
|
||||||
})
|
})
|
||||||
.refine(
|
.refine(
|
||||||
|
|||||||
Reference in new issue
Block a user