All files / app/customer EmailField.tsx

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36  10x   10x 10x           10x 105x   213x                 105x       105x               10x  
import { FieldProps } from 'formik';
import React, { memo, useCallback, useMemo, FunctionComponent } from 'react';
 
import { TranslatedString } from '../locale';
import { FormField, TextInput } from '../ui/form';
 
export interface EmailFieldProps {
    onChange?(value: string): void;
}
 
const EmailField: FunctionComponent<EmailFieldProps>  = ({
    onChange,
}) => {
    const renderInput = useCallback((props: FieldProps) => (
        <TextInput
            { ...props.field }
            autoComplete={ props.field.name }
            id={ props.field.name }
            type="email"
        />
    ), []);
 
    const labelContent = useMemo(() => (
        <TranslatedString id="customer.email_label" />
    ), []);
 
    return <FormField
        input={ renderInput }
        labelContent={ labelContent }
        name="email"
        onChange={ onChange }
    />;
};
 
export default memo(EmailField);