/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/
import {
EuiFieldText,
EuiFlexGroup,
EuiFlexItem,
EuiFormRow,
EuiSpacer,
} from '@elastic/eui';
import React, { useContext } from 'react';
import { MainContext } from '../../../Main/Main';
import {
validateAwsRegion,
validateEmail,
validateRoleArn,
validateSenderName,
} from '../../utils/validationHelper';
interface CreateSESSenderFormProps {
senderName: string;
setSenderName: (name: string) => void;
email: string;
setEmail: (email: string) => void;
roleArn: string;
setRoleArn: (roleArn: string) => void;
awsRegion: string;
setAwsRegion: (awsRegion: string) => void;
inputErrors: { [key: string]: string[] };
setInputErrors: (errors: { [key: string]: string[] }) => void;
}
export function CreateSESSenderForm(props: CreateSESSenderFormProps) {
const mainStateContext = useContext(MainContext)!;
return (
<>
0}
>
props.setSenderName(e.target.value)}
isInvalid={props.inputErrors.senderName.length > 0}
onBlur={() => {
props.setInputErrors({
...props.inputErrors,
senderName: validateSenderName(props.senderName),
});
}}
/>
0}
>
props.setEmail(e.target.value)}
isInvalid={props.inputErrors.email.length > 0}
onBlur={() => {
props.setInputErrors({
...props.inputErrors,
email: validateEmail(props.email),
});
}}
/>
IAM Role ARN -{' '}
optional
) : (
'IAM Role ARN'
)
}
error={props.inputErrors.roleArn.join(' ')}
isInvalid={props.inputErrors.roleArn.length > 0}
>
props.setRoleArn(e.target.value)}
isInvalid={props.inputErrors.roleArn.length > 0}
onBlur={() => {
if (!mainStateContext.tooltipSupport) {
props.setInputErrors({
...props.inputErrors,
roleArn: validateRoleArn(props.roleArn),
});
}
}}
/>
0}
>
props.setAwsRegion(e.target.value)}
isInvalid={props.inputErrors.awsRegion.length > 0}
onBlur={() => {
props.setInputErrors({
...props.inputErrors,
awsRegion: validateAwsRegion(props.awsRegion),
});
}}
/>
>
);
}