Skip to content

Commit

Permalink
fix vpc create drawer bug default values
Browse files Browse the repository at this point in the history
  • Loading branch information
coliu-akamai committed Dec 9, 2024
1 parent e06832c commit 2291f7f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ export const VPCTopSectionContent = (props: Props) => {
currentCapability="VPCs"
disabled={isDrawer ? true : disabled}
errorText={fieldState.error?.message}
onChange={(e, region) => field.onChange(region?.id ?? '')}
onBlur={field.onBlur}
onChange={(_, region) => field.onChange(region?.id ?? '')}
regions={regions}
value={field.value}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ export const VPCCreateDrawer = (props: Props) => {
title={'Create VPC'}
>
{userCannotAddVPC && CannotCreateVPCNotice}

<FormProvider {...form}>
<Grid>
<form onSubmit={handleSubmit(onCreateVPC)} ref={formContainerRef}>
Expand Down
25 changes: 14 additions & 11 deletions packages/manager/src/hooks/useCreateVPC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,20 +84,23 @@ export const useCreateVPC = (inputs: UseCreateVPCInputs) => {
}
};

const defaultValues = {
description: '',
label: '',
region: selectedRegion ?? '',
subnets: [
{
ipv4: DEFAULT_SUBNET_IPV4_VALUE,
label: '',
},
],
};

const form = useForm<CreateVPCPayload>({
defaultValues: {
description: '',
label: '',
region: selectedRegion ?? '',
subnets: [
{
ipv4: DEFAULT_SUBNET_IPV4_VALUE,
label: '',
},
],
},
defaultValues,
mode: 'onBlur',
resolver: yupResolver(createVPCSchema),
values: { ...defaultValues },
});

const { errors } = form.formState;
Expand Down

0 comments on commit 2291f7f

Please sign in to comment.