summaryrefslogtreecommitdiff
path: root/frontend/src/routes.js
blob: 61c6aacd6f9613ad0c20f6e655906670b73aeb45 (plain)
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
// @flow
import { fork } from 'redux-saga/effects';
import { SevenWondersSession } from './api/sevenWondersApi';
import Error404 from './components/errors/Error404';
import GameBrowser from './containers/gameBrowser';
import HomePage from './containers/home';
import Lobby from './containers/lobby';
import { HomeLayout, LobbyLayout } from './layouts';
import gameBrowserSaga from './sagas/gameBrowser';
import homeSaga from './sagas/home';
import lobbySaga from './sagas/lobby';

export const makeSagaRoutes = (sevenWondersSession: SevenWondersSession) => ({
  *'/'() {
    yield fork(homeSaga, sevenWondersSession);
  },
  *'/games'() {
    yield fork(gameBrowserSaga, sevenWondersSession);
  },
  *'/lobby/*'() {
    yield fork(lobbySaga, sevenWondersSession);
  },
});

export const routes = [
  {
    path: '/',
    component: HomeLayout,
    indexRoute: { component: HomePage },
  },
  {
    path: '/',
    component: LobbyLayout,
    childRoutes: [{ path: '/games', component: GameBrowser }, { path: '/lobby/*', component: Lobby }],
  },
  {
    path: '*',
    component: Error404,
  },
];
bgstack15