feat(Editor): use REST API endpoint to create step
This commit is contained in:
24
packages/web/src/hooks/useCreateStep.js
Normal file
24
packages/web/src/hooks/useCreateStep.js
Normal 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;
|
||||
}
|
Reference in New Issue
Block a user