@magento/venia-ui 9.2.0-beta.1 → 9.3.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/i18n/en_US.json +17 -3
- package/lib/RootComponents/CMS/__tests__/__snapshots__/cms.spec.js.snap +19 -0
- package/lib/RootComponents/CMS/__tests__/cms.spec.js +4 -9
- package/lib/RootComponents/CMS/cms.js +5 -4
- package/lib/RootComponents/CMS/cms.shimmer.js +18 -0
- package/lib/RootComponents/Category/__tests__/__snapshots__/categoryContent.shimmer.spec.js.snap +12 -0
- package/lib/RootComponents/Category/categoryContent.js +4 -1
- package/lib/components/AccountChip/accountChip.js +3 -1
- package/lib/components/AccountInformationPage/accountInformationPage.js +3 -1
- package/lib/components/AccountInformationPage/editModal.js +9 -2
- package/lib/components/AccountMenu/accountMenuItems.js +8 -3
- package/lib/components/CartPage/GiftCards/giftCards.js +1 -1
- package/lib/components/CartPage/PriceAdjustments/CouponCode/couponCode.js +5 -1
- package/lib/components/CartPage/PriceAdjustments/GiftOptions/__tests__/__snapshots__/giftOptions.spec.js.snap +1018 -78
- package/lib/components/CartPage/PriceAdjustments/GiftOptions/__tests__/giftOptions.spec.js +221 -35
- package/lib/components/CartPage/PriceAdjustments/GiftOptions/giftOptions.js +287 -40
- package/lib/components/CartPage/PriceAdjustments/GiftOptions/giftOptions.module.css +56 -1
- package/lib/components/CartPage/PriceAdjustments/__tests__/__snapshots__/giftCardSection.ee.spec.js.snap +12 -0
- package/lib/components/CartPage/PriceAdjustments/__tests__/__snapshots__/giftOptionsSection.ce.spec.js.snap +3 -0
- package/lib/components/CartPage/PriceAdjustments/__tests__/__snapshots__/giftOptionsSection.ee.spec.js.snap +16 -0
- package/lib/components/CartPage/PriceAdjustments/__tests__/__snapshots__/priceAdjustments.spec.js.snap +1 -32
- package/lib/components/CartPage/PriceAdjustments/__tests__/giftCardSection.ce.spec.js +17 -0
- package/lib/components/CartPage/PriceAdjustments/__tests__/giftCardSection.ee.spec.js +36 -0
- package/lib/components/CartPage/PriceAdjustments/__tests__/giftOptionsSection.ce.spec.js +17 -0
- package/lib/components/CartPage/PriceAdjustments/__tests__/giftOptionsSection.ee.spec.js +54 -0
- package/lib/components/CartPage/PriceAdjustments/__tests__/priceAdjustments.spec.js +1 -1
- package/lib/components/CartPage/PriceAdjustments/{giftCardSection.js → giftCardSection.ce.js} +0 -0
- package/lib/components/CartPage/PriceAdjustments/giftOptionsSection.ce.js +7 -0
- package/lib/components/CartPage/PriceAdjustments/giftOptionsSection.ee.js +38 -0
- package/lib/components/CartPage/PriceAdjustments/priceAdjustments.js +2 -14
- package/lib/components/CartPage/PriceSummary/__tests__/__snapshots__/discountSummary.spec.js.snap +496 -42
- package/lib/components/CartPage/PriceSummary/__tests__/__snapshots__/giftCardSummary.ce.spec.js.snap +3 -0
- package/lib/components/CartPage/PriceSummary/__tests__/__snapshots__/{giftCardSummary.spec.js.snap → giftCardSummary.ee.spec.js.snap} +4 -4
- package/lib/components/CartPage/PriceSummary/__tests__/__snapshots__/giftOptionsSummary.ce.spec.js.snap +3 -0
- package/lib/components/CartPage/PriceSummary/__tests__/__snapshots__/giftOptionsSummary.ee.spec.js.snap +63 -0
- package/lib/components/CartPage/PriceSummary/__tests__/__snapshots__/priceSummary.spec.js.snap +201 -141
- package/lib/components/CartPage/PriceSummary/__tests__/discountSummary.spec.js +41 -1
- package/lib/components/CartPage/PriceSummary/__tests__/giftCardSummary.ce.spec.js +17 -0
- package/lib/components/CartPage/PriceSummary/__tests__/giftCardSummary.ee.spec.js +84 -0
- package/lib/components/CartPage/PriceSummary/__tests__/giftOptionsSummary.ce.spec.js +17 -0
- package/lib/components/CartPage/PriceSummary/__tests__/giftOptionsSummary.ee.spec.js +69 -0
- package/lib/components/CartPage/PriceSummary/__tests__/priceSummary.spec.js +2 -0
- package/lib/components/CartPage/PriceSummary/discountSummary.js +99 -49
- package/lib/components/CartPage/PriceSummary/discountSummary.module.css +40 -0
- package/lib/components/CartPage/PriceSummary/giftOptionsSummary.ce.js +5 -0
- package/lib/components/CartPage/PriceSummary/giftOptionsSummary.ee.js +40 -0
- package/lib/components/CartPage/PriceSummary/priceSummary.js +95 -53
- package/lib/components/CartPage/PriceSummary/priceSummary.module.css +2 -0
- package/lib/components/CartPage/ProductListing/EditModal/__tests__/__snapshots__/productDetail.spec.js.snap +57 -0
- package/lib/components/CartPage/ProductListing/EditModal/__tests__/__snapshots__/productForm.spec.js.snap +22 -0
- package/lib/components/CartPage/ProductListing/EditModal/__tests__/productDetail.spec.js +42 -3
- package/lib/components/CartPage/ProductListing/EditModal/productDetail.js +13 -10
- package/lib/components/CartPage/ProductListing/EditModal/productForm.js +7 -2
- package/lib/components/CartPage/ProductListing/product.js +1 -0
- package/lib/components/CartPage/ProductListing/productListing.js +1 -1
- package/lib/components/CartPage/cartPage.js +1 -1
- package/lib/components/Checkbox/checkbox.js +6 -1
- package/lib/components/Checkbox/checkbox.module.css +1 -0
- package/lib/components/CheckoutPage/ItemsReview/__tests__/__snapshots__/item.spec.js.snap +2 -2
- package/lib/components/CheckoutPage/ItemsReview/__tests__/__snapshots__/itemsReview.spec.js.snap +33 -0
- package/lib/components/CheckoutPage/ItemsReview/__tests__/item.spec.js +2 -2
- package/lib/components/CheckoutPage/ItemsReview/itemsReview.js +4 -1
- package/lib/components/CheckoutPage/OrderConfirmationPage/__tests__/createAccount.spec.js +4 -0
- package/lib/components/CheckoutPage/OrderConfirmationPage/createAccount.js +9 -1
- package/lib/components/CheckoutPage/OrderConfirmationPage/orderConfirmationPage.js +12 -3
- package/lib/components/CheckoutPage/PaymentInformation/__tests__/__snapshots__/creditCard.spec.js.snap +1 -0
- package/lib/components/CheckoutPage/PaymentInformation/__tests__/creditCard.spec.js +2 -1
- package/lib/components/CheckoutPage/PaymentInformation/brainTreeDropIn.js +2 -18
- package/lib/components/CheckoutPage/PaymentInformation/creditCard.js +13 -3
- package/lib/components/CheckoutPage/PriceAdjustments/__tests__/__snapshots__/priceAdjustments.spec.js.snap +1 -6
- package/lib/components/CheckoutPage/PriceAdjustments/__tests__/priceAdjustments.spec.js +2 -2
- package/lib/components/CheckoutPage/PriceAdjustments/priceAdjustments.js +8 -12
- package/lib/components/CheckoutPage/ShippingInformation/AddressForm/customerForm.js +1 -1
- package/lib/components/CheckoutPage/ShippingInformation/shippingInformation.js +4 -1
- package/lib/components/CheckoutPage/ShippingMethod/shippingMethod.js +5 -2
- package/lib/components/CheckoutPage/__tests__/__snapshots__/checkoutPage.spec.js.snap +3 -3
- package/lib/components/CheckoutPage/__tests__/checkoutPage.spec.js +5 -0
- package/lib/components/CheckoutPage/checkoutPage.js +25 -4
- package/lib/components/CheckoutPage/checkoutPage.module.css +8 -1
- package/lib/components/CmsDynamicBlock/__tests__/__snapshots__/cmsDynamicBlock.ce.spec.js.snap +3 -0
- package/lib/components/CmsDynamicBlock/__tests__/__snapshots__/cmsDynamicBlock.ee.spec.js.snap +61 -0
- package/lib/components/CmsDynamicBlock/__tests__/__snapshots__/dynamicBlock.spec.js.snap +7 -0
- package/lib/components/CmsDynamicBlock/__tests__/cmsDynamicBlock.ce.spec.js +17 -0
- package/lib/components/CmsDynamicBlock/__tests__/cmsDynamicBlock.ee.spec.js +211 -0
- package/lib/components/CmsDynamicBlock/__tests__/constants.spec.js +37 -0
- package/lib/components/CmsDynamicBlock/__tests__/dynamicBlock.spec.js +33 -0
- package/lib/components/CmsDynamicBlock/cmsDynamicBlock.ce.js +5 -0
- package/lib/components/CmsDynamicBlock/cmsDynamicBlock.ee.js +73 -0
- package/lib/components/CmsDynamicBlock/constants.js +6 -0
- package/lib/components/CmsDynamicBlock/dynamicBlock.js +32 -0
- package/lib/components/CmsDynamicBlock/index.js +2 -0
- package/lib/components/CreateAccount/__tests__/createAccount.spec.js +6 -1
- package/lib/components/CreateAccount/createAccount.js +7 -2
- package/lib/components/Field/field.module.css +6 -0
- package/lib/components/FilterSidebar/filterSidebar.js +4 -1
- package/lib/components/Footer/__tests__/__snapshots__/footer.spec.js.snap +8 -2
- package/lib/components/Footer/footer.js +16 -9
- package/lib/components/Footer/footer.module.css +7 -2
- package/lib/components/ForgotPassword/ForgotPasswordForm/__tests__/__snapshots__/forgotPasswordForm.spec.js.snap +109 -1
- package/lib/components/ForgotPassword/ForgotPasswordForm/__tests__/forgotPasswordForm.spec.js +22 -3
- package/lib/components/ForgotPassword/ForgotPasswordForm/forgotPasswordForm.js +13 -3
- package/lib/components/ForgotPassword/ForgotPasswordForm/forgotPasswordForm.module.css +1 -1
- package/lib/components/ForgotPassword/__tests__/__snapshots__/forgotPassword.spec.js.snap +5 -6
- package/lib/components/ForgotPassword/__tests__/forgotPassword.spec.js +41 -28
- package/lib/components/ForgotPassword/forgotPassword.js +10 -3
- package/lib/components/ForgotPassword/forgotPassword.module.css +2 -2
- package/lib/components/Gallery/__tests__/__snapshots__/gallery.spec.js.snap +22 -0
- package/lib/components/Gallery/__tests__/__snapshots__/item.spec.js.snap +17 -0
- package/lib/components/Gallery/addToCartButton.js +2 -0
- package/lib/components/Gallery/gallery.js +6 -1
- package/lib/components/Gallery/item.js +7 -2
- package/lib/components/GoogleReCaptcha/googleReCaptcha.js +49 -0
- package/lib/components/GoogleReCaptcha/googleReCaptcha.module.css +3 -0
- package/lib/components/GoogleReCaptcha/index.js +1 -0
- package/lib/components/Header/currencySwitcher.js +2 -1
- package/lib/components/Header/header.js +1 -1
- package/lib/components/Header/header.module.css +2 -2
- package/lib/components/Header/searchTrigger.js +3 -1
- package/lib/components/Header/storeSwitcher.js +18 -4
- package/lib/components/Header/switcherItem.js +4 -1
- package/lib/components/HomePage/homePage.module.css +12 -0
- package/lib/components/Image/resourceImage.js +8 -1
- package/lib/components/Image/simpleImage.js +8 -1
- package/lib/components/Link/link.js +15 -13
- package/lib/components/LoadingIndicator/spinner.js +5 -7
- package/lib/components/LoadingIndicator/spinner.module.css +4 -17
- package/lib/components/MiniCart/ProductList/__tests__/__snapshots__/item.spec.js.snap +44 -0
- package/lib/components/MiniCart/ProductList/__tests__/item.spec.js +2 -2
- package/lib/components/MiniCart/ProductList/item.js +3 -2
- package/lib/components/MiniCart/miniCart.js +6 -3
- package/lib/components/MyAccount/ResetPassword/__tests__/__snapshots__/resetPassword.spec.js.snap +274 -254
- package/lib/components/MyAccount/ResetPassword/__tests__/resetPassword.spec.js +10 -5
- package/lib/components/MyAccount/ResetPassword/resetPassword.js +55 -55
- package/lib/components/MyAccount/ResetPassword/resetPassword.module.css +27 -79
- package/lib/components/Newsletter/newsletter.js +6 -2
- package/lib/components/OrderHistoryPage/OrderDetails/__tests__/__snapshots__/item.spec.js.snap +11 -0
- package/lib/components/ProductFullDetail/productFullDetail.js +12 -3
- package/lib/components/ProductImageCarousel/__tests__/__snapshots__/carousel.spec.js.snap +61 -0
- package/lib/components/ProductImageCarousel/__tests__/__snapshots__/thumbnail.spec.js.snap +26 -0
- package/lib/components/ProductOptions/__tests__/options.spec.js +1 -1
- package/lib/components/ProductOptions/__tests__/swatch.spec.js +1 -1
- package/lib/components/ProductOptions/__tests__/swatchList.spec.js +1 -1
- package/lib/components/ProductOptions/__tests__/tile.spec.js +1 -1
- package/lib/components/ProductOptions/__tests__/tileList.spec.js +1 -1
- package/lib/components/ProductOptions/option.js +4 -1
- package/lib/components/ProductSort/productSort.js +22 -14
- package/lib/components/Rating/rating.js +1 -1
- package/lib/components/SearchBar/__tests__/__snapshots__/suggestedProduct.spec.js.snap +11 -0
- package/lib/components/SearchBar/autocomplete.js +4 -2
- package/lib/components/SearchBar/suggestedProduct.js +1 -1
- package/lib/components/SearchBar/suggestions.js +1 -1
- package/lib/components/SignIn/__tests__/signIn.spec.js +11 -20
- package/lib/components/SignIn/signIn.js +6 -16
- package/lib/components/TextInput/textInput.module.css +0 -4
- package/lib/components/Wishlist/WishlistDialog/WishlistLineItem/__tests__/__snapshots__/wishlistLineItem.spec.js.snap +5 -1
- package/lib/components/Wishlist/WishlistDialog/WishlistLineItem/wishlistLineItem.js +7 -1
- package/lib/components/Wishlist/WishlistDialog/WishlistLineItem/wishlistLineItem.module.css +7 -0
- package/lib/components/Wishlist/WishlistDialog/__tests__/__snapshots__/wishlistDialog.spec.js.snap +6 -1
- package/lib/components/WishlistPage/__tests__/__snapshots__/wishlist.spec.js.snap +4 -0
- package/lib/components/WishlistPage/__tests__/__snapshots__/wishlistItem.spec.js.snap +22 -0
- package/lib/components/WishlistPage/__tests__/__snapshots__/wishlistPage.spec.js.snap +9 -3
- package/lib/components/WishlistPage/createWishlist.ee.js +3 -1
- package/lib/components/WishlistPage/wishlist.js +1 -1
- package/lib/components/WishlistPage/wishlist.module.css +3 -0
- package/lib/components/WishlistPage/wishlistPage.js +1 -1
- package/package.json +5 -4
- package/lib/components/CartPage/PriceSummary/__tests__/giftCardSummary.spec.js +0 -84
|
@@ -1,36 +1,15 @@
|
|
|
1
1
|
import React, { Fragment } from 'react';
|
|
2
|
-
import { FormattedMessage } from 'react-intl';
|
|
2
|
+
import { FormattedMessage, useIntl } from 'react-intl';
|
|
3
3
|
import Price from '@magento/venia-ui/lib/components/Price';
|
|
4
|
-
|
|
5
4
|
import { useStyle } from '../../../classify';
|
|
5
|
+
import Icon from '../../Icon';
|
|
6
|
+
import { ChevronDown as ArrowDown, ChevronUp as ArrowUp } from 'react-feather';
|
|
7
|
+
import defaultClasses from './discountSummary.module.css';
|
|
8
|
+
import AnimateHeight from 'react-animate-height';
|
|
9
|
+
import { useDiscountSummary } from '@magento/peregrine/lib/talons/CartPage/PriceSummary/useDiscountSummary';
|
|
6
10
|
|
|
7
11
|
const MINUS_SYMBOL = '-';
|
|
8
12
|
|
|
9
|
-
const DEFAULT_AMOUNT = {
|
|
10
|
-
currency: 'USD',
|
|
11
|
-
value: 0
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Reduces discounts array into a single amount.
|
|
16
|
-
*
|
|
17
|
-
* @param {Array} discounts
|
|
18
|
-
*/
|
|
19
|
-
const getDiscount = (discounts = []) => {
|
|
20
|
-
// discounts from data can be null
|
|
21
|
-
if (!discounts || !discounts.length) {
|
|
22
|
-
return DEFAULT_AMOUNT;
|
|
23
|
-
} else {
|
|
24
|
-
return {
|
|
25
|
-
currency: discounts[0].amount.currency,
|
|
26
|
-
value: discounts.reduce(
|
|
27
|
-
(acc, discount) => acc + discount.amount.value,
|
|
28
|
-
0
|
|
29
|
-
)
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
|
|
34
13
|
/**
|
|
35
14
|
* A component that renders the discount summary line item.
|
|
36
15
|
*
|
|
@@ -38,30 +17,101 @@ const getDiscount = (discounts = []) => {
|
|
|
38
17
|
* @param {Object} props.data fragment response data
|
|
39
18
|
*/
|
|
40
19
|
const DiscountSummary = props => {
|
|
41
|
-
const classes = useStyle(
|
|
42
|
-
const
|
|
20
|
+
const classes = useStyle(defaultClasses, props.classes);
|
|
21
|
+
const { formatMessage } = useIntl();
|
|
43
22
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
23
|
+
const {
|
|
24
|
+
totalDiscount,
|
|
25
|
+
discountData,
|
|
26
|
+
expanded,
|
|
27
|
+
handleClick
|
|
28
|
+
} = useDiscountSummary(props);
|
|
29
|
+
|
|
30
|
+
const toggleDiscountsAriaLabel = expanded
|
|
31
|
+
? formatMessage({
|
|
32
|
+
id: 'priceSummary.discountSummary.hideDiscounts',
|
|
33
|
+
defaultMessage: 'Hide individual discounts.'
|
|
34
|
+
})
|
|
35
|
+
: formatMessage({
|
|
36
|
+
id: 'priceSummary.discountSummary.showDiscounts',
|
|
37
|
+
defaultMessage: 'Show individual discounts.'
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const iconSrc = expanded ? ArrowUp : ArrowDown;
|
|
41
|
+
|
|
42
|
+
const individualDiscounts = discountData ? (
|
|
43
|
+
<AnimateHeight duration={500} height={expanded ? 'auto' : 0}>
|
|
44
|
+
<ul
|
|
45
|
+
className={classes.individualDiscountsList}
|
|
46
|
+
data-cy="DiscountSummary-IndividualDiscount"
|
|
58
47
|
>
|
|
59
|
-
{
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
48
|
+
<hr className={classes.individualDiscountSeparator} />
|
|
49
|
+
{discountData.map(discount => {
|
|
50
|
+
return (
|
|
51
|
+
<li
|
|
52
|
+
className={classes.individualDiscountsListLineItem}
|
|
53
|
+
key={discount.label}
|
|
54
|
+
>
|
|
55
|
+
<span
|
|
56
|
+
className={classes.lineItemLabel}
|
|
57
|
+
data-cy="DiscountSummary-IndividualDiscount-Label"
|
|
58
|
+
>
|
|
59
|
+
<span data-cy="DiscountSummary-IndividualDiscount-DiscountLabel">
|
|
60
|
+
{discount.label}
|
|
61
|
+
</span>
|
|
62
|
+
</span>
|
|
63
|
+
<span
|
|
64
|
+
data-cy="DiscountSummary-IndividualDiscount-DiscountValue"
|
|
65
|
+
className={classes.price}
|
|
66
|
+
>
|
|
67
|
+
{MINUS_SYMBOL}
|
|
68
|
+
<Price
|
|
69
|
+
value={discount.amount.value}
|
|
70
|
+
currencyCode={discount.amount.currency}
|
|
71
|
+
/>
|
|
72
|
+
</span>
|
|
73
|
+
</li>
|
|
74
|
+
);
|
|
75
|
+
})}
|
|
76
|
+
<hr className={classes.individualDiscountSeparator} />
|
|
77
|
+
</ul>
|
|
78
|
+
</AnimateHeight>
|
|
79
|
+
) : null;
|
|
80
|
+
|
|
81
|
+
return totalDiscount.value ? (
|
|
82
|
+
<Fragment>
|
|
83
|
+
<li className={classes.discountLineItems}>
|
|
84
|
+
<span
|
|
85
|
+
className={classes.discountLineItemLabel}
|
|
86
|
+
data-cy="PriceSummary-DiscountSummary-Label"
|
|
87
|
+
>
|
|
88
|
+
<FormattedMessage
|
|
89
|
+
id={'discountSummary.lineItemLabel'}
|
|
90
|
+
defaultMessage={'Applied discounts'}
|
|
91
|
+
/>
|
|
92
|
+
<button
|
|
93
|
+
onClick={handleClick}
|
|
94
|
+
data-cy="DiscountSummary-DiscountValue-TriggerButton"
|
|
95
|
+
type="button"
|
|
96
|
+
aria-expanded={expanded}
|
|
97
|
+
aria-label={toggleDiscountsAriaLabel}
|
|
98
|
+
className={classes.discountsButton}
|
|
99
|
+
>
|
|
100
|
+
<Icon src={iconSrc} />
|
|
101
|
+
</button>
|
|
102
|
+
</span>
|
|
103
|
+
<span
|
|
104
|
+
data-cy="DiscountSummary-discountValue"
|
|
105
|
+
className={classes.price}
|
|
106
|
+
>
|
|
107
|
+
{MINUS_SYMBOL}
|
|
108
|
+
<Price
|
|
109
|
+
value={totalDiscount.value}
|
|
110
|
+
currencyCode={totalDiscount.currency}
|
|
111
|
+
/>
|
|
112
|
+
</span>
|
|
113
|
+
</li>
|
|
114
|
+
{individualDiscounts}
|
|
65
115
|
</Fragment>
|
|
66
116
|
) : null;
|
|
67
117
|
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
.root {
|
|
2
|
+
}
|
|
3
|
+
|
|
4
|
+
.discountsButton {
|
|
5
|
+
composes: grid from global;
|
|
6
|
+
composes: items-center from global;
|
|
7
|
+
composes: ml-2 from global;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.discountLineItems {
|
|
11
|
+
composes: lineItems from './priceSummary.module.css';
|
|
12
|
+
|
|
13
|
+
composes: items-center from global;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.discountLineItemLabel {
|
|
17
|
+
composes: lineItemLabel from './priceSummary.module.css';
|
|
18
|
+
|
|
19
|
+
composes: grid from global;
|
|
20
|
+
composes: grid-flow-col from global;
|
|
21
|
+
composes: items-center from global;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.individualDiscountSeparator {
|
|
25
|
+
composes: mx-0 from global;
|
|
26
|
+
composes: my-4 from global;
|
|
27
|
+
|
|
28
|
+
color: rgb(var(--venia-global-color-gray-300));
|
|
29
|
+
}
|
|
30
|
+
.individualDiscountsList {
|
|
31
|
+
composes: lineItemLabel from './priceSummary.module.css';
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.individualDiscountsListLineItem {
|
|
35
|
+
composes: lineItems from './priceSummary.module.css';
|
|
36
|
+
composes: mx-0 from global;
|
|
37
|
+
composes: pl-4 from global;
|
|
38
|
+
|
|
39
|
+
color: rgb(var(--venia-global-color-gray-700));
|
|
40
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React, { Fragment } from 'react';
|
|
2
|
+
import { FormattedMessage } from 'react-intl';
|
|
3
|
+
|
|
4
|
+
import { useStyle } from '@magento/venia-ui/lib/classify';
|
|
5
|
+
import Price from '@magento/venia-ui/lib/components/Price';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A component that renders the gift options summary line item.
|
|
9
|
+
*
|
|
10
|
+
* @param {Object} props.classes
|
|
11
|
+
* @param {Object} props.data fragment response data
|
|
12
|
+
*/
|
|
13
|
+
export default props => {
|
|
14
|
+
const classes = useStyle({}, props.classes);
|
|
15
|
+
const giftOptions = props?.data?.printed_card || {};
|
|
16
|
+
|
|
17
|
+
if (!giftOptions || !giftOptions.value) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<Fragment>
|
|
23
|
+
<span
|
|
24
|
+
className={classes.lineItemLabel}
|
|
25
|
+
data-cy="PriceSummary-GiftOptionsSummary-label"
|
|
26
|
+
>
|
|
27
|
+
<FormattedMessage
|
|
28
|
+
id={'giftOptionsSummary.lineItemLabel'}
|
|
29
|
+
defaultMessage={'Printed Card'}
|
|
30
|
+
/>
|
|
31
|
+
</span>
|
|
32
|
+
<span className={classes.price}>
|
|
33
|
+
<Price
|
|
34
|
+
value={giftOptions.value}
|
|
35
|
+
currencyCode={giftOptions.currency}
|
|
36
|
+
/>
|
|
37
|
+
</span>
|
|
38
|
+
</Fragment>
|
|
39
|
+
);
|
|
40
|
+
};
|
|
@@ -7,6 +7,7 @@ import { useStyle } from '../../../classify';
|
|
|
7
7
|
import defaultClasses from './priceSummary.module.css';
|
|
8
8
|
import DiscountSummary from './discountSummary';
|
|
9
9
|
import GiftCardSummary from './giftCardSummary';
|
|
10
|
+
import GiftOptionsSummary from './giftOptionsSummary';
|
|
10
11
|
import ShippingSummary from './shippingSummary';
|
|
11
12
|
import TaxSummary from './taxSummary';
|
|
12
13
|
|
|
@@ -57,7 +58,15 @@ const PriceSummary = props => {
|
|
|
57
58
|
return null;
|
|
58
59
|
}
|
|
59
60
|
|
|
60
|
-
const {
|
|
61
|
+
const {
|
|
62
|
+
subtotal,
|
|
63
|
+
total,
|
|
64
|
+
discounts,
|
|
65
|
+
giftCards,
|
|
66
|
+
giftOptions,
|
|
67
|
+
taxes,
|
|
68
|
+
shipping
|
|
69
|
+
} = flatData;
|
|
61
70
|
|
|
62
71
|
const isPriceUpdating = isUpdating || isLoading;
|
|
63
72
|
const priceClass = isPriceUpdating ? classes.priceUpdating : classes.price;
|
|
@@ -93,59 +102,92 @@ const PriceSummary = props => {
|
|
|
93
102
|
|
|
94
103
|
return (
|
|
95
104
|
<div className={classes.root} data-cy="PriceSummary-root">
|
|
96
|
-
<div
|
|
97
|
-
<
|
|
98
|
-
<
|
|
99
|
-
|
|
100
|
-
|
|
105
|
+
<div>
|
|
106
|
+
<ul>
|
|
107
|
+
<li className={classes.lineItems}>
|
|
108
|
+
<span
|
|
109
|
+
data-cy="PriceSummary-lineItemLabel"
|
|
110
|
+
className={classes.lineItemLabel}
|
|
111
|
+
>
|
|
112
|
+
<FormattedMessage
|
|
113
|
+
id={'priceSummary.lineItemLabel'}
|
|
114
|
+
defaultMessage={'Subtotal'}
|
|
115
|
+
/>
|
|
116
|
+
</span>
|
|
117
|
+
<span
|
|
118
|
+
data-cy="PriceSummary-subtotalValue"
|
|
119
|
+
className={priceClass}
|
|
120
|
+
>
|
|
121
|
+
<Price
|
|
122
|
+
value={subtotal.value}
|
|
123
|
+
currencyCode={subtotal.currency}
|
|
124
|
+
/>
|
|
125
|
+
</span>
|
|
126
|
+
</li>
|
|
127
|
+
<DiscountSummary
|
|
128
|
+
classes={{
|
|
129
|
+
lineItems: classes.lineItems,
|
|
130
|
+
lineItemLabel: classes.lineItemLabel,
|
|
131
|
+
price: priceClass
|
|
132
|
+
}}
|
|
133
|
+
data={discounts}
|
|
101
134
|
/>
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
135
|
+
<li className={classes.lineItems}>
|
|
136
|
+
<GiftCardSummary
|
|
137
|
+
classes={{
|
|
138
|
+
lineItemLabel: classes.lineItemLabel,
|
|
139
|
+
price: priceClass
|
|
140
|
+
}}
|
|
141
|
+
data={giftCards}
|
|
142
|
+
/>
|
|
143
|
+
</li>
|
|
144
|
+
<li className={classes.lineItems}>
|
|
145
|
+
<GiftOptionsSummary
|
|
146
|
+
classes={{
|
|
147
|
+
lineItemLabel: classes.lineItemLabel,
|
|
148
|
+
price: priceClass
|
|
149
|
+
}}
|
|
150
|
+
data={giftOptions}
|
|
151
|
+
/>
|
|
152
|
+
</li>
|
|
153
|
+
<li className={classes.lineItems}>
|
|
154
|
+
<TaxSummary
|
|
155
|
+
classes={{
|
|
156
|
+
lineItemLabel: classes.lineItemLabel,
|
|
157
|
+
price: priceClass
|
|
158
|
+
}}
|
|
159
|
+
data={taxes}
|
|
160
|
+
isCheckout={isCheckout}
|
|
161
|
+
/>
|
|
162
|
+
</li>
|
|
163
|
+
<li className={classes.lineItems}>
|
|
164
|
+
<ShippingSummary
|
|
165
|
+
classes={{
|
|
166
|
+
lineItemLabel: classes.lineItemLabel,
|
|
167
|
+
price: priceClass
|
|
168
|
+
}}
|
|
169
|
+
data={shipping}
|
|
170
|
+
isCheckout={isCheckout}
|
|
171
|
+
/>
|
|
172
|
+
</li>
|
|
173
|
+
<li className={classes.lineItems}>
|
|
174
|
+
<span
|
|
175
|
+
data-cy="PriceSummary-totalLabel"
|
|
176
|
+
className={classes.totalLabel}
|
|
177
|
+
>
|
|
178
|
+
{totalPriceLabel}
|
|
179
|
+
</span>
|
|
180
|
+
<span
|
|
181
|
+
data-cy="PriceSummary-totalValue"
|
|
182
|
+
className={totalPriceClass}
|
|
183
|
+
>
|
|
184
|
+
<Price
|
|
185
|
+
value={total.value}
|
|
186
|
+
currencyCode={total.currency}
|
|
187
|
+
/>
|
|
188
|
+
</span>
|
|
189
|
+
</li>
|
|
190
|
+
</ul>
|
|
149
191
|
</div>
|
|
150
192
|
{proceedToCheckoutButton}
|
|
151
193
|
</div>
|
|
@@ -57,6 +57,63 @@ exports[`renders product details with base price and in stock 1`] = `
|
|
|
57
57
|
</div>
|
|
58
58
|
`;
|
|
59
59
|
|
|
60
|
+
exports[`renders product details with configured variant image 1`] = `
|
|
61
|
+
<div
|
|
62
|
+
className="root"
|
|
63
|
+
>
|
|
64
|
+
<Image
|
|
65
|
+
alt="Configurable Product"
|
|
66
|
+
classes={
|
|
67
|
+
Object {
|
|
68
|
+
"image": "image",
|
|
69
|
+
"root": "imageContainer",
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
resource="https://test.cdn/image_variant.jpg"
|
|
73
|
+
width={240}
|
|
74
|
+
/>
|
|
75
|
+
<span
|
|
76
|
+
className="productName"
|
|
77
|
+
>
|
|
78
|
+
Configurable Product
|
|
79
|
+
</span>
|
|
80
|
+
<div
|
|
81
|
+
className="stockRow"
|
|
82
|
+
>
|
|
83
|
+
<span>
|
|
84
|
+
<mock-FormattedMessage
|
|
85
|
+
defaultMessage="SKU # {sku}"
|
|
86
|
+
id="productDetail.skuNumber"
|
|
87
|
+
values={
|
|
88
|
+
Object {
|
|
89
|
+
"sku": "SP-01",
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/>
|
|
93
|
+
</span>
|
|
94
|
+
<span>
|
|
95
|
+
In stock
|
|
96
|
+
</span>
|
|
97
|
+
</div>
|
|
98
|
+
<div
|
|
99
|
+
className="price"
|
|
100
|
+
>
|
|
101
|
+
<span>
|
|
102
|
+
$
|
|
103
|
+
</span>
|
|
104
|
+
<span>
|
|
105
|
+
123
|
|
106
|
+
</span>
|
|
107
|
+
<span>
|
|
108
|
+
.
|
|
109
|
+
</span>
|
|
110
|
+
<span>
|
|
111
|
+
45
|
|
112
|
+
</span>
|
|
113
|
+
</div>
|
|
114
|
+
</div>
|
|
115
|
+
`;
|
|
116
|
+
|
|
60
117
|
exports[`renders product details with unknown stock value 1`] = `
|
|
61
118
|
<div
|
|
62
119
|
className="root"
|
|
@@ -90,6 +90,11 @@ exports[`renders form errors 1`] = `
|
|
|
90
90
|
className="image placeholder"
|
|
91
91
|
loading="eager"
|
|
92
92
|
src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHdpZHRoPSc0JyBoZWlnaHQ9JzUnPjxyZWN0IHdpZHRoPSc0JyBoZWlnaHQ9JzUnIHN0eWxlPSdmaWxsOiBub25lJyAvPjwvc3ZnPg=="
|
|
93
|
+
style={
|
|
94
|
+
Object {
|
|
95
|
+
"--width": "240px",
|
|
96
|
+
}
|
|
97
|
+
}
|
|
93
98
|
width={240}
|
|
94
99
|
/>
|
|
95
100
|
<img
|
|
@@ -109,6 +114,12 @@ https://master-7rqtwti-mfwmkrjfqvbjk.us-4.magentosite.cloud/media/catalog/produc
|
|
|
109
114
|
https://master-7rqtwti-mfwmkrjfqvbjk.us-4.magentosite.cloud/media/catalog/product/cache/d3ba9f7bcd3b0724e976dc5144b29c7d/v/s/vsw02-pe_main_2.jpg?auto=webp&format=pjpg&width=1280&height=1600&fit=cover 1280w,
|
|
110
115
|
https://master-7rqtwti-mfwmkrjfqvbjk.us-4.magentosite.cloud/media/catalog/product/cache/d3ba9f7bcd3b0724e976dc5144b29c7d/v/s/vsw02-pe_main_2.jpg?auto=webp&format=pjpg&width=1600&height=2000&fit=cover 1600w,
|
|
111
116
|
https://master-7rqtwti-mfwmkrjfqvbjk.us-4.magentosite.cloud/media/catalog/product/cache/d3ba9f7bcd3b0724e976dc5144b29c7d/v/s/vsw02-pe_main_2.jpg?auto=webp&format=pjpg&width=2560&height=3200&fit=cover 2560w"
|
|
117
|
+
style={
|
|
118
|
+
Object {
|
|
119
|
+
"--height": "300px",
|
|
120
|
+
"--width": "240px",
|
|
121
|
+
}
|
|
122
|
+
}
|
|
112
123
|
width={240}
|
|
113
124
|
/>
|
|
114
125
|
</div>
|
|
@@ -436,6 +447,11 @@ exports[`renders form with data 1`] = `
|
|
|
436
447
|
className="image placeholder"
|
|
437
448
|
loading="eager"
|
|
438
449
|
src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHdpZHRoPSc0JyBoZWlnaHQ9JzUnPjxyZWN0IHdpZHRoPSc0JyBoZWlnaHQ9JzUnIHN0eWxlPSdmaWxsOiBub25lJyAvPjwvc3ZnPg=="
|
|
450
|
+
style={
|
|
451
|
+
Object {
|
|
452
|
+
"--width": "240px",
|
|
453
|
+
}
|
|
454
|
+
}
|
|
439
455
|
width={240}
|
|
440
456
|
/>
|
|
441
457
|
<img
|
|
@@ -455,6 +471,12 @@ https://master-7rqtwti-mfwmkrjfqvbjk.us-4.magentosite.cloud/media/catalog/produc
|
|
|
455
471
|
https://master-7rqtwti-mfwmkrjfqvbjk.us-4.magentosite.cloud/media/catalog/product/cache/d3ba9f7bcd3b0724e976dc5144b29c7d/v/s/vsw02-pe_main_2.jpg?auto=webp&format=pjpg&width=1280&height=1600&fit=cover 1280w,
|
|
456
472
|
https://master-7rqtwti-mfwmkrjfqvbjk.us-4.magentosite.cloud/media/catalog/product/cache/d3ba9f7bcd3b0724e976dc5144b29c7d/v/s/vsw02-pe_main_2.jpg?auto=webp&format=pjpg&width=1600&height=2000&fit=cover 1600w,
|
|
457
473
|
https://master-7rqtwti-mfwmkrjfqvbjk.us-4.magentosite.cloud/media/catalog/product/cache/d3ba9f7bcd3b0724e976dc5144b29c7d/v/s/vsw02-pe_main_2.jpg?auto=webp&format=pjpg&width=2560&height=3200&fit=cover 2560w"
|
|
474
|
+
style={
|
|
475
|
+
Object {
|
|
476
|
+
"--height": "300px",
|
|
477
|
+
"--width": "240px",
|
|
478
|
+
}
|
|
479
|
+
}
|
|
458
480
|
width={240}
|
|
459
481
|
/>
|
|
460
482
|
</div>
|
|
@@ -2,9 +2,11 @@ import React from 'react';
|
|
|
2
2
|
import { createTestInstance } from '@magento/peregrine';
|
|
3
3
|
|
|
4
4
|
import ProductDetail from '../productDetail';
|
|
5
|
+
import configuredVariant from '@magento/peregrine/lib/util/configuredVariant';
|
|
5
6
|
|
|
6
7
|
jest.mock('../../../../../classify');
|
|
7
8
|
jest.mock('../../../../Image', () => 'Image');
|
|
9
|
+
jest.mock('@magento/peregrine/lib/util/configuredVariant');
|
|
8
10
|
|
|
9
11
|
const mockProduct = {
|
|
10
12
|
name: 'Simple Product',
|
|
@@ -23,6 +25,8 @@ const mockItem = {
|
|
|
23
25
|
}
|
|
24
26
|
};
|
|
25
27
|
|
|
28
|
+
const configurableThumbnailSource = 'parent';
|
|
29
|
+
|
|
26
30
|
describe('renders product details', () => {
|
|
27
31
|
test('with base price and in stock', () => {
|
|
28
32
|
const item = {
|
|
@@ -33,7 +37,12 @@ describe('renders product details', () => {
|
|
|
33
37
|
}
|
|
34
38
|
};
|
|
35
39
|
|
|
36
|
-
const tree = createTestInstance(
|
|
40
|
+
const tree = createTestInstance(
|
|
41
|
+
<ProductDetail
|
|
42
|
+
item={item}
|
|
43
|
+
configurableThumbnailSource={configurableThumbnailSource}
|
|
44
|
+
/>
|
|
45
|
+
);
|
|
37
46
|
expect(tree.toJSON()).toMatchSnapshot();
|
|
38
47
|
});
|
|
39
48
|
|
|
@@ -52,7 +61,32 @@ describe('renders product details', () => {
|
|
|
52
61
|
};
|
|
53
62
|
|
|
54
63
|
const tree = createTestInstance(
|
|
55
|
-
<ProductDetail
|
|
64
|
+
<ProductDetail
|
|
65
|
+
item={item}
|
|
66
|
+
variantPrice={variantPrice}
|
|
67
|
+
configurableThumbnailSource={configurableThumbnailSource}
|
|
68
|
+
/>
|
|
69
|
+
);
|
|
70
|
+
expect(tree.toJSON()).toMatchSnapshot();
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
test('with configured variant image', () => {
|
|
74
|
+
configuredVariant.mockReturnValueOnce({
|
|
75
|
+
small_image: {
|
|
76
|
+
url: 'https://test.cdn/image_variant.jpg'
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
const item = {
|
|
80
|
+
...mockItem,
|
|
81
|
+
product: {
|
|
82
|
+
...mockProduct,
|
|
83
|
+
name: 'Configurable Product',
|
|
84
|
+
stock_status: 'IN_STOCK'
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const tree = createTestInstance(
|
|
89
|
+
<ProductDetail item={item} configurableThumbnailSource={'itself'} />
|
|
56
90
|
);
|
|
57
91
|
expect(tree.toJSON()).toMatchSnapshot();
|
|
58
92
|
});
|
|
@@ -67,6 +101,11 @@ test('renders product details with unknown stock value', () => {
|
|
|
67
101
|
}
|
|
68
102
|
};
|
|
69
103
|
|
|
70
|
-
const tree = createTestInstance(
|
|
104
|
+
const tree = createTestInstance(
|
|
105
|
+
<ProductDetail
|
|
106
|
+
item={item}
|
|
107
|
+
configurableThumbnailSource={configurableThumbnailSource}
|
|
108
|
+
/>
|
|
109
|
+
);
|
|
71
110
|
expect(tree.toJSON()).toMatchSnapshot();
|
|
72
111
|
});
|