fix: [AH-580]: fix issue with reinitialising forms with new values after changing package type (#2929)

* fix: [AH-580]: fix issue with reinitialising forms with new values after changing package type
pull/3586/head
Shivanand Sonnad 2024-11-05 18:01:37 +00:00 committed by Harness
parent 4ee52b0cf8
commit 3404495893
1 changed files with 6 additions and 8 deletions

View File

@ -70,14 +70,6 @@ function FormContent(props: FormContentProps): JSX.Element {
const { values } = formikProps
const { packageType } = values
useEffect(() => {
const newDefaultValues = getDefaultValuesByRepositoryType(
packageType as UpstreamProxyPackageType,
{} as UpstreamRegistryRequest
)
formikProps.setValues(newDefaultValues)
}, [packageType, getDefaultValuesByRepositoryType])
return (
<Container>
<Layout.Vertical spacing="small">
@ -92,6 +84,12 @@ function FormContent(props: FormContentProps): JSX.Element {
label: getString(each.label)
}))}
staticItems
onChange={(val: UpstreamProxyPackageType) => {
const newDefaultValues = getDefaultValuesByRepositoryType(val, {
identifier: values.identifier
} as UpstreamRegistryRequest)
formikProps.setValues(newDefaultValues)
}}
isReadonly={isPackageTypeReadonly}
/>
</Container>