App.jsx 4.71 KB
Newer Older
Florent Chehab's avatar
Florent Chehab committed
1
2
/** General app JS entry
 */
3

4
import React, { useMemo } from "react";
5
6
import { compose } from "recompose";
import { Route, Switch } from "react-router-dom";
7
import FullScreenDialogServiceComponent from "../services/FullScreenDialogServiceComponent";
8
import { withErrorBoundary } from "../common/ErrorBoundary";
9

10
11
12
13
import PageMap from "../pages/PageMap";
import PageHome from "../pages/PageHome";
import PageUniversity from "../pages/PageUniversity";
import PageSearch from "../pages/PageSearch";
14
import PageSettings from "../pages/PageThemeSettings";
15
import PageUser from "../pages/PageUser";
16
import PageLists from "../pages/PageLists";
17
import MainAppFrame from "./MainAppFrame";
18
import APP_ROUTES from "../../config/appRoutes";
19
import PageAboutProject from "../pages/PageAboutProject";
20
import { PageCgu, PageRgpd } from "../pages/PagesRgpdCgu";
21
import PageNotFound from "../pages/PageNotFound";
22
23
import PageEditPreviousExchanges from "../pages/PageEditExchangeFeedbacks";
import PageMyExchanges from "../pages/PageMyExchanges";
24
25
import NotifierImportantInformation from "./NotifierImportantInformation";
import FooterImportantInformation from "./FooterImportantInformation";
26
import PageAboutUnlinkedPartners from "../pages/PageAboutUnlinkedPartners";
Florent Chehab's avatar
Florent Chehab committed
27
import PageLogout from "../pages/PageLogout";
28
import withNetworkWrapper, { NetWrapParam } from "../../hoc/withNetworkWrapper";
29
import FullScreenDialogService from "../../services/FullScreenDialogService";
30
31
import NotificationServiceComponent from "../services/NotificationServiceComponent";
import NotificationService from "../../services/NotificationService";
32
33
34
35
36
import UniversityService from "../../services/data/UniversityService";
import CityService from "../../services/data/CityService";
import CountryService from "../../services/data/CountryService";
import CurrencyService from "../../services/data/CurrencyService";
import LanguageService from "../../services/data/LanguageService";
37

38
39
40
41
42
43
44
const SERVICES_TO_INITIALIZE = [
  UniversityService,
  CityService,
  CountryService,
  CurrencyService,
  LanguageService
];
45
// import PageFiles from "../pages/PageFiles";
46

Florent Chehab's avatar
Florent Chehab committed
47
/**
48
 * Main entry
Florent Chehab's avatar
Florent Chehab committed
49
 */
50
function App() {
51
52
53
  // Not using useEffect as it might not be called on first render exactly,
  // Here we really need to have this stuff initialzed.
  useMemo(() => {
54
55
56
    SERVICES_TO_INITIALIZE.forEach(service => service.initialize());
  }, []);

57
58
59
60
61
62
63
64
65
66
  return (
    <div
      style={{
        display: "flex",
        flexDirection: "column",
        justifyItems: "flex-end",
        minHeight: "100vh"
      }}
    >
      <MainAppFrame>
67
68
69
70
        <FullScreenDialogServiceComponent
          ref={FullScreenDialogService.setComponent}
        />
        <NotificationServiceComponent ref={NotificationService.setComponent} />
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
        <NotifierImportantInformation />
        <main>
          <Switch>
            <Route exact path={APP_ROUTES.base} component={PageHome} />
            <Route path={APP_ROUTES.search} component={PageSearch} />
            <Route path={APP_ROUTES.map} component={PageMap} />
            <Route path={APP_ROUTES.themeSettings} component={PageSettings} />
            <Route path={APP_ROUTES.listsWithParams} component={PageLists} />
            <Route
              path={APP_ROUTES.universityWithParams}
              component={PageUniversity}
            />
            <Route path={APP_ROUTES.myExchanges} component={PageMyExchanges} />
            <Route
              path={APP_ROUTES.editPreviousExchangeWithParams}
              component={PageEditPreviousExchanges}
            />
            <Route path={APP_ROUTES.userWithParams} component={PageUser} />
            {/* <Route path={APP_ROUTES.userFilesWithParams} component={PageFiles}/> WARNING BETA */}
            <Route
              path={APP_ROUTES.aboutProject}
              component={PageAboutProject}
            />
            <Route path={APP_ROUTES.aboutRgpd} component={PageRgpd} />
            <Route path={APP_ROUTES.aboutCgu} component={PageCgu} />
            <Route
              path={APP_ROUTES.aboutUnlinkedPartners}
              component={PageAboutUnlinkedPartners}
            />
            <Route path={APP_ROUTES.logout} component={PageLogout} />
            <Route component={PageNotFound} />
          </Switch>
        </main>
      </MainAppFrame>
      <FooterImportantInformation />
    </div>
  );
Florent Chehab's avatar
Florent Chehab committed
108
109
}

110
App.propTypes = {};
Florent Chehab's avatar
Florent Chehab committed
111

112
export default compose(
113
114
115
116
117
118
119
120
121
  withNetworkWrapper([
    new NetWrapParam("countries", "all"),
    new NetWrapParam("cities", "all"),
    new NetWrapParam("universities", "all"),
    new NetWrapParam("mainCampuses", "all"),
    new NetWrapParam("currencies", "all"),
    new NetWrapParam("languages", "all"),
    new NetWrapParam("serverModerationStatus", "all") // not needed for server moderation status
  ]),
122
  withErrorBoundary()
123
)(App);