feat: use REST API endpoint to delete flow

This commit is contained in:
Ali BARIN
2024-09-18 15:44:43 +00:00
committed by Faruk AYDIN
parent 97fa983305
commit 5de06d4482
2 changed files with 26 additions and 15 deletions

View File

@@ -0,0 +1,23 @@
import { useMutation, useQueryClient } from '@tanstack/react-query';
import api from 'helpers/api';
export default function useDeleteFlow() {
const queryClient = useQueryClient();
const query = useMutation({
mutationFn: async (flowId) => {
const { data } = await api.delete(`/v1/flows/${flowId}`);
return data;
},
onSuccess: () => {
queryClient.invalidateQueries({
queryKey: ['flows'],
});
},
});
return query;
}