2021-10-07 15:39:12 +13:00
|
|
|
import * as React from 'react';
|
|
|
|
import Box from '@mui/material/Box';
|
|
|
|
import Stepper from '@mui/material/Stepper';
|
|
|
|
import Step from '@mui/material/Step';
|
2021-10-13 07:34:38 +13:00
|
|
|
import StepLabel from '@mui/material/StepLabel';
|
2021-10-07 15:39:12 +13:00
|
|
|
import Button from '@mui/material/Button';
|
|
|
|
|
2021-10-20 16:15:15 +13:00
|
|
|
import LocationStep from './steps/locationstep/LocationStep'
|
|
|
|
import SoilStep from './steps/soilvariantstep/SoilStep'
|
2021-10-07 15:39:12 +13:00
|
|
|
import ResultsStep from './steps/Results'
|
|
|
|
|
2021-10-13 07:34:38 +13:00
|
|
|
const steps = [
|
2021-10-07 15:39:12 +13:00
|
|
|
{'label': 'Select location', 'component': LocationStep },
|
|
|
|
{'label': 'Choose soil', 'component': SoilStep },
|
|
|
|
{'label': 'Choose habitat', 'component': SoilStep },
|
|
|
|
{'label': 'Select zone', 'component': SoilStep },
|
|
|
|
{'label': 'Project specifics', 'component': SoilStep },
|
|
|
|
{'label': 'Summary', 'component': SoilStep }
|
2021-10-13 07:34:38 +13:00
|
|
|
];
|
2021-10-07 15:39:12 +13:00
|
|
|
|
2021-10-13 07:34:38 +13:00
|
|
|
export default function StepperWizard(props) {
|
|
|
|
const [activeStep, setActiveStep] = React.useState(0);
|
2021-10-19 09:03:42 +13:00
|
|
|
const [nextDisabled, setNextDisabled] = React.useState(true);
|
2021-10-07 15:39:12 +13:00
|
|
|
|
|
|
|
const handleNext = () => {
|
2021-10-13 07:34:38 +13:00
|
|
|
setActiveStep((prevActiveStep) => prevActiveStep + 1);
|
2021-10-19 09:03:42 +13:00
|
|
|
setNextDisabled(true);
|
2021-10-07 15:39:12 +13:00
|
|
|
};
|
|
|
|
|
|
|
|
const handleBack = () => {
|
|
|
|
setActiveStep((prevActiveStep) => prevActiveStep - 1);
|
2021-10-19 09:03:42 +13:00
|
|
|
setNextDisabled(true);
|
2021-10-07 15:39:12 +13:00
|
|
|
};
|
|
|
|
|
|
|
|
const handleReset = () => {
|
|
|
|
setActiveStep(0);
|
2021-10-19 09:03:42 +13:00
|
|
|
setNextDisabled(true);
|
2021-10-07 15:39:12 +13:00
|
|
|
};
|
|
|
|
|
2021-10-13 07:34:38 +13:00
|
|
|
let CurrentStep = activeStep >= steps.length ? steps[steps.length-1].component : steps[activeStep].component;
|
2021-10-07 15:39:12 +13:00
|
|
|
|
|
|
|
return (
|
2021-10-18 15:46:18 +13:00
|
|
|
<Box sx={{ width: '100%', height: '100%', display: "flex", flexDirection: "column"}}>
|
|
|
|
<Stepper activeStep={activeStep} sx={{ paddingRight: '3vw', paddingLeft: '3vw', marginBottom:'2vw' }}>
|
2021-10-13 07:34:38 +13:00
|
|
|
{steps.map((step, index) => {
|
|
|
|
return (
|
|
|
|
<Step key={step.label}>
|
|
|
|
<StepLabel>{step.label}</StepLabel>
|
|
|
|
</Step>
|
|
|
|
);
|
|
|
|
})}
|
2021-10-07 15:39:12 +13:00
|
|
|
</Stepper>
|
2021-10-13 07:34:38 +13:00
|
|
|
{activeStep === steps.length ? (
|
2021-10-18 15:46:18 +13:00
|
|
|
<React.Fragment sx={{ flexGrow: 1 }}>
|
2021-10-13 07:34:38 +13:00
|
|
|
<ResultsStep {...props} />
|
2021-10-18 12:01:39 +13:00
|
|
|
<Box sx={{ display: 'flex', flexDirection: 'row', pt: 2, pb: 2, paddingRight: '3vw', paddingLeft: '3vw' }}>
|
2021-10-13 07:34:38 +13:00
|
|
|
<Box sx={{ flex: '1 1 auto' }} />
|
|
|
|
<Button onClick={handleReset}>Reset</Button>
|
|
|
|
</Box>
|
|
|
|
</React.Fragment>
|
|
|
|
) : (
|
|
|
|
<React.Fragment>
|
2021-10-19 09:03:42 +13:00
|
|
|
<CurrentStep {...props} setNextDisabled={setNextDisabled} />
|
2021-10-18 12:01:39 +13:00
|
|
|
<Box sx={{ display: 'flex', flexDirection: 'row', pt: 2, pb: 2, paddingRight: '3vw', paddingLeft: '3vw' }}>
|
2021-10-13 07:34:38 +13:00
|
|
|
<Button
|
|
|
|
color="inherit"
|
|
|
|
disabled={activeStep === 0}
|
|
|
|
onClick={handleBack}
|
|
|
|
sx={{ mr: 1 }}
|
|
|
|
>
|
|
|
|
Back
|
|
|
|
</Button>
|
|
|
|
<Box sx={{ flex: '1 1 auto' }} />
|
2021-10-19 09:03:42 +13:00
|
|
|
<Button onClick={handleNext} disabled={nextDisabled}>
|
2021-10-13 07:34:38 +13:00
|
|
|
{activeStep === steps.length - 1 ? 'Finish' : 'Next'}
|
|
|
|
</Button>
|
|
|
|
</Box>
|
|
|
|
</React.Fragment>
|
|
|
|
)}
|
2021-10-07 15:39:12 +13:00
|
|
|
</Box>
|
|
|
|
);
|
|
|
|
}
|