diff --git a/apps/web/components/booking/BookingListItem.tsx b/apps/web/components/booking/BookingListItem.tsx
index 5eef3d21a5..30dee6737b 100644
--- a/apps/web/components/booking/BookingListItem.tsx
+++ b/apps/web/components/booking/BookingListItem.tsx
@@ -366,7 +366,7 @@ function BookingListItem(booking: BookingItemProps) {
)}
-
+ |
{isUpcoming && !isCancelled ? (
<>
{isPending && user?.id === booking.user?.id && }
diff --git a/apps/web/pages/api/availability/calendar.ts b/apps/web/pages/api/availability/calendar.ts
index 94a5309090..87d45f2630 100644
--- a/apps/web/pages/api/availability/calendar.ts
+++ b/apps/web/pages/api/availability/calendar.ts
@@ -76,7 +76,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
});
// get user's credentials + their connected integrations
- const calendarCredentials = getCalendarCredentials(user.credentials, user.id);
+ const calendarCredentials = getCalendarCredentials(user.credentials);
// get all the connected integrations' calendars (from third party)
const connectedCalendars = await getConnectedCalendars(calendarCredentials, user.selectedCalendars);
const calendars = connectedCalendars.flatMap((c) => c.calendars).filter(notEmpty);
diff --git a/packages/core/CalendarManager.ts b/packages/core/CalendarManager.ts
index b31ad46d4e..e4db1f9b81 100644
--- a/packages/core/CalendarManager.ts
+++ b/packages/core/CalendarManager.ts
@@ -5,9 +5,7 @@ import cache from "memory-cache";
import { getCalendar } from "@calcom/app-store/_utils/getCalendar";
import getApps from "@calcom/app-store/utils";
-import { sendBrokenIntegrationEmail } from "@calcom/emails";
import { getUid } from "@calcom/lib/CalEventParser";
-import { getErrorFromUnknown } from "@calcom/lib/errors";
import logger from "@calcom/lib/logger";
import { performance } from "@calcom/lib/server/perfObserver";
import type { CalendarEvent, EventBusyDate, NewCalendarEventType } from "@calcom/types/Calendar";
@@ -15,13 +13,13 @@ import type { EventResult } from "@calcom/types/EventManager";
const log = logger.getChildLogger({ prefix: ["CalendarManager"] });
-export const getCalendarCredentials = (credentials: Array, userId: number) => {
+export const getCalendarCredentials = (credentials: Array) => {
const calendarCredentials = getApps(credentials)
.filter((app) => app.type.endsWith("_calendar"))
.flatMap((app) => {
const credentials = app.credentials.flatMap((credential) => {
const calendar = getCalendar(credential);
- return [{ integration: app, credential, calendar }];
+ return app.variant === "calendar" ? [{ integration: app, credential, calendar }] : [];
});
return credentials.length ? credentials : [];
});
@@ -54,9 +52,15 @@ export const getConnectedCalendars = async (
}))
.sortBy(["primary"])
.value();
- const primary = calendars.find((item) => item.primary) ?? calendars[0];
+ const primary = calendars.find((item) => item.primary) ?? calendars.find((cal) => cal !== undefined);
if (!primary) {
- throw new Error("No primary calendar found");
+ return {
+ integration,
+ credentialId,
+ error: {
+ message: "No primary calendar found",
+ },
+ };
}
return {
integration,
diff --git a/packages/trpc/server/routers/viewer.tsx b/packages/trpc/server/routers/viewer.tsx
index b966364490..3271a6d5cd 100644
--- a/packages/trpc/server/routers/viewer.tsx
+++ b/packages/trpc/server/routers/viewer.tsx
@@ -625,7 +625,7 @@ const loggedInViewerRouter = createProtectedRouter()
async resolve({ ctx }) {
const { user } = ctx;
// get user's credentials + their connected integrations
- const calendarCredentials = getCalendarCredentials(user.credentials, user.id);
+ const calendarCredentials = getCalendarCredentials(user.credentials);
// get all the connected integrations' calendars (from third party)
const connectedCalendars = await getConnectedCalendars(calendarCredentials, user.selectedCalendars);
@@ -691,7 +691,7 @@ const loggedInViewerRouter = createProtectedRouter()
async resolve({ ctx, input }) {
const { user } = ctx;
const { integration, externalId, eventTypeId } = input;
- const calendarCredentials = getCalendarCredentials(user.credentials, user.id);
+ const calendarCredentials = getCalendarCredentials(user.credentials);
const connectedCalendars = await getConnectedCalendars(calendarCredentials, user.selectedCalendars);
const allCals = connectedCalendars.map((cal) => cal.calendars ?? []).flat();
|