2018-12-15 12:01:40 +00:00
|
|
|
import React from 'react';
|
2018-12-15 20:15:17 +00:00
|
|
|
import { HashRouter as Router, Route, Link, Switch } from 'react-router-dom'
|
2018-12-15 12:01:40 +00:00
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import classNames from 'classnames';
|
|
|
|
import { withStyles } from '@material-ui/core/styles';
|
|
|
|
import Drawer from '@material-ui/core/Drawer';
|
|
|
|
import CssBaseline from '@material-ui/core/CssBaseline';
|
|
|
|
import AppBar from '@material-ui/core/AppBar';
|
|
|
|
import Toolbar from '@material-ui/core/Toolbar';
|
|
|
|
import List from '@material-ui/core/List';
|
|
|
|
import Typography from '@material-ui/core/Typography';
|
|
|
|
import Divider from '@material-ui/core/Divider';
|
|
|
|
import IconButton from '@material-ui/core/IconButton';
|
|
|
|
import MenuIcon from '@material-ui/icons/Menu';
|
|
|
|
import ChevronLeftIcon from '@material-ui/icons/ChevronLeft';
|
|
|
|
import ChevronRightIcon from '@material-ui/icons/ChevronRight';
|
|
|
|
import ListItem from '@material-ui/core/ListItem';
|
|
|
|
import ListItemIcon from '@material-ui/core/ListItemIcon';
|
|
|
|
import ListItemText from '@material-ui/core/ListItemText';
|
|
|
|
import InboxIcon from '@material-ui/icons/MoveToInbox';
|
2019-01-10 20:44:45 +00:00
|
|
|
import { ScaleLoader } from 'react-spinners'
|
2018-12-15 19:09:31 +00:00
|
|
|
import FundsManagement from './FundsManagement'
|
2018-12-15 20:15:17 +00:00
|
|
|
import ContractAdmin from './ContractAdmin'
|
2018-12-15 20:31:24 +00:00
|
|
|
import TransferGraph from './TransfersGraph'
|
2018-12-16 17:59:33 +00:00
|
|
|
import Dashboard from './Dashboard'
|
2018-12-15 12:01:40 +00:00
|
|
|
|
2018-12-15 19:09:31 +00:00
|
|
|
const drawerWidth = 240
|
2018-12-15 12:01:40 +00:00
|
|
|
|
|
|
|
const styles = theme => ({
|
|
|
|
root: {
|
|
|
|
display: 'flex',
|
|
|
|
},
|
|
|
|
appBar: {
|
|
|
|
transition: theme.transitions.create(['margin', 'width'], {
|
|
|
|
easing: theme.transitions.easing.sharp,
|
|
|
|
duration: theme.transitions.duration.leavingScreen,
|
|
|
|
}),
|
|
|
|
},
|
|
|
|
appBarShift: {
|
|
|
|
width: `calc(100% - ${drawerWidth}px)`,
|
|
|
|
marginLeft: drawerWidth,
|
|
|
|
transition: theme.transitions.create(['margin', 'width'], {
|
|
|
|
easing: theme.transitions.easing.easeOut,
|
|
|
|
duration: theme.transitions.duration.enteringScreen,
|
|
|
|
}),
|
|
|
|
},
|
2018-12-19 20:57:17 +00:00
|
|
|
appBarBg: {
|
|
|
|
backgroundColor: '#111735'
|
|
|
|
},
|
2018-12-15 12:01:40 +00:00
|
|
|
menuButton: {
|
|
|
|
marginLeft: 12,
|
|
|
|
marginRight: 20,
|
|
|
|
},
|
|
|
|
hide: {
|
|
|
|
display: 'none',
|
|
|
|
},
|
|
|
|
drawer: {
|
|
|
|
width: drawerWidth,
|
|
|
|
flexShrink: 0,
|
|
|
|
},
|
|
|
|
drawerPaper: {
|
|
|
|
width: drawerWidth,
|
|
|
|
},
|
|
|
|
drawerHeader: {
|
|
|
|
display: 'flex',
|
|
|
|
alignItems: 'center',
|
|
|
|
padding: '0 8px',
|
|
|
|
...theme.mixins.toolbar,
|
|
|
|
justifyContent: 'flex-end',
|
|
|
|
},
|
|
|
|
content: {
|
|
|
|
flexGrow: 1,
|
|
|
|
padding: theme.spacing.unit * 3,
|
|
|
|
transition: theme.transitions.create('margin', {
|
|
|
|
easing: theme.transitions.easing.sharp,
|
|
|
|
duration: theme.transitions.duration.leavingScreen,
|
|
|
|
}),
|
|
|
|
marginLeft: -drawerWidth,
|
|
|
|
},
|
|
|
|
contentShift: {
|
|
|
|
transition: theme.transitions.create('margin', {
|
|
|
|
easing: theme.transitions.easing.easeOut,
|
|
|
|
duration: theme.transitions.duration.enteringScreen,
|
|
|
|
}),
|
|
|
|
marginLeft: 0,
|
|
|
|
},
|
2018-12-15 20:15:17 +00:00
|
|
|
link: {
|
|
|
|
textDecoration: 'none'
|
|
|
|
}
|
2018-12-15 12:01:40 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
class PersistentDrawerLeft extends React.Component {
|
|
|
|
state = {
|
|
|
|
open: false,
|
|
|
|
};
|
|
|
|
|
|
|
|
handleDrawerOpen = () => {
|
2018-12-15 20:15:17 +00:00
|
|
|
this.setState({ open: true })
|
2018-12-15 12:01:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
handleDrawerClose = () => {
|
2018-12-15 20:15:17 +00:00
|
|
|
this.setState({ open: false })
|
2018-12-15 12:01:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
render() {
|
2019-01-10 20:44:45 +00:00
|
|
|
const { classes, theme, loading } = this.props
|
2018-12-15 20:15:17 +00:00
|
|
|
const { open } = this.state
|
2018-12-15 12:01:40 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div className={classes.root}>
|
|
|
|
<CssBaseline />
|
|
|
|
<AppBar
|
|
|
|
position="fixed"
|
2018-12-19 20:57:17 +00:00
|
|
|
className={classNames(classes.appBar, classes.appBarBg, {
|
2018-12-15 12:01:40 +00:00
|
|
|
[classes.appBarShift]: open,
|
|
|
|
})}
|
|
|
|
>
|
|
|
|
<Toolbar disableGutters={!open}>
|
|
|
|
<IconButton
|
|
|
|
color="inherit"
|
|
|
|
aria-label="Open drawer"
|
|
|
|
onClick={this.handleDrawerOpen}
|
2019-01-10 20:44:45 +00:00
|
|
|
className={classNames(classes.menuButton, open && !loading && classes.hide)}
|
2018-12-15 12:01:40 +00:00
|
|
|
>
|
2019-01-10 20:44:45 +00:00
|
|
|
{loading
|
|
|
|
? <ScaleLoader
|
|
|
|
sizeUnit={"px"}
|
|
|
|
height={20}
|
|
|
|
width={2}
|
|
|
|
margin="3px"
|
|
|
|
color={'#FFFFFF'}
|
|
|
|
/>
|
|
|
|
: <MenuIcon />}
|
2018-12-15 12:01:40 +00:00
|
|
|
</IconButton>
|
|
|
|
<Typography variant="h6" color="inherit" noWrap>
|
|
|
|
Liquid Funding
|
|
|
|
</Typography>
|
|
|
|
</Toolbar>
|
|
|
|
</AppBar>
|
|
|
|
<Drawer
|
|
|
|
className={classes.drawer}
|
|
|
|
variant="persistent"
|
|
|
|
anchor="left"
|
|
|
|
open={open}
|
|
|
|
classes={{
|
|
|
|
paper: classes.drawerPaper,
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<div className={classes.drawerHeader}>
|
|
|
|
<IconButton onClick={this.handleDrawerClose}>
|
|
|
|
{theme.direction === 'ltr' ? <ChevronLeftIcon /> : <ChevronRightIcon />}
|
|
|
|
</IconButton>
|
|
|
|
</div>
|
|
|
|
<Divider />
|
|
|
|
<List>
|
2018-12-16 17:59:33 +00:00
|
|
|
<Link to="/dashboard" className={classes.link}>
|
|
|
|
<ListItem button>
|
|
|
|
<ListItemIcon><InboxIcon /></ListItemIcon>
|
|
|
|
<ListItemText primary="Dashboard" />
|
|
|
|
</ListItem>
|
|
|
|
</Link>
|
2018-12-15 15:37:57 +00:00
|
|
|
</List>
|
|
|
|
<List>
|
2018-12-15 20:15:17 +00:00
|
|
|
<Link to="/funds-management/" className={classes.link}>
|
|
|
|
<ListItem button>
|
|
|
|
<ListItemIcon><InboxIcon /></ListItemIcon>
|
|
|
|
<ListItemText primary="Funds Management" />
|
|
|
|
</ListItem>
|
|
|
|
</Link>
|
2018-12-15 12:01:40 +00:00
|
|
|
</List>
|
|
|
|
<List>
|
2018-12-15 20:31:24 +00:00
|
|
|
<Link to="/insights/" className={classes.link}>
|
|
|
|
<ListItem button>
|
|
|
|
<ListItemIcon><InboxIcon /></ListItemIcon>
|
|
|
|
<ListItemText primary="Insights" />
|
|
|
|
</ListItem>
|
|
|
|
</Link>
|
2018-12-15 12:01:40 +00:00
|
|
|
</List>
|
2018-12-15 15:37:57 +00:00
|
|
|
<List>
|
2018-12-15 20:15:17 +00:00
|
|
|
<Link to="/admin/" className={classes.link}>
|
|
|
|
<ListItem button>
|
|
|
|
<ListItemIcon><InboxIcon /></ListItemIcon>
|
|
|
|
<ListItemText primary="Contract Admin" />
|
|
|
|
</ListItem>
|
|
|
|
</Link>
|
2018-12-15 15:37:57 +00:00
|
|
|
</List>
|
|
|
|
<Divider />
|
2018-12-15 12:01:40 +00:00
|
|
|
</Drawer>
|
|
|
|
<main
|
|
|
|
className={classNames(classes.content, {
|
|
|
|
[classes.contentShift]: open,
|
|
|
|
})}
|
|
|
|
>
|
|
|
|
<div className={classes.drawerHeader} />
|
2019-01-18 19:03:01 +00:00
|
|
|
<div className={classNames(classes.appBar)}>
|
2018-12-16 17:59:33 +00:00
|
|
|
<Switch>
|
|
|
|
<Route path="/(|dashboard)" component={Dashboard} />
|
|
|
|
<Route path="/admin" component={ContractAdmin} />
|
|
|
|
<Route path="/funds-management" render={() => <FundsManagement open={open} />} />
|
|
|
|
<Route path="/insights" component={TransferGraph} />
|
|
|
|
</Switch>
|
2018-12-15 19:09:31 +00:00
|
|
|
{this.props.children}
|
|
|
|
</div>
|
2018-12-15 12:01:40 +00:00
|
|
|
</main>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PersistentDrawerLeft.propTypes = {
|
|
|
|
classes: PropTypes.object.isRequired,
|
|
|
|
theme: PropTypes.object.isRequired,
|
2019-01-10 20:44:45 +00:00
|
|
|
loading: PropTypes.bool.isRequired
|
2018-12-15 12:01:40 +00:00
|
|
|
};
|
|
|
|
|
2018-12-15 19:09:31 +00:00
|
|
|
export default withStyles(styles, { withTheme: true })(PersistentDrawerLeft)
|