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
This commit is contained in:
1 parent
04c581a25e
commit
870cadd81f
4 files changed
+16
-5
No files matched your search
@@ -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)
|
||||
|
||||
@@ -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({
|
||||
|
||||
@@ -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,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
Reference in new issue
Block a user