zepio/app/router/router.js

98 lines
2.5 KiB
JavaScript
Raw Normal View History

// @flow
import React from 'react';
import {
Route, Switch, type Location, type RouterHistory,
} from 'react-router-dom';
import styled from 'styled-components';
import { ScrollTopComponent } from './scroll-top';
import { SidebarContainer } from '../containers/sidebar';
2018-12-10 09:09:05 -08:00
import { DashboardContainer } from '../containers/dashboard';
2018-12-15 14:36:50 -08:00
import { TransactionsContainer } from '../containers/transactions';
2018-12-20 10:56:45 -08:00
import { SendContainer } from '../containers/send';
2019-01-07 10:06:16 -08:00
import { ReceiveContainer } from '../containers/receive';
2019-01-12 10:01:16 -08:00
import { SettingsContainer } from '../containers/settings';
import { NotFoundView } from '../views/not-found';
2018-12-05 08:32:13 -08:00
import { ConsoleView } from '../views/console';
import { AppContainer as LayoutComponent } from '../containers/app';
2018-12-12 11:05:33 -08:00
import { HeaderComponent } from '../components/header';
2018-12-05 08:32:13 -08:00
import {
2018-12-15 07:10:39 -08:00
DASHBOARD_ROUTE,
SEND_ROUTE,
RECEIVE_ROUTE,
SETTINGS_ROUTE,
CONSOLE_ROUTE,
2018-12-15 14:36:50 -08:00
TRANSACTIONS_ROUTE,
} from '../constants/routes';
2018-12-12 11:05:33 -08:00
const FullWrapper = styled.div`
display: flex;
flex-direction: column;
width: 100%;
`;
const ContentWrapper = styled.div`
display: flex;
flex-direction: row;
width: 100vw;
`;
2018-12-12 11:54:34 -08:00
const getTitle = (path: string) => {
if (path === '/') return 'Dashboard';
return path.replace('/', '');
};
export const RouterComponent = ({
location,
history,
}: {
location: Location,
history: RouterHistory,
}) => (
2018-12-12 11:05:33 -08:00
<FullWrapper>
2018-12-12 11:54:34 -08:00
<HeaderComponent title={getTitle(location.pathname)} />
2018-12-12 11:05:33 -08:00
<ContentWrapper>
2019-02-04 20:41:45 -08:00
<SidebarContainer
location={location}
history={history}
/>
2018-12-20 09:18:07 -08:00
{/* $FlowFixMe */}
<LayoutComponent>
<ScrollTopComponent>
2018-12-12 11:05:33 -08:00
<Switch>
2019-02-04 20:41:45 -08:00
<Route
exact
path={DASHBOARD_ROUTE}
component={DashboardContainer}
/>
<Route
path={SEND_ROUTE}
component={SendContainer}
/>
<Route
path={RECEIVE_ROUTE}
component={ReceiveContainer}
/>
<Route
path={SETTINGS_ROUTE}
component={SettingsContainer}
/>
<Route
path={CONSOLE_ROUTE}
component={ConsoleView}
/>
<Route
path={TRANSACTIONS_ROUTE}
component={TransactionsContainer}
/>
2018-12-12 11:05:33 -08:00
<Route component={NotFoundView} />
</Switch>
2018-12-20 09:18:07 -08:00
</ScrollTopComponent>
</LayoutComponent>
2018-12-12 11:05:33 -08:00
</ContentWrapper>
</FullWrapper>
);