Files
calendar/packages/platform/atoms/connect/conferencing-apps/hooks/useUpdateUserDefaultConferencingApp.ts
T
063400fcbc 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 <33722304+ThyMinimalDev@users.noreply.github.com>
2024-12-06 19:03:04 +05:30

35 lines
973 B
TypeScript

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);
});
},
});
};