2022-03-03 02:02:30 -05:00
|
|
|
import React, { useEffect } from 'react';
|
2022-03-03 04:44:25 -05:00
|
|
|
import { BrowserRouter, Route, Routes, useLocation, useNavigate } from 'react-router-dom';
|
2022-03-04 04:26:34 -05:00
|
|
|
import { SWRConfig } from 'swr';
|
2022-02-27 21:35:14 -05:00
|
|
|
import './scss/normalized.scss';
|
2022-03-04 04:26:34 -05:00
|
|
|
|
2022-02-16 02:04:34 -05:00
|
|
|
import * as styles from './App.module.scss';
|
2022-03-03 02:15:33 -05:00
|
|
|
import AppContent from './components/AppContent';
|
2022-02-27 21:35:14 -05:00
|
|
|
import Content from './components/Content';
|
2022-03-03 02:02:30 -05:00
|
|
|
import Sidebar, { getPath, sections } from './components/Sidebar';
|
2022-03-09 23:52:56 -05:00
|
|
|
import Toast from './components/Toast';
|
2022-02-27 21:35:14 -05:00
|
|
|
import Topbar from './components/Topbar';
|
2022-02-28 09:18:01 -05:00
|
|
|
import initI18n from './i18n/init';
|
2022-03-09 04:56:50 -05:00
|
|
|
import ApiResourceDetails from './pages/ApiResourceDetails';
|
2022-03-03 04:44:25 -05:00
|
|
|
import ApiResources from './pages/ApiResources';
|
2022-03-08 01:53:49 -05:00
|
|
|
import ApplicationDetails from './pages/ApplicationDetails';
|
2022-03-03 23:47:02 -05:00
|
|
|
import Applications from './pages/Applications';
|
2022-03-09 02:54:46 -05:00
|
|
|
import ConnectorDetails from './pages/ConnectorDetails';
|
2022-03-07 22:10:46 -05:00
|
|
|
import Connectors from './pages/Connectors';
|
2022-03-04 04:26:34 -05:00
|
|
|
import { fetcher } from './swr';
|
2022-02-28 09:18:01 -05:00
|
|
|
|
2022-03-03 02:44:42 -05:00
|
|
|
const isBasenameNeeded = process.env.NODE_ENV !== 'development' || process.env.PORT === '5002';
|
|
|
|
|
2022-02-28 09:18:01 -05:00
|
|
|
void initI18n();
|
2022-02-16 02:04:34 -05:00
|
|
|
|
2022-03-03 02:02:30 -05:00
|
|
|
const Main = () => {
|
|
|
|
const location = useLocation();
|
|
|
|
const navigate = useNavigate();
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
if (location.pathname === '/') {
|
|
|
|
navigate(getPath(sections[0]?.items[0]?.title ?? ''));
|
|
|
|
}
|
|
|
|
}, [location.pathname, navigate]);
|
|
|
|
|
2022-02-27 21:35:14 -05:00
|
|
|
return (
|
2022-03-04 04:26:34 -05:00
|
|
|
<SWRConfig value={{ fetcher }}>
|
2022-03-09 23:52:56 -05:00
|
|
|
<Toast />
|
2022-03-04 04:26:34 -05:00
|
|
|
<AppContent theme="light">
|
|
|
|
<Topbar />
|
|
|
|
<div className={styles.content}>
|
|
|
|
<Sidebar />
|
|
|
|
<Content>
|
|
|
|
<Routes>
|
2022-03-08 01:53:49 -05:00
|
|
|
<Route path="applications">
|
|
|
|
<Route index element={<Applications />} />
|
|
|
|
<Route path=":id" element={<ApplicationDetails />} />
|
|
|
|
</Route>
|
2022-03-09 04:56:50 -05:00
|
|
|
<Route path="api-resources">
|
|
|
|
<Route index element={<ApiResources />} />
|
|
|
|
<Route path=":id" element={<ApiResourceDetails />} />
|
|
|
|
</Route>
|
2022-03-08 23:32:44 -05:00
|
|
|
<Route path="connectors">
|
|
|
|
<Route index element={<Connectors />} />
|
|
|
|
<Route path="social" element={<Connectors />} />
|
2022-03-09 02:54:46 -05:00
|
|
|
<Route path=":connectorId" element={<ConnectorDetails />} />
|
2022-03-08 23:32:44 -05:00
|
|
|
</Route>
|
2022-03-04 04:26:34 -05:00
|
|
|
</Routes>
|
|
|
|
</Content>
|
|
|
|
</div>
|
|
|
|
</AppContent>
|
|
|
|
</SWRConfig>
|
2022-02-27 21:35:14 -05:00
|
|
|
);
|
2022-02-16 02:04:34 -05:00
|
|
|
};
|
2022-03-03 02:02:30 -05:00
|
|
|
|
|
|
|
const App = () => (
|
2022-03-03 02:44:42 -05:00
|
|
|
<BrowserRouter basename={isBasenameNeeded ? '/console' : ''}>
|
2022-03-03 02:02:30 -05:00
|
|
|
<Main />
|
|
|
|
</BrowserRouter>
|
|
|
|
);
|
|
|
|
|
|
|
|
export default App;
|