All files / app/payment/creditCard CreditCardCustomerCodeField.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  52x   52x 52x           52x 1x             1x                       1x             52x  
import { FieldProps } from 'formik';
import React, { memo, useCallback, useMemo, Fragment, FunctionComponent } from 'react';
 
import { TranslatedString } from '../../locale';
import { FormField, TextInput } from '../../ui/form';
 
export interface CreditCardCustomerCodeFieldProps {
    name: string;
}
 
const CreditCardCustomerCodeField: FunctionComponent<CreditCardCustomerCodeFieldProps> = ({ name }) => {
    const renderInput = useCallback(({ field }: FieldProps) => (
        <TextInput
            { ...field }
            id={ field.name }
        />
    ), []);
 
    const labelContent = useMemo(() => (
        <Fragment>
            <TranslatedString id="payment.credit_card_customer_code_label" />
 
            { ' ' }
 
            <small className="optimizedCheckout-contentSecondary">
                <TranslatedString id="common.optional_text" />
            </small>
        </Fragment>
    ), []);
 
    return <FormField
        input={ renderInput }
        labelContent={ labelContent }
        name={ name }
    />;
};
 
export default memo(CreditCardCustomerCodeField);