import { useLocation, useParams } from 'react-router-dom';

const useIds = () => {
  const params = useParams();
  const location = useLocation();
  const searchParams = new URLSearchParams(location.search);

  const tag = searchParams.get('tag') || '';
  const taskId = params.taskId ? parseInt(params.taskId) : undefined;
  const courseId = params.courseId ? parseInt(params.courseId) : undefined;
  const pathId = params.pathId ? parseInt(params.pathId) : undefined;

  return {
    tag,
    taskId,
    courseId,
    pathId,
  };
};

export default useIds;
