App.jsx 4.97 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
import FilterService from "../../services/FilterService";
Florent Chehab's avatar
Florent Chehab committed
38
39
import AlertServiceComponent from "../services/AlertServiceComponent";
import AlertService from "../../services/AlertService";
40

41
42
43
44
45
const SERVICES_TO_INITIALIZE = [
  UniversityService,
  CityService,
  CountryService,
  CurrencyService,
46
47
  LanguageService,
  FilterService
48
];
49
// import PageFiles from "../pages/PageFiles";
50

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

61
62
63
64
65
66
67
68
69
70
  return (
    <div
      style={{
        display: "flex",
        flexDirection: "column",
        justifyItems: "flex-end",
        minHeight: "100vh"
      }}
    >
      <MainAppFrame>
Florent Chehab's avatar
Florent Chehab committed
71
        <AlertServiceComponent ref={AlertService.setComponent} />
72
73
74
75
        <FullScreenDialogServiceComponent
          ref={FullScreenDialogService.setComponent}
        />
        <NotificationServiceComponent ref={NotificationService.setComponent} />
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
108
109
110
111
112
        <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
113
114
}

115
App.propTypes = {};
Florent Chehab's avatar
Florent Chehab committed
116

117
export default compose(
118
119
120
121
122
123
124
125
126
  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
  ]),
127
  withErrorBoundary()
128
)(App);