bbgo_origin/apps/frontend/components/ExchangeSessionTabPanel.js

50 lines
1.2 KiB
JavaScript
Raw Normal View History

2022-06-12 15:11:42 +00:00
import Paper from '@mui/material/Paper';
import Tabs from '@mui/material/Tabs';
import Tab from '@mui/material/Tab';
2022-06-11 00:57:54 +00:00
import React, { useEffect, useState } from 'react';
import { querySessions } from '../api/bbgo';
2022-06-12 15:11:42 +00:00
import Typography from '@mui/material/Typography';
2022-06-12 15:19:39 +00:00
import { makeStyles } from '@mui/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
}