Skip to content

Commit

Permalink
Fix url. add refetch for list
Browse files Browse the repository at this point in the history
  • Loading branch information
maxiadlovskii committed Nov 14, 2023
1 parent 9c28f5d commit 0f87920
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* along with this program. If not, see
* <http://www.mongodb.com/licensing/server-side-public-license>.
*/
import { useMutation } from '@tanstack/react-query';
import { useMutation, useQueryClient } from '@tanstack/react-query';

import { qualifyUrl } from 'util/URLUtils';
import fetch from 'logic/rest/FetchProvider';
Expand Down Expand Up @@ -50,13 +50,16 @@ const putFieldType = async ({
};

const useRemoveCustomFieldTypeMutation = () => {
const queryClient = useQueryClient();

const put = useMutation(putFieldType, {
onError: (errorThrown) => {
UserNotification.error(`Removing custom field type failed with status: ${errorThrown}`,
'Could Removing custom the field type');
},
onSuccess: () => {
UserNotification.success('Custom field type removed successfully', 'Success!');
queryClient.refetchQueries({ queryKey: ['indexSetFieldTypes'], type: 'active' });
},
});

Expand Down

0 comments on commit 0f87920

Please sign in to comment.