From 14f3e1ed8925c83fe2b5f67cf0aa3fea40a9429c Mon Sep 17 00:00:00 2001 From: CK-7vn Date: Wed, 15 Jan 2025 17:07:09 -0500 Subject: [PATCH] fix: make library title library viewer header on top of page --- frontend/src/Components/PageNav.tsx | 21 ++++++++++++++------- frontend/src/Pages/LibraryViewer.tsx | 5 ++--- 2 files changed, 16 insertions(+), 10 deletions(-) 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) ? (