feat: use REST API endpoint to delete flow
This commit is contained in:
23
packages/web/src/hooks/useDeleteFlow.js
Normal file
23
packages/web/src/hooks/useDeleteFlow.js
Normal 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;
|
||||
}
|
Reference in New Issue
Block a user