* feat: add areDefaultEventTypesEnabled to PlatformOAuthClient * feat: specify areDefaultEventTypesEnabled when creating OAuth client * feat: specify areDefaultEventTypesEnabled when updating OAuth client * feat: display areDefaultEventTypesEnabled in OAuth clients list * refactor: set areDefaultEventTypesEnabled by default to false on API level * feat: v2 API CREATE managed user toggle default event types * refactor: centralize OAuth inputs and outputs in platform/types * fix: correct response types for OAuth hooks * refactor: web/lib/hooks/settings/platform/oauth-clients/useOAuthClients.ts * refactor: web/lib/hooks/settings/platform/oauth-clients/useOAuthClients.ts * refactor: split web OAuth hooks into separate files * refactor: split web OAuth hooks into separate files * docs: v2 OAuth client inputs and outputs * refactor: update and create oauth client inputs
42 lines
1.1 KiB
TypeScript
42 lines
1.1 KiB
TypeScript
import { useMutation } from "@tanstack/react-query";
|
|
|
|
import { SUCCESS_STATUS } from "@calcom/platform-constants";
|
|
import type { ApiResponse, SubscribeTeamInput } from "@calcom/platform-types";
|
|
|
|
export const useUpgradeTeamSubscriptionInStripe = (
|
|
{
|
|
onSuccess,
|
|
onError,
|
|
teamId,
|
|
}: { teamId?: number | null; onSuccess: (redirectUrl: string) => void; onError: () => void } = {
|
|
onSuccess: () => {
|
|
return;
|
|
},
|
|
onError: () => {
|
|
return;
|
|
},
|
|
}
|
|
) => {
|
|
const mutation = useMutation<ApiResponse<{ action: string; url: string }>, unknown, SubscribeTeamInput>({
|
|
mutationFn: (data) => {
|
|
return fetch(`/api/v2/billing/${teamId}/upgrade`, {
|
|
method: "post",
|
|
headers: { "Content-type": "application/json" },
|
|
body: JSON.stringify(data),
|
|
}).then((res) => res?.json());
|
|
},
|
|
onSuccess: (data) => {
|
|
if (data.status === SUCCESS_STATUS) {
|
|
onSuccess?.(data.data?.url);
|
|
} else {
|
|
onError?.();
|
|
}
|
|
},
|
|
onError: () => {
|
|
onError?.();
|
|
},
|
|
});
|
|
|
|
return mutation;
|
|
};
|