Scheduling infrastructure for absolutely everyone.
fix: dry run improvements for v2 (#19196)
Rajiv Sahal870cadd81f4e
diff --git a/apps/api/v2/src/modules/slots/slots-2024-04-15/services/slots.service.ts b/apps/api/v2/src/modules/slots/slots-2024-04-15/services/slots.service.tsindex f1f12035bd8..e97ab48e1bf 100644--- a/apps/api/v2/src/modules/slots/slots-2024-04-15/services/slots.service.ts+++ b/apps/api/v2/src/modules/slots/slots-2024-04-15/services/slots.service.ts@@ -1,10 +1,8 @@import { EventTypesRepository_2024_04_15 } from "@/ee/event-types/event-types_2024_04_15/event-types.repository";import { SlotsRepository_2024_04_15 } from "@/modules/slots/slots-2024-04-15/slots.repository";-import { Injectable, NotFoundException, BadRequestException } from "@nestjs/common";-import { DateTime } from "luxon";+import { Injectable, NotFoundException } from "@nestjs/common";import { v4 as uuid } from "uuid";-import { SlotFormat } from "@calcom/platform-enums";import { ReserveSlotInput_2024_04_15 } from "@calcom/platform-types";@Injectable()@@ -33,7 +31,7 @@ export class SlotsService_2024_04_15 {}}- if (eventType && shouldReserveSlot) {+ if (eventType && shouldReserveSlot && !input._isDryRun) {await Promise.all(eventType.users.map((user) =>this.slotsRepo.upsertSelectedSlot(user.id, input, uid, eventType.seatsPerTimeSlot !== null)diff --git a/packages/platform/atoms/booker/BookerPlatformWrapper.tsx b/packages/platform/atoms/booker/BookerPlatformWrapper.tsxindex 0197bb9ff0e..eeb5d3159f4 100644--- a/packages/platform/atoms/booker/BookerPlatformWrapper.tsx+++ b/packages/platform/atoms/booker/BookerPlatformWrapper.tsx@@ -403,6 +403,7 @@ export const BookerPlatformWrapper = (onReserveSlotError: props.onReserveSlotError,onDeleteSlotSuccess: props.onDeleteSlotSuccess,onDeleteSlotError: props.onDeleteSlotError,+ isBookingDryRun: routingParams?.isBookingDryRun,});const { data: connectedCalendars, isPending: fetchingConnectedCalendars } = useConnectedCalendars({diff --git a/packages/platform/atoms/hooks/useSlots.ts b/packages/platform/atoms/hooks/useSlots.tsindex 60d15d2fbae..faf5ca87642 100644--- a/packages/platform/atoms/hooks/useSlots.ts+++ b/packages/platform/atoms/hooks/useSlots.ts@@ -26,7 +26,13 @@ export type UseSlotsReturnType = ReturnType<typeof useSlots>;export const useSlots = (event: { data?: Pick<BookerEvent, "id" | "length"> | null },- { onReserveSlotSuccess, onReserveSlotError, onDeleteSlotSuccess, onDeleteSlotError }: UseSlotsCallbacks = {}+ {+ onReserveSlotSuccess,+ onReserveSlotError,+ onDeleteSlotSuccess,+ onDeleteSlotError,+ isBookingDryRun,+ }: UseSlotsCallbacks & { isBookingDryRun?: boolean } = {}) => {const selectedDuration = useBookerStore((state) => state.selectedDuration);const [selectedTimeslot, setSelectedTimeslot] = useBookerStore(@@ -64,6 +70,7 @@ export const useSlots = (.utc().add(selectedDuration || event.data.length, "minutes").format(),+ _isDryRun: isBookingDryRun,});}};diff --git a/packages/platform/types/slots/slots-2024-04-15/inputs/index.ts b/packages/platform/types/slots/slots-2024-04-15/inputs/index.tsindex af937ad9ef8..b225caf3904 100644--- a/packages/platform/types/slots/slots-2024-04-15/inputs/index.ts+++ b/packages/platform/types/slots/slots-2024-04-15/inputs/index.ts@@ -164,4 +164,9 @@ export class ReserveSlotInput_2024_04_15 {description: "Optional but only for events with seats. Used to retrieve booking of a seated event.",})bookingUid?: string;++ @IsBoolean()+ @IsOptional()+ @ApiHideProperty()+ _isDryRun?: boolean;}