-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.web.js
51 lines (43 loc) · 1.9 KB
/
App.web.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import * as React from 'react';
import { Switch, Router, Route } from 'react-router-dom';
import { createBrowserHistory } from 'history';
import * as routes from '~/constants/routes';
import { Home } from '~/screens/home';
import { About } from '~/screens/about';
import { Results } from '~/screens/results';
import { Login } from '~/screens/login';
import { ForgottenPassword } from '~/screens/forgotten-password';
import { Subscriptions } from '~/screens/subscriptions';
import { SubscriptionModal } from '~/screens/subscriptions/components/details';
import { SearchPlaceModal } from '~/screens/search-destination';
import { SearchDateModal } from '~/screens/search-date';
import { FiltersModal } from '~/screens/filters';
const customHistory = createBrowserHistory();
const navigation = {
navigate: (path, opt) => customHistory.push(path, opt),
goBack: customHistory.goBack,
};
const getPath = route => `/${route}`;
const render = Component => ({ match, location }) => (
<Component navigation={navigation} params={match?.params} search={location?.search} />
);
const getRoute = (Component, route) => <Route path={getPath(route)} render={render(Component)} />;
const App = () => {
return (
<Router history={customHistory}>
<Switch>
{getRoute(About, routes.about)}
{getRoute(Results, routes.results)}
{getRoute(Login, routes.login)}
{getRoute(ForgottenPassword, routes.forgottenPassword)}
{getRoute(Subscriptions, routes.subscriptions)}
{getRoute(SubscriptionModal, `${routes.subscriptionModal}/:id`)}
{getRoute(SearchPlaceModal, routes.searchPlaceModal)}
{getRoute(SearchDateModal, routes.searchDateModal)}
{getRoute(FiltersModal, routes.filtersModal)}
{getRoute(Home, '')}
</Switch>
</Router>
);
};
export default App;