chore: Disables syncing of calendarList on overlay calendar fetch (#27020)
* chore: Disables syncing of calendarList on overlay calendar fetch * Unwrap ToggledConnectedCalendars * Pick the right type for connectedCalendars * further type amends * Type fixes, tons of em * Some further fixups consistent with what was before * fix: resolve type incompatibility in getConnectedDestinationCalendars return type Co-Authored-By: [email protected] <[email protected]> * fix: update DestinationCalendarProps to accept tRPC handler return type Co-Authored-By: [email protected] <[email protected]> * fix: use generic type for DestinationCalendarProps to accept tRPC enriched types Co-Authored-By: [email protected] <[email protected]> * fix: simplify DestinationCalendarProps type for better compatibility Co-Authored-By: [email protected] <[email protected]> * fix: export ConnectedCalendar type for consistent type inference Co-Authored-By: [email protected] <[email protected]> * fix: use permissive type for connectedCalendars to accept tRPC enriched types Co-Authored-By: [email protected] <[email protected]> * fix: export ConnectedCalendar and ConnectedDestinationCalendars types from platform-libraries Co-Authored-By: [email protected] <[email protected]> * fix: update ConnectedCalendar type to use boolean | null for primary field Co-Authored-By: [email protected] <[email protected]> * Update ConnectedCalendarItem * Undo some of Devins fixes, more fixes * Fixup the destination calendar return type, historically not null * Change init to undefined to deal with null * Approach to connect selected calendars with the right credential * This return type is used way too much everywhere, not refactoring * Add the selectedCalendars to the type * Actually fix overlay calendar * set calendarsToLoad param as required * Apply suggestion from @cubic-dev-ai[bot] Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com> * Add new translation for 'Calendar Settings' --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
This commit is contained in:
22 files changed
+486
-428
No files matched your search
@@ -1,15 +1,15 @@
|
||||
"use client";
|
||||
|
||||
import { useState, useEffect, useMemo } from "react";
|
||||
|
||||
import { SingleValueComponent } from "@calcom/features/calendars/DestinationCalendarSelector";
|
||||
import { OptionComponent } from "@calcom/features/calendars/DestinationCalendarSelector";
|
||||
import {
|
||||
OptionComponent,
|
||||
SingleValueComponent,
|
||||
} from "@calcom/features/calendars/DestinationCalendarSelector";
|
||||
import type { ConnectedDestinationCalendars } from "@calcom/features/calendars/lib/getConnectedDestinationCalendars";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import classNames from "@calcom/ui/classNames";
|
||||
import { Badge } from "@calcom/ui/components/badge";
|
||||
import { Select } from "@calcom/ui/components/form";
|
||||
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import { getPlaceholderContent } from "../lib/getPlaceholderContent";
|
||||
|
||||
export type DestinationCalendarProps = {
|
||||
@@ -43,8 +43,7 @@ export const DestinationCalendarSelector = ({
|
||||
|
||||
useEffect(() => {
|
||||
const selected = connectedCalendars
|
||||
.map((connected) => connected.calendars ?? [])
|
||||
.flat()
|
||||
.flatMap((connected) => connected.calendars ?? [])
|
||||
.find((cal) => cal.externalId === value);
|
||||
|
||||
if (selected) {
|
||||
@@ -52,15 +51,16 @@ export const DestinationCalendarSelector = ({
|
||||
integration.calendars?.some((calendar) => calendar.externalId === selected.externalId)
|
||||
);
|
||||
|
||||
const label = selected.name ? `${selected.name} ` : "";
|
||||
setSelectedOption({
|
||||
value: `${selected.integration}:${selected.externalId}`,
|
||||
label: selected.name ? `${selected.name} ` : "",
|
||||
label,
|
||||
subtitle: `(${selectedIntegration?.integration.title?.replace(/calendar/i, "")} - ${
|
||||
selectedIntegration?.primary?.name
|
||||
})`,
|
||||
});
|
||||
}
|
||||
}, [connectedCalendars]);
|
||||
}, [connectedCalendars, value]);
|
||||
|
||||
const options = useMemo(() => {
|
||||
return (
|
||||
@@ -95,8 +95,8 @@ export const DestinationCalendarSelector = ({
|
||||
!hidePlaceholder ? (
|
||||
`${t("create_events_on")}`
|
||||
) : (
|
||||
<span className="text-default min-w-0 overflow-hidden truncate whitespace-nowrap">
|
||||
<Badge variant="blue">Default</Badge>{" "}
|
||||
<span className="min-w-0 overflow-hidden truncate whitespace-nowrap text-default">
|
||||
<Badge variant="blue">{t("default")}</Badge>{" "}
|
||||
{destinationCalendar?.primaryEmail &&
|
||||
`${destinationCalendar.name} (${destinationCalendar?.integrationTitle} - ${destinationCalendar.primaryEmail})`}
|
||||
</span>
|
||||
@@ -119,7 +119,7 @@ export const DestinationCalendarSelector = ({
|
||||
}}
|
||||
isSearchable={false}
|
||||
className={classNames(
|
||||
"border-default my-2 block w-full min-w-0 flex-1 rounded-none rounded-r-sm text-sm"
|
||||
"my-2 block w-full min-w-0 flex-1 rounded-none rounded-r-sm border-default text-sm"
|
||||
)}
|
||||
onChange={(newValue) => {
|
||||
setSelectedOption(newValue);
|
||||
|
||||
@@ -51,7 +51,9 @@ export type {
|
||||
} from "@calcom/features/bookings/types";
|
||||
|
||||
export { getBusyCalendarTimes } from "@calcom/features/calendars/lib/CalendarManager";
|
||||
export type { ConnectedCalendar } from "@calcom/features/calendars/lib/CalendarManager";
|
||||
export { getConnectedDestinationCalendarsAndEnsureDefaultsInDb } from "@calcom/features/calendars/lib/getConnectedDestinationCalendars";
|
||||
export type { ConnectedDestinationCalendars } from "@calcom/features/calendars/lib/getConnectedDestinationCalendars";
|
||||
export type { CityTimezones } from "@calcom/features/cityTimezones/cityTimezonesHandler";
|
||||
|
||||
export { cityTimezonesHandler } from "@calcom/features/cityTimezones/cityTimezonesHandler";
|
||||
|
||||
Reference in new issue
Block a user