@@ -10,6 +10,7 @@ import Loader from '@helsenorge/designsystem-react/components/Loader';
10
10
import FormButtons from './formButtons/formButtons' ;
11
11
import { ValidationSummary } from './validation/validation-summary' ;
12
12
import { Resources } from '@/util/resources' ;
13
+ import { buttonOrderMicrowebStep } from '@/types/formTypes/formButton' ;
13
14
14
15
interface RenderFormProps {
15
16
isAuthorized : boolean ;
@@ -66,32 +67,68 @@ const RenderForm = ({
66
67
nextStep ( ) ;
67
68
}
68
69
} ;
70
+
71
+ const cancelButtonClicked = ( ) : void => {
72
+ // eslint-disable-next-line no-console
73
+ console . log ( 'Refero props: On cancel button clicked' ) ;
74
+ if ( referoProps . customNavigationCallBack ) {
75
+ referoProps . customNavigationCallBack ( 'cancel' , undefined ) ;
76
+ }
77
+ } ;
78
+
79
+ const backButtonClicked = ( ) : void => {
80
+ // eslint-disable-next-line no-console
81
+ console . log ( 'On back button clicked' ) ;
82
+ if ( referoProps . customNavigationCallBack ) {
83
+ referoProps . customNavigationCallBack ( 'back' , undefined ) ;
84
+ }
85
+ } ;
86
+
69
87
return (
70
88
< >
71
89
< form onSubmit = { methods . handleSubmit ( onSubmitReactHookForm , onErrorReactHookForm ) } >
72
90
{ displayValidationSummaryOnTop && < ValidationSummary resources = { resources } /> }
73
91
{ children }
74
92
{ ! displayValidationSummaryOnTop && < ValidationSummary resources = { resources } /> }
75
93
</ form >
76
- < FormButtons
77
- isStepView = { isStepView }
78
- submitButtonText = { displayNextButton && resources . nextStep ? resources . nextStep : resources . formSend }
79
- cancelButtonText = { resources . formCancel }
80
- pauseButtonText = { displayPreviousButton && isStepView ? resources . previousStep || 'Lagre' : resources . formSave }
81
- submitButtonDisabled = { referoProps . submitButtonDisabled }
82
- pauseButtonDisabled = { referoProps . saveButtonDisabled }
83
- onSubmitButtonClicked = {
84
- displayNextButton
85
- ? methods . handleSubmit ( handleNextStep , onErrorReactHookForm )
86
- : methods . handleSubmit ( onSubmitReactHookForm , onErrorReactHookForm )
87
- }
88
- onCancelButtonClicked = { ( ) : void => {
89
- referoProps . onCancel && referoProps . onCancel ( ) ;
90
- } }
91
- onPauseButtonClicked = { isStepView ? displayPauseButtonInStepView : displayPauseButtonInNormalView }
92
- isAuthorized = { isAuthorized }
93
- loginButton = { referoProps . loginButton }
94
- />
94
+
95
+ { referoProps . customProps ?. isMicroweb && (
96
+ < FormButtons
97
+ isStepView = { false }
98
+ submitButtonText = { 'Neste' }
99
+ cancelButtonText = { 'Avbryt' }
100
+ pauseButtonText = { 'Tilbake' }
101
+ onSubmitButtonClicked = { methods . handleSubmit ( onSubmitReactHookForm , onErrorReactHookForm ) } // hmm. how to callback here? forwardButtonClicked
102
+ onCancelButtonClicked = { cancelButtonClicked }
103
+ onPauseButtonClicked = { backButtonClicked }
104
+ isAuthorized = { isAuthorized }
105
+ loginButton = { referoProps . loginButton }
106
+ overrideButtonOrder = { buttonOrderMicrowebStep }
107
+ showSaveButtonAsBackButton = { true }
108
+ />
109
+ ) }
110
+
111
+ { referoProps . customProps ?. isMicroweb === undefined && (
112
+ < FormButtons
113
+ isStepView = { isStepView }
114
+ submitButtonText = { displayNextButton && resources . nextStep ? resources . nextStep : resources . formSend }
115
+ cancelButtonText = { resources . formCancel }
116
+ pauseButtonText = { displayPreviousButton && isStepView ? resources . previousStep || 'Lagre' : resources . formSave }
117
+ submitButtonDisabled = { referoProps . submitButtonDisabled }
118
+ pauseButtonDisabled = { referoProps . saveButtonDisabled }
119
+ onSubmitButtonClicked = {
120
+ displayNextButton
121
+ ? methods . handleSubmit ( handleNextStep , onErrorReactHookForm )
122
+ : methods . handleSubmit ( onSubmitReactHookForm , onErrorReactHookForm )
123
+ }
124
+ onCancelButtonClicked = { ( ) : void => {
125
+ referoProps . onCancel && referoProps . onCancel ( ) ;
126
+ } }
127
+ onPauseButtonClicked = { isStepView ? displayPauseButtonInStepView : displayPauseButtonInNormalView }
128
+ isAuthorized = { isAuthorized }
129
+ loginButton = { referoProps . loginButton }
130
+ />
131
+ ) }
95
132
</ >
96
133
) ;
97
134
} ;
0 commit comments