feat(Editor): use REST API endpoint to create step

This commit is contained in:
Ali BARIN
2024-09-06 17:30:34 +00:00
parent 813646e392
commit af56fa2830
3 changed files with 42 additions and 40 deletions

View File

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