Fix: EventType Duplication (#6778)

This commit is contained in:
Hariom Balhara
2023-01-30 12:55:08 +01:00
committed by GitHub
parent 6c23813192
commit 8cf0050d1f
@@ -676,7 +676,13 @@ export const eventTypesRouter = router({
}),
duplicate: eventOwnerProcedure.input(EventTypeDuplicateInput.strict()).mutation(async ({ ctx, input }) => {
try {
const { id: originalEventTypeId, title: newEventTitle, slug: newSlug } = input;
const {
id: originalEventTypeId,
title: newEventTitle,
slug: newSlug,
description: newDescription,
length: newLength,
} = input;
const eventType = await ctx.prisma.eventType.findUnique({
where: {
id: originalEventTypeId,
@@ -735,6 +741,8 @@ export const eventTypesRouter = router({
...rest,
title: newEventTitle,
slug: newSlug,
description: newDescription,
length: newLength,
locations: locations ?? undefined,
teamId: team ? team.id : undefined,
users: users ? { connect: users.map((user) => ({ id: user.id })) } : undefined,