2023-01-14 07:33:17 +01:00
|
|
|
/*
|
|
|
|
* Copyright [2021] [wisemapping]
|
|
|
|
*
|
|
|
|
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
|
|
|
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
|
|
|
* "powered by wisemapping" text requirement on every single page;
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the license at
|
|
|
|
*
|
|
|
|
* http://www.wisemapping.org/license
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
2022-11-16 22:15:34 +01:00
|
|
|
import React, { ReactElement, Suspense, useEffect } from 'react';
|
2022-11-12 18:08:14 +01:00
|
|
|
import { FormattedMessage, IntlProvider } from 'react-intl';
|
2022-11-16 22:15:34 +01:00
|
|
|
import { Route, Routes, BrowserRouter as Router, useNavigate } from 'react-router-dom';
|
2021-02-23 08:02:15 +01:00
|
|
|
import ForgotPasswordSuccessPage from './components/forgot-password-success-page';
|
|
|
|
import RegistationPage from './components/registration-page';
|
|
|
|
import LoginPage from './components/login-page';
|
|
|
|
import store from './redux/store';
|
|
|
|
import { ForgotPasswordPage } from './components/forgot-password-page';
|
|
|
|
import { Provider } from 'react-redux';
|
|
|
|
import { QueryClient, QueryClientProvider } from 'react-query';
|
|
|
|
import { theme } from './theme';
|
|
|
|
import AppI18n, { Locales } from './classes/app-i18n';
|
2022-02-06 01:42:43 +01:00
|
|
|
import CssBaseline from '@mui/material/CssBaseline';
|
2023-01-05 01:48:01 +01:00
|
|
|
import { ThemeProvider as MuiThemeProvider, StyledEngineProvider } from '@mui/material/styles';
|
2022-05-29 19:22:57 +02:00
|
|
|
import ReactGA from 'react-ga4';
|
2022-02-16 05:39:52 +01:00
|
|
|
import AppConfig from './classes/app-config';
|
2022-08-16 05:35:27 +02:00
|
|
|
import RegistrationSuccessPage from './components/registration-success-page';
|
2023-01-05 01:48:01 +01:00
|
|
|
import { ThemeProvider } from '@emotion/react';
|
2022-12-16 04:32:22 +01:00
|
|
|
import RegistrationCallbackPage from './components/registration-callback';
|
2021-02-27 21:15:48 +01:00
|
|
|
|
2022-11-17 03:32:33 +01:00
|
|
|
const EditorPage = React.lazy(() => import('./components/editor-page'));
|
2022-08-16 05:00:49 +02:00
|
|
|
const MapsPage = React.lazy(() => import('./components/maps-page'));
|
2022-02-06 01:42:43 +01:00
|
|
|
|
2021-02-27 21:15:48 +01:00
|
|
|
// Google Analytics Initialization.
|
2023-01-14 07:33:17 +01:00
|
|
|
const trackingId = AppConfig.getGoogleAnalyticsAccount();
|
|
|
|
if (trackingId) {
|
|
|
|
ReactGA.initialize([
|
|
|
|
{
|
|
|
|
trackingId: trackingId,
|
|
|
|
},
|
|
|
|
]);
|
|
|
|
}
|
2021-02-02 09:20:35 +01:00
|
|
|
const queryClient = new QueryClient({
|
2022-07-09 03:34:52 +02:00
|
|
|
defaultOptions: {
|
|
|
|
queries: {
|
|
|
|
refetchIntervalInBackground: false,
|
|
|
|
staleTime: 5 * 1000 * 60, // 10 minutes
|
2021-02-23 07:37:29 +01:00
|
|
|
},
|
2022-07-09 03:34:52 +02:00
|
|
|
},
|
2021-02-23 08:02:15 +01:00
|
|
|
});
|
2021-02-02 09:20:35 +01:00
|
|
|
|
2022-11-16 22:15:34 +01:00
|
|
|
// eslint-disable-next-line react/prop-types
|
|
|
|
function Redirect({ to }) {
|
|
|
|
const navigate = useNavigate();
|
|
|
|
useEffect(() => {
|
|
|
|
navigate(to);
|
|
|
|
});
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2021-02-23 07:37:29 +01:00
|
|
|
const App = (): ReactElement => {
|
2022-07-09 03:34:52 +02:00
|
|
|
const locale = AppI18n.getDefaultLocale();
|
2022-02-21 03:50:03 +01:00
|
|
|
|
2022-07-09 03:34:52 +02:00
|
|
|
return locale.message ? (
|
|
|
|
<Provider store={store}>
|
|
|
|
<QueryClientProvider client={queryClient}>
|
|
|
|
<IntlProvider
|
|
|
|
locale={locale.code}
|
|
|
|
defaultLocale={Locales.EN.code}
|
|
|
|
messages={locale.message as Record<string, string>}
|
|
|
|
>
|
|
|
|
<StyledEngineProvider injectFirst>
|
2023-01-05 01:48:01 +01:00
|
|
|
<MuiThemeProvider theme={theme}>
|
|
|
|
<ThemeProvider theme={theme}>
|
|
|
|
<CssBaseline />
|
|
|
|
<Router>
|
|
|
|
<Routes>
|
|
|
|
<Route path="/" element={<Redirect to="/c/login" />} />
|
|
|
|
<Route path="/c/login" element={<LoginPage />} />
|
|
|
|
<Route path="/c/registration" element={<RegistationPage />} />
|
|
|
|
<Route path="/c/registration-google" element={<RegistrationCallbackPage />} />
|
|
|
|
<Route path="/c/registration-success" element={<RegistrationSuccessPage />} />
|
|
|
|
<Route path="/c/forgot-password" element={<ForgotPasswordPage />} />
|
|
|
|
<Route
|
|
|
|
path="/c/forgot-password-success"
|
|
|
|
element={<ForgotPasswordSuccessPage />}
|
|
|
|
/>
|
|
|
|
<Route
|
|
|
|
path="/c/maps/"
|
|
|
|
element={
|
|
|
|
<Suspense
|
|
|
|
fallback={
|
|
|
|
<div>
|
|
|
|
<FormattedMessage id="dialog.loading" defaultMessage="Loading ..." />
|
|
|
|
</div>
|
|
|
|
}
|
|
|
|
>
|
|
|
|
<MapsPage />
|
|
|
|
</Suspense>
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
<Route
|
|
|
|
path="/c/maps/:id/edit"
|
|
|
|
element={
|
|
|
|
<Suspense
|
|
|
|
fallback={
|
|
|
|
<div>
|
|
|
|
<FormattedMessage id="dialog.loading" defaultMessage="Loading ..." />
|
|
|
|
</div>
|
|
|
|
}
|
|
|
|
>
|
|
|
|
<EditorPage isTryMode={false} />
|
|
|
|
</Suspense>
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
<Route
|
|
|
|
path="/c/maps/:id/try"
|
|
|
|
element={
|
|
|
|
<Suspense
|
|
|
|
fallback={
|
|
|
|
<div>
|
|
|
|
<FormattedMessage id="dialog.loading" defaultMessage="Loading ..." />
|
|
|
|
</div>
|
|
|
|
}
|
|
|
|
>
|
|
|
|
<EditorPage isTryMode={true} />
|
|
|
|
</Suspense>
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
</Routes>
|
|
|
|
</Router>
|
|
|
|
</ThemeProvider>
|
|
|
|
</MuiThemeProvider>
|
2022-07-09 03:34:52 +02:00
|
|
|
</StyledEngineProvider>
|
|
|
|
</IntlProvider>
|
|
|
|
</QueryClientProvider>
|
|
|
|
</Provider>
|
|
|
|
) : (
|
2023-01-05 06:32:13 +01:00
|
|
|
<div>
|
|
|
|
<FormattedMessage id="dialog.loading" defaultMessage="Loading ..." />
|
|
|
|
</div>
|
2022-07-09 03:34:52 +02:00
|
|
|
);
|
2021-02-23 08:02:15 +01:00
|
|
|
};
|
2020-12-05 08:47:02 +01:00
|
|
|
|
2021-02-23 08:02:15 +01:00
|
|
|
export default App;
|