fix: prevent overwriting existing event type values with undefined (#25624)
When updating an event type, fields like autoTranslateDescriptionEnabled and disableGuests were being overwritten with false/default values even when they weren't explicitly provided in the update request. Changes: - autoTranslateDescriptionEnabled: Only set when explicitly provided (not undefined) to avoid overwriting existing true values with false - disableGuests: Only set when bookingFields is explicitly provided, since it's derived from the guests field in bookingFields Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
parent
908128ca5d
commit
dc44825ce5
@@ -232,7 +232,10 @@ export const updateHandler = async ({ ctx, input }: UpdateOptions) => {
|
||||
const data: Prisma.EventTypeUpdateInput = {
|
||||
...rest,
|
||||
// autoTranslate feature is allowed for org users only
|
||||
autoTranslateDescriptionEnabled: !!(ctx.user.organizationId && autoTranslateDescriptionEnabled),
|
||||
// Only set if explicitly provided to avoid overwriting existing value with false
|
||||
...(autoTranslateDescriptionEnabled !== undefined && {
|
||||
autoTranslateDescriptionEnabled: Boolean(ctx.user.organizationId && autoTranslateDescriptionEnabled),
|
||||
}),
|
||||
description: newDescription,
|
||||
title: newTitle,
|
||||
bookingFields,
|
||||
@@ -242,7 +245,10 @@ export const updateHandler = async ({ ctx, input }: UpdateOptions) => {
|
||||
rest.rrSegmentQueryValue === null ? Prisma.DbNull : (rest.rrSegmentQueryValue as Prisma.InputJsonValue),
|
||||
metadata: rest.metadata === null ? Prisma.DbNull : (rest.metadata as Prisma.InputJsonObject),
|
||||
eventTypeColor: eventTypeColor === null ? Prisma.DbNull : (eventTypeColor as Prisma.InputJsonObject),
|
||||
disableGuests: guestsField?.hidden ?? false,
|
||||
// Only set disableGuests if bookingFields is explicitly provided to avoid overwriting existing value
|
||||
...(bookingFields !== undefined && {
|
||||
disableGuests: guestsField?.hidden ?? false,
|
||||
}),
|
||||
seatsPerTimeSlot,
|
||||
maxLeadThreshold: isLoadBalancingDisabled ? null : rest.maxLeadThreshold,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user