0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-01-06 20:40:08 -05:00
logto/packages/console/src/App.tsx

101 lines
3.8 KiB
TypeScript
Raw Normal View History

2022-05-17 08:37:30 -05:00
import { LogtoProvider } from '@logto/react';
import { adminConsoleApplicationId, managementResource } from '@logto/schemas/lib/seeds';
import { getBasename } from '@logto/shared';
2022-05-17 08:37:30 -05:00
import React from 'react';
import { BrowserRouter, Navigate, Route, Routes } from 'react-router-dom';
import { SWRConfig } from 'swr';
2022-02-27 21:35:14 -05:00
import './scss/normalized.scss';
// eslint-disable-next-line import/no-unassigned-import
import '@fontsource/roboto-mono';
import AppBoundary from './components/AppBoundary';
import AppContent from './components/AppContent';
import ErrorBoundary from './components/ErrorBoundary';
import Toast from './components/Toast';
import useSwrOptions from './hooks/use-swr-options';
2022-02-28 09:18:01 -05:00
import initI18n from './i18n/init';
import ApiResourceDetails from './pages/ApiResourceDetails';
import ApiResources from './pages/ApiResources';
import ApplicationDetails from './pages/ApplicationDetails';
import Applications from './pages/Applications';
2022-06-01 03:54:24 -05:00
import AuditLogs from './pages/AuditLogs';
2022-03-15 00:22:07 -05:00
import Callback from './pages/Callback';
import ConnectorDetails from './pages/ConnectorDetails';
2022-03-07 22:10:46 -05:00
import Connectors from './pages/Connectors';
2022-06-01 01:01:40 -05:00
import Dashboard from './pages/Dashboard';
import GetStarted from './pages/GetStarted';
2022-03-16 02:49:30 -05:00
import NotFound from './pages/NotFound';
2022-04-23 22:46:35 -05:00
import Settings from './pages/Settings';
2022-04-12 02:30:43 -05:00
import SignInExperience from './pages/SignInExperience';
2022-03-14 23:54:15 -05:00
import UserDetails from './pages/UserDetails';
2022-03-14 04:13:24 -05:00
import Users from './pages/Users';
2022-02-28 09:18:01 -05:00
void initI18n();
const Main = () => {
const swrOptions = useSwrOptions();
2022-02-27 21:35:14 -05:00
return (
<ErrorBoundary>
<SWRConfig value={swrOptions}>
<AppBoundary>
<Toast />
<Routes>
<Route path="callback" element={<Callback />} />
<Route element={<AppContent />}>
<Route path="*" element={<NotFound />} />
<Route path="get-started" element={<GetStarted />} />
<Route path="applications">
<Route index element={<Applications />} />
<Route path=":id">
<Route index element={<Navigate to="settings" />} />
<Route path="settings" element={<ApplicationDetails />} />
<Route path="advanced-settings" element={<ApplicationDetails />} />
</Route>
</Route>
<Route path="api-resources">
<Route index element={<ApiResources />} />
<Route path=":id" element={<ApiResourceDetails />} />
</Route>
<Route path="connectors">
<Route index element={<Connectors />} />
<Route path="social" element={<Connectors />} />
<Route path=":connectorId" element={<ConnectorDetails />} />
</Route>
<Route path="users">
<Route index element={<Users />} />
<Route path=":id" element={<UserDetails />} />
</Route>
<Route path="sign-in-experience">
<Route index element={<Navigate to="experience" />} />
<Route path=":tab" element={<SignInExperience />} />
</Route>
<Route path="settings" element={<Settings />} />
<Route path="audit-logs">
<Route index element={<AuditLogs />} />
</Route>
<Route path="dashboard" element={<Dashboard />} />
2022-03-11 06:04:27 -05:00
</Route>
</Routes>
</AppBoundary>
</SWRConfig>
</ErrorBoundary>
2022-02-27 21:35:14 -05:00
);
};
const App = () => (
<BrowserRouter basename={getBasename('console', '5002')}>
<LogtoProvider
config={{
endpoint: window.location.origin,
appId: adminConsoleApplicationId,
resources: [managementResource.indicator],
}}
>
<Main />
</LogtoProvider>
</BrowserRouter>
);
export default App;