import { useMutation } from 'react-query';

import { createPath } from 'src/pages/dashboard/Learning/Paths/services';

import { type CreatePathPostType } from '../types';

import { useNewPathStepper } from './useNewPathStepper';

const useCreateDraftMutation = () => {
  const { setStep } = useNewPathStepper();

  return useMutation({
    mutationFn: (data: CreatePathPostType) => createPath(data),
    onSuccess: () => setStep('content'),
  });
};

export default useCreateDraftMutation;
