import PropTypes from 'prop-types' import { useState } from 'react' import { useMediaQuery } from 'react-responsive' import { Typography, Flex, Steps, Divider, Progress, Button, Dropdown } from 'antd' import NewObjectButtons from './NewObjectButtons' const { Title } = Typography const WizardView = ({ showSteps = true, steps, title = 'Wizard View', onSubmit, formValid, loading, sideBar = null, submitText = 'Done', progress = 0, actions = [], sideBarGrow = false, disabled = false }) => { const [currentStep, setCurrentStep] = useState(0) const isMobile = useMediaQuery({ maxWidth: 768 }) return ( {!isMobile && showSteps == true ? ( sideBar != null ? ( sideBar ) : (
) ) : null} {!isMobile && showSteps == true ? ( ) : null} {title}
{steps[currentStep].content}
{progress > 0 ? ( ) : null} {(actions || []).map((action) => { if (action.steps.includes(steps[currentStep].key)) { if (action.children) { return ( ) } return ( ) } return null })} setCurrentStep((prev) => prev - 1)} onNext={() => setCurrentStep((prev) => prev + 1)} onSubmit={onSubmit} formValid={formValid} submitLoading={loading} submitText={submitText} />
) } WizardView.propTypes = { onSubmit: PropTypes.func.isRequired, formValid: PropTypes.bool.isRequired, steps: PropTypes.array.isRequired, showSteps: PropTypes.bool, title: PropTypes.string, loading: PropTypes.bool, disabled: PropTypes.bool, sideBar: PropTypes.node, submitText: PropTypes.string, progress: PropTypes.number, actions: PropTypes.array, sideBarGrow: PropTypes.bool } export default WizardView