All files / app/payment/hostedCreditCard HostedCreditCardFieldset.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 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 7829x   29x 29x   29x 29x 29x 29x                                             29x 22x 22x 22x 22x 22x 22x 22x                                                                           29x  
import React, { FunctionComponent, ReactNode } from 'react';
 
import { TranslatedString } from '../../locale';
import { Fieldset, Legend } from '../../ui/form';
 
import HostedCreditCardCodeField from './HostedCreditCardCodeField';
import HostedCreditCardExpiryField from './HostedCreditCardExpiryField';
import HostedCreditCardNameField from './HostedCreditCardNameField';
import HostedCreditCardNumberField from './HostedCreditCardNumberField';
 
export interface HostedCreditCardFieldsetProps {
    additionalFields?: ReactNode;
    cardCodeId?: string;
    cardExpiryId: string;
    cardNameId?: string;
    cardNumberId: string;
    focusedFieldType?: string;
}
 
export interface HostedCreditCardFieldsetValues {
    hostedForm: {
        cardType?: string;
        errors?: {
            cardCode?: string;
            cardExpiry?: string;
            cardName?: string;
            cardNumber?: string;
        };
    };
}
 
const HostedCreditCardFieldset: FunctionComponent<HostedCreditCardFieldsetProps> = ({
    additionalFields,
    cardCodeId,
    cardExpiryId,
    cardNameId,
    cardNumberId,
    focusedFieldType,
}) => (
    <Fieldset
        legend={
            <Legend hidden>
                <TranslatedString id="payment.credit_card_text" />
            </Legend>
        }
    >
        <div className="form-ccFields">
            <HostedCreditCardNumberField
                appearFocused={ focusedFieldType === 'cardNumber' }
                id={ cardNumberId }
                name="hostedForm.errors.cardNumber"
            />
 
            <HostedCreditCardExpiryField
                appearFocused={ focusedFieldType === 'cardExpiry' }
                id={ cardExpiryId }
                name="hostedForm.errors.cardExpiry"
            />
 
            { cardNameId && <HostedCreditCardNameField
                appearFocused={ focusedFieldType === 'cardName' }
                id={ cardNameId }
                name="hostedForm.errors.cardName"
            /> }
 
            { cardCodeId && <HostedCreditCardCodeField
                appearFocused={ focusedFieldType === 'cardCode' }
                id={ cardCodeId }
                name="hostedForm.errors.cardCode"
            /> }
 
            { additionalFields }
        </div>
    </Fieldset>
);
 
export default HostedCreditCardFieldset;