@@ -6,9 +6,9 @@ import NavigateBackIcon from '@material-ui/icons/NavigateBefore';
66import Send from '@material-ui/icons/Send' ;
77import { useFieldApi } from '@data-driven-forms/react-form-renderer' ;
88
9- const SimpleNext = ( { next, valid, handleNext, submit } ) => (
9+ const SimpleNext = ( { next, valid, handleNext, submit, buttonLabels } ) => (
1010 < Button variant = "contained" type = "button" color = "primary" onClick = { ( ) => ( valid ? handleNext ( next ) : submit ( ) ) } >
11- Continue
11+ { buttonLabels . next }
1212 < NavigateNextIcon />
1313 </ Button >
1414) ;
@@ -17,7 +17,10 @@ SimpleNext.propTypes = {
1717 next : PropTypes . string ,
1818 valid : PropTypes . bool ,
1919 handleNext : PropTypes . func . isRequired ,
20- submit : PropTypes . func . isRequired
20+ submit : PropTypes . func . isRequired ,
21+ buttonLabels : PropTypes . shape ( {
22+ next : PropTypes . node
23+ } )
2124} ;
2225
2326const ConditionalNext = ( { nextStep, ...rest } ) => {
@@ -34,37 +37,38 @@ ConditionalNext.propTypes = {
3437 } ) . isRequired
3538} ;
3639
37- const submitButton = ( handleSubmit ) => (
40+ const submitButton = ( handleSubmit , label ) => (
3841 < Button type = "button" variant = "contained" color = "primary" onClick = { handleSubmit } >
39- Submit < Send />
42+ { label } < Send />
4043 </ Button >
4144) ;
4245
4346const renderNextButton = ( { nextStep, handleSubmit, ...rest } ) =>
4447 ! nextStep ? (
45- submitButton ( handleSubmit )
48+ submitButton ( handleSubmit , rest . buttonLabels . submit )
4649 ) : typeof nextStep === 'object' ? (
4750 < ConditionalNext nextStep = { nextStep } { ...rest } />
4851 ) : (
4952 < SimpleNext next = { nextStep } { ...rest } />
5053 ) ;
5154
52- const WizardStepButtons = ( { formOptions, disableBack, handlePrev, nextStep, handleNext } ) => (
55+ const WizardStepButtons = ( { formOptions, disableBack, handlePrev, nextStep, handleNext, buttonLabels } ) => (
5356 < div >
5457 { formOptions . onCancel && (
5558 < Button type = "button" variant = "contained" color = "secondary" onClick = { formOptions . onCancel } >
56- Cancel
59+ { buttonLabels . cancel }
5760 </ Button >
5861 ) }
5962
6063 < Button type = "button" variant = "contained" disabled = { disableBack } onClick = { handlePrev } >
6164 < NavigateBackIcon />
62- Back
65+ { buttonLabels . back }
6366 </ Button >
6467 { renderNextButton ( {
6568 ...formOptions ,
6669 handleNext,
67- nextStep
70+ nextStep,
71+ buttonLabels
6872 } ) }
6973 </ div >
7074) ;
@@ -83,7 +87,13 @@ WizardStepButtons.propTypes = {
8387 when : PropTypes . string . isRequired ,
8488 stepMapper : PropTypes . object . isRequired
8589 } )
86- ] )
90+ ] ) ,
91+ buttonLabels : PropTypes . shape ( {
92+ submit : PropTypes . node ,
93+ cancel : PropTypes . node ,
94+ back : PropTypes . node ,
95+ next : PropTypes . node
96+ } )
8797} ;
8898
8999export default WizardStepButtons ;
0 commit comments