bbgo_origin/apps/frontend/components/ReviewSessions.js

89 lines
2.0 KiB
JavaScript
Raw Permalink Normal View History

2021-02-02 09:26:35 +00:00
import React from 'react';
2022-06-12 15:11:42 +00:00
import Grid from '@mui/material/Grid';
import Button from '@mui/material/Button';
import Typography from '@mui/material/Typography';
import List from '@mui/material/List';
import ListItem from '@mui/material/ListItem';
import ListItemText from '@mui/material/ListItemText';
import ListItemIcon from '@mui/material/ListItemIcon';
import PowerIcon from '@mui/icons-material/Power';
2021-02-02 09:26:35 +00:00
2022-06-12 15:19:39 +00:00
import { makeStyles } from '@mui/styles';
2022-06-11 00:57:54 +00:00
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
}