@@ -29,7 +29,7 @@ import {
2929 CreateManagedControlPlaneResource ,
3030 CreateManagedControlPlaneType ,
3131} from '../../lib/api/types/crate/createManagedControlPlane.ts' ;
32- import { ErrorDialogHandle } from '../Shared/ErrorMessageBox.tsx' ;
32+ import { ErrorDialog , ErrorDialogHandle } from '../Shared/ErrorMessageBox.tsx' ;
3333import { useToast } from '../../context/ToastContext.tsx' ;
3434
3535export type CreateDialogProps = {
@@ -71,13 +71,13 @@ export const CreateManagedControlPlaneWizardContainer: FC<
7171 const errorDialogRef = useRef < ErrorDialogHandle > ( null ) ;
7272 const resetFormAndClose = ( ) => {
7373 reset ( ) ;
74- setSelectedStep ( 1 ) ;
74+ setSelectedStep ( '1' ) ;
7575 setIsOpen ( false ) ;
7676 } ;
7777 console . log ( errors ) ;
7878 // const { t } = useTranslation();
7979 const { user } = useAuth ( ) ;
80- const [ selectedStep , setSelectedStep ] = useState ( 1 ) ;
80+ const [ selectedStep , setSelectedStep ] = useState < string > ( '1' ) ;
8181 const username = user ?. email ;
8282 const toast = useToast ( ) ;
8383 const clearForm = useCallback ( ( ) => {
@@ -99,6 +99,7 @@ export const CreateManagedControlPlaneWizardContainer: FC<
9999 const { trigger } = useApiResourceMutation < CreateManagedControlPlaneType > (
100100 CreateManagedControlPlaneResource ( projectName , workspaceName ) ,
101101 ) ;
102+
102103 const handleCreateManagedControlPlane = async ( {
103104 name,
104105 displayName,
@@ -129,23 +130,25 @@ export const CreateManagedControlPlaneWizardContainer: FC<
129130 return false ;
130131 }
131132 } ;
132-
133+ const handleStepChange = ( e : any ) => {
134+ setSelectedStep ( e . detail . step . dataset . step ) ;
135+ } ;
133136 const onNextClick = ( ) => {
134137 console . log ( 'test' ) ;
135138 console . log ( getValues ( ) ) ;
136- if ( selectedStep === 1 ) {
139+ if ( selectedStep === '1' ) {
137140 handleSubmit (
138141 ( ) => {
139142 console . log ( 'valid' ) ;
140- setSelectedStep ( 2 ) ;
143+ setSelectedStep ( '2' ) ;
141144 } ,
142145 ( ) => {
143146 console . log ( 'not valid' ) ;
144147 console . log ( errors ) ;
145148 } ,
146149 ) ( ) ;
147150 }
148- if ( selectedStep === 2 ) {
151+ if ( selectedStep === '2' ) {
149152 handleCreateManagedControlPlane ( getValues ( ) ) ;
150153 }
151154 } ;
@@ -166,25 +169,23 @@ export const CreateManagedControlPlaneWizardContainer: FC<
166169 Close
167170 </ Button >
168171 < Button design = "Emphasized" onClick = { onNextClick } >
169- { selectedStep === 2 ? 'Create' : 'Next' }
172+ { selectedStep === '2' ? 'Create' : 'Next' }
170173 </ Button >
171174 </ div >
172175 }
173176 />
174177 }
175178 onClose = { ( ) => setIsOpen ( false ) }
176179 >
177- < Wizard contentLayout = { 'SingleStep' } >
180+ < Wizard contentLayout = { 'SingleStep' } onStepChange = { handleStepChange } >
178181 < WizardStep
179182 icon = { 'create-form' }
180183 titleText = "Metadata"
181184 disabled = { false }
182- selected = { selectedStep === 1 }
185+ selected = { selectedStep === '1' }
183186 data-step = { '1' }
184- onClick = { ( ) => {
185- setSelectedStep ( 1 ) ;
186- } }
187187 >
188+ { selectedStep }
188189 < MetadataAndMembersForm
189190 members = { watch ( 'members' ) }
190191 register = { register }
@@ -195,12 +196,9 @@ export const CreateManagedControlPlaneWizardContainer: FC<
195196 < WizardStep
196197 icon = { 'activities' }
197198 titleText = "Summarize"
198- disabled = { ! isValid }
199- selected = { selectedStep === 2 }
199+ disabled = { selectedStep === '1' || ! isValid }
200+ selected = { selectedStep === '2' }
200201 data-step = { '2' }
201- onClick = { ( ) => {
202- setSelectedStep ( 2 ) ;
203- } }
204202 >
205203 < h1 > Summarize</ h1 >
206204 < Grid defaultSpan = "XL6 L6 M6 S6" >
@@ -234,6 +232,7 @@ export const CreateManagedControlPlaneWizardContainer: FC<
234232 </ List >
235233 </ div >
236234 < div >
235+ { selectedStep }
237236 < YamlViewer
238237 yamlString = { stringify ( getValues ( 'members' ) ) }
239238 filename = { 'test' }
@@ -242,6 +241,7 @@ export const CreateManagedControlPlaneWizardContainer: FC<
242241 </ Grid >
243242 </ WizardStep >
244243 </ Wizard >
244+ < ErrorDialog ref = { errorDialogRef } />
245245 </ Dialog >
246246 ) ;
247247} ;
0 commit comments