Skip to content

Commit

Permalink
feat(payment): INT-2432 Comments from Luis addressed
Browse files Browse the repository at this point in the history
  • Loading branch information
Carlos Lopez committed Mar 30, 2020
1 parent 25f05f3 commit c7b1e81
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 22 deletions.
8 changes: 7 additions & 1 deletion src/app/payment/paymentMethod/AdyenV2CardValidation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@ const AdyenV2CardValidation: React.FunctionComponent<AdyenV2CardValidationProps>
</p> }

<div className="form-ccFields" id={ verificationFieldsContainerId }>
<div className="form-field form-field--ccNumber" style={ { display: (shouldShowNumberField) ? undefined : 'none', flexBasis: (paymentMethodType === 'bcmc') ? '50%' : '65%' } }>
<div className={ classNames(
'form-field',
'form-field--ccNumber',
{ 'form-field--ccNumber--hasExpiryDate': paymentMethodType === 'bcmc' },
{ 'form-field-ccNumber--show': shouldShowNumberField }
) }
>
<label htmlFor="encryptedCardNumber">
<TranslatedString id="payment.credit_card_number_label" />
</label>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class HostedWidgetPaymentMethod extends Component<
onSelectInstrument={ this.handleSelectInstrument }
onUseNewInstrument={ this.handleUseNewCard }
selectedInstrumentId={ selectedInstrumentId }
shouldHideInstrumentExpiryDate={ shouldHideInstrumentExpiryDate }
shouldHideExpiryDate={ shouldHideInstrumentExpiryDate }
validateInstrument={ this.getValidateInstrument() }
/> }

Expand Down
8 changes: 4 additions & 4 deletions src/app/payment/storedInstrument/CardInstrumentFieldset.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import ManageInstrumentsModal from './ManageInstrumentsModal';
export interface CardInstrumentFieldsetProps {
instruments: CardInstrument[];
selectedInstrumentId?: string;
shouldHideInstrumentExpiryDate?: boolean;
shouldHideExpiryDate?: boolean;
validateInstrument?: React.ReactNode;
onSelectInstrument(id: string): void;
onUseNewInstrument(): void;
Expand All @@ -29,7 +29,7 @@ const CardInstrumentFieldset: FunctionComponent<CardInstrumentFieldsetProps> = (
onSelectInstrument,
onUseNewInstrument,
selectedInstrumentId,
shouldHideInstrumentExpiryDate = false,
shouldHideExpiryDate = false,
validateInstrument = null,
}) => {
const renderInput = useCallback((field: FieldProps) => (
Expand All @@ -39,14 +39,14 @@ const CardInstrumentFieldset: FunctionComponent<CardInstrumentFieldsetProps> = (
onSelectInstrument={ onSelectInstrument }
onUseNewInstrument={ onUseNewInstrument }
selectedInstrumentId={ selectedInstrumentId }
shouldHideInstrumentExpiryDate={ shouldHideInstrumentExpiryDate }
shouldHideExpiryDate={ shouldHideExpiryDate }
/>
), [
instruments,
onSelectInstrument,
onUseNewInstrument,
selectedInstrumentId,
shouldHideInstrumentExpiryDate,
shouldHideExpiryDate,
]);

const renderModal = useCallback((props: ModalTriggerModalProps) => (
Expand Down
32 changes: 16 additions & 16 deletions src/app/payment/storedInstrument/InstrumentSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import mapFromInstrumentCardType from './mapFromInstrumentCardType';
export interface InstrumentSelectProps extends FieldProps<string> {
instruments: CardInstrument[];
selectedInstrumentId?: string;
shouldHideInstrumentExpiryDate?: boolean;
shouldHideExpiryDate?: boolean;
onSelectInstrument(id: string): void;
onUseNewInstrument(): void;
}
Expand Down Expand Up @@ -54,7 +54,7 @@ class InstrumentSelect extends PureComponent<InstrumentSelectProps> {
onSelectInstrument,
onUseNewInstrument,
selectedInstrumentId,
shouldHideInstrumentExpiryDate = false,
shouldHideExpiryDate = false,
} = this.props;

const selectedInstrument = find(instruments, { bigpayToken: selectedInstrumentId });
Expand All @@ -68,13 +68,13 @@ class InstrumentSelect extends PureComponent<InstrumentSelectProps> {
onSelectInstrument={ onSelectInstrument }
onUseNewInstrument={ onUseNewInstrument }
selectedInstrumentId={ selectedInstrumentId }
shouldHideInstrumentExpiryDate={ shouldHideInstrumentExpiryDate }
shouldHideExpiryDate={ shouldHideExpiryDate }
/>
}
>
<InstrumentSelectButton
instrument={ selectedInstrument }
shouldHideInstrumentExpiryDate={ shouldHideInstrumentExpiryDate }
shouldHideExpiryDate={ shouldHideExpiryDate }
testId="instrument-select"
/>

Expand All @@ -100,15 +100,15 @@ class InstrumentSelect extends PureComponent<InstrumentSelectProps> {
interface InstrumentMenuProps {
instruments: CardInstrument[];
selectedInstrumentId?: string;
shouldHideInstrumentExpiryDate?: boolean;
shouldHideExpiryDate?: boolean;
onSelectInstrument(id: string): void;
onUseNewInstrument(): void;
}

const InstrumentMenu: FunctionComponent<InstrumentMenuProps> = ({
instruments,
selectedInstrumentId,
shouldHideInstrumentExpiryDate = false,
shouldHideExpiryDate = false,
onSelectInstrument,
onUseNewInstrument,
}) => {
Expand All @@ -127,7 +127,7 @@ const InstrumentMenu: FunctionComponent<InstrumentMenuProps> = ({
<InstrumentOption
instrument={ instrument }
onClick={ onSelectInstrument }
shouldHideInstrumentExpiryDate={ shouldHideInstrumentExpiryDate }
shouldHideExpiryDate={ shouldHideExpiryDate }
testId="instrument-select-option"
/>
</li>
Expand All @@ -144,14 +144,14 @@ const InstrumentMenu: FunctionComponent<InstrumentMenuProps> = ({

interface InstrumentSelectButtonProps {
instrument?: CardInstrument;
shouldHideInstrumentExpiryDate?: boolean;
shouldHideExpiryDate?: boolean;
testId?: string;
onClick?(): void;
}

const InstrumentSelectButton: FunctionComponent<InstrumentSelectButtonProps> = ({
instrument,
shouldHideInstrumentExpiryDate = false,
shouldHideExpiryDate = false,
testId,
onClick,
}) => {
Expand All @@ -169,7 +169,7 @@ const InstrumentSelectButton: FunctionComponent<InstrumentSelectButtonProps> = (
className="instrumentSelect-button optimizedCheckout-form-select dropdown-button form-input"
instrument={ instrument }
onClick={ onClick }
shouldHideInstrumentExpiryDate={ shouldHideInstrumentExpiryDate }
shouldHideExpiryDate={ shouldHideExpiryDate }
testId={ testId }
/>
);
Expand All @@ -178,13 +178,13 @@ const InstrumentSelectButton: FunctionComponent<InstrumentSelectButtonProps> = (
interface InstrumentOptionProps {
instrument: CardInstrument;
testId?: string;
shouldHideInstrumentExpiryDate?: boolean;
shouldHideExpiryDate?: boolean;
onClick?(token: string): void;
}

const InstrumentOption: FunctionComponent<InstrumentOptionProps> = ({
instrument,
shouldHideInstrumentExpiryDate = false,
shouldHideExpiryDate = false,
onClick = noop,
}) => {
const handleClick = useCallback(() => {
Expand All @@ -198,7 +198,7 @@ const InstrumentOption: FunctionComponent<InstrumentOptionProps> = ({
<InstrumentMenuItem
instrument={ instrument }
onClick={ handleClick }
shouldHideInstrumentExpiryDate={ shouldHideInstrumentExpiryDate }
shouldHideExpiryDate={ shouldHideExpiryDate }
testId="instrument-select-option"
/>
);
Expand All @@ -208,15 +208,15 @@ interface InstrumentMenuItemProps {
className?: string;
instrument: CardInstrument;
testId?: string;
shouldHideInstrumentExpiryDate?: boolean;
shouldHideExpiryDate?: boolean;
onClick?(): void;
}

const InstrumentMenuItem: FunctionComponent<InstrumentMenuItemProps> = ({
className,
instrument,
testId,
shouldHideInstrumentExpiryDate = false,
shouldHideExpiryDate = false,
onClick,
}) => {
const cardType = mapFromInstrumentCardType(instrument.brand);
Expand Down Expand Up @@ -255,7 +255,7 @@ const InstrumentMenuItem: FunctionComponent<InstrumentMenuItemProps> = ({
/> }
</div>

{ !shouldHideInstrumentExpiryDate && <div
{ !shouldHideExpiryDate && <div
className={ classNames(
'instrumentSelect-expiry',
{ 'instrumentSelect-expiry--expired': isExpired }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@
flex-basis: 65%;
}

.form-field--ccNumber--hasExpiryDate {
flex-basis: 50%;
}

.form-field-ccNumber--show {
display: none;
}

.form-ccFields-field--ccCvv,
.form-field--ccExpiry {
flex-basis: 1%;
Expand Down

0 comments on commit c7b1e81

Please sign in to comment.