From 76ca977067f018c55bbf432df8d46d58c7890bf6 Mon Sep 17 00:00:00 2001 From: Georgi 7DIGIT Date: Fri, 13 Sep 2024 15:58:19 +0300 Subject: [PATCH] Create: hook to remove provider from organziation --- src/hooks/index.js | 1 + src/hooks/useRemoveProviderFromOrganization.js | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 src/hooks/useRemoveProviderFromOrganization.js diff --git a/src/hooks/index.js b/src/hooks/index.js index d2c7ad1..7e511a0 100644 --- a/src/hooks/index.js +++ b/src/hooks/index.js @@ -38,3 +38,4 @@ export * from "./useCreateOrganization.js"; export * from './useGetOrganizationById'; export * from './useGetAllProviderNames'; export * from './useAssignProvidersToOrganization'; +export * from './useRemoveProviderFromOrganization'; diff --git a/src/hooks/useRemoveProviderFromOrganization.js b/src/hooks/useRemoveProviderFromOrganization.js new file mode 100644 index 0000000..093ca70 --- /dev/null +++ b/src/hooks/useRemoveProviderFromOrganization.js @@ -0,0 +1,17 @@ +import { useMutation } from "@tanstack/react-query"; +import { organizationSvc } from "@USupport-components-library/services"; +import { useError } from "./useError"; + +export const useRemoveProviderFromOrganization = (onSuccess, onError) => { + return useMutation({ + mutationFn: async (data) => { + return await organizationSvc.removeProviderFromOrganization(data); + }, + onSuccess, + onError: (error) => { + const { message: errorMessage } = useError(error); + onError(errorMessage); + }, + }); +}; +export default useRemoveProviderFromOrganization;