Fix the frontend API calls and implement logins on frontend #7
@@ -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<string, string> = {
|
||||
"/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() {
|
||||
<Route path="/" element={<Navigate to="/login" replace />} />
|
||||
<Route path="/login" element={<LoginPage />} />
|
||||
<Route path="/upload" element={<UploadPage />} />
|
||||
<Route path="/dataset/:datasetId/status" element={<DatasetStatusPage />} />
|
||||
<Route path="/stats" element={<StatPage />} />
|
||||
</Route>
|
||||
</Routes>
|
||||
|
||||
15
frontend/src/utils/documentTitle.ts
Normal file
15
frontend/src/utils/documentTitle.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
const DEFAULT_TITLE = "Ethnograph View";
|
||||
|
||||
const STATIC_TITLES: Record<string, string> = {
|
||||
"/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;
|
||||
};
|
||||
Reference in New Issue
Block a user