From caf7943c91eae8ce7e87d94a17d63ee403d0e2e1 Mon Sep 17 00:00:00 2001 From: Amit Sharma <74371312+Amit91848@users.noreply.github.com> Date: Wed, 10 Jul 2024 16:30:59 +0530 Subject: [PATCH] fix: set conferencing apps as default (#15376) * fix: set conferencing apps as default * fix in other oauth conferencing apps * creating default event-types should set the user's default location * Update getDefaultLocations.ts * fix: unit test * default install only for first oauth app * fix: type-check * update default on success * fix: pass callback prop * chore: code cleanup * Fix condition * no longer needed - as we reverted https://github.com/calcom/cal.com/commit/20fdb50081ae684723a5af78436068c0b09509a4 --------- Co-authored-by: Somay Chauhan Co-authored-by: Hariom --- .../components/AppConnectionItem.tsx | 18 +++++++++++++--- .../steps-views/ConnectedVideoStep.tsx | 11 ++++++++++ .../app-store/_utils/useAddAppMutation.ts | 2 +- packages/app-store/components.tsx | 4 +++- .../server/routers/viewer/apps/_router.tsx | 21 +++++++++++++++++++ .../apps/setDefaultConferencingApp.handler.ts | 15 +++++++++++++ .../apps/setDefaultConferencingApp.schema.ts | 7 +++++++ 7 files changed, 73 insertions(+), 5 deletions(-) create mode 100644 packages/trpc/server/routers/viewer/apps/setDefaultConferencingApp.handler.ts create mode 100644 packages/trpc/server/routers/viewer/apps/setDefaultConferencingApp.schema.ts diff --git a/apps/web/components/getting-started/components/AppConnectionItem.tsx b/apps/web/components/getting-started/components/AppConnectionItem.tsx index 579a52a2a2..895eb0e36d 100644 --- a/apps/web/components/getting-started/components/AppConnectionItem.tsx +++ b/apps/web/components/getting-started/components/AppConnectionItem.tsx @@ -4,9 +4,9 @@ import type { TDependencyData } from "@calcom/app-store/_appRegistry"; import { InstallAppButtonWithoutPlanCheck } from "@calcom/app-store/components"; import { WEBAPP_URL } from "@calcom/lib/constants"; import { useLocale } from "@calcom/lib/hooks/useLocale"; +import { trpc } from "@calcom/trpc/react"; import type { App } from "@calcom/types/App"; -import { Icon } from "@calcom/ui"; -import { Button } from "@calcom/ui"; +import { Badge, Button, Icon } from "@calcom/ui"; interface IAppConnectionItem { title: string; @@ -14,21 +14,33 @@ interface IAppConnectionItem { logo: string; type: App["type"]; installed?: boolean; + isDefault?: boolean; + defaultInstall?: boolean; + slug?: string; dependencyData?: TDependencyData; } const AppConnectionItem = (props: IAppConnectionItem) => { - const { title, logo, type, installed } = props; + const { title, logo, type, installed, isDefault, defaultInstall, slug } = props; const { t } = useLocale(); + const setDefaultConferencingApp = trpc.viewer.appsRouter.setDefaultConferencingApp.useMutation(); const dependency = props.dependencyData?.find((data) => !data.installed); return (
{title}

{title}

+ {isDefault && {t("default")}}
{ + if (defaultInstall && slug) { + setDefaultConferencingApp.mutate({ slug }); + } + }, + }} render={(buttonProps) => (