CAL-300 Ensure we show the default calendar name based in the advanced tab for event types. (#5551)

This commit is contained in:
Jeroen Reumkens
2022-11-16 20:03:19 +00:00
committed by GitHub
parent fac0b0fa32
commit 112efbbda2
2 changed files with 8 additions and 1 deletions
@@ -74,6 +74,7 @@ export const EventAdvancedTab = ({ eventType, team }: Pick<EventTypeSetupInfered
defaultValue={eventType.destinationCalendar || undefined}
render={({ field: { onChange, value } }) => (
<DestinationCalendarSelector
destinationCalendar={eventType.destinationCalendar}
value={value ? value.externalId : undefined}
onChange={onChange}
hidePlaceholder
@@ -115,6 +115,11 @@ const DestinationCalendarSelector = ({
value: `${cal.integration}:${cal.externalId}`,
})),
})) ?? [];
// Get primary calendar, which is shown in the placeholder since this is the calendar that will
// be used when no destination calendar is selected.
const primaryCalendar = query.data.connectedCalendars.filter((cal) => Boolean(cal.primary))[0];
return (
<div className="relative" title={`${t("select_destination_calendar")}: ${selectedOption?.label || ""}`}>
<Select
@@ -124,7 +129,8 @@ const DestinationCalendarSelector = ({
`${t("select_destination_calendar")}`
) : (
<span>
{t("default_calendar_selected")} ({destinationCalendar?.externalId})
{t("default_calendar_selected")}{" "}
{primaryCalendar?.primary?.externalId && `(${primaryCalendar?.primary?.externalId})`}
</span>
)
}