bbgo_origin/apps/frontend/pages/setup/index.js

133 lines
3.1 KiB
JavaScript
Raw Normal View History

2021-02-01 09:13:27 +00:00
import React from 'react';
2022-06-12 15:19:39 +00:00
import { makeStyles } from '@mui/styles';
2022-06-12 15:11:42 +00:00
import Typography from '@mui/material/Typography';
import Box from '@mui/material/Box';
import Paper from '@mui/material/Paper';
import Stepper from '@mui/material/Stepper';
import Step from '@mui/material/Step';
import StepLabel from '@mui/material/StepLabel';
2021-02-01 10:23:26 +00:00
2022-06-11 00:57:54 +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';
import SaveConfigAndRestart from '../../components/SaveConfigAndRestart';
2021-02-01 09:13:27 +00:00
import PlainLayout from '../../layouts/PlainLayout';
const useStyles = makeStyles((theme) => ({
2022-06-11 00:57:54 +00:00
paper: {
padding: theme.spacing(2),
},
2021-02-01 09:13:27 +00:00
}));
2022-06-11 00:57:54 +00:00
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) {
2022-06-11 00:57:54 +00:00
switch (step) {
case 0:
return (
<ConfigureDatabaseForm
onConfigured={() => {
setActiveStep(1);
}}
/>
);
case 1:
return (
<AddExchangeSessionForm
onBack={() => {
setActiveStep(0);
}}
onAdded={() => {
setActiveStep(2);
}}
/>
);
case 2:
return (
<ReviewSessions
onBack={() => {
setActiveStep(1);
}}
onNext={() => {
setActiveStep(3);
}}
/>
);
case 3:
return (
<ConfigureGridStrategyForm
onBack={() => {
setActiveStep(2);
}}
onAdded={() => {
setActiveStep(4);
}}
/>
);
case 4:
return (
<ReviewStrategies
onBack={() => {
setActiveStep(3);
}}
onNext={() => {
setActiveStep(5);
}}
/>
);
2022-06-11 00:57:54 +00:00
case 5:
return (
<SaveConfigAndRestart
onBack={() => {
setActiveStep(4);
}}
onRestarted={() => {}}
/>
);
2021-02-03 07:59:06 +00:00
2022-06-11 00:57:54 +00:00
default:
throw new Error('Unknown step');
}
2021-02-01 10:23:26 +00:00
}
export default function Setup() {
2022-06-11 00:57:54 +00:00
const classes = useStyles();
const [activeStep, setActiveStep] = React.useState(0);
2021-02-01 10:23:26 +00:00
2022-06-11 00:57:54 +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
2022-06-11 00:57:54 +00:00
<Stepper activeStep={activeStep} className={classes.stepper}>
{steps.map((label) => (
<Step key={label}>
<StepLabel>{label}</StepLabel>
</Step>
))}
</Stepper>
2021-02-01 10:23:26 +00:00
2022-06-11 00:57:54 +00:00
<React.Fragment>
{getStepContent(activeStep, setActiveStep)}
</React.Fragment>
</Paper>
</Box>
</PlainLayout>
);
2021-02-01 09:13:27 +00:00
}