56 lines
1.2 KiB
JavaScript
56 lines
1.2 KiB
JavaScript
import PropTypes from 'prop-types'
|
|
import { Button, Flex } from 'antd'
|
|
|
|
const NewObjectButtons = ({
|
|
currentStep,
|
|
totalSteps,
|
|
onPrevious,
|
|
onNext,
|
|
onSubmit,
|
|
formValid,
|
|
submitLoading,
|
|
submitText = 'Done'
|
|
}) => {
|
|
return (
|
|
<Flex justify='end'>
|
|
{totalSteps > 1 ? (
|
|
<Button
|
|
style={{ margin: '0 8px' }}
|
|
onClick={onPrevious}
|
|
disabled={currentStep === 0}
|
|
>
|
|
Previous
|
|
</Button>
|
|
) : null}
|
|
|
|
{currentStep < totalSteps - 1 ? (
|
|
<Button type='primary' disabled={!formValid} onClick={onNext}>
|
|
Next
|
|
</Button>
|
|
) : (
|
|
<Button
|
|
type='primary'
|
|
loading={submitLoading}
|
|
disabled={!formValid}
|
|
onClick={onSubmit}
|
|
>
|
|
{submitText}
|
|
</Button>
|
|
)}
|
|
</Flex>
|
|
)
|
|
}
|
|
|
|
NewObjectButtons.propTypes = {
|
|
currentStep: PropTypes.number.isRequired,
|
|
totalSteps: PropTypes.number.isRequired,
|
|
onPrevious: PropTypes.func.isRequired,
|
|
onNext: PropTypes.func.isRequired,
|
|
onSubmit: PropTypes.func.isRequired,
|
|
formValid: PropTypes.bool.isRequired,
|
|
submitLoading: PropTypes.bool,
|
|
submitText: PropTypes.string
|
|
}
|
|
|
|
export default NewObjectButtons
|