@@ -11,12 +11,14 @@ interface Props {
1111 currentStep : number ;
1212 maxCompletedStep : number ;
1313 updateCurrentStep : ( step : number ) => void ;
14+ isFormValid : boolean ;
1415}
1516
1617export const PolicyNavigation : React . FunctionComponent < Props > = ( {
1718 currentStep,
1819 maxCompletedStep,
1920 updateCurrentStep,
21+ isFormValid,
2022} ) => {
2123 const { i18n } = useServices ( ) ;
2224
@@ -27,6 +29,7 @@ export const PolicyNavigation: React.FunctionComponent<Props> = ({
2729 } ) ,
2830 isComplete : maxCompletedStep >= 1 ,
2931 isSelected : currentStep === 1 ,
32+ disabled : ! isFormValid && currentStep !== 1 ,
3033 onClick : ( ) => updateCurrentStep ( 1 ) ,
3134 } ,
3235 {
@@ -35,7 +38,7 @@ export const PolicyNavigation: React.FunctionComponent<Props> = ({
3538 } ) ,
3639 isComplete : maxCompletedStep >= 2 ,
3740 isSelected : currentStep === 2 ,
38- disabled : maxCompletedStep < 1 ,
41+ disabled : maxCompletedStep < 1 || ( ! isFormValid && currentStep !== 2 ) ,
3942 onClick : ( ) => updateCurrentStep ( 2 ) ,
4043 } ,
4144 {
@@ -44,7 +47,7 @@ export const PolicyNavigation: React.FunctionComponent<Props> = ({
4447 } ) ,
4548 isComplete : maxCompletedStep >= 3 ,
4649 isSelected : currentStep === 3 ,
47- disabled : maxCompletedStep < 2 ,
50+ disabled : maxCompletedStep < 2 || ( ! isFormValid && currentStep !== 3 ) ,
4851 onClick : ( ) => updateCurrentStep ( 3 ) ,
4952 } ,
5053 {
@@ -53,7 +56,7 @@ export const PolicyNavigation: React.FunctionComponent<Props> = ({
5356 } ) ,
5457 isComplete : maxCompletedStep >= 3 ,
5558 isSelected : currentStep === 4 ,
56- disabled : maxCompletedStep < 3 ,
59+ disabled : maxCompletedStep < 3 || ( ! isFormValid && currentStep !== 4 ) ,
5760 onClick : ( ) => updateCurrentStep ( 4 ) ,
5861 } ,
5962 ] ;
0 commit comments