Skip to content

Commit 870cadd

Browse files
authored
fix: dry run improvements for v2 (#19196)
* add dry run param for v2 getSlots * fixup * revert changes * dont reserve a slot for booking dry run * accept dry run prop as a parameter instead of computing * fix merge conflicts * fixup * dont reserve slots for booking dry run
1 parent 04c581a commit 870cadd

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed

apps/api/v2/src/modules/slots/slots-2024-04-15/services/slots.service.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import { EventTypesRepository_2024_04_15 } from "@/ee/event-types/event-types_2024_04_15/event-types.repository";
22
import { SlotsRepository_2024_04_15 } from "@/modules/slots/slots-2024-04-15/slots.repository";
3-
import { Injectable, NotFoundException, BadRequestException } from "@nestjs/common";
4-
import { DateTime } from "luxon";
3+
import { Injectable, NotFoundException } from "@nestjs/common";
54
import { v4 as uuid } from "uuid";
65

7-
import { SlotFormat } from "@calcom/platform-enums";
86
import { ReserveSlotInput_2024_04_15 } from "@calcom/platform-types";
97

108
@Injectable()
@@ -33,7 +31,7 @@ export class SlotsService_2024_04_15 {
3331
}
3432
}
3533

36-
if (eventType && shouldReserveSlot) {
34+
if (eventType && shouldReserveSlot && !input._isDryRun) {
3735
await Promise.all(
3836
eventType.users.map((user) =>
3937
this.slotsRepo.upsertSelectedSlot(user.id, input, uid, eventType.seatsPerTimeSlot !== null)

packages/platform/atoms/booker/BookerPlatformWrapper.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,7 @@ export const BookerPlatformWrapper = (
403403
onReserveSlotError: props.onReserveSlotError,
404404
onDeleteSlotSuccess: props.onDeleteSlotSuccess,
405405
onDeleteSlotError: props.onDeleteSlotError,
406+
isBookingDryRun: routingParams?.isBookingDryRun,
406407
});
407408

408409
const { data: connectedCalendars, isPending: fetchingConnectedCalendars } = useConnectedCalendars({

packages/platform/atoms/hooks/useSlots.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,13 @@ export type UseSlotsReturnType = ReturnType<typeof useSlots>;
2626

2727
export const useSlots = (
2828
event: { data?: Pick<BookerEvent, "id" | "length"> | null },
29-
{ onReserveSlotSuccess, onReserveSlotError, onDeleteSlotSuccess, onDeleteSlotError }: UseSlotsCallbacks = {}
29+
{
30+
onReserveSlotSuccess,
31+
onReserveSlotError,
32+
onDeleteSlotSuccess,
33+
onDeleteSlotError,
34+
isBookingDryRun,
35+
}: UseSlotsCallbacks & { isBookingDryRun?: boolean } = {}
3036
) => {
3137
const selectedDuration = useBookerStore((state) => state.selectedDuration);
3238
const [selectedTimeslot, setSelectedTimeslot] = useBookerStore(
@@ -64,6 +70,7 @@ export const useSlots = (
6470
.utc()
6571
.add(selectedDuration || event.data.length, "minutes")
6672
.format(),
73+
_isDryRun: isBookingDryRun,
6774
});
6875
}
6976
};

packages/platform/types/slots/slots-2024-04-15/inputs/index.ts

+5
Original file line numberDiff line numberDiff line change
@@ -164,4 +164,9 @@ export class ReserveSlotInput_2024_04_15 {
164164
description: "Optional but only for events with seats. Used to retrieve booking of a seated event.",
165165
})
166166
bookingUid?: string;
167+
168+
@IsBoolean()
169+
@IsOptional()
170+
@ApiHideProperty()
171+
_isDryRun?: boolean;
167172
}

0 commit comments

Comments
 (0)