import { ReactElement, useMemo, useState } from 'react'; import AnHostConfigInputGroup from './AnHostConfigInputGroup'; import AnIdInputGroup, { INPUT_ID_AI_DOMAIN, INPUT_ID_AI_PREFIX, INPUT_ID_AI_SEQUENCE, } from './AnIdInputGroup'; import AnNetworkConfigInputGroup, { INPUT_ID_ANC_DNS, INPUT_ID_ANC_MTU, INPUT_ID_ANC_NTP, } from './AnNetworkConfigInputGroup'; import FlexBox from '../FlexBox'; const DEFAULT_NETWORK_LIST: ManifestNetworkList = { bcn1: { networkMinIp: '10.201.0.0', networkNumber: 1, networkSubnetMask: '255.255.0.0', networkType: 'bcn', }, sn1: { networkMinIp: '10.101.0.0', networkNumber: 1, networkSubnetMask: '255.255.0.0', networkType: 'sn', }, ifn1: { networkMinIp: '', networkNumber: 1, networkSubnetMask: '', networkType: 'ifn', }, }; const AddManifestInputGroup = < M extends { [K in | typeof INPUT_ID_AI_DOMAIN | typeof INPUT_ID_AI_PREFIX | typeof INPUT_ID_AI_SEQUENCE | typeof INPUT_ID_ANC_DNS | typeof INPUT_ID_ANC_MTU | typeof INPUT_ID_ANC_NTP]: string; }, >({ formUtils, knownFences, knownUpses, previous: { hostConfig: previousHostConfig, networkConfig: previousNetworkConfig = {}, ...previousAnId } = {}, }: AddManifestInputGroupProps): ReactElement => { const { networks: previousNetworkList = DEFAULT_NETWORK_LIST } = previousNetworkConfig; const [anSequence, setAnSequence] = useState( previousAnId?.sequence ?? 0, ); const [networkList, setNetworkList] = useState(previousNetworkList); const networkListEntries = useMemo( () => Object.entries(networkList), [networkList], ); return ( { const { target: { value }, } = event; setAnSequence(Number(value)); }} previous={previousAnId} /> ); }; export default AddManifestInputGroup;