import { BreadcrumbItem } from 'src/types/libraries';

import { useLibrariesTitle } from './useLibrariesTitle';

const useGetBreadcrumbPath = () => {
  const { librariesTitle } = useLibrariesTitle();

  const getBreadcrumbPath = (
    items: BreadcrumbItem[],
    onClick: (id?: number) => () => void,
  ) => {
    const path = [
      {
        title: librariesTitle,
        onClick: onClick(),
      },
    ];

    items.forEach(({ title, id }) => {
      path.push({
        title,
        onClick: onClick(id),
      });
    });

    return path;
  };

  return getBreadcrumbPath;
};

export default useGetBreadcrumbPath;
