feat: added office 365 video to conferencing atoms (#18067)
* feat: added office 365 video to conferencing atoms * added documentation for conferencing atoms * added props table to the documentation --------- Co-authored-by: Morgan <[email protected]>
This commit is contained in:
1 parent
79d488faca
commit
f8be2b3833
13 files changed
+337
-41
No files matched your search
+19
-2
@@ -1,13 +1,14 @@
|
||||
"use client";
|
||||
|
||||
import { useQueryClient } from "@tanstack/react-query";
|
||||
import { useReducer } from "react";
|
||||
import { useReducer, useState } from "react";
|
||||
|
||||
import AccountDialog from "@calcom/app-store/office365video/components/AccountDialog";
|
||||
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 { GOOGLE_MEET, OFFICE_365_VIDEO, ZOOM } from "@calcom/platform-constants";
|
||||
import { QueryCell } from "@calcom/trpc/components/QueryCell";
|
||||
import type { App } from "@calcom/types/App";
|
||||
import {
|
||||
@@ -91,6 +92,8 @@ export const ConferencingAppsViewPlatformWrapper = ({
|
||||
}
|
||||
);
|
||||
|
||||
const [isAccountModalOpen, setIsAccountModalOpen] = useState(false);
|
||||
|
||||
const handleModelClose = () => {
|
||||
updateModal({ isOpen: false, credentialId: null, app: null });
|
||||
};
|
||||
@@ -199,6 +202,14 @@ export const ConferencingAppsViewPlatformWrapper = ({
|
||||
</DropdownItem>
|
||||
</DropdownMenuItem>
|
||||
)}
|
||||
|
||||
{installedApps && !installedApps?.find((app) => app.slug == OFFICE_365_VIDEO) && (
|
||||
<DropdownMenuItem>
|
||||
<DropdownItem color="secondary" onClick={() => setIsAccountModalOpen(true)}>
|
||||
{t("office_365_video")}
|
||||
</DropdownItem>
|
||||
</DropdownMenuItem>
|
||||
)}
|
||||
</DropdownMenuContent>
|
||||
</Dropdown>
|
||||
);
|
||||
@@ -257,6 +268,12 @@ export const ConferencingAppsViewPlatformWrapper = ({
|
||||
app={modal.app}
|
||||
handleRemoveApp={handleRemoveApp}
|
||||
/>
|
||||
|
||||
<AccountDialog
|
||||
open={isAccountModalOpen}
|
||||
onOpenChange={setIsAccountModalOpen}
|
||||
handleSubmit={() => connect(OFFICE_365_VIDEO)}
|
||||
/>
|
||||
</>
|
||||
</SettingsHeader>
|
||||
</AtomsWrapper>
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
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 {
|
||||
SUCCESS_STATUS,
|
||||
ERROR_STATUS,
|
||||
ZOOM,
|
||||
GOOGLE_MEET,
|
||||
OFFICE_365_VIDEO,
|
||||
} from "@calcom/platform-constants";
|
||||
import type { ApiErrorResponse, ApiResponse } from "@calcom/platform-types";
|
||||
import type { App } from "@calcom/types/App";
|
||||
|
||||
@@ -12,7 +18,7 @@ export type UseGetOauthAuthUrlProps = {
|
||||
onErrorReturnTo?: string;
|
||||
};
|
||||
|
||||
export const useGetOauthAuthUrl = ({ returnTo, onErrorReturnTo }: UseGetOauthAuthUrlProps) => {
|
||||
export const useGetZoomOauthAuthUrl = ({ returnTo, onErrorReturnTo }: UseGetOauthAuthUrlProps) => {
|
||||
return useQuery({
|
||||
queryKey: ["get-zoom-auth-url"],
|
||||
staleTime: Infinity,
|
||||
@@ -35,6 +41,29 @@ export const useGetOauthAuthUrl = ({ returnTo, onErrorReturnTo }: UseGetOauthAut
|
||||
});
|
||||
};
|
||||
|
||||
export const useOffice365GetOauthAuthUrl = ({ returnTo, onErrorReturnTo }: UseGetOauthAuthUrlProps) => {
|
||||
return useQuery({
|
||||
queryKey: ["get-office365-auth-url"],
|
||||
staleTime: Infinity,
|
||||
enabled: false,
|
||||
queryFn: () => {
|
||||
return http
|
||||
?.get<ApiResponse<{ url: string }>>(
|
||||
`conferencing/${OFFICE_365_VIDEO}/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;
|
||||
@@ -69,18 +98,25 @@ export const useConnectNonOauthApp = (
|
||||
};
|
||||
|
||||
export const useConnect = ({ returnTo, onErrorReturnTo, ...props }: UseConnectGoogleMeetProps) => {
|
||||
const { refetch } = useGetOauthAuthUrl({ returnTo, onErrorReturnTo });
|
||||
const { refetch: refetchZoomAuthUrl } = useGetZoomOauthAuthUrl({ returnTo, onErrorReturnTo });
|
||||
const { refetch: refetchOffice365AuthUrl } = useOffice365GetOauthAuthUrl({ 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;
|
||||
const zoomRedirectUri = await refetchZoomAuthUrl();
|
||||
if (zoomRedirectUri.data) {
|
||||
window.location.href = zoomRedirectUri.data;
|
||||
}
|
||||
break;
|
||||
|
||||
case OFFICE_365_VIDEO:
|
||||
const office365RedirectUri = await refetchOffice365AuthUrl();
|
||||
if (office365RedirectUri.data) {
|
||||
window.location.href = office365RedirectUri.data;
|
||||
}
|
||||
break;
|
||||
case GOOGLE_MEET:
|
||||
connectNonOauthApp.mutate(app);
|
||||
|
||||
|
||||
@@ -20,9 +20,13 @@ export const GOOGLE_MEET_ID = "google-meet";
|
||||
export const ZOOM = "zoom";
|
||||
export const ZOOM_TYPE = "zoom_video";
|
||||
|
||||
export const CAL_VIDEO = "daily-video";
|
||||
export const OFFICE_365_VIDEO = "msteams";
|
||||
export const OFFICE_365_VIDEO_TYPE = "office365_video";
|
||||
|
||||
export const CONFERENCING_APPS = [GOOGLE_MEET, ZOOM];
|
||||
export const CAL_VIDEO = "daily-video";
|
||||
export const CAL_VIDEO_TYPE = "daily_video";
|
||||
|
||||
export const CONFERENCING_APPS = [GOOGLE_MEET, ZOOM, OFFICE_365_VIDEO];
|
||||
export const APPS_TYPE_ID_MAPPING = {
|
||||
[GOOGLE_CALENDAR_TYPE]: GOOGLE_CALENDAR_ID,
|
||||
[OFFICE_365_CALENDAR_TYPE]: OFFICE_365_CALENDAR_ID,
|
||||
|
||||
Reference in new issue
Block a user