/* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 */ import { EuiComboBox, EuiComboBoxOptionOption, EuiFieldText, EuiFormRow, EuiSpacer, EuiText, EuiTextArea, } from '@elastic/eui'; import React from 'react'; import { onComboBoxCreateOption } from '../../utils/helper'; import { validateRecipientGroupEmails, validateRecipientGroupName, } from '../../utils/validationHelper'; interface CreateRecipientGroupFormProps { name: string; setName: (name: string) => void; description: string; setDescription: (name: string) => void; selectedEmailOptions: Array>; setSelectedEmailOptions: ( options: Array> ) => void; emailOptions: Array>; setEmailOptions: (options: Array>) => void; inputErrors: { [key: string]: string[] }; setInputErrors: (errors: { [key: string]: string[] }) => void; } export function CreateRecipientGroupForm(props: CreateRecipientGroupFormProps) { return ( <> 0} > props.setName(e.target.value)} isInvalid={props.inputErrors.name.length > 0} onBlur={() => { props.setInputErrors({ ...props.inputErrors, name: validateRecipientGroupName(props.name), }); }} /> Description - optional } style={{ maxWidth: '650px' }} > <> Describe the purpose of the channel. props.setDescription(e.target.value)} /> 0} > <> Select or type in one or more email addresses. onComboBoxCreateOption( searchValue, flattenedOptions, props.emailOptions, props.setEmailOptions, props.selectedEmailOptions, props.setSelectedEmailOptions, (options) => props.setInputErrors({ ...props.inputErrors, emailOptions: validateRecipientGroupEmails(options), }) ) } customOptionText={'Add {searchValue} as an email address'} isClearable={true} isInvalid={props.inputErrors.emailOptions.length > 0} onBlur={() => { props.setInputErrors({ ...props.inputErrors, emailOptions: validateRecipientGroupEmails( props.selectedEmailOptions ), }); }} /> ); }