Skip to content

Commit c036777

Browse files
committed
fixes
1 parent efb07fb commit c036777

File tree

2 files changed

+26
-16
lines changed

2 files changed

+26
-16
lines changed

src/components/ControlPlanes/List/ControlPlaneListWorkspaceGridTile.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,8 @@ export function ControlPlaneListWorkspaceGridTile({
210210
<CreateManagedControlPlaneWizardContainer
211211
isOpen={isCreateManagedControlPlaneWizardOpen}
212212
setIsOpen={setIsCreateManagedControlPlaneWizardOpen}
213+
projectName={projectNamespace}
214+
workspaceName={workspaceName}
213215
/>
214216
</>
215217
);

src/components/Wizards/CreateManagedControlPlaneWizardContainer.tsx

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,21 @@ export type CreateDialogProps = {
4242
type CreateManagedControlPlaneWizardContainerProps = {
4343
isOpen: boolean;
4444
setIsOpen: (isOpen: boolean) => void;
45-
project?: string;
45+
projectName?: string;
46+
workspaceName?: string;
4647
};
4748

4849
export const CreateManagedControlPlaneWizardContainer: FC<
4950
CreateManagedControlPlaneWizardContainerProps
50-
> = ({ isOpen, setIsOpen, project = '' }) => {
51+
> = ({ isOpen, setIsOpen, projectName = '', workspaceName = '' }) => {
5152
const {
5253
register,
5354
handleSubmit,
5455
resetField,
5556
setValue,
5657
reset,
5758
getValues,
59+
5860
formState: { errors, isValid },
5961
watch,
6062
} = useForm<CreateDialogProps>({
@@ -95,7 +97,7 @@ export const CreateManagedControlPlaneWizardContainer: FC<
9597
}
9698
}, [resetField, setValue, username, isOpen, clearForm]);
9799
const { trigger } = useApiResourceMutation<CreateManagedControlPlaneType>(
98-
CreateManagedControlPlaneResource(namespace),
100+
CreateManagedControlPlaneResource(projectName, workspaceName),
99101
);
100102
const handleCreateManagedControlPlane = async ({
101103
name,
@@ -105,7 +107,7 @@ export const CreateManagedControlPlaneWizardContainer: FC<
105107
}: OnCreatePayload): Promise<boolean> => {
106108
try {
107109
await trigger(
108-
CreateManagedControlPlane(name, namespace, {
110+
CreateManagedControlPlane(name, workspaceName, {
109111
displayName: displayName,
110112
chargingTarget: chargingTarget,
111113
members: members,
@@ -130,16 +132,22 @@ export const CreateManagedControlPlaneWizardContainer: FC<
130132

131133
const onNextClick = () => {
132134
console.log('test');
133-
handleSubmit(
134-
() => {
135-
console.log('valid');
136-
setSelectedStep(2);
137-
},
138-
() => {
139-
console.log('not valid');
140-
console.log(errors);
141-
},
142-
)();
135+
console.log(getValues());
136+
if (selectedStep === 1) {
137+
handleSubmit(
138+
() => {
139+
console.log('valid');
140+
setSelectedStep(2);
141+
},
142+
() => {
143+
console.log('not valid');
144+
console.log(errors);
145+
},
146+
)();
147+
}
148+
if (selectedStep === 2) {
149+
handleCreateManagedControlPlane(getValues());
150+
}
143151
};
144152
return (
145153
<Dialog
@@ -156,7 +164,7 @@ export const CreateManagedControlPlaneWizardContainer: FC<
156164
Close
157165
</Button>
158166
<Button design="Emphasized" onClick={onNextClick}>
159-
Next
167+
{selectedStep === 2 ? 'Create' : 'Next'}
160168
</Button>
161169
</div>
162170
}
@@ -189,7 +197,7 @@ export const CreateManagedControlPlaneWizardContainer: FC<
189197
selected={selectedStep === 2}
190198
data-step={'2'}
191199
onClick={() => {
192-
setSelectedStep(1);
200+
setSelectedStep(2);
193201
}}
194202
>
195203
<h1>Summarize</h1>

0 commit comments

Comments
 (0)