All files / app/cart withRedeemable.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 503x       3x   3x   3x           14x                 14x 98x   14x                                              
import React, { ComponentType, FunctionComponent } from 'react';
 
import { OrderSummaryProps, OrderSummarySubtotalsProps } from '../order';
 
import mapToOrderSummarySubtotalsProps from './mapToOrderSummarySubtotalsProps';
import { WithCheckoutCartSummaryProps } from './CartSummary';
import Redeemable from './Redeemable';
 
export default function withRedeemable(
    OriginalComponent: ComponentType<OrderSummaryProps & OrderSummarySubtotalsProps>
): FunctionComponent<
    WithCheckoutCartSummaryProps &
    { headerLink?: any }
> {
    return props => {
        const {
            checkout,
            storeCurrency,
            shopperCurrency,
            headerLink,
            onRemovedCoupon,
            onRemovedGiftCertificate,
            storeCreditAmount,
            ...redeemableProps
        } = props;
 
        return (
            <OriginalComponent
                { ...mapToOrderSummarySubtotalsProps(checkout) }
                additionalLineItems={
                    <Redeemable { ...{
                        ...redeemableProps,
                        onRemovedCoupon,
                        onRemovedGiftCertificate,
                    } }
                    />
                }
                headerLink={ headerLink }
                lineItems={ checkout.cart.lineItems }
                onRemovedCoupon={ onRemovedCoupon }
                onRemovedGiftCertificate={ onRemovedGiftCertificate }
                shopperCurrency={ shopperCurrency }
                storeCreditAmount={ storeCreditAmount }
                storeCurrency={ storeCurrency }
                total={ checkout.outstandingBalance }
            />
        );
    };
}