2021-02-08 11:03:30 -05:00
|
|
|
import React from 'react';
|
|
|
|
import { Route, Switch } from 'react-router-dom';
|
2018-09-17 16:27:52 -04:00
|
|
|
|
2019-11-13 14:23:22 -05:00
|
|
|
import 'bootstrap/dist/css/bootstrap.min.css';
|
2019-11-13 14:20:47 -05:00
|
|
|
import './app.css';
|
|
|
|
|
2021-02-08 11:03:30 -05:00
|
|
|
import { AuthRoute, PrivateRoute } from './route';
|
2021-02-22 01:59:24 -05:00
|
|
|
import { AuthProvider } from './auth-context';
|
2021-01-24 22:50:48 -05:00
|
|
|
import { Header } from './header';
|
2021-02-22 01:59:24 -05:00
|
|
|
import { MapApp } from './map-app';
|
|
|
|
import { Building, UserVerified } from './models/building';
|
2019-11-07 02:39:26 -05:00
|
|
|
import { User } from './models/user';
|
2019-08-14 03:37:27 -04:00
|
|
|
import AboutPage from './pages/about';
|
2019-11-14 10:28:12 -05:00
|
|
|
import ChangesPage from './pages/changes';
|
2020-02-03 16:15:49 -05:00
|
|
|
import CodeOfConductPage from './pages/code-of-conduct';
|
2019-11-07 02:39:26 -05:00
|
|
|
import ContactPage from './pages/contact';
|
2019-08-14 03:37:27 -04:00
|
|
|
import ContributorAgreementPage from './pages/contributor-agreement';
|
2019-11-07 02:39:26 -05:00
|
|
|
import DataAccuracyPage from './pages/data-accuracy';
|
2019-09-30 11:03:16 -04:00
|
|
|
import DataExtracts from './pages/data-extracts';
|
2019-12-16 08:26:13 -05:00
|
|
|
import LeaderboardPage from './pages/leaderboard';
|
2019-11-07 02:39:26 -05:00
|
|
|
import OrdnanceSurveyLicencePage from './pages/ordnance-survey-licence';
|
|
|
|
import OrdnanceSurveyUprnPage from './pages/ordnance-survey-uprn';
|
|
|
|
import PrivacyPolicyPage from './pages/privacy-policy';
|
|
|
|
import ForgottenPassword from './user/forgotten-password';
|
2021-02-08 11:03:30 -05:00
|
|
|
import { Login } from './user/login';
|
|
|
|
import { MyAccountPage } from './user/my-account';
|
2019-08-23 09:16:40 -04:00
|
|
|
import PasswordReset from './user/password-reset';
|
2021-02-08 11:03:30 -05:00
|
|
|
import { SignUp } from './user/signup';
|
|
|
|
import { NotFound } from './pages/not-found';
|
2019-08-14 04:02:57 -04:00
|
|
|
|
2019-09-08 20:09:05 -04:00
|
|
|
|
|
|
|
interface AppProps {
|
2019-11-05 15:13:10 -05:00
|
|
|
user?: User;
|
|
|
|
building?: Building;
|
2021-02-22 01:59:24 -05:00
|
|
|
user_verified?: UserVerified;
|
|
|
|
revisionId: string;
|
2019-09-08 20:09:05 -04:00
|
|
|
}
|
2019-08-14 03:37:27 -04:00
|
|
|
|
2019-02-05 16:41:31 -05:00
|
|
|
/**
|
|
|
|
* App component
|
|
|
|
*
|
|
|
|
* This is the top-level stateful frontend component
|
|
|
|
* - rendered from props, instantiated either server-side in server.js or client-side in
|
|
|
|
* client.js
|
|
|
|
* - state (including user, current building) is initialised from props
|
|
|
|
* - callbacks to update top-level state are passed down to subcomponents
|
|
|
|
* - render method wraps a react-router switch - this drives which version of the sidebar and
|
|
|
|
* map or other pages are rendered, based on the URL. Use a react-router-dom <Link /> in
|
|
|
|
* child components to navigate without a full page reload.
|
|
|
|
*/
|
2018-09-09 17:22:44 -04:00
|
|
|
|
2021-02-08 11:03:30 -05:00
|
|
|
export const App: React.FC<AppProps> = props => {
|
|
|
|
const mapAppPaths = ['/', '/:mode(view|edit|multi-edit)/:category/:building(\\d+)?/(history)?'];
|
2018-09-09 17:22:44 -04:00
|
|
|
|
2021-02-08 11:03:30 -05:00
|
|
|
return (
|
2021-02-17 17:43:04 -05:00
|
|
|
<AuthProvider preloadedUser={props.user}>
|
2019-10-28 12:46:22 -04:00
|
|
|
<Switch>
|
2021-02-08 11:03:30 -05:00
|
|
|
<Route exact path={mapAppPaths}>
|
|
|
|
<Header animateLogo={false} />
|
2019-10-28 12:46:22 -04:00
|
|
|
</Route>
|
|
|
|
<Route>
|
2021-02-08 11:03:30 -05:00
|
|
|
<Header animateLogo={true} />
|
2019-10-28 12:46:22 -04:00
|
|
|
</Route>
|
|
|
|
</Switch>
|
2019-08-14 14:33:26 -04:00
|
|
|
<Switch>
|
|
|
|
<Route exact path="/about.html" component={AboutPage} />
|
2021-02-08 11:03:30 -05:00
|
|
|
<AuthRoute exact path="/login.html" component={Login} />
|
|
|
|
<AuthRoute exact path="/forgotten-password.html" component={ForgottenPassword} />
|
|
|
|
<AuthRoute exact path="/password-reset.html" component={PasswordReset} />
|
|
|
|
<AuthRoute exact path="/sign-up.html" component={SignUp} />
|
|
|
|
<PrivateRoute exact path="/my-account.html" component={MyAccountPage} />
|
2019-08-14 14:33:26 -04:00
|
|
|
<Route exact path="/privacy-policy.html" component={PrivacyPolicyPage} />
|
|
|
|
<Route exact path="/contributor-agreement.html" component={ContributorAgreementPage} />
|
2019-10-03 09:55:54 -04:00
|
|
|
<Route exact path="/ordnance-survey-licence.html" component={OrdnanceSurveyLicencePage} />
|
|
|
|
<Route exact path="/ordnance-survey-uprn.html" component={OrdnanceSurveyUprnPage} />
|
2019-10-02 14:26:18 -04:00
|
|
|
<Route exact path="/data-accuracy.html" component={DataAccuracyPage} />
|
2019-09-30 10:06:01 -04:00
|
|
|
<Route exact path="/data-extracts.html" component={DataExtracts} />
|
2019-10-02 13:38:12 -04:00
|
|
|
<Route exact path="/contact.html" component={ContactPage} />
|
2020-02-03 16:15:49 -05:00
|
|
|
<Route exact path="/code-of-conduct.html" component={CodeOfConductPage} />
|
2019-12-16 08:26:13 -05:00
|
|
|
<Route exact path="/leaderboard.html" component={LeaderboardPage} />
|
2019-11-14 10:28:12 -05:00
|
|
|
<Route exact path="/history.html" component={ChangesPage} />
|
2021-02-22 01:59:24 -05:00
|
|
|
<Route exact path={mapAppPaths} >
|
|
|
|
<MapApp
|
|
|
|
building={props.building}
|
|
|
|
user_verified={props.user_verified}
|
|
|
|
revisionId={props.revisionId}
|
|
|
|
/>
|
|
|
|
</Route>
|
2019-08-14 14:33:26 -04:00
|
|
|
<Route component={NotFound} />
|
|
|
|
</Switch>
|
2021-02-08 11:03:30 -05:00
|
|
|
</AuthProvider>
|
|
|
|
);
|
|
|
|
};
|