import { useMutation } from 'react-query';

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

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

export const useUpdatePartialPathMutation = (pathId: number | null) => {
  return useMutation({
    mutationFn: (data: Partial<CreateLearningPath>) => {
      if (!pathId) {
        throw new Error(
          '[useUpdatePartialPathMutation] - Path ID is required ',
        );
      }
      return updatePartialPath(pathId, data);
    },
  });
};
