feat: use REST API endpoint to update flow status

This commit is contained in:
Ali BARIN
2024-09-19 07:53:29 +00:00
committed by Faruk AYDIN
parent 8cc732c8d1
commit 184d748890
2 changed files with 27 additions and 25 deletions

View File

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