2022-05-17 08:37:30 -05:00
|
|
|
import { LogtoProvider } from '@logto/react';
|
2022-06-02 02:32:46 -05:00
|
|
|
import { adminConsoleApplicationId, managementResource } from '@logto/schemas/lib/seeds';
|
2022-05-30 23:39:03 -05:00
|
|
|
import { getBasename } from '@logto/shared';
|
2022-06-07 08:33:53 -05:00
|
|
|
import React, { Suspense } from 'react';
|
2022-05-17 08:37:30 -05:00
|
|
|
import { BrowserRouter, Navigate, Route, Routes } from 'react-router-dom';
|
|
|
|
import { SWRConfig } from 'swr';
|
2022-06-07 08:33:53 -05:00
|
|
|
|
2022-02-27 21:35:14 -05:00
|
|
|
import './scss/normalized.scss';
|
2022-05-14 07:51:55 -05:00
|
|
|
// eslint-disable-next-line import/no-unassigned-import
|
|
|
|
import '@fontsource/roboto-mono';
|
2022-06-07 08:33:53 -05:00
|
|
|
import AppBoundary from '@/components/AppBoundary';
|
2022-06-09 23:52:32 -05:00
|
|
|
import AppLoading from '@/components/AppLoading';
|
2022-06-07 08:33:53 -05:00
|
|
|
import ErrorBoundary from '@/components/ErrorBoundary';
|
|
|
|
import Toast from '@/components/Toast';
|
|
|
|
import useSwrOptions from '@/hooks/use-swr-options';
|
|
|
|
import initI18n from '@/i18n/init';
|
2022-03-04 04:26:34 -05:00
|
|
|
|
2022-06-07 08:33:53 -05:00
|
|
|
const AppContent = React.lazy(async () => import('@/components/AppContent'));
|
|
|
|
const ApiResourceDetails = React.lazy(async () => import('@/pages/ApiResourceDetails'));
|
|
|
|
const ApiResources = React.lazy(async () => import('@/pages/ApiResources'));
|
|
|
|
const ApplicationDetails = React.lazy(async () => import('@/pages/ApplicationDetails'));
|
|
|
|
const Applications = React.lazy(async () => import('@/pages/Applications'));
|
|
|
|
const AuditLogs = React.lazy(async () => import('@/pages/AuditLogs'));
|
2022-06-08 02:58:50 -05:00
|
|
|
const AuditLogDetails = React.lazy(async () => import('@/pages/AuditLogDetails'));
|
2022-06-07 08:33:53 -05:00
|
|
|
const Callback = React.lazy(async () => import('@/pages/Callback'));
|
|
|
|
const ConnectorDetails = React.lazy(async () => import('@/pages/ConnectorDetails'));
|
|
|
|
const Connectors = React.lazy(async () => import('@/pages/Connectors'));
|
|
|
|
const Dashboard = React.lazy(async () => import('@/pages/Dashboard'));
|
|
|
|
const GetStarted = React.lazy(async () => import('@/pages/GetStarted'));
|
|
|
|
const NotFound = React.lazy(async () => import('@/pages/NotFound'));
|
|
|
|
const Settings = React.lazy(async () => import('@/pages/Settings'));
|
|
|
|
const SignInExperience = React.lazy(async () => import('@/pages/SignInExperience'));
|
|
|
|
const UserDetails = React.lazy(async () => import('@/pages/UserDetails'));
|
|
|
|
const Users = React.lazy(async () => import('@/pages/Users'));
|
2022-03-03 02:44:42 -05:00
|
|
|
|
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 = () => {
|
2022-06-06 22:59:17 -05:00
|
|
|
const swrOptions = useSwrOptions();
|
2022-05-05 05:42:10 -05:00
|
|
|
|
2022-02-27 21:35:14 -05:00
|
|
|
return (
|
2022-05-05 00:24:01 -05:00
|
|
|
<ErrorBoundary>
|
2022-06-06 22:59:17 -05:00
|
|
|
<SWRConfig value={swrOptions}>
|
2022-06-01 02:13:48 -05:00
|
|
|
<AppBoundary>
|
|
|
|
<Toast />
|
2022-06-09 23:52:32 -05:00
|
|
|
<Suspense fallback={<AppLoading />}>
|
2022-06-07 08:33:53 -05:00
|
|
|
<Routes>
|
|
|
|
<Route path="callback" element={<Callback />} />
|
2022-06-08 22:42:52 -05:00
|
|
|
{/* TODO: add register route */}
|
|
|
|
<Route path="register" element={<div>register</div>} />
|
2022-06-07 08:33:53 -05:00
|
|
|
<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>
|
2022-06-01 02:13:48 -05:00
|
|
|
</Route>
|
2022-06-07 08:33:53 -05:00
|
|
|
<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 />} />
|
2022-06-09 21:33:46 -05:00
|
|
|
<Route path=":id/logs" element={<UserDetails />} />
|
2022-06-07 08:33:53 -05:00
|
|
|
</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 />} />
|
2022-06-08 02:58:50 -05:00
|
|
|
<Route path=":logId" element={<AuditLogDetails />} />
|
2022-06-07 08:33:53 -05:00
|
|
|
</Route>
|
|
|
|
<Route path="dashboard" element={<Dashboard />} />
|
2022-05-05 00:24:01 -05:00
|
|
|
</Route>
|
2022-06-07 08:33:53 -05:00
|
|
|
</Routes>
|
|
|
|
</Suspense>
|
2022-06-01 02:13:48 -05:00
|
|
|
</AppBoundary>
|
2022-05-05 00:24:01 -05:00
|
|
|
</SWRConfig>
|
|
|
|
</ErrorBoundary>
|
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-05-30 23:39:03 -05:00
|
|
|
<BrowserRouter basename={getBasename('console', '5002')}>
|
2022-03-16 02:34:03 -05:00
|
|
|
<LogtoProvider
|
2022-05-23 06:18:48 -05:00
|
|
|
config={{
|
|
|
|
endpoint: window.location.origin,
|
|
|
|
appId: adminConsoleApplicationId,
|
2022-06-02 02:32:46 -05:00
|
|
|
resources: [managementResource.indicator],
|
2022-05-23 06:18:48 -05:00
|
|
|
}}
|
2022-03-16 02:34:03 -05:00
|
|
|
>
|
|
|
|
<Main />
|
|
|
|
</LogtoProvider>
|
2022-03-03 02:02:30 -05:00
|
|
|
</BrowserRouter>
|
|
|
|
);
|
|
|
|
|
|
|
|
export default App;
|