feat: use REST API endpoint to duplicate flow

This commit is contained in:
Ali BARIN
2024-09-11 09:26:57 +00:00
committed by Faruk AYDIN
parent 0d126a8e2b
commit 22299868fa
2 changed files with 35 additions and 5 deletions

View File

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