zepio/app/router/router.js

75 lines
2.2 KiB
JavaScript
Raw Normal View History

// @flow
import React from 'react';
2018-12-11 16:15:38 -08:00
import { Route, Switch, type Location } 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';
import { SettingsView } from '../views/settings';
import { NotFoundView } from '../views/not-found';
2018-12-05 08:32:13 -08:00
import { ConsoleView } from '../views/console';
import { LayoutComponent } from '../components/layout';
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('/', '');
};
2018-12-11 16:15:38 -08:00
export const RouterComponent = ({ location }: { location: Location }) => (
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>
<SidebarContainer location={location} />
2018-12-20 09:18:07 -08:00
{/* $FlowFixMe */}
<LayoutComponent>
<ScrollTopComponent>
2018-12-12 11:05:33 -08:00
<Switch>
2018-12-15 07:10:39 -08:00
<Route
exact
path={DASHBOARD_ROUTE}
component={DashboardContainer}
/>
2018-12-20 10:56:45 -08:00
<Route path={SEND_ROUTE} component={SendContainer} />
2019-01-07 10:06:16 -08:00
<Route path={RECEIVE_ROUTE} component={ReceiveContainer} />
2018-12-12 11:05:33 -08:00
<Route path={SETTINGS_ROUTE} component={SettingsView} />
<Route path={CONSOLE_ROUTE} component={ConsoleView} />
2018-12-15 14:36:50 -08:00
<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>
);