import { useQuery } from 'react-query';

import { getArticleTree } from 'src/services/libraries';
import { getBreadcrumbItems } from 'src/utils/libraries';

import { librariesKeys } from '../queries';

export const useGetLibraryTree = (id: number | string) => {
  return useQuery(librariesKeys.tree(id), () => getArticleTree(id), {
    select: response => getBreadcrumbItems(response.data),
  });
};

export default useGetLibraryTree;
