diff --git a/apps/hpc-cdm/src/app/app.tsx b/apps/hpc-cdm/src/app/app.tsx
index 989cb596..1bdfe9e7 100644
--- a/apps/hpc-cdm/src/app/app.tsx
+++ b/apps/hpc-cdm/src/app/app.tsx
@@ -1,5 +1,5 @@
import React, { useState, useEffect } from 'react';
-import { Navigate, Route, Routes } from 'react-router';
+import { Outlet } from 'react-router';
import { ToastContainer } from 'react-toastify';
import 'react-toastify/dist/ReactToastify.css';
@@ -11,13 +11,8 @@ import { LANGUAGE_CHOICE, LanguageKey, t } from '../i18n';
import { Z_INDEX } from './layout';
import * as paths from './paths';
import PageMeta from './components/page-meta';
-import { RouteParamsValidator } from './components/route-params-validator';
-import PageAdmin from './pages/admin';
import PageNotLoggedIn from './pages/not-logged-in';
-import PageNotFound from './pages/not-found';
-import PageOperationsList from './pages/operations-list';
-import PageOperation from './pages/operation';
const environmentWarning = (env: Environment, lang: LanguageKey) => {
const warning = env.getDevHeaderWarning(lang);
@@ -143,32 +138,7 @@ export const App = () => {
: []),
]}
/>
-
- }
- />
- }
- />
- }
- routeParam="id"
- />
- }
- />
- {canModifyGlobalUserAccess && (
- }
- />
- )}
- } />
-
+
) : (
<>
diff --git a/apps/hpc-cdm/src/app/pages/admin.tsx b/apps/hpc-cdm/src/app/pages/admin.tsx
index 5e1db298..9d43ffa2 100644
--- a/apps/hpc-cdm/src/app/pages/admin.tsx
+++ b/apps/hpc-cdm/src/app/pages/admin.tsx
@@ -12,44 +12,50 @@ import PageMeta from '../components/page-meta';
const PageAdmin = () => {
return (
- {({ lang }) => (
-
-
s.navigation.admin)]} />
- s.navigation.manageAccess),
- path: paths.adminAccess(),
- },
- ]}
- >
-
- }
- />
-
- }
- />
- s.components.notFound)}
- />
- }
- />
-
-
-
- )}
+ {({ lang, access }) => {
+ const { canModifyGlobalUserAccess } = access().permissions;
+ if (!canModifyGlobalUserAccess) {
+ return ;
+ }
+ return (
+
+
s.navigation.admin)]} />
+ s.navigation.manageAccess),
+ path: paths.adminAccess(),
+ },
+ ]}
+ >
+
+ }
+ />
+
+ }
+ />
+ s.components.notFound)}
+ />
+ }
+ />
+
+
+
+ );
+ }}
);
};
diff --git a/apps/hpc-cdm/src/main.tsx b/apps/hpc-cdm/src/main.tsx
index 8e1a4d8f..6b599fa8 100644
--- a/apps/hpc-cdm/src/main.tsx
+++ b/apps/hpc-cdm/src/main.tsx
@@ -1,10 +1,17 @@
import React from 'react';
import ReactDOM from 'react-dom/client';
-import { BrowserRouter } from 'react-router';
+import { createBrowserRouter, Navigate, RouterProvider } from 'react-router';
import { ThemeProvider } from '@unocha/hpc-ui';
import App from './app/app';
import './assets/styles/enketo.css';
+import { RouteParamsValidator } from './app/components/route-params-validator';
+import * as paths from './app/paths';
+
+import PageAdmin from './app/pages/admin';
+import PageNotFound from './app/pages/not-found';
+import PageOperationsList from './app/pages/operations-list';
+import PageOperation from './app/pages/operation';
const rootElement = document.getElementById('root');
if (!rootElement) {
@@ -12,10 +19,30 @@ if (!rootElement) {
}
const root = ReactDOM.createRoot(rootElement);
-root.render(
-
-
-
-
-
-);
+const router = createBrowserRouter([
+ {
+ path: paths.home(),
+ element: (
+
+
+
+ ),
+ children: [
+ { path: paths.home(), element: },
+ { path: paths.operations(), element: },
+ {
+ path: paths.operationRoot(),
+ element: (
+ } routeParam="id" />
+ ),
+ },
+ {
+ path: paths.adminRoot(),
+ element: ,
+ },
+ { path: paths.root(), element: },
+ ],
+ },
+]);
+
+root.render();