@@ -6,17 +6,21 @@ import { createUseStyles } from 'react-jss';
66
77import { Button , Intent } from '@blueprintjs/core' ;
88
9- const NextButton = ( { nextStep, handleNext, buttonLabels, getState, handleSubmit, isDisabled, ...props } ) => (
10- < Button
11- disabled = { isDisabled }
12- onClick = { ( ) => ( nextStep ? handleNext ( selectNext ( nextStep , getState ) ) : handleSubmit ( ) ) }
13- rightIcon = { nextStep ? 'arrow-right' : 'arrow-up' }
14- intent = { Intent . SUCCESS }
15- { ...props }
16- >
17- { nextStep ? buttonLabels . next : buttonLabels . submit }
18- </ Button >
19- ) ;
9+ const NextButton = ( { nextStep, handleNext, buttonLabels, getState, handleSubmit, isDisabled, conditionalSubmitFlag, ...props } ) => {
10+ const nextResult = nextStep ? selectNext ( nextStep , getState ) : nextStep ;
11+ const progressNext = nextResult !== conditionalSubmitFlag && nextStep ;
12+ return (
13+ < Button
14+ disabled = { isDisabled }
15+ onClick = { ( ) => ( progressNext ? handleNext ( nextResult ) : handleSubmit ( ) ) }
16+ rightIcon = { progressNext ? 'arrow-right' : 'arrow-up' }
17+ intent = { Intent . SUCCESS }
18+ { ...props }
19+ >
20+ { progressNext ? buttonLabels . next : buttonLabels . submit }
21+ </ Button >
22+ ) ;
23+ } ;
2024
2125NextButton . propTypes = {
2226 handleNext : PropTypes . func ,
@@ -29,7 +33,8 @@ NextButton.propTypes = {
2933 nextStep : PropTypes . oneOfType ( [ PropTypes . string , PropTypes . func , PropTypes . object ] ) ,
3034 getState : PropTypes . func ,
3135 handleSubmit : PropTypes . func ,
32- isDisabled : PropTypes . bool
36+ isDisabled : PropTypes . bool ,
37+ conditionalSubmitFlag : PropTypes . string . isRequired
3338} ;
3439
3540const useStyles = createUseStyles ( {
@@ -57,7 +62,8 @@ const StepButtons = ({
5762 CancelButtonProps,
5863 BackButtonProps,
5964 NextButtonProps,
60- SubmitButtonProps
65+ SubmitButtonProps,
66+ conditionalSubmitFlag
6167} ) => {
6268 const { buttonGroup } = useStyles ( ) ;
6369
@@ -77,6 +83,7 @@ const StepButtons = ({
7783 handleNext = { handleNext }
7884 isDisabled = { ! formOptions . valid || isNextDisabled }
7985 handleSubmit = { formOptions . handleSubmit }
86+ conditionalSubmitFlag = { conditionalSubmitFlag }
8087 { ...( currentStep . nextStep ? NextButtonProps : SubmitButtonProps ) }
8188 />
8289 </ div >
@@ -88,6 +95,7 @@ StepButtons.propTypes = {
8895 currentStep : PropTypes . object ,
8996 handlePrev : PropTypes . func ,
9097 handleNext : PropTypes . func ,
98+ conditionalSubmitFlag : PropTypes . string . isRequired ,
9199 formOptions : PropTypes . shape ( {
92100 onCancel : PropTypes . func ,
93101 renderForm : PropTypes . func ,
0 commit comments