Fix: EventType Duplication (#6778)

pull/6791/head
Hariom Balhara 2023-01-30 17:25:08 +05:30 committed by GitHub
parent 6c23813192
commit 8cf0050d1f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 1 deletions

View File

@ -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,