Newer
Older
import React from 'react'
import { Route, Switch, Redirect, HashRouter } from 'react-router-dom'
import { createBrowserHistory } from 'history'
import { Layout, Main, Content } from 'cozy-ui/react/Layout'
import { Sprite as IconSprite } from 'cozy-ui/react/Icon'
import { FluidType } from 'enum/fluid.enum'
import AppContextProvider from 'components/Contexts/AppContextProvider'
import Navbar from 'components/ContentComponents/Navbar/Navbar'
import ScrollToTop from 'components/ContainerComponents/ScrollToTop/ScrollToTop'
import HomeViewContainer from 'components/ContainerComponents/ViewContainer/HomeViewContainer'
import ChallengesViewContainer from 'components/ContainerComponents/ViewContainer/ChallengesViewContainer'
import SingleFluidViewContainer from './SingleFluidViewContainer'
import ParametersViewContainer from 'components/ContainerComponents/ViewContainer/ParametersViewContainer'
import FAQViewContainer from 'components/ContainerComponents/ViewContainer/FAQViewContainer'
import FinishedChallengeDetailsViewContainer from './FinishedChallengeDetailsViewContainer'
import OngoingChallengeDetailsViewContainer from './OngoingChallengeDetailsViewContainer'
import LockedChallengeDetailsViewContainer from './LockedChallengeDetailsViewContainer'
import AvailableChallengeDetailsViewContainer from './AvailableChallengeDetailsViewContainer'
import SplashContainer from 'components/ContainerComponents/SplashContainer/SplashContainer'
import WelcomeModalContainer from '../WelcomeModalContainer/WelcomeModalContainer'
export const history = createBrowserHistory()
export const ViewContainer = () => {
return (
<HashRouter {...history}>
<Layout>
<AppContextProvider>
<Navbar />
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<Main>
<Content className="app-content">
<ScrollToTop>
<Switch>
<Route
path="/consumption"
render={({ match: { url } }) => (
<>
<Route
path={`${url}/electricité`}
component={() => (
<SingleFluidViewContainer
fluidTypes={[FluidType.ELECTRICITY]}
/>
)}
/>
<Route
path={`${url}/eau`}
component={() => (
<SingleFluidViewContainer
fluidTypes={[FluidType.WATER]}
/>
)}
/>
<Route
path={`${url}/gaz`}
component={() => (
<SingleFluidViewContainer
fluidTypes={[FluidType.GAS]}
/>
)}
/>
<Route
path={`${url}/`}
component={HomeViewContainer}
exact
/>
</>
)}
/>
<Route
path="/challenges"
render={({ match: { url } }) => (
<>
<Route
path={`${url}/locked`}
component={LockedChallengeDetailsViewContainer}
/>
<Route
path={`${url}/available`}
component={AvailableChallengeDetailsViewContainer}
/>
<Route
path={`${url}/ongoing`}
component={OngoingChallengeDetailsViewContainer}
/>
<Route
path={`${url}/finished`}
component={FinishedChallengeDetailsViewContainer}
/>
<Route
path={`${url}/`}
component={ChallengesViewContainer}
exact
/>
</>
)}
/>
<Route
path="/parameters"
render={({ match: { url } }) => (
<>
<Route
path={`${url}/FAQ`}
component={FAQViewContainer}
/>
<Route
path={`${url}/`}
component={ParametersViewContainer}
exact
/>
</>
)}
/>
<Route path="/splash" component={SplashContainer} />
<Redirect from="/" to="/consumption" />
<Redirect from="*" to="/consumption" />
</Switch>
</ScrollToTop>
</Content>
</Main>
<IconSprite />
</AppContextProvider>
</Layout>
</HashRouter>
)
}
export default ViewContainer