import React from 'react' ; import { APMPolicyForm } from '.' ; import { PackagePolicyVars , NewPackagePolicy , PackagePolicyCreateExtensionComponentProps , } from './typings' ; interface Props { newPolicy : NewPackagePolicy ; onChange : PackagePolicyCreateExtensionComponentProps [ 'onChange' ] ; } export function CreateAPMPolicyForm ( { newPolicy , onChange } ) { const [ firstInput , ... restInputs ] = newPolicy ?. inputs ; const vars = firstInput ?. vars ; function updateAPMPolicy ( newVars , isValid ) { onChange ( { isValid , updatedPolicy : { ... newPolicy , inputs : [ { ... firstInput , vars : newVars } , ... restInputs ] , } , } ) ; } return ( < APMPolicyForm vars = { vars } updateAPMPolicy = { updateAPMPolicy } isCloudPolicy = { false } / > ) ; }