All files / app/order OrderSummaryDiscount.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 489x   9x 9x   9x               9x 37x 37x 37x 37x 37x 37x                                                     9x  
import React, { memo, FunctionComponent } from 'react';
 
import { ShopperCurrency } from '../currency';
import { TranslatedString } from '../locale';
 
import OrderSummaryPrice, { OrderSummaryPriceProps } from './OrderSummaryPrice';
 
export interface OrderSummaryDiscountProps extends OrderSummaryPriceProps {
    remaining?: number;
    code?: string;
    onRemoved?(code: string): void;
}
 
const OrderSummaryDiscount: FunctionComponent<OrderSummaryDiscountProps> = ({
    code,
    remaining,
    amount,
    onRemoved,
    ...rest
}) => (
    <OrderSummaryPrice
        { ...rest }
        { ...(onRemoved && {
            onActionTriggered: () => code && onRemoved(code),
            actionLabel: <TranslatedString id="cart.remove_action" />,
        }) }
        amount={ -1 * (amount || 0) }
    >
        { !!remaining && remaining > 0 && <span
            className="cart-priceItem-postFix optimizedCheckout-contentSecondary"
            data-test="cart-price-remaining"
        >
            <TranslatedString id="cart.remaining_text" />
            { ': ' }
            <ShopperCurrency amount={ remaining } />
        </span> }
 
        { code && <span
            className="cart-priceItem-postFix optimizedCheckout-contentSecondary"
            data-test="cart-price-code"
        >
            { code }
        </span> }
    </OrderSummaryPrice>
);
 
export default memo(OrderSummaryDiscount);