bbgo_origin/frontend/components/ReviewSessions.js

89 lines
2.1 KiB
JavaScript
Raw Normal View History

2021-02-02 09:26:35 +00:00
import React from 'react';
import Grid from '@material-ui/core/Grid';
import Button from '@material-ui/core/Button';
import Typography from '@material-ui/core/Typography';
import List from '@material-ui/core/List';
import ListItem from '@material-ui/core/ListItem';
import ListItemText from '@material-ui/core/ListItemText';
import ListItemIcon from '@material-ui/core/ListItemIcon';
import PowerIcon from '@material-ui/icons/Power';
2022-06-11 00:57:54 +00:00
import { makeStyles } from '@material-ui/core/styles';
import { querySessions } from '../api/bbgo';
2021-02-02 09:26:35 +00:00
const useStyles = makeStyles((theme) => ({
2022-06-11 00:57:54 +00:00
formControl: {
marginTop: theme.spacing(1),
marginBottom: theme.spacing(1),
minWidth: 120,
},
buttons: {
display: 'flex',
justifyContent: 'flex-end',
marginTop: theme.spacing(2),
paddingTop: theme.spacing(2),
paddingBottom: theme.spacing(2),
'& > *': {
marginLeft: theme.spacing(1),
2021-02-02 09:26:35 +00:00
},
2022-06-11 00:57:54 +00:00
},
2021-02-02 09:26:35 +00:00
}));
2022-06-11 00:57:54 +00:00
export default function ReviewSessions({ onBack, onNext }) {
const classes = useStyles();
2021-02-02 09:26:35 +00:00
2022-06-11 00:57:54 +00:00
const [sessions, setSessions] = React.useState([]);
2021-02-02 09:26:35 +00:00
2022-06-11 00:57:54 +00:00
React.useEffect(() => {
querySessions((sessions) => {
setSessions(sessions);
});
}, []);
2021-02-02 09:26:35 +00:00
2022-06-11 00:57:54 +00:00
const items = sessions.map((session, i) => {
console.log(session);
2021-02-02 09:26:35 +00:00
return (
2022-06-11 00:57:54 +00:00
<ListItem key={session.name}>
<ListItemIcon>
<PowerIcon />
</ListItemIcon>
<ListItemText primary={session.name} secondary={session.exchange} />
</ListItem>
);
});
2021-02-02 09:26:35 +00:00
2022-06-11 00:57:54 +00:00
return (
<React.Fragment>
<Typography variant="h6" gutterBottom>
Review Sessions
</Typography>
2021-02-02 09:26:35 +00:00
2022-06-11 00:57:54 +00:00
<List component="nav">{items}</List>
2021-02-02 09:26:35 +00:00
2022-06-11 00:57:54 +00:00
<div className={classes.buttons}>
<Button
onClick={() => {
if (onBack) {
onBack();
}
}}
>
Back
</Button>
<Button
variant="contained"
color="primary"
onClick={() => {
if (onNext) {
onNext();
}
}}
>
Next
</Button>
</div>
</React.Fragment>
);
2021-02-02 09:26:35 +00:00
}