diff --git a/packages/webapp/src/app.tsx b/packages/webapp/src/app.tsx index d58a1dfb..23784aa4 100644 --- a/packages/webapp/src/app.tsx +++ b/packages/webapp/src/app.tsx @@ -34,6 +34,7 @@ import AppConfig from './classes/app-config'; import RegistrationSuccessPage from './components/registration-success-page'; import { ThemeProvider } from '@emotion/react'; import RegistrationCallbackPage from './components/registration-callback'; +import ErrorPage from './components/error-page'; const EditorPage = React.lazy(() => import('./components/editor-page')); const MapsPage = React.lazy(() => import('./components/maps-page')); @@ -67,7 +68,9 @@ function Redirect({ to }) { const App = (): ReactElement => { const locale = AppI18n.getDefaultLocale(); + const overwriteView = window.errorMvcView; + // This is a hack to move error handling on Spring MVC. return locale.message ? ( @@ -80,62 +83,77 @@ const App = (): ReactElement => { - - - } /> - } /> - } /> - } /> - } /> - } /> - } - /> - - - - } - > - - - } - /> - - - - } - > - - - } - /> - - - - } - > - - - } - /> - - + {!overwriteView ? ( + + + } /> + } /> + } /> + } /> + } /> + } /> + } + /> + + + + } + > + + + } + /> + + + + } + > + + + } + /> + + + + } + > + + + } + /> + + + ) : ( + + + + )} diff --git a/packages/webapp/src/components/error-page/index.tsx b/packages/webapp/src/components/error-page/index.tsx new file mode 100644 index 00000000..f0f1ebdc --- /dev/null +++ b/packages/webapp/src/components/error-page/index.tsx @@ -0,0 +1,60 @@ +import React, { useEffect } from 'react'; +import { FormattedMessage, useIntl } from 'react-intl'; +import Header from '../layout/header'; +import Typography from '@mui/material/Typography'; +import ReactGA from 'react-ga4'; +import { ErrorBody } from './styled'; + +export type ErrorPageType = { + isSecurity: boolean; +}; + +const ErrorPage = ({ isSecurity }: ErrorPageType): React.ReactElement => { + const intl = useIntl(); + + useEffect(() => { + document.title = intl.formatMessage({ + id: 'error.page-title', + defaultMessage: 'Unexpected Error | WiseMapping', + }); + ReactGA.send({ hitType: 'pageview', page: window.location.pathname, title: 'ErrorPage' }); + }, []); + + return ( +
+
+ + + + {isSecurity ? ( + + ) : ( + + )} + + + + {isSecurity ? ( + + ) : ( + + )} + + +
+ ); +}; + +export default ErrorPage; diff --git a/packages/webapp/src/components/error-page/styled.ts b/packages/webapp/src/components/error-page/styled.ts new file mode 100644 index 00000000..5b1c6105 --- /dev/null +++ b/packages/webapp/src/components/error-page/styled.ts @@ -0,0 +1,7 @@ +import styled from 'styled-components'; + +export const ErrorBody = styled.div` + margin: auto; + width: 90%; + padding: 10px; +`; diff --git a/packages/webapp/src/components/layout/header/index.tsx b/packages/webapp/src/components/layout/header/index.tsx index ae411760..38a890fd 100644 --- a/packages/webapp/src/components/layout/header/index.tsx +++ b/packages/webapp/src/components/layout/header/index.tsx @@ -6,15 +6,17 @@ import { Link } from 'react-router-dom'; import Button from '@mui/material/Button'; import logo from './logo-small.svg'; +import { JSX } from '@emotion/react/jsx-runtime'; interface HeaderProps { type: 'only-signup' | 'only-signin' | 'none'; } export const Header = ({ type }: HeaderProps): React.ReactElement => { - let signUpButton; - let text; - let signInButton; + let signUpButton: string | JSX.Element | undefined; + let text: string | JSX.Element | undefined; + let signInButton: string | JSX.Element | undefined; + if (type === 'only-signup') { text = ( diff --git a/packages/webapp/src/index.tsx b/packages/webapp/src/index.tsx index d3e2c624..d6759619 100644 --- a/packages/webapp/src/index.tsx +++ b/packages/webapp/src/index.tsx @@ -7,6 +7,7 @@ import { createRoot } from 'react-dom/client'; declare global { interface Window { newrelic: { noticeError: (Error) => void }; + errorMvcView: string; } }