Fixes availability to reset to default on save non-team (#5710)

pull/5775/head
Alex van Andel 2022-11-29 09:36:05 +00:00 committed by GitHub
parent 74aa366f1e
commit d44c5fd8b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 11 deletions

View File

@ -150,6 +150,21 @@ const EventTypePage = (props: inferSSRProps<typeof getServerSideProps>) => {
endDate: new Date(eventType.periodEndDate || Date.now()),
});
const metadata = eventType.metadata;
// fallback to !!eventType.schedule when 'useHostSchedulesForTeamEvent' is undefined
if (!!team) {
metadata.config = {
...metadata.config,
useHostSchedulesForTeamEvent:
typeof eventType.metadata.config?.useHostSchedulesForTeamEvent !== "undefined"
? eventType.metadata.config?.useHostSchedulesForTeamEvent === true
: !!eventType.schedule,
};
} else {
// Make sure non-team events NEVER have this config key;
delete metadata.config?.useHostSchedulesForTeamEvent;
}
const formMethods = useForm<FormValues>({
defaultValues: {
title: eventType.title,
@ -172,17 +187,7 @@ const EventTypePage = (props: inferSSRProps<typeof getServerSideProps>) => {
findDurationType(eventType.minimumBookingNotice),
eventType.minimumBookingNotice
),
// fallback to !!eventType.schedule when 'useHostSchedulesForTeamEvent' is undefined
metadata: {
...eventType.metadata,
config: {
...eventType.metadata.config,
useHostSchedulesForTeamEvent:
typeof eventType.metadata.config?.useHostSchedulesForTeamEvent !== "undefined"
? eventType.metadata.config?.useHostSchedulesForTeamEvent === true
: !!eventType.schedule,
},
},
metadata,
},
});