All files / app/payment/creditCard TextFieldForm.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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 6252x   52x 52x                               52x 20x   5x               5x       5x               52x 5x 5x 5x 5x 5x                         52x  
import React, { memo, useCallback, useMemo, FunctionComponent } from 'react';
 
import { TranslatedString } from '../../locale';
import { Fieldset, FormField, TextInput } from '../../ui/form';
 
export interface TextFieldProps {
    additionalClassName: string;
    autoComplete: string;
    labelId: string;
    name: string;
}
 
export interface TextFieldFormProps {
    additionalClassName: string;
    autoComplete: string;
    labelId: string;
    name: string;
}
 
const TextField: FunctionComponent<TextFieldProps> = props => {
    const { additionalClassName, autoComplete, labelId, name } = props;
 
    const renderInput = useCallback(({ field }) => (
        <TextInput
            { ...field }
            autoComplete={ autoComplete }
            id={ field.name }
        />
    ), [autoComplete]);
 
    const labelContent = useMemo(() => (
        <TranslatedString id={ labelId } />
    ), [labelId]);
 
    return <FormField
        additionalClassName={ additionalClassName }
        input={ renderInput }
        labelContent={ labelContent }
        name={ name }
    />;
};
 
const TextFieldForm: FunctionComponent<TextFieldFormProps> = ({
    additionalClassName,
    autoComplete,
    labelId,
    name,
}) => (
    <Fieldset>
        <div className="form-ccFields">
            <TextField
                additionalClassName={ additionalClassName }
                autoComplete={ autoComplete }
                labelId={ labelId }
                name={ name }
            />
        </div>
    </Fieldset>
);
 
export default memo(TextFieldForm);