2022-10-12 10:21:49 -04:00
|
|
|
import { useMemo, useState } from 'react';
|
2022-10-31 15:09:21 -04:00
|
|
|
// @ts-ignore
|
|
|
|
// import { Container } from '@carbon/react';
|
2022-10-12 10:21:49 -04:00
|
|
|
|
|
|
|
import { BrowserRouter, Routes, Route } from 'react-router-dom';
|
|
|
|
import ErrorContext from './contexts/ErrorContext';
|
|
|
|
import NavigationBar from './components/NavigationBar';
|
|
|
|
|
|
|
|
import HomePage from './routes/HomePage';
|
|
|
|
import TaskShow from './routes/TaskShow';
|
|
|
|
import ErrorBoundary from './components/ErrorBoundary';
|
|
|
|
import AdminRoutes from './routes/AdminRoutes';
|
|
|
|
import SubNavigation from './components/SubNavigation';
|
2022-10-18 16:41:13 -04:00
|
|
|
import { ErrorForDisplay } from './interfaces';
|
2022-10-12 10:21:49 -04:00
|
|
|
|
|
|
|
export default function App() {
|
2022-10-18 16:41:13 -04:00
|
|
|
const [errorMessage, setErrorMessage] = useState<ErrorForDisplay | null>(
|
|
|
|
null
|
|
|
|
);
|
2022-10-12 10:21:49 -04:00
|
|
|
|
|
|
|
const errorContextValueArray = useMemo(
|
|
|
|
() => [errorMessage, setErrorMessage],
|
|
|
|
[errorMessage]
|
|
|
|
);
|
|
|
|
|
|
|
|
let errorTag = null;
|
2022-10-18 16:41:13 -04:00
|
|
|
if (errorMessage) {
|
|
|
|
let sentryLinkTag = null;
|
|
|
|
if (errorMessage.sentry_link) {
|
|
|
|
sentryLinkTag = (
|
|
|
|
<span>
|
|
|
|
{
|
|
|
|
': Find details about this error here (it may take a moment to become available): '
|
|
|
|
}
|
|
|
|
<a href={errorMessage.sentry_link} target="_blank" rel="noreferrer">
|
|
|
|
{errorMessage.sentry_link}
|
|
|
|
</a>
|
|
|
|
</span>
|
|
|
|
);
|
|
|
|
}
|
2022-10-12 10:21:49 -04:00
|
|
|
errorTag = (
|
|
|
|
<div id="filter-errors" className="mt-4 alert alert-danger" role="alert">
|
2022-10-18 16:41:13 -04:00
|
|
|
{errorMessage.message}
|
|
|
|
{sentryLinkTag}
|
2022-10-12 10:21:49 -04:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<ErrorContext.Provider value={errorContextValueArray}>
|
|
|
|
<NavigationBar />
|
2022-10-31 15:09:21 -04:00
|
|
|
<div>
|
2022-10-12 10:21:49 -04:00
|
|
|
{errorTag}
|
|
|
|
<ErrorBoundary>
|
|
|
|
<BrowserRouter>
|
|
|
|
<SubNavigation />
|
|
|
|
<main style={{ padding: '1rem 0' }}>
|
|
|
|
<Routes>
|
|
|
|
<Route path="/" element={<HomePage />} />
|
|
|
|
<Route path="/tasks" element={<HomePage />} />
|
|
|
|
<Route path="/admin/*" element={<AdminRoutes />} />
|
|
|
|
<Route
|
|
|
|
path="/tasks/:process_instance_id/:task_id"
|
|
|
|
element={<TaskShow />}
|
|
|
|
/>
|
|
|
|
<Route
|
|
|
|
path="/tasks/:process_instance_id/:task_id"
|
|
|
|
element={<TaskShow />}
|
|
|
|
/>
|
|
|
|
</Routes>
|
|
|
|
</main>
|
|
|
|
</BrowserRouter>
|
|
|
|
</ErrorBoundary>
|
2022-10-31 15:09:21 -04:00
|
|
|
</div>
|
2022-10-12 10:21:49 -04:00
|
|
|
</ErrorContext.Provider>
|
|
|
|
);
|
|
|
|
}
|