fix: destination calendar selection resetting to default on page reload (#13440)

* fix: destination calendar selection resetting to default on page reload

* fix: duplicate destination calendar settings on duplicate event

* fix: zod error in test

---------

Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com>
This commit is contained in:
Somay Chauhan
2024-01-29 10:03:26 +00:00
committed by GitHub
co-authored by Udit Takkar
parent 8bc265faaa
commit 43c1bd63ca
3 changed files with 19 additions and 4 deletions
@@ -268,6 +268,7 @@ const EventTypePage = (props: EventTypeSetupProps) => {
seatsShowAvailabilityCount: eventType.seatsShowAvailabilityCount,
lockTimeZoneToggleOnBookingPage: eventType.lockTimeZoneToggleOnBookingPage,
locations: eventType.locations || [],
destinationCalendar: eventType.destinationCalendar,
recurringEvent: eventType.recurringEvent || null,
isInstantEvent: eventType.isInstantEvent,
description: eventType.description ?? undefined,
@@ -5,6 +5,7 @@ import { prisma } from "@calcom/prisma";
import { TRPCError } from "@trpc/server";
import type { TrpcSessionUser } from "../../../trpc";
import { setDestinationCalendarHandler } from "../../loggedInViewer/setDestinationCalendar.handler";
import type { TDuplicateInputSchema } from "./duplicate.schema";
type DuplicateOptions = {
@@ -34,6 +35,7 @@ export const duplicateHandler = async ({ ctx, input }: DuplicateOptions) => {
team: true,
workflows: true,
webhooks: true,
destinationCalendar: true,
},
});
@@ -66,6 +68,7 @@ export const duplicateHandler = async ({ ctx, input }: DuplicateOptions) => {
durationLimits,
metadata,
workflows,
destinationCalendar,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
id: _id,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -120,6 +123,15 @@ export const duplicateHandler = async ({ ctx, input }: DuplicateOptions) => {
data: relationCreateData,
});
}
if (destinationCalendar) {
await setDestinationCalendarHandler({
ctx,
input: {
...destinationCalendar,
eventTypeId: newEventType.id,
},
});
}
return {
eventType: newEventType,
@@ -9,10 +9,12 @@ export const EventTypeUpdateInput = _EventTypeModel
.extend({
isInstantEvent: z.boolean().optional(),
customInputs: z.array(customInputSchema).optional(),
destinationCalendar: _DestinationCalendarModel.pick({
integration: true,
externalId: true,
}),
destinationCalendar: _DestinationCalendarModel
.pick({
integration: true,
externalId: true,
})
.nullable(),
users: z.array(stringOrNumber).optional(),
children: z
.array(