bbgo_origin/frontend/components/ExchangeSessionTabPanel.js

50 lines
1.2 KiB
JavaScript
Raw Normal View History

2022-06-11 00:57:54 +00:00
import Paper from '@material-ui/core/Paper';
import Tabs from '@material-ui/core/Tabs';
import Tab from '@material-ui/core/Tab';
import React, { useEffect, useState } from 'react';
import { querySessions } from '../api/bbgo';
import Typography from '@material-ui/core/Typography';
import { makeStyles } from '@material-ui/core/styles';
2021-01-29 04:55:11 +00:00
const useStyles = makeStyles((theme) => ({
2022-06-11 00:57:54 +00:00
paper: {
margin: theme.spacing(2),
padding: theme.spacing(2),
},
2021-01-29 04:55:11 +00:00
}));
2021-01-25 10:29:31 +00:00
export default function ExchangeSessionTabPanel() {
2022-06-11 00:57:54 +00:00
const classes = useStyles();
2021-01-29 04:55:11 +00:00
2022-06-11 00:57:54 +00:00
const [tabIndex, setTabIndex] = React.useState(0);
const handleTabClick = (event, newValue) => {
setTabIndex(newValue);
};
2021-01-25 10:29:31 +00:00
2022-06-11 00:57:54 +00:00
const [sessions, setSessions] = useState([]);
2021-01-25 10:29:31 +00:00
2022-06-11 00:57:54 +00:00
useEffect(() => {
querySessions((sessions) => {
setSessions(sessions);
});
}, []);
2021-01-25 10:29:31 +00:00
2022-06-11 00:57:54 +00:00
return (
<Paper className={classes.paper}>
<Typography variant="h4" gutterBottom>
Sessions
</Typography>
<Tabs
value={tabIndex}
onChange={handleTabClick}
indicatorColor="primary"
textColor="primary"
>
{sessions.map((session) => {
return <Tab key={session.name} label={session.name} />;
})}
</Tabs>
2021-01-25 10:29:31 +00:00
</Paper>
2022-06-11 00:57:54 +00:00
);
2021-01-25 10:29:31 +00:00
}