import { Grid } from '@mui/material'; import { FC, useMemo } from 'react'; import { v4 as uuidv4 } from 'uuid'; import Autocomplete from '../Autocomplete'; import FlexBox from '../FlexBox'; import IconButton from '../IconButton'; import SelectWithLabel from '../SelectWithLabel'; import { BodyText, SmallText } from '../Text'; import UncontrolledInput from '../UncontrolledInput'; const LEVEL_OPTIONS: SelectItem[] = [ { displayValue: 'Critical', value: 1 }, { displayValue: 'Warning', value: 2 }, { displayValue: 'Notice', value: 3 }, { displayValue: 'Info', value: 4 }, ]; const AlertOverrideInputGroup: FC = (props) => { const { alertOverrideTargetOptions, alertOverrideUuid, mailRecipientUuid: mrUuid, formikUtils, } = props; const aoUuid = useMemo( () => alertOverrideUuid ?? uuidv4(), [alertOverrideUuid], ); const { formik } = formikUtils; const { values: { [mrUuid]: mailRecipient }, } = formik; const { alertOverrides: { [aoUuid]: alertOverride }, } = mailRecipient; const overrideChain = useMemo( () => `${mrUuid}.alertOverrides.${aoUuid}`, [aoUuid, mrUuid], ); const targetChain = useMemo( () => `${overrideChain}.target`, [overrideChain], ); const levelChain = useMemo( () => `${overrideChain}.level`, [overrideChain], ); return ( option.name} id={targetChain} isOptionEqualToValue={(option, value) => option.uuid === value.uuid} label="Target" noOptionsText="No node or subnode found." onChange={(event, value) => formik.setFieldValue(targetChain, value, true) } openOnFocus options={alertOverrideTargetOptions} renderOption={(optionProps, option) => (
  • {option.type === 'node' ? ( {option.name} {option.description} ) : ( {option.name} )}
  • )} value={alertOverride.target} />
    } /> { formik.setFieldValue(overrideChain, undefined, true); }} size="small" />
    ); }; export default AlertOverrideInputGroup;