bbgo_origin/frontend/pages/setup/index.js

99 lines
3.1 KiB
JavaScript
Raw Normal View History

2021-02-01 09:13:27 +00:00
import React from 'react';
import {makeStyles} from '@material-ui/core/styles';
import Typography from '@material-ui/core/Typography';
import Box from '@material-ui/core/Box';
import Paper from '@material-ui/core/Paper';
2021-02-01 10:23:26 +00:00
import Stepper from '@material-ui/core/Stepper';
import Step from '@material-ui/core/Step';
import StepLabel from '@material-ui/core/StepLabel';
2021-02-02 09:26:35 +00:00
import ConfigureDatabaseForm from "../../components/ConfigureDatabaseForm";
import AddExchangeSessionForm from "../../components/AddExchangeSessionForm";
import ReviewSessions from "../../components/ReviewSessions";
import ConfigureGridStrategyForm from "../../components/ConfigureGridStrategyForm";
import ReviewStrategies from "../../components/ReviewStrategies";
2021-02-01 09:13:27 +00:00
import PlainLayout from '../../layouts/PlainLayout';
const useStyles = makeStyles((theme) => ({
paper: {
padding: theme.spacing(2),
},
}));
const steps = ['Configure Database', 'Add Exchange Session', 'Review Sessions', 'Configure Strategy', 'Review Strategies', 'Save Config and Restart'];
2021-02-01 10:23:26 +00:00
2021-02-02 09:26:35 +00:00
function getStepContent(step, setActiveStep) {
2021-02-01 10:23:26 +00:00
switch (step) {
case 0:
2021-02-02 09:26:35 +00:00
return <ConfigureDatabaseForm onConfigured={() => {
setActiveStep(1)
}}/>;
2021-02-01 10:23:26 +00:00
case 1:
return (
<AddExchangeSessionForm
onBack={() => { setActiveStep(0) }}
onAdded={() => { setActiveStep(2) }}
/>
);
2021-02-01 10:23:26 +00:00
case 2:
return (
<ReviewSessions
onBack={() => { setActiveStep(1) }}
onNext={() => { setActiveStep(3) }}
/>
);
2021-02-02 03:46:04 +00:00
case 3:
return (
<ConfigureGridStrategyForm
onBack={() => { setActiveStep(2) }}
onAdded={() => { setActiveStep(4) }}
/>
2021-02-02 18:26:41 +00:00
);
case 4:
return (
<ReviewStrategies
onBack={() => { setActiveStep(3) }}
onNext={() => { setActiveStep(5) }}
/>
);
case 5:
return
2021-02-01 10:23:26 +00:00
default:
throw new Error('Unknown step');
}
}
export default function Setup() {
2021-02-01 09:13:27 +00:00
const classes = useStyles();
2021-02-01 10:23:26 +00:00
const [activeStep, setActiveStep] = React.useState(0);
2021-02-01 09:13:27 +00:00
return (
<PlainLayout>
<Box m={4}>
<Paper className={classes.paper}>
<Typography variant="h4" component="h2" gutterBottom>
Setup Session
</Typography>
2021-02-01 10:23:26 +00:00
<Stepper activeStep={activeStep} className={classes.stepper}>
{steps.map((label) => (
<Step key={label}>
<StepLabel>{label}</StepLabel>
</Step>
))}
</Stepper>
<React.Fragment>
2021-02-02 09:26:35 +00:00
{getStepContent(activeStep, setActiveStep)}
2021-02-01 10:23:26 +00:00
</React.Fragment>
2021-02-01 09:13:27 +00:00
</Paper>
</Box>
</PlainLayout>
);
}