Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add destination calendar name to DestinationCalendarSelector #6701

Merged
merged 7 commits into from
Feb 27, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'main' into add-destination-calendar-name
  • Loading branch information
joeauyeung committed Feb 23, 2023
commit 50750d6419a21bb4be6510b648f761f68699bcf1
12 changes: 7 additions & 5 deletions packages/features/calendars/DestinationCalendarSelector.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import classNames from "classnames";
import { useEffect, useState } from "react";
import { components, OptionProps, SingleValueProps } from "react-select";
import type { OptionProps, SingleValueProps } from "react-select";
import { components } from "react-select";

import { useLocale } from "@calcom/lib/hooks/useLocale";
import { DestinationCalendar } from "@calcom/prisma/client";
import type { DestinationCalendar } from "@calcom/prisma/client";
import { trpc } from "@calcom/trpc/react";
import { Select } from "@calcom/ui";

Expand Down Expand Up @@ -131,9 +132,10 @@ const DestinationCalendarSelector = ({
!hidePlaceholder ? (
`${t("select_destination_calendar")}`
) : (
<span>
{t("default_calendar_selected")} {primaryCalendar && `(${primaryCalendar})`}
{`(${query.data.destinationCalendar.name || primaryCalendar?.primary?.externalId})`}
<span className="min-w-0 overflow-hidden truncate whitespace-nowrap">
{t("default_calendar_selected")}{" "}
{queryDestinationCalendar.name &&
`(${queryDestinationCalendar?.integration} - ${queryDestinationCalendar.name})`}
</span>
)
}
Expand Down
16 changes: 16 additions & 0 deletions packages/features/tips/Tips.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,22 @@ export const tips = [
description: "Make time work for you and automate tasks",
href: "https://go.cal.com/workflows",
},
{
id: 9,
thumbnailUrl: "https://img.youtube.com/vi/93iOmzHieCU/0.jpg",
mediaLink: "https://go.cal.com/round-robin",
title: "Round-Robin",
description: "Create advanced group meetings with round-robin",
href: "https://go.cal.com/round-robin",
},
{
id: 10,
thumbnailUrl: "https://img.youtube.com/vi/jvaBafzVUQc/0.jpg",
mediaLink: "https://go.cal.com/video",
title: "Cal Video",
description: "Free video conferencing with recording",
href: "https://go.cal.com/video",
},
];

export default function Tips() {
Expand Down
25 changes: 15 additions & 10 deletions packages/trpc/server/routers/viewer.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { AppCategories, BookingStatus, DestinationCalendar, IdentityProvider, Prisma } from "@prisma/client";
import type { DestinationCalendar, Prisma } from "@prisma/client";
import { AppCategories, BookingStatus, IdentityProvider } from "@prisma/client";
import _ from "lodash";
import { authenticator } from "otplib";
import z from "zod";
Expand Down Expand Up @@ -374,24 +375,28 @@ const loggedInViewerRouter = router({
destinationCalendarEmail = destinationCal?.email ?? user.destinationCalendar?.externalId;
}

let destinationCalendarName = undefined;
let destinationCalendarName = user.destinationCalendar?.externalId || "";
let destinationCalendarIntegration = "";

for (const integration of connectedCalendars) {
if (integration?.calendars && integration.credentialId === user.destinationCalendar?.credentialId) {
for (const calendar of integration?.calendars) {
if (calendar.externalId === user.destinationCalendar?.externalId)
destinationCalendarName = calendar.name;
if (integration.calendars) {
for (const calendar of integration.calendars) {
if (calendar.externalId === user.destinationCalendar?.externalId) {
destinationCalendarName = calendar.name || calendar.externalId;
destinationCalendarIntegration = integration.integration.title || "";
break;
}
}
}
}

return {
connectedCalendars,
// destinationCalendar: user.destinationCalendar,
destinationCalendar: {
...user.destinationCalendar,
...(destinationCalendarName && { name: destinationCalendarName }),
} as DestinationCalendar & { name?: string | undefined },
...(user.destinationCalendar as DestinationCalendar),
name: destinationCalendarName,
integration: destinationCalendarIntegration,
},
destinationCalendarEmail,
};
}),
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.