Files
infisical/frontend/src/hooks/api/githubOrgSyncConfig/mutations.tsx
2025-04-28 19:48:56 +05:30

43 lines
1.3 KiB
TypeScript

import { useMutation, useQueryClient } from "@tanstack/react-query";
import { apiRequest } from "@app/config/request";
import { githubOrgSyncConfigQueryKeys } from "./queries";
import { TCreateGithubOrgSyncDTO, TUpdateGithubOrgSyncDTO } from "./types";
export const useCreateGithubSyncOrgConfig = () => {
const queryClient = useQueryClient();
return useMutation({
mutationFn: (dto: TCreateGithubOrgSyncDTO) => {
return apiRequest.post("/api/v1/github-org-sync-config", dto);
},
onSuccess: () => {
queryClient.invalidateQueries(githubOrgSyncConfigQueryKeys.get());
}
});
};
export const useUpdateGithubSyncOrgConfig = () => {
const queryClient = useQueryClient();
return useMutation({
mutationFn: (dto: TUpdateGithubOrgSyncDTO) => {
return apiRequest.patch("/api/v1/github-org-sync-config", dto);
},
onSuccess: () => {
queryClient.invalidateQueries(githubOrgSyncConfigQueryKeys.get());
}
});
};
export const useDeleteGithubSyncOrgConfig = () => {
const queryClient = useQueryClient();
return useMutation({
mutationFn: () => {
return apiRequest.delete("/api/v1/github-org-sync-config");
},
onSuccess: () => {
queryClient.invalidateQueries(githubOrgSyncConfigQueryKeys.get());
}
});
};