feat: slack integration deletion

This commit is contained in:
Sheen Capadngan
2024-09-02 20:34:13 +08:00
parent f6d3831d6d
commit 07fd489982
7 changed files with 276 additions and 135 deletions
+1 -1
View File
@@ -1,2 +1,2 @@
export { useUpdateSlackIntegration } from "./mutation";
export { useDeleteSlackIntegration, useUpdateSlackIntegration } from "./mutation";
export { fetchSlackInstallUrl, useGetSlackIntegrationByProject } from "./queries";
+16 -1
View File
@@ -3,7 +3,7 @@ import { useMutation, useQueryClient } from "@tanstack/react-query";
import { apiRequest } from "@app/config/request";
import { slackKeys } from "./queries";
import { TUpdateSlackIntegrationDTO } from "./types";
import { TDeleteSlackIntegrationDTO, TUpdateSlackIntegrationDTO } from "./types";
export const useUpdateSlackIntegration = () => {
const queryClient = useQueryClient();
@@ -19,3 +19,18 @@ export const useUpdateSlackIntegration = () => {
}
});
};
export const useDeleteSlackIntegration = () => {
const queryClient = useQueryClient();
return useMutation<{}, {}, TDeleteSlackIntegrationDTO>({
mutationFn: async (dto) => {
const { data } = await apiRequest.delete(`/api/v1/slack/${dto.id}`);
return data;
},
onSuccess: (_, { workspaceId }) => {
queryClient.invalidateQueries(slackKeys.getSlackIntegrationByProject(workspaceId));
}
});
};
+5
View File
@@ -15,3 +15,8 @@ export type TUpdateSlackIntegrationDTO = {
isSecretRequestNotificationEnabled?: boolean;
secretRequestChannels?: string;
};
export type TDeleteSlackIntegrationDTO = {
id: string;
workspaceId: string;
};