diff --git a/frontend/src/Components/PageNav.tsx b/frontend/src/Components/PageNav.tsx index 53f9841a..9093b8a5 100644 --- a/frontend/src/Components/PageNav.tsx +++ b/frontend/src/Components/PageNav.tsx @@ -1,14 +1,12 @@ -import { useEffect, useRef } from 'react'; +import { useState, useEffect, useRef } from 'react'; import { isAdministrator, useAuth } from '@/useAuth'; import { Bars3Icon, BuildingOffice2Icon } from '@heroicons/react/24/solid'; import ULIComponent from '@/Components/ULIComponent.tsx'; -import { Facility } from '@/common'; +import { Facility, TitleHandler } from '@/common'; import { useMatches, useLoaderData } from 'react-router-dom'; import API from '@/api/api'; -interface HandleType { - title: string; -} +let setGlobalPageTitle: (newTitle: string) => void; export default function PageNav({ showOpenMenu, @@ -22,7 +20,11 @@ export default function PageNav({ const facilityNames = useLoaderData() as Facility[] | null; const matches = useMatches(); const currentRoute = matches[matches.length - 1]; - const pageTitle = (currentRoute?.handle as HandleType)?.title; + const pageTitle = (currentRoute?.handle as TitleHandler)?.title; + const [globalPageTitle, _setGlobalPageTitle] = useState( + pageTitle || 'Library Viewer' + ); + setGlobalPageTitle = _setGlobalPageTitle; useEffect(() => { const closeDropdown = ({ target }: MouseEvent) => { @@ -66,7 +68,11 @@ export default function PageNav({ iconClassName="lg:hidden cursor-pointer" /> )} -

{pageTitle}

+

+ {pageTitle == 'Library Viewer' + ? globalPageTitle + : pageTitle} +

{user && isAdministrator(user) ? (