More dry run fixes (#18865)
This commit is contained in:
1 parent
ec55454e43
commit
b06a94ab57
8 files changed
+34
-4
No files matched your search
@@ -94,6 +94,7 @@ export function getFieldResponse({
|
||||
|
||||
/**
|
||||
* Not called in preview mode or dry run mode
|
||||
* It takes care of sending webhooks and emails for form submissions
|
||||
*/
|
||||
export async function onFormSubmission(
|
||||
form: Ensure<
|
||||
|
||||
@@ -19,7 +19,9 @@ export const DryRunMessage = ({ isEmbed }: { isEmbed?: boolean }) => {
|
||||
<div className="relative">
|
||||
<Icon name="info" className="h-5 w-5 text-orange-500" />
|
||||
</div>
|
||||
<div className="text-emphasis font-medium">{t("dry_run_mode_active")}</div>
|
||||
<div className="text-emphasis font-medium" data-testid="dry-run-msg">
|
||||
{t("dry_run_mode_active")}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -4,14 +4,17 @@ import { shallow } from "zustand/shallow";
|
||||
import dayjs from "@calcom/dayjs";
|
||||
import { useBookerStore } from "@calcom/features/bookings/Booker/store";
|
||||
import { useSlotReservationId } from "@calcom/features/bookings/Booker/useSlotReservationId";
|
||||
import { isBookingDryRun } from "@calcom/features/bookings/Booker/utils/isBookingDryRun";
|
||||
import type { BookerEvent } from "@calcom/features/bookings/types";
|
||||
import { MINUTES_TO_BOOK } from "@calcom/lib/constants";
|
||||
import { useCompatSearchParams } from "@calcom/lib/hooks/useCompatSearchParams";
|
||||
import { trpc } from "@calcom/trpc";
|
||||
|
||||
export type UseSlotsReturnType = ReturnType<typeof useSlots>;
|
||||
|
||||
export const useSlots = (event: { data?: Pick<BookerEvent, "id" | "length"> | null }) => {
|
||||
const selectedDuration = useBookerStore((state) => state.selectedDuration);
|
||||
const searchParams = useCompatSearchParams();
|
||||
const [selectedTimeslot, setSelectedTimeslot] = useBookerStore(
|
||||
(state) => [state.selectedTimeslot, state.setSelectedTimeslot],
|
||||
shallow
|
||||
@@ -45,6 +48,7 @@ export const useSlots = (event: { data?: Pick<BookerEvent, "id" | "length"> | nu
|
||||
.utc()
|
||||
.add(selectedDuration || event.data.length, "minutes")
|
||||
.format(),
|
||||
_isDryRun: isBookingDryRun(searchParams),
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -21,7 +21,7 @@ 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 } = input;
|
||||
const { slotUtcStartDate, slotUtcEndDate, eventTypeId, bookingUid, _isDryRun } = input;
|
||||
const releaseAt = dayjs.utc().add(parseInt(MINUTES_TO_BOOK), "minutes").format();
|
||||
const eventType = await prisma.eventType.findUnique({
|
||||
where: { id: eventTypeId },
|
||||
@@ -54,7 +54,7 @@ export const reserveSlotHandler = async ({ ctx, input }: ReserveSlotOptions) =>
|
||||
}
|
||||
}
|
||||
|
||||
if (eventType && shouldReserveSlot) {
|
||||
if (eventType && shouldReserveSlot && !_isDryRun) {
|
||||
try {
|
||||
await Promise.all(
|
||||
eventType.users.map((user) =>
|
||||
|
||||
@@ -56,6 +56,7 @@ export const reserveSlotSchema = z
|
||||
// endTime ISOString
|
||||
slotUtcEndDate: z.string(),
|
||||
bookingUid: z.string().optional(),
|
||||
_isDryRun: z.boolean().optional(),
|
||||
})
|
||||
.refine(
|
||||
(data) => !!data.eventTypeId || !!data.slotUtcStartDate || !!data.slotUtcEndDate,
|
||||
|
||||
Reference in new issue
Block a user