refactor(web): rewrite mutation with PATCH /v1/flows/:flowId

This commit is contained in:
Ali BARIN
2024-08-29 15:05:47 +00:00
parent 9519ec53ef
commit 562341adfe
3 changed files with 28 additions and 28 deletions

View File

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