import { observer } from "mobx-react"; import { useTranslation } from "react-i18next"; import type Collection from "~/models/Collection"; import Tab from "~/components/Tab"; import Tabs from "~/components/Tabs"; import { collectionPath } from "~/utils/routeHelpers"; import { type SidebarContextType } from "~/components/Sidebar/components/SidebarContext"; export enum CollectionTab { Overview = "overview", Recent = "recent", Popular = "popular", Updated = "updated", Published = "published", Old = "old", Alphabetical = "alphabetical", } type Props = { /** The collection for which to render navigation tabs */ collection: Collection; /** Callback when the tab is changed */ onChangeTab: (tab: CollectionTab) => void; /** Whether to show the overview tab */ showOverview?: boolean; /** Contextual information for the sidebar */ sidebarContext: SidebarContextType; }; /** * Navigation component for collection tabs, providing navigation between * different views of collection documents. */ const Navigation = observer(function Navigation({ collection, onChangeTab, showOverview, sidebarContext, }: Props) { const { t } = useTranslation(); const tabProps = (path: CollectionTab) => ({ exact: true, onClick: () => onChangeTab(path), to: { pathname: collectionPath(collection, path), state: { sidebarContext }, }, }); return ( {showOverview && ( {t("Overview")} )} {t("Documents")} {!collection.isArchived && ( <> {t("Popular")} {t("Recently updated")} {t("Recently published")} {t("Least recently updated")} {t("A–Z")} )} ); }); export default Navigation;