feat: conferencing atoms (#17988)
* added api/v2 for zoom connect * Update conferencing.controller.ts * fix: added api for ConferencingAppsViewPlatformWrapper * type fixes * added getBulkEventTypes api for bulk-update default location * added bulk-update-to-default-location * fix:bulk-update-to-default-location * invalidated * fixed returnTo and onErrorReturnTo * make logos work for conferencing atoms * smalll improvements * fixup * share common types * type fix, and fixed a typo * fix: type-error * fix: json.parse(json.parse()) * fix: invalidate query * fix: removing app throws error in the main app * undo platform-libraries-1.2.3 * update platform-libraries version --------- Co-authored-by: Morgan <[email protected]>
This commit is contained in:
1 parent
44115ac7fa
commit
063400fcbc
54 files changed
+1898
-413
No files matched your search
@@ -5,7 +5,10 @@ import { useMemo, useState } from "react";
|
||||
import { Controller, useFieldArray, useForm, useWatch } from "react-hook-form";
|
||||
|
||||
import dayjs from "@calcom/dayjs";
|
||||
import type { BulkUpdatParams } from "@calcom/features/eventtypes/components/BulkEditDefaultForEventsModal";
|
||||
import type {
|
||||
BulkUpdatParams,
|
||||
EventTypes,
|
||||
} from "@calcom/features/eventtypes/components/BulkEditDefaultForEventsModal";
|
||||
import { BulkEditDefaultForEventsModal } from "@calcom/features/eventtypes/components/BulkEditDefaultForEventsModal";
|
||||
import { DateOverrideInputDialog, DateOverrideList } from "@calcom/features/schedules";
|
||||
import WebSchedule, {
|
||||
@@ -109,6 +112,9 @@ type AvailabilitySettingsProps = {
|
||||
setIsOpen: Dispatch<SetStateAction<boolean>>;
|
||||
save: (params: BulkUpdatParams) => void;
|
||||
isSaving: boolean;
|
||||
eventTypes?: EventTypes;
|
||||
isEventTypesFetching?: boolean;
|
||||
handleBulkEditDialogToggle: () => void;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -365,6 +371,9 @@ export function AvailabilitySettings({
|
||||
setOpen={bulkUpdateModalProps.setIsOpen}
|
||||
bulkUpdateFunction={bulkUpdateModalProps?.save}
|
||||
description={t("default_schedules_bulk_description")}
|
||||
eventTypes={bulkUpdateModalProps?.eventTypes}
|
||||
isEventTypesFetching={bulkUpdateModalProps?.isEventTypesFetching}
|
||||
handleBulkEditDialogToggle={bulkUpdateModalProps.handleBulkEditDialogToggle}
|
||||
/>
|
||||
)}
|
||||
|
||||
|
||||
+264
@@ -0,0 +1,264 @@
|
||||
"use client";
|
||||
|
||||
import { useQueryClient } from "@tanstack/react-query";
|
||||
import { useReducer } from "react";
|
||||
|
||||
import { AppList } from "@calcom/features/apps/components/AppList";
|
||||
import DisconnectIntegrationModal from "@calcom/features/apps/components/DisconnectIntegrationModal";
|
||||
import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { GOOGLE_MEET, ZOOM } from "@calcom/platform-constants";
|
||||
import { QueryCell } from "@calcom/trpc/components/QueryCell";
|
||||
import type { App } from "@calcom/types/App";
|
||||
import {
|
||||
Button,
|
||||
SkeletonContainer,
|
||||
SkeletonText,
|
||||
Dropdown,
|
||||
DropdownMenuTrigger,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuItem,
|
||||
DropdownItem,
|
||||
EmptyScreen,
|
||||
} from "@calcom/ui";
|
||||
|
||||
import { AtomsWrapper } from "../../src/components/atoms-wrapper";
|
||||
import { useToast } from "../../src/components/ui/use-toast";
|
||||
import type {
|
||||
BulkUpdatParams,
|
||||
UpdateUsersDefaultConferencingAppParams,
|
||||
} from "./ConferencingAppsViewWebWrapper";
|
||||
import { useAtomBulkUpdateEventTypesToDefaultLocation } from "./hooks/useAtomBulkUpdateEventTypesToDefaultLocation";
|
||||
import { useAtomGetEventTypes } from "./hooks/useAtomGetEventTypes";
|
||||
import {
|
||||
useAtomsGetInstalledConferencingApps,
|
||||
QUERY_KEY as atomsConferencingAppsQueryKey,
|
||||
} from "./hooks/useAtomsGetInstalledConferencingApps";
|
||||
import { useConnect } from "./hooks/useConnect";
|
||||
import { useDeleteCredential } from "./hooks/useDeleteCredential";
|
||||
import {
|
||||
useGetDefaultConferencingApp,
|
||||
QUERY_KEY as defaultConferencingAppQueryKey,
|
||||
} from "./hooks/useGetDefaultConferencingApp";
|
||||
import { useUpdateUserDefaultConferencingApp } from "./hooks/useUpdateUserDefaultConferencingApp";
|
||||
|
||||
type ConferencingAppsViewPlatformWrapperProps = {
|
||||
disableToasts?: boolean;
|
||||
returnTo?: string;
|
||||
onErrorReturnTo?: string;
|
||||
};
|
||||
|
||||
type RemoveAppParams = { callback: () => void; app?: App["slug"] };
|
||||
|
||||
const SkeletonLoader = () => {
|
||||
return (
|
||||
<SkeletonContainer>
|
||||
<div className="divide-subtle border-subtle space-y-6 rounded-b-lg border border-t-0 px-6 py-4">
|
||||
<SkeletonText className="h-8 w-full" />
|
||||
<SkeletonText className="h-8 w-full" />
|
||||
</div>
|
||||
</SkeletonContainer>
|
||||
);
|
||||
};
|
||||
|
||||
type ModalState = {
|
||||
isOpen: boolean;
|
||||
credentialId: null | number;
|
||||
app: App["slug"] | null;
|
||||
};
|
||||
|
||||
export const ConferencingAppsViewPlatformWrapper = ({
|
||||
disableToasts = false,
|
||||
returnTo,
|
||||
onErrorReturnTo,
|
||||
}: ConferencingAppsViewPlatformWrapperProps) => {
|
||||
const { t } = useLocale();
|
||||
const queryClient = useQueryClient();
|
||||
const { toast } = useToast();
|
||||
|
||||
const showToast = (message: string, variant: "success" | "warning" | "error") => {
|
||||
if (!disableToasts) {
|
||||
toast({ description: message });
|
||||
}
|
||||
};
|
||||
|
||||
const [modal, updateModal] = useReducer(
|
||||
(data: ModalState, partialData: Partial<ModalState>) => ({ ...data, ...partialData }),
|
||||
{
|
||||
isOpen: false,
|
||||
credentialId: null,
|
||||
app: null,
|
||||
}
|
||||
);
|
||||
|
||||
const handleModelClose = () => {
|
||||
updateModal({ isOpen: false, credentialId: null, app: null });
|
||||
};
|
||||
|
||||
const handleDisconnect = (credentialId: number, app: App["slug"]) => {
|
||||
updateModal({ isOpen: true, credentialId, app });
|
||||
};
|
||||
|
||||
const installedIntegrationsQuery = useAtomsGetInstalledConferencingApps();
|
||||
const { data: defaultConferencingApp } = useGetDefaultConferencingApp();
|
||||
const { data: eventTypesQuery, isFetching: isEventTypesFetching } = useAtomGetEventTypes();
|
||||
|
||||
const deleteCredentialMutation = useDeleteCredential({
|
||||
onSuccess: () => {
|
||||
showToast(t("app_removed_successfully"), "success");
|
||||
handleModelClose();
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: [atomsConferencingAppsQueryKey],
|
||||
});
|
||||
queryClient.resetQueries({
|
||||
queryKey: [defaultConferencingAppQueryKey],
|
||||
});
|
||||
},
|
||||
onError: () => {
|
||||
showToast(t("error_removing_app"), "error");
|
||||
handleModelClose();
|
||||
},
|
||||
});
|
||||
|
||||
const updateDefaultAppMutation = useUpdateUserDefaultConferencingApp({});
|
||||
|
||||
const bulkUpdateEventTypesToDefaultLocation = useAtomBulkUpdateEventTypesToDefaultLocation({});
|
||||
|
||||
const handleRemoveApp = ({ app }: RemoveAppParams) => {
|
||||
!!app && deleteCredentialMutation.mutate(app);
|
||||
};
|
||||
|
||||
const handleUpdateUserDefaultConferencingApp = ({
|
||||
appSlug,
|
||||
onSuccessCallback,
|
||||
onErrorCallback,
|
||||
}: UpdateUsersDefaultConferencingAppParams) => {
|
||||
updateDefaultAppMutation.mutate(appSlug, {
|
||||
onSuccess: () => {
|
||||
showToast("Default app updated successfully", "success");
|
||||
queryClient.invalidateQueries({ queryKey: [defaultConferencingAppQueryKey] });
|
||||
onSuccessCallback();
|
||||
},
|
||||
onError: (error) => {
|
||||
showToast(`Error: ${error.message}`, "error");
|
||||
onErrorCallback();
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
const handleBulkUpdateDefaultLocation = ({ eventTypeIds, callback }: BulkUpdatParams) => {
|
||||
bulkUpdateEventTypesToDefaultLocation.mutate(eventTypeIds, {
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: [defaultConferencingAppQueryKey] });
|
||||
callback();
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
const handleConnectDisconnectIntegrationMenuToggle = () => {
|
||||
queryClient.invalidateQueries({ queryKey: [atomsConferencingAppsQueryKey] });
|
||||
};
|
||||
|
||||
const handleBulkEditDialogToggle = () => {
|
||||
queryClient.invalidateQueries({ queryKey: [defaultConferencingAppQueryKey] });
|
||||
};
|
||||
|
||||
const { connect } = useConnect({
|
||||
onSuccess: () => {
|
||||
showToast("app installed successfully", "success");
|
||||
queryClient.invalidateQueries({ queryKey: [atomsConferencingAppsQueryKey] });
|
||||
},
|
||||
onError: () => {
|
||||
queryClient.invalidateQueries({ queryKey: [atomsConferencingAppsQueryKey] });
|
||||
showToast(`Error: unable to install app`, "error");
|
||||
},
|
||||
returnTo,
|
||||
onErrorReturnTo,
|
||||
});
|
||||
|
||||
const AddConferencingButtonPlatform = ({ installedApps }: { installedApps?: Array<{ slug: string }> }) => {
|
||||
return (
|
||||
<Dropdown>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button color="secondary" StartIcon="plus">
|
||||
{t("add")}
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent>
|
||||
{installedApps && !installedApps.find((app) => app.slug == GOOGLE_MEET) && (
|
||||
<DropdownMenuItem>
|
||||
<DropdownItem color="secondary" onClick={() => connect(GOOGLE_MEET)}>
|
||||
{t("google_meet")}
|
||||
</DropdownItem>
|
||||
</DropdownMenuItem>
|
||||
)}
|
||||
{installedApps && !installedApps?.find((app) => app.slug == ZOOM) && (
|
||||
<DropdownMenuItem>
|
||||
<DropdownItem color="secondary" onClick={() => connect(ZOOM)}>
|
||||
{t("zoom")}
|
||||
</DropdownItem>
|
||||
</DropdownMenuItem>
|
||||
)}
|
||||
</DropdownMenuContent>
|
||||
</Dropdown>
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<AtomsWrapper>
|
||||
<SettingsHeader
|
||||
title={t("conferencing")}
|
||||
description={t("conferencing_description")}
|
||||
CTA={<AddConferencingButtonPlatform installedApps={installedIntegrationsQuery.data?.items} />}
|
||||
borderInShellHeader={true}>
|
||||
<>
|
||||
<div className="bg-default w-full sm:mx-0 xl:mt-0">
|
||||
<QueryCell
|
||||
query={installedIntegrationsQuery}
|
||||
customLoader={<SkeletonLoader />}
|
||||
success={({ data }) => {
|
||||
if (!data.items.length) {
|
||||
return (
|
||||
<EmptyScreen
|
||||
Icon="calendar"
|
||||
headline={t("no_category_apps", {
|
||||
category: t("conferencing").toLowerCase(),
|
||||
})}
|
||||
description={t("no_category_apps_description_conferencing")}
|
||||
buttonRaw={<AddConferencingButtonPlatform installedApps={data?.items} />}
|
||||
/>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<AppList
|
||||
listClassName="rounded-lg rounded-t-none border-t-0 max-w-full"
|
||||
handleDisconnect={handleDisconnect}
|
||||
data={data}
|
||||
variant="conferencing"
|
||||
defaultConferencingApp={defaultConferencingApp}
|
||||
handleUpdateUserDefaultConferencingApp={handleUpdateUserDefaultConferencingApp}
|
||||
handleBulkUpdateDefaultLocation={handleBulkUpdateDefaultLocation}
|
||||
isBulkUpdateDefaultLocationPending={bulkUpdateEventTypesToDefaultLocation?.isPending}
|
||||
eventTypes={eventTypesQuery?.eventTypes}
|
||||
isEventTypesFetching={isEventTypesFetching}
|
||||
handleConnectDisconnectIntegrationMenuToggle={
|
||||
handleConnectDisconnectIntegrationMenuToggle
|
||||
}
|
||||
handleBulkEditDialogToggle={handleBulkEditDialogToggle}
|
||||
/>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
<DisconnectIntegrationModal
|
||||
handleModelClose={handleModelClose}
|
||||
isOpen={modal.isOpen}
|
||||
credentialId={modal.credentialId}
|
||||
app={modal.app}
|
||||
handleRemoveApp={handleRemoveApp}
|
||||
/>
|
||||
</>
|
||||
</SettingsHeader>
|
||||
</AtomsWrapper>
|
||||
);
|
||||
};
|
||||
+33
-6
@@ -16,8 +16,14 @@ type ConferencingAppsViewWebWrapperProps = {
|
||||
add: string;
|
||||
};
|
||||
|
||||
type UpdateDefaultConferencingAppParams = { appSlug: string; callback: () => void };
|
||||
type BulkUpdatParams = { eventTypeIds: number[]; callback: () => void };
|
||||
export type UpdateUsersDefaultConferencingAppParams = {
|
||||
appSlug: string;
|
||||
appLink?: string;
|
||||
onSuccessCallback: () => void;
|
||||
onErrorCallback: () => void;
|
||||
};
|
||||
|
||||
export type BulkUpdatParams = { eventTypeIds: number[]; callback: () => void };
|
||||
type RemoveAppParams = { credentialId: number; teamId?: number; callback: () => void };
|
||||
|
||||
const SkeletonLoader = () => {
|
||||
@@ -73,6 +79,9 @@ export const ConferencingAppsViewWebWrapper = ({
|
||||
|
||||
const updateLocationsMutation = trpc.viewer.eventTypes.bulkUpdateToDefaultLocation.useMutation();
|
||||
|
||||
const { data: eventTypesQueryData, isFetching: isEventTypesFetching } =
|
||||
trpc.viewer.eventTypes.bulkEventFetch.useQuery();
|
||||
|
||||
const handleRemoveApp = ({ credentialId, teamId, callback }: RemoveAppParams) => {
|
||||
deleteCredentialMutation.mutate(
|
||||
{ id: credentialId, teamId },
|
||||
@@ -91,17 +100,31 @@ export const ConferencingAppsViewWebWrapper = ({
|
||||
);
|
||||
};
|
||||
|
||||
const handleUpdateDefaultConferencingApp = ({ appSlug, callback }: UpdateDefaultConferencingAppParams) => {
|
||||
const handleConnectDisconnectIntegrationMenuToggle = () => {
|
||||
utils.viewer.integrations.invalidate();
|
||||
};
|
||||
|
||||
const handleBulkEditDialogToggle = () => {
|
||||
utils.viewer.getUsersDefaultConferencingApp.invalidate();
|
||||
};
|
||||
|
||||
const handleUpdateUserDefaultConferencingApp = ({
|
||||
appSlug,
|
||||
appLink,
|
||||
onSuccessCallback,
|
||||
onErrorCallback,
|
||||
}: UpdateUsersDefaultConferencingAppParams) => {
|
||||
updateDefaultAppMutation.mutate(
|
||||
{ appSlug },
|
||||
{ appSlug, appLink },
|
||||
{
|
||||
onSuccess: () => {
|
||||
showToast("Default app updated successfully", "success");
|
||||
utils.viewer.getUsersDefaultConferencingApp.invalidate();
|
||||
callback();
|
||||
onSuccessCallback();
|
||||
},
|
||||
onError: (error) => {
|
||||
showToast(`Error: ${error.message}`, "error");
|
||||
onErrorCallback();
|
||||
},
|
||||
}
|
||||
);
|
||||
@@ -167,9 +190,13 @@ export const ConferencingAppsViewWebWrapper = ({
|
||||
data={data}
|
||||
variant="conferencing"
|
||||
defaultConferencingApp={defaultConferencingApp}
|
||||
handleUpdateDefaultConferencingApp={handleUpdateDefaultConferencingApp}
|
||||
handleUpdateUserDefaultConferencingApp={handleUpdateUserDefaultConferencingApp}
|
||||
handleBulkUpdateDefaultLocation={handleBulkUpdateDefaultLocation}
|
||||
isBulkUpdateDefaultLocationPending={updateDefaultAppMutation.isPending}
|
||||
eventTypes={eventTypesQueryData?.eventTypes}
|
||||
isEventTypesFetching={isEventTypesFetching}
|
||||
handleConnectDisconnectIntegrationMenuToggle={handleConnectDisconnectIntegrationMenuToggle}
|
||||
handleBulkEditDialogToggle={handleBulkEditDialogToggle}
|
||||
/>
|
||||
);
|
||||
}}
|
||||
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
import { useMutation } from "@tanstack/react-query";
|
||||
|
||||
import { V2_ENDPOINTS, SUCCESS_STATUS } from "@calcom/platform-constants";
|
||||
import type { ApiSuccessResponse } from "@calcom/platform-types";
|
||||
import type { EventType } from "@calcom/prisma/client";
|
||||
|
||||
import http from "../../../lib/http";
|
||||
|
||||
export const QUERY_KEY = "bulk-update-event-types-to-default-location";
|
||||
|
||||
export type UseAtomBulkUpdateEventTypesToDefaultLocationProps = {
|
||||
onSuccess?: () => void;
|
||||
onError?: (err: Error) => void;
|
||||
onSettled?: () => void;
|
||||
};
|
||||
export const useAtomBulkUpdateEventTypesToDefaultLocation = ({
|
||||
onSuccess = () => {
|
||||
return;
|
||||
},
|
||||
onError = () => {
|
||||
return;
|
||||
},
|
||||
onSettled = () => {
|
||||
return;
|
||||
},
|
||||
}: UseAtomBulkUpdateEventTypesToDefaultLocationProps) => {
|
||||
return useMutation({
|
||||
onSuccess,
|
||||
onError,
|
||||
onSettled,
|
||||
mutationFn: (eventTypeIds: number[]) => {
|
||||
if (!eventTypeIds || eventTypeIds.length < 1) throw new Error("Event type ids are required");
|
||||
const pathname = `/atoms/${V2_ENDPOINTS.eventTypes}/bulk-update-to-default-location`;
|
||||
|
||||
return http?.patch(pathname, { eventTypeIds }).then((res) => {
|
||||
if (res.data.status === SUCCESS_STATUS) {
|
||||
return (res.data as ApiSuccessResponse<EventType>).data;
|
||||
}
|
||||
throw new Error(res.data.error.message);
|
||||
});
|
||||
},
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
|
||||
import { V2_ENDPOINTS, SUCCESS_STATUS } from "@calcom/platform-constants";
|
||||
import type { ApiResponse, ApiSuccessResponse } from "@calcom/platform-types";
|
||||
|
||||
import { useAtomsContext } from "../../../hooks/useAtomsContext";
|
||||
import http from "../../../lib/http";
|
||||
|
||||
export const QUERY_KEY = "use-get-event-types";
|
||||
|
||||
type ResponseEventType = { eventTypes: Array<{ id: number; title: string }> };
|
||||
|
||||
export const useAtomGetEventTypes = () => {
|
||||
const pathname = `/atoms/${V2_ENDPOINTS.eventTypes}/`;
|
||||
const { isInit, accessToken } = useAtomsContext();
|
||||
|
||||
return useQuery({
|
||||
queryKey: [QUERY_KEY],
|
||||
queryFn: () => {
|
||||
return http?.get<ApiResponse<ResponseEventType>>(pathname).then((res) => {
|
||||
if (res.data.status === SUCCESS_STATUS) {
|
||||
return (res.data as ApiSuccessResponse<ResponseEventType>).data;
|
||||
}
|
||||
throw new Error(res.data.error.message);
|
||||
});
|
||||
},
|
||||
enabled: isInit && !!accessToken,
|
||||
});
|
||||
};
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
|
||||
import { SUCCESS_STATUS } from "@calcom/platform-constants";
|
||||
import type { ConnectedApps } from "@calcom/platform-libraries";
|
||||
import type { ApiResponse, ApiSuccessResponse } from "@calcom/platform-types";
|
||||
|
||||
import { useAtomsContext } from "../../../hooks/useAtomsContext";
|
||||
import http from "../../../lib/http";
|
||||
|
||||
export const QUERY_KEY = "get-installed-conferencing-apps";
|
||||
|
||||
export const useAtomsGetInstalledConferencingApps = () => {
|
||||
const pathname = `/atoms/conferencing`;
|
||||
const { isInit, accessToken } = useAtomsContext();
|
||||
|
||||
return useQuery({
|
||||
queryKey: [QUERY_KEY],
|
||||
queryFn: () => {
|
||||
return http?.get<ApiResponse<ConnectedApps>>(pathname).then((res) => {
|
||||
if (res.data.status === SUCCESS_STATUS) {
|
||||
return (res.data as ApiSuccessResponse<ConnectedApps>).data;
|
||||
}
|
||||
throw new Error(res.data.error.message);
|
||||
});
|
||||
},
|
||||
enabled: isInit && !!accessToken,
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,93 @@
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { useMutation } from "@tanstack/react-query";
|
||||
|
||||
import { SUCCESS_STATUS, ERROR_STATUS, ZOOM, GOOGLE_MEET } from "@calcom/platform-constants";
|
||||
import type { ApiErrorResponse, ApiResponse } from "@calcom/platform-types";
|
||||
import type { App } from "@calcom/types/App";
|
||||
|
||||
import http from "../../../lib/http";
|
||||
|
||||
export type UseGetOauthAuthUrlProps = {
|
||||
returnTo?: string;
|
||||
onErrorReturnTo?: string;
|
||||
};
|
||||
|
||||
export const useGetOauthAuthUrl = ({ returnTo, onErrorReturnTo }: UseGetOauthAuthUrlProps) => {
|
||||
return useQuery({
|
||||
queryKey: ["get-zoom-auth-url"],
|
||||
staleTime: Infinity,
|
||||
enabled: false,
|
||||
queryFn: () => {
|
||||
return http
|
||||
?.get<ApiResponse<{ url: string }>>(
|
||||
`conferencing/${ZOOM}/oauth/auth-url${returnTo ? `?returnTo=${encodeURIComponent(returnTo)}` : ""}${
|
||||
onErrorReturnTo ? `&onErrorReturnTo=${encodeURIComponent(onErrorReturnTo)}` : ""
|
||||
}`
|
||||
)
|
||||
.then(({ data: responseBody }) => {
|
||||
if (responseBody.status === SUCCESS_STATUS) {
|
||||
return responseBody.data.url;
|
||||
}
|
||||
if (responseBody.status === ERROR_STATUS) throw new Error(responseBody.error.message);
|
||||
return "";
|
||||
});
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
export type UseConnectGoogleMeetProps = {
|
||||
onSuccess?: (res: ApiResponse) => void;
|
||||
onError?: (err: ApiErrorResponse) => void;
|
||||
returnTo?: string;
|
||||
onErrorReturnTo?: string;
|
||||
};
|
||||
|
||||
export const useConnectNonOauthApp = (
|
||||
{ onSuccess, onError }: UseConnectGoogleMeetProps = {
|
||||
onSuccess: () => {
|
||||
return;
|
||||
},
|
||||
onError: () => {
|
||||
return;
|
||||
},
|
||||
}
|
||||
) => {
|
||||
return useMutation({
|
||||
mutationFn: (app: string) => {
|
||||
const pathname = `/conferencing/${app}/connect`;
|
||||
return http?.post(pathname).then((res) => {
|
||||
if (res.data.status === SUCCESS_STATUS) {
|
||||
return { status: res.data };
|
||||
} else {
|
||||
throw new Error(res.data.error.message);
|
||||
}
|
||||
});
|
||||
},
|
||||
onSuccess,
|
||||
onError,
|
||||
});
|
||||
};
|
||||
|
||||
export const useConnect = ({ returnTo, onErrorReturnTo, ...props }: UseConnectGoogleMeetProps) => {
|
||||
const { refetch } = useGetOauthAuthUrl({ returnTo, onErrorReturnTo });
|
||||
const connectNonOauthApp = useConnectNonOauthApp(props);
|
||||
|
||||
const connect = async (app: App["slug"]) => {
|
||||
switch (app) {
|
||||
case ZOOM:
|
||||
const redirectUri = await refetch();
|
||||
if (redirectUri.data) {
|
||||
window.location.href = redirectUri.data;
|
||||
}
|
||||
break;
|
||||
|
||||
case GOOGLE_MEET:
|
||||
connectNonOauthApp.mutate(app);
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
return { connect };
|
||||
};
|
||||
@@ -0,0 +1,30 @@
|
||||
import { useMutation } from "@tanstack/react-query";
|
||||
|
||||
import { SUCCESS_STATUS } from "@calcom/platform-constants";
|
||||
import type { App } from "@calcom/types/App";
|
||||
|
||||
import http from "../../../lib/http";
|
||||
|
||||
export const QUERY_KEY = "use-delete-credential";
|
||||
export type UseDeleteEventTypeProps = {
|
||||
onSuccess?: () => void;
|
||||
onError?: (err: Error) => void;
|
||||
onSettled?: () => void;
|
||||
};
|
||||
export const useDeleteCredential = ({ onSuccess, onError, onSettled }: UseDeleteEventTypeProps) => {
|
||||
return useMutation({
|
||||
onSuccess,
|
||||
onError,
|
||||
onSettled,
|
||||
mutationFn: (app: App["slug"]) => {
|
||||
if (!app) throw new Error("app is required");
|
||||
const pathname = `/conferencing/${app}/disconnect`;
|
||||
return http?.delete(pathname).then((res) => {
|
||||
if (res.data.status === SUCCESS_STATUS) {
|
||||
return;
|
||||
}
|
||||
throw new Error(res.data.error.message);
|
||||
});
|
||||
},
|
||||
});
|
||||
};
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
|
||||
import { SUCCESS_STATUS } from "@calcom/platform-constants";
|
||||
import type { ApiSuccessResponse } from "@calcom/platform-types";
|
||||
import type { ApiResponse } from "@calcom/platform-types";
|
||||
|
||||
import { useAtomsContext } from "../../../hooks/useAtomsContext";
|
||||
import http from "../../../lib/http";
|
||||
|
||||
export const QUERY_KEY = "use-get-default-conferencing-app";
|
||||
|
||||
type ResponseDataType =
|
||||
| {
|
||||
appSlug?: string;
|
||||
appLink?: string;
|
||||
}
|
||||
| undefined;
|
||||
export const useGetDefaultConferencingApp = () => {
|
||||
const pathname = `/conferencing/default`;
|
||||
const { isInit, accessToken } = useAtomsContext();
|
||||
|
||||
return useQuery({
|
||||
queryKey: [QUERY_KEY],
|
||||
queryFn: () => {
|
||||
return http?.get<ApiResponse<ResponseDataType>>(pathname).then((res) => {
|
||||
if (res.data.status === SUCCESS_STATUS) {
|
||||
return (res.data as ApiSuccessResponse<ResponseDataType>).data;
|
||||
}
|
||||
throw new Error(res.data.error.message);
|
||||
});
|
||||
},
|
||||
enabled: isInit && !!accessToken,
|
||||
});
|
||||
};
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
import { useMutation } from "@tanstack/react-query";
|
||||
|
||||
import { SUCCESS_STATUS } from "@calcom/platform-constants";
|
||||
import type { App } from "@calcom/types/App";
|
||||
|
||||
import http from "../../../lib/http";
|
||||
|
||||
export const QUERY_KEY = "use-update-user-default-conferencing-app";
|
||||
export type UseUpdateUserDefaultConferencingAppProps = {
|
||||
onSuccess?: () => void;
|
||||
onError?: (err: Error) => void;
|
||||
onSettled?: () => void;
|
||||
};
|
||||
export const useUpdateUserDefaultConferencingApp = ({
|
||||
onSuccess,
|
||||
onError,
|
||||
onSettled,
|
||||
}: UseUpdateUserDefaultConferencingAppProps) => {
|
||||
return useMutation({
|
||||
onSuccess,
|
||||
onError,
|
||||
onSettled,
|
||||
mutationFn: (app: App["slug"]) => {
|
||||
if (!app) throw new Error("app is required");
|
||||
const pathname = `/conferencing/${app}/default`;
|
||||
return http?.post(pathname).then((res) => {
|
||||
if (res.data.status === SUCCESS_STATUS) {
|
||||
return;
|
||||
}
|
||||
throw new Error(res.data.error.message);
|
||||
});
|
||||
},
|
||||
});
|
||||
};
|
||||
@@ -25,6 +25,7 @@ export { DestinationCalendarSettingsPlatformWrapper as DestinationCalendarSettin
|
||||
export { CalendarSettingsPlatformWrapper as CalendarSettings } from "./calendar-settings/index";
|
||||
export type { UpdateScheduleInput_2024_06_11 as UpdateScheduleBody } from "@calcom/platform-types";
|
||||
export { EventTypePlatformWrapper as EventTypeSettings } from "./event-types/wrappers/EventTypePlatformWrapper";
|
||||
export { ConferencingAppsViewPlatformWrapper as ConferencingAppsSettings } from "./connect/conferencing-apps/ConferencingAppsViewPlatformWrapper";
|
||||
export { StripeConnect } from "./connect/stripe/StripeConnect";
|
||||
export { CreateEventTypePlatformWrapper as CreateEventType } from "./event-types/wrappers/CreateEventTypePlatformWrapper";
|
||||
export { PaymentForm } from "./event-types/payments/PaymentForm";
|
||||
@@ -17,8 +17,12 @@ export const GOOGLE_MEET = "google-meet";
|
||||
export const GOOGLE_MEET_TYPE = "google_video";
|
||||
export const GOOGLE_MEET_ID = "google-meet";
|
||||
|
||||
export const CONFERENCING_APPS = [GOOGLE_MEET];
|
||||
export const ZOOM = "zoom";
|
||||
export const ZOOM_TYPE = "zoom_video";
|
||||
|
||||
export const CAL_VIDEO = "daily-video";
|
||||
|
||||
export const CONFERENCING_APPS = [GOOGLE_MEET, ZOOM];
|
||||
export const APPS_TYPE_ID_MAPPING = {
|
||||
[GOOGLE_CALENDAR_TYPE]: GOOGLE_CALENDAR_ID,
|
||||
[OFFICE_365_CALENDAR_TYPE]: OFFICE_365_CALENDAR_ID,
|
||||
|
||||
@@ -34,6 +34,10 @@ export function Navbar({ username }: { username?: string }) {
|
||||
<li>
|
||||
<Link href="/embed">Embed</Link>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<Link href="/conferencing-apps">Conferencing Apps</Link>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
import { Navbar } from "@/components/Navbar";
|
||||
import { Inter } from "next/font/google";
|
||||
import { usePathname } from "next/navigation";
|
||||
|
||||
import { ConferencingAppsSettings } from "@calcom/atoms";
|
||||
|
||||
const inter = Inter({ subsets: ["latin"] });
|
||||
|
||||
export default function ConferencingApps(props: { calUsername: string; calEmail: string }) {
|
||||
const pathname = usePathname();
|
||||
const callbackUri = `${window.location.origin}${pathname}`;
|
||||
|
||||
return (
|
||||
<main
|
||||
className={`flex min-h-screen flex-col ${inter.className} main text-default flex min-h-full w-full flex-col items-center overflow-visible`}>
|
||||
<Navbar username={props.calUsername} />
|
||||
<div className="my-8">
|
||||
<ConferencingAppsSettings returnTo={callbackUri} onErrorReturnTo={callbackUri} />
|
||||
</div>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
@@ -20,6 +20,7 @@ import { getBookingForReschedule } from "@calcom/features/bookings/lib/get-booki
|
||||
import getBookingInfo from "@calcom/features/bookings/lib/getBookingInfo";
|
||||
import handleCancelBooking from "@calcom/features/bookings/lib/handleCancelBooking";
|
||||
import * as newBookingMethods from "@calcom/features/bookings/lib/handleNewBooking";
|
||||
import handleDeleteCredential from "@calcom/features/credentials/handleDeleteCredential";
|
||||
import { getClientSecretFromPayment } from "@calcom/features/ee/payments/pages/getClientSecretFromPayment";
|
||||
import { getPublicEvent } from "@calcom/features/eventtypes/lib/getPublicEvent";
|
||||
import { handleCreatePhoneCall } from "@calcom/features/handleCreatePhoneCall";
|
||||
@@ -28,6 +29,7 @@ import * as instantMeetingMethods from "@calcom/features/instant-meeting/handleI
|
||||
import getEnabledAppsFromCredentials from "@calcom/lib/apps/getEnabledAppsFromCredentials";
|
||||
import getAllUserBookings from "@calcom/lib/bookings/getAllUserBookings";
|
||||
import { symmetricEncrypt, symmetricDecrypt } from "@calcom/lib/crypto";
|
||||
import getBulkEventTypes from "@calcom/lib/event-types/getBulkEventTypes";
|
||||
import { getTranslation } from "@calcom/lib/server/i18n";
|
||||
import { MembershipRole } from "@calcom/prisma/enums";
|
||||
import { credentialForCalendarServiceSelect } from "@calcom/prisma/selects/credential";
|
||||
@@ -81,6 +83,10 @@ export { handleNewRecurringBooking } from "@calcom/features/bookings/lib/handleN
|
||||
|
||||
export { getConnectedDestinationCalendars } from "@calcom/lib/getConnectedDestinationCalendars";
|
||||
export type { ConnectedDestinationCalendars } from "@calcom/lib/getConnectedDestinationCalendars";
|
||||
|
||||
export { getConnectedApps } from "@calcom/lib/getConnectedApps";
|
||||
export { bulkUpdateEventsToDefaultLocation } from "@calcom/lib/bulkUpdateEventsToDefaultLocation";
|
||||
export type { ConnectedApps } from "@calcom/lib/getConnectedApps";
|
||||
export { getBusyCalendarTimes } from "@calcom/core/CalendarManager";
|
||||
|
||||
export {
|
||||
@@ -218,3 +224,5 @@ export { AttendeeUpdatedEmail };
|
||||
export { OrganizerRequestEmail };
|
||||
|
||||
export { AttendeeRequestEmail };
|
||||
export { handleDeleteCredential };
|
||||
export { getBulkEventTypes };
|
||||
Reference in new issue
Block a user