import { ArticleTree } from 'src/types/libraries';
import { Library, LibraryStatus } from 'src/types/libraries';

export const getActiveLibraries = (libraries: Library[] = []): Library[] =>
  libraries.filter(library => library.status === LibraryStatus.ENABLED);

export const getBreadcrumbItems = (tree: ArticleTree) => {
  const path = [
    {
      title: tree.title,
      id: tree.id,
    },
  ];

  while (tree.children) {
    [tree] = tree.children;

    path.push({
      title: tree.title,
      id: tree.id,
    });
  }

  return path;
};
