From d11c5acb776008110cab41d1f7657f1143f785aa Mon Sep 17 00:00:00 2001 From: Dylan De Faoite Date: Tue, 3 Mar 2026 18:18:05 +0000 Subject: [PATCH] refactor: calculation of document titles into another class --- frontend/src/App.tsx | 11 ++++------- frontend/src/utils/documentTitle.ts | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 7 deletions(-) create mode 100644 frontend/src/utils/documentTitle.ts diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 1207317..a39a0a1 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -1,21 +1,17 @@ import { useEffect } from "react"; import { Navigate, Route, Routes, useLocation } from "react-router-dom"; import AppLayout from "./components/AppLayout"; +import DatasetStatusPage from "./pages/DatasetStatus"; import LoginPage from "./pages/Login"; import UploadPage from "./pages/Upload"; import StatPage from "./pages/Stats"; +import { getDocumentTitle } from "./utils/documentTitle"; function App() { const location = useLocation(); useEffect(() => { - const routeTitles: Record = { - "/login": "Sign In", - "/upload": "Upload Dataset", - "/stats": "Stats", - }; - - document.title = routeTitles[location.pathname]; + document.title = getDocumentTitle(location.pathname); }, [location.pathname]); return ( @@ -24,6 +20,7 @@ function App() { } /> } /> } /> + } /> } /> diff --git a/frontend/src/utils/documentTitle.ts b/frontend/src/utils/documentTitle.ts new file mode 100644 index 0000000..0e1986f --- /dev/null +++ b/frontend/src/utils/documentTitle.ts @@ -0,0 +1,15 @@ +const DEFAULT_TITLE = "Ethnograph View"; + +const STATIC_TITLES: Record = { + "/login": "Sign In", + "/upload": "Upload Dataset", + "/stats": "Stats", +}; + +export const getDocumentTitle = (pathname: string) => { + if (pathname.includes("status")) { + return "Processing Dataset"; + } + + return STATIC_TITLES[pathname] ?? DEFAULT_TITLE; +};