@riosst100/pwa-marketplace 1.3.2 → 1.3.4
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/.github/workflows/dependabot.yml +28 -28
- package/package.json +18 -18
- package/src/componentOverrideMapping.js +14 -0
- package/src/components/BecomeSellerLink/becomeSellerLink.js +1 -1
- package/src/components/BecomeSellerLink/becomeSellerLink.module.css +0 -4
- package/src/components/CurrencySwitcher/currencySwitcher.himmer.js +6 -0
- package/src/components/CurrencySwitcher/currencySwitcher.module.css +102 -0
- package/src/components/CurrencySwitcher/index.js +107 -0
- package/src/components/CurrencySwitcher/switcherItem.js +47 -0
- package/src/components/CurrencySwitcher/switcherItem.module.css +20 -0
- package/src/components/FilterOption/FilterOptionModal.module.css +90 -0
- package/src/components/FilterOption/filterOptionModal.js +48 -0
- package/src/components/FilterOptionModal/filterOptionModal.js +66 -0
- package/src/components/Header/becomeSellerLink.module.css +0 -4
- package/src/components/Header/websiteSwitcher.js +0 -1
- package/src/components/Header/websiteSwitcher.module.css +107 -111
- package/src/components/WebsiteSwitcher/websiteSwitcher.js +18 -6
- package/src/components/WebsiteSwitcher/websiteSwitcher.module.css +107 -111
- package/src/overwrites/peregrine/lib/talons/FilterModal/useFilterList.js +62 -0
- package/src/overwrites/peregrine/lib/talons/MegaMenu/useMegaMenuItem.js +66 -0
- package/src/overwrites/peregrine/lib/talons/MegaMenu/useSubMenu.js +20 -0
- package/src/overwrites/peregrine/lib/talons/RootComponents/Category/useCategoryContent.js +0 -2
- package/src/overwrites/venia-ui/lib/RootComponents/Category/NoProductsFound/index.js +1 -0
- package/src/overwrites/venia-ui/lib/RootComponents/Category/NoProductsFound/noProductsFound.js +77 -0
- package/src/overwrites/venia-ui/lib/RootComponents/Category/NoProductsFound/noProductsFound.module.css +39 -0
- package/src/overwrites/venia-ui/lib/RootComponents/Category/NoProductsFound/noProductsFound.png +0 -0
- package/src/overwrites/venia-ui/lib/RootComponents/Category/category.gql.js +17 -0
- package/src/overwrites/venia-ui/lib/RootComponents/Category/category.js +91 -0
- package/src/overwrites/venia-ui/lib/RootComponents/Category/category.module.css +77 -0
- package/src/overwrites/venia-ui/lib/RootComponents/Category/categoryContent.js +12 -14
- package/src/overwrites/venia-ui/lib/RootComponents/Category/categoryContent.shimmer.js +74 -0
- package/src/overwrites/venia-ui/lib/RootComponents/Category/images/001.jpg +0 -0
- package/src/overwrites/venia-ui/lib/RootComponents/Category/images/002.jpg +0 -0
- package/src/overwrites/venia-ui/lib/RootComponents/Category/images/003.jpg +0 -0
- package/src/overwrites/venia-ui/lib/RootComponents/Category/images/004.jpg +0 -0
- package/src/overwrites/venia-ui/lib/RootComponents/Category/images/005.jpg +0 -0
- package/src/overwrites/venia-ui/lib/RootComponents/Category/images/006.jpg +0 -0
- package/src/overwrites/venia-ui/lib/RootComponents/Category/images/007.jpg +0 -0
- package/src/overwrites/venia-ui/lib/RootComponents/Category/images/008.jpg +0 -0
- package/src/overwrites/venia-ui/lib/RootComponents/Category/images/009.jpg +0 -0
- package/src/overwrites/venia-ui/lib/RootComponents/Category/images/010.jpg +0 -0
- package/src/overwrites/venia-ui/lib/RootComponents/Category/images/011.jpg +0 -0
- package/src/overwrites/venia-ui/lib/RootComponents/Category/images/012.jpg +0 -0
- package/src/overwrites/venia-ui/lib/RootComponents/Category/images/index.js +12 -0
- package/src/overwrites/venia-ui/lib/RootComponents/Category/index.js +6 -0
- package/src/overwrites/venia-ui/lib/components/Breadcrumbs/breadcrumbs.js +112 -0
- package/src/overwrites/venia-ui/lib/components/Breadcrumbs/breadcrumbs.module.css +32 -0
- package/src/overwrites/venia-ui/lib/components/Breadcrumbs/breadcrumbs.shimmer.js +24 -0
- package/src/overwrites/venia-ui/lib/components/Breadcrumbs/index.js +2 -0
- package/src/overwrites/venia-ui/lib/components/Checkbox/checkbox.js +78 -0
- package/src/overwrites/venia-ui/lib/components/Checkbox/checkbox.module.css +73 -0
- package/src/overwrites/venia-ui/lib/components/Checkbox/index.js +1 -0
- package/src/overwrites/venia-ui/lib/components/FilterModal/CurrentFilters/currentFilter.js +60 -0
- package/src/overwrites/venia-ui/lib/components/FilterModal/CurrentFilters/currentFilter.module.css +21 -0
- package/src/overwrites/venia-ui/lib/components/FilterModal/CurrentFilters/currentFilters.js +65 -0
- package/src/overwrites/venia-ui/lib/components/FilterModal/CurrentFilters/currentFilters.module.css +17 -0
- package/src/overwrites/venia-ui/lib/components/FilterModal/CurrentFilters/index.js +1 -0
- package/src/overwrites/venia-ui/lib/components/FilterModal/FilterList/filterDefault.js +18 -18
- package/src/overwrites/venia-ui/lib/components/FilterModal/FilterList/filterDefault.module.css +0 -0
- package/src/overwrites/venia-ui/lib/components/FilterModal/FilterList/filterItem.js +79 -0
- package/src/overwrites/venia-ui/lib/components/FilterModal/FilterList/filterItemRadio.js +76 -0
- package/src/overwrites/venia-ui/lib/components/FilterModal/FilterList/filterItemRadio.module.css +0 -0
- package/src/overwrites/venia-ui/lib/components/FilterModal/FilterList/filterItemRadioGroup.js +86 -0
- package/src/overwrites/venia-ui/lib/components/FilterModal/FilterList/filterList.js +265 -0
- package/src/overwrites/venia-ui/lib/components/FilterModal/FilterList/filterList.module.css +20 -0
- package/src/overwrites/venia-ui/lib/components/FilterModal/FilterList/index.js +1 -0
- package/src/overwrites/venia-ui/lib/components/FilterModal/filterBlock.js +135 -0
- package/src/overwrites/venia-ui/lib/components/FilterModal/filterBlock.module.css +25 -0
- package/src/overwrites/venia-ui/lib/components/FilterModal/filterFooter.js +49 -0
- package/src/overwrites/venia-ui/lib/components/FilterModal/filterFooter.module.css +10 -0
- package/src/overwrites/venia-ui/lib/components/FilterModal/filterModal.js +166 -0
- package/src/overwrites/venia-ui/lib/components/FilterModal/filterModal.module.css +87 -0
- package/src/overwrites/venia-ui/lib/components/FilterModal/filterSearch.module.css +3 -0
- package/src/overwrites/venia-ui/lib/components/FilterModal/index.js +1 -0
- package/src/overwrites/venia-ui/lib/components/FilterSidebar/__tests__/filterSidebar.spec.js +246 -0
- package/src/overwrites/venia-ui/lib/components/FilterSidebar/filterSidebar.js +10 -10
- package/src/overwrites/venia-ui/lib/components/FilterSidebar/filterSidebar.module.css +57 -0
- package/src/overwrites/venia-ui/lib/components/FilterSidebar/filterSidebar.shimmer.js +24 -0
- package/src/overwrites/venia-ui/lib/components/FilterSidebar/index.js +2 -0
- package/src/overwrites/venia-ui/lib/components/Gallery/addToCartButton.js +116 -0
- package/src/overwrites/venia-ui/lib/components/Gallery/addToCartButton.module.css +38 -0
- package/src/overwrites/venia-ui/lib/components/Gallery/gallery.js +56 -0
- package/src/overwrites/venia-ui/lib/components/Gallery/gallery.module.css +28 -0
- package/src/overwrites/venia-ui/lib/components/Gallery/gallery.shimmer.js +39 -0
- package/src/overwrites/venia-ui/lib/components/Gallery/index.js +3 -0
- package/src/overwrites/venia-ui/lib/components/Gallery/item.js +204 -0
- package/src/overwrites/venia-ui/lib/components/Gallery/item.module.css +109 -0
- package/src/overwrites/venia-ui/lib/components/Gallery/item.shimmer.js +38 -0
- package/src/overwrites/venia-ui/lib/components/Gallery/star.js +12 -0
- package/src/overwrites/venia-ui/lib/components/Header/accountTrigger.js +98 -0
- package/src/overwrites/venia-ui/lib/components/Header/cartTrigger.js +116 -0
- package/src/overwrites/venia-ui/lib/components/Header/header.js +12 -9
- package/src/overwrites/venia-ui/lib/components/Header/storeSwitcher.js +22 -8
- package/src/overwrites/venia-ui/lib/components/Header/storeSwitcher.module.css +107 -0
- package/src/overwrites/venia-ui/lib/components/Header/wishlistTrigger.js +23 -0
- package/src/overwrites/venia-ui/lib/components/MegaMenu/megaMenuItem.js +1 -1
- package/src/overwrites/venia-ui/lib/components/MegaMenu/submenu.module.css +0 -1
- package/src/overwrites/venia-ui/lib/components/Pagination/index.js +1 -0
- package/src/overwrites/venia-ui/lib/components/Pagination/navButton.js +65 -0
- package/src/overwrites/venia-ui/lib/components/Pagination/pagination.js +107 -0
- package/src/overwrites/venia-ui/lib/components/Pagination/tile.js +41 -0
- package/src/overwrites/venia-ui/lib/components/ProductFullDetail/CustomAttributes/AttributeType/Boolean/boolean.js +74 -0
- package/src/overwrites/venia-ui/lib/components/ProductFullDetail/CustomAttributes/AttributeType/Boolean/boolean.module.css +9 -0
- package/src/overwrites/venia-ui/lib/components/ProductFullDetail/CustomAttributes/AttributeType/Boolean/index.js +1 -0
- package/src/overwrites/venia-ui/lib/components/ProductFullDetail/CustomAttributes/AttributeType/Date/date.js +82 -0
- package/src/overwrites/venia-ui/lib/components/ProductFullDetail/CustomAttributes/AttributeType/Date/date.module.css +9 -0
- package/src/overwrites/venia-ui/lib/components/ProductFullDetail/CustomAttributes/AttributeType/Date/index.js +1 -0
- package/src/overwrites/venia-ui/lib/components/ProductFullDetail/CustomAttributes/AttributeType/DateTime/dateTime.js +85 -0
- package/src/overwrites/venia-ui/lib/components/ProductFullDetail/CustomAttributes/AttributeType/DateTime/dateTime.module.css +9 -0
- package/src/overwrites/venia-ui/lib/components/ProductFullDetail/CustomAttributes/AttributeType/DateTime/index.js +1 -0
- package/src/overwrites/venia-ui/lib/components/ProductFullDetail/CustomAttributes/AttributeType/Multiselect/index.js +1 -0
- package/src/overwrites/venia-ui/lib/components/ProductFullDetail/CustomAttributes/AttributeType/Multiselect/multiselect.js +104 -0
- package/src/overwrites/venia-ui/lib/components/ProductFullDetail/CustomAttributes/AttributeType/Multiselect/multiselect.module.css +22 -0
- package/src/overwrites/venia-ui/lib/components/ProductFullDetail/CustomAttributes/AttributeType/Price/index.js +1 -0
- package/src/overwrites/venia-ui/lib/components/ProductFullDetail/CustomAttributes/AttributeType/Price/price.js +74 -0
- package/src/overwrites/venia-ui/lib/components/ProductFullDetail/CustomAttributes/AttributeType/Price/price.module.css +9 -0
- package/src/overwrites/venia-ui/lib/components/ProductFullDetail/CustomAttributes/AttributeType/Select/index.js +1 -0
- package/src/overwrites/venia-ui/lib/components/ProductFullDetail/CustomAttributes/AttributeType/Select/select.js +99 -0
- package/src/overwrites/venia-ui/lib/components/ProductFullDetail/CustomAttributes/AttributeType/Select/select.module.css +13 -0
- package/src/overwrites/venia-ui/lib/components/ProductFullDetail/CustomAttributes/AttributeType/Text/index.js +1 -0
- package/src/overwrites/venia-ui/lib/components/ProductFullDetail/CustomAttributes/AttributeType/Text/text.js +88 -0
- package/src/overwrites/venia-ui/lib/components/ProductFullDetail/CustomAttributes/AttributeType/Text/text.module.css +13 -0
- package/src/overwrites/venia-ui/lib/components/ProductFullDetail/CustomAttributes/AttributeType/Textarea/index.js +1 -0
- package/src/overwrites/venia-ui/lib/components/ProductFullDetail/CustomAttributes/AttributeType/Textarea/textarea.js +94 -0
- package/src/overwrites/venia-ui/lib/components/ProductFullDetail/CustomAttributes/AttributeType/Textarea/textarea.module.css +13 -0
- package/src/overwrites/venia-ui/lib/components/ProductFullDetail/CustomAttributes/AttributeType/attributeType.js +67 -0
- package/src/overwrites/venia-ui/lib/components/ProductFullDetail/CustomAttributes/AttributeType/index.js +1 -0
- package/src/overwrites/venia-ui/lib/components/ProductFullDetail/CustomAttributes/customAttributes.js +64 -0
- package/src/overwrites/venia-ui/lib/components/ProductFullDetail/CustomAttributes/customAttributes.module.css +9 -0
- package/src/overwrites/venia-ui/lib/components/ProductFullDetail/CustomAttributes/index.js +1 -0
- package/src/overwrites/venia-ui/lib/components/ProductFullDetail/index.js +1 -0
- package/src/overwrites/venia-ui/lib/components/ProductFullDetail/productFullDetail.gql.js +7 -0
- package/src/overwrites/venia-ui/lib/components/ProductFullDetail/productFullDetail.js +413 -0
- package/src/overwrites/venia-ui/lib/components/ProductFullDetail/productFullDetail.module.css +203 -0
- package/src/overwrites/venia-ui/lib/components/ProductImageCarousel/carousel.js +180 -0
- package/src/overwrites/venia-ui/lib/components/ProductImageCarousel/carousel.module.css +102 -0
- package/src/overwrites/venia-ui/lib/components/ProductImageCarousel/carousel.shimmer.js +51 -0
- package/src/overwrites/venia-ui/lib/components/ProductImageCarousel/carousel.shimmer.module.css +7 -0
- package/src/overwrites/venia-ui/lib/components/ProductImageCarousel/index.js +1 -0
- package/src/overwrites/venia-ui/lib/components/ProductImageCarousel/thumbnail.js +108 -0
- package/src/overwrites/venia-ui/lib/components/ProductImageCarousel/thumbnail.module.css +47 -0
- package/src/overwrites/venia-ui/lib/components/ProductSort/index.js +2 -0
- package/src/overwrites/venia-ui/lib/components/ProductSort/productSort.js +233 -0
- package/src/overwrites/venia-ui/lib/components/ProductSort/productSort.module.css +65 -0
- package/src/overwrites/venia-ui/lib/components/ProductSort/productSort.shimmer.js +28 -0
- package/src/overwrites/venia-ui/lib/components/ProductSort/productSort.shimmer.module.css +10 -0
- package/src/overwrites/venia-ui/lib/components/ProductSort/sortItem.js +57 -0
- package/src/overwrites/venia-ui/lib/components/ProductSort/sortItem.module.css +23 -0
- package/src/overwrites/venia-ui/lib/components/QuantityStepper/index.js +1 -0
- package/src/overwrites/venia-ui/lib/components/QuantityStepper/quantityStepper.js +94 -0
- package/src/overwrites/venia-ui/lib/components/QuantityStepper/quantityStepper.module.css +78 -0
- package/src/overwrites/venia-ui/lib/components/RichContent/index.js +1 -0
- package/src/overwrites/venia-ui/lib/components/RichContent/plainHtmlRenderer.js +17 -0
- package/src/overwrites/venia-ui/lib/components/RichContent/richContent.js +59 -0
- package/src/overwrites/venia-ui/lib/components/RichContent/richContent.module.css +146 -0
- package/src/overwrites/venia-ui/lib/components/RichContent/richContentRenderers.js +7 -0
- package/src/overwrites/venia-ui/lib/components/SearchBar/searchBar.module.css +1 -2
- package/src/overwrites/venia-ui/lib/components/SearchBar/searchField.js +3 -2
- package/src/overwrites/venia-ui/lib/components/TextInput/field.module.css +50 -0
- package/src/overwrites/venia-ui/lib/components/TextInput/index.js +1 -0
- package/src/overwrites/venia-ui/lib/components/TextInput/textInput.js +48 -0
- package/src/overwrites/venia-ui/lib/components/TextInput/textInput.module.css +21 -0
- package/src/talons/FilterOption/useFilterOptionModal.js +11 -0
- package/src/talons/FilterOptionModal/useFilterOptionModal.js +11 -0
- package/src/theme/vars.js +12 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { useAttributeType } from '@magento/peregrine/lib/talons/ProductFullDetail/CustomAttributes/AttributeType/useAttributeType';
|
|
4
|
+
|
|
5
|
+
import Boolean from './Boolean';
|
|
6
|
+
import Date from './Date';
|
|
7
|
+
import DateTime from './DateTime';
|
|
8
|
+
import Multiselect from './Multiselect';
|
|
9
|
+
import Price from './Price';
|
|
10
|
+
import Select from './Select';
|
|
11
|
+
import Text from './Text';
|
|
12
|
+
import Textarea from './Textarea';
|
|
13
|
+
|
|
14
|
+
const defaultTypeConfig = {
|
|
15
|
+
boolean: {
|
|
16
|
+
component: Boolean
|
|
17
|
+
},
|
|
18
|
+
date: {
|
|
19
|
+
component: Date
|
|
20
|
+
},
|
|
21
|
+
datetime: {
|
|
22
|
+
component: DateTime
|
|
23
|
+
},
|
|
24
|
+
multiselect: {
|
|
25
|
+
component: Multiselect
|
|
26
|
+
},
|
|
27
|
+
price: {
|
|
28
|
+
component: Price
|
|
29
|
+
},
|
|
30
|
+
select: {
|
|
31
|
+
component: Select
|
|
32
|
+
},
|
|
33
|
+
text: {
|
|
34
|
+
component: Text
|
|
35
|
+
},
|
|
36
|
+
textarea: {
|
|
37
|
+
component: Textarea
|
|
38
|
+
},
|
|
39
|
+
texteditor: {
|
|
40
|
+
component: Textarea
|
|
41
|
+
},
|
|
42
|
+
pagebuilder: {
|
|
43
|
+
component: Textarea
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const AttributeType = props => {
|
|
48
|
+
const { data, ...rest } = props;
|
|
49
|
+
const { ui_input_type: type } = data?.attribute_metadata.ui_input || {};
|
|
50
|
+
|
|
51
|
+
const { getAttributeTypeConfig } = useAttributeType({
|
|
52
|
+
typeConfig: defaultTypeConfig
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
if (type) {
|
|
56
|
+
const attributeTypeConfig = getAttributeTypeConfig(type.toLowerCase());
|
|
57
|
+
if (attributeTypeConfig && attributeTypeConfig.component) {
|
|
58
|
+
const Component = attributeTypeConfig.component;
|
|
59
|
+
|
|
60
|
+
return <Component {...data} {...rest} />;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return null;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export default AttributeType;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './attributeType';
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
|
+
import { array, shape, string } from 'prop-types';
|
|
3
|
+
|
|
4
|
+
import { useStyle } from '@magento/venia-ui/lib/classify';
|
|
5
|
+
|
|
6
|
+
import AttributeType from './AttributeType';
|
|
7
|
+
import defaultClasses from './customAttributes.module.css';
|
|
8
|
+
|
|
9
|
+
export const IS_VISIBLE_ON_FRONT = 'PRODUCT_DETAILS_PAGE';
|
|
10
|
+
|
|
11
|
+
const CustomAttributes = props => {
|
|
12
|
+
const { customAttributes, showLabels } = props;
|
|
13
|
+
const classes = useStyle(defaultClasses, props.classes);
|
|
14
|
+
|
|
15
|
+
const list = useMemo(
|
|
16
|
+
() =>
|
|
17
|
+
customAttributes.reduce((previousAttribute, currentAttribute) => {
|
|
18
|
+
const usedInComponents =
|
|
19
|
+
currentAttribute.attribute_metadata?.used_in_components ||
|
|
20
|
+
[];
|
|
21
|
+
// Visible on front attributes only
|
|
22
|
+
if (usedInComponents.includes(IS_VISIBLE_ON_FRONT)) {
|
|
23
|
+
const attributeContent = (
|
|
24
|
+
<li
|
|
25
|
+
key={currentAttribute.attribute_metadata.uid}
|
|
26
|
+
className={classes.listItem}
|
|
27
|
+
>
|
|
28
|
+
<AttributeType
|
|
29
|
+
showLabels={showLabels}
|
|
30
|
+
data={currentAttribute}
|
|
31
|
+
/>
|
|
32
|
+
</li>
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
previousAttribute.push(attributeContent);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return previousAttribute;
|
|
39
|
+
}, []),
|
|
40
|
+
[classes, customAttributes, showLabels]
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
if (list.length === 0) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<div className={classes.root}>
|
|
49
|
+
<ul className={classes.list}>{list}</ul>
|
|
50
|
+
</div>
|
|
51
|
+
);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
CustomAttributes.propTypes = {
|
|
55
|
+
classes: shape({
|
|
56
|
+
root: string,
|
|
57
|
+
title: string,
|
|
58
|
+
list: string,
|
|
59
|
+
listItem: string
|
|
60
|
+
}),
|
|
61
|
+
customAttributes: array.isRequired
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export default CustomAttributes;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './customAttributes';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './productFullDetail';
|
|
@@ -0,0 +1,413 @@
|
|
|
1
|
+
import React, { useMemo, Fragment, Suspense } from 'react';
|
|
2
|
+
import { FormattedMessage, useIntl } from 'react-intl';
|
|
3
|
+
import { arrayOf, bool, number, shape, string } from 'prop-types';
|
|
4
|
+
import { Form } from 'informed';
|
|
5
|
+
import { Info } from 'react-feather';
|
|
6
|
+
|
|
7
|
+
import Price from '@magento/venia-ui/lib/components/Price';
|
|
8
|
+
import { useProductFullDetail } from '@magento/peregrine/lib/talons/ProductFullDetail/useProductFullDetail';
|
|
9
|
+
import { isProductConfigurable } from '@magento/peregrine/lib/util/isProductConfigurable';
|
|
10
|
+
|
|
11
|
+
import { useStyle } from '@magento/venia-ui/lib/classify';
|
|
12
|
+
import Breadcrumbs from '../Breadcrumbs';
|
|
13
|
+
import Button from '@magento/venia-ui/lib/components/Button';
|
|
14
|
+
import Carousel from '../ProductImageCarousel';
|
|
15
|
+
import FormError from '@magento/venia-ui/lib/components/FormError';
|
|
16
|
+
import QuantityStepper from '../QuantityStepper';
|
|
17
|
+
import RichContent from '../RichContent/richContent';
|
|
18
|
+
import { ProductOptionsShimmer } from '@magento/venia-ui/lib/components/ProductOptions';
|
|
19
|
+
import CustomAttributes from './CustomAttributes';
|
|
20
|
+
import defaultClasses from './productFullDetail.module.css';
|
|
21
|
+
import cn from 'classnames';
|
|
22
|
+
|
|
23
|
+
const WishlistButton = React.lazy(() => import('@magento/venia-ui/lib/components/Wishlist/AddToListButton'));
|
|
24
|
+
const Options = React.lazy(() => import('@magento/venia-ui/lib/components/ProductOptions'));
|
|
25
|
+
|
|
26
|
+
// Correlate a GQL error message to a field. GQL could return a longer error
|
|
27
|
+
// string but it may contain contextual info such as product id. We can use
|
|
28
|
+
// parts of the string to check for which field to apply the error.
|
|
29
|
+
const ERROR_MESSAGE_TO_FIELD_MAPPING = {
|
|
30
|
+
'The requested qty is not available': 'quantity',
|
|
31
|
+
'Product that you are trying to add is not available.': 'quantity',
|
|
32
|
+
"The product that was requested doesn't exist.": 'quantity'
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
// Field level error messages for rendering.
|
|
36
|
+
const ERROR_FIELD_TO_MESSAGE_MAPPING = {
|
|
37
|
+
quantity: 'The requested quantity is not available.'
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const ProductFullDetail = props => {
|
|
41
|
+
const { product } = props;
|
|
42
|
+
|
|
43
|
+
const talonProps = useProductFullDetail({ product });
|
|
44
|
+
|
|
45
|
+
const {
|
|
46
|
+
breadcrumbCategoryId,
|
|
47
|
+
errorMessage,
|
|
48
|
+
handleAddToCart,
|
|
49
|
+
handleSelectionChange,
|
|
50
|
+
isOutOfStock,
|
|
51
|
+
isEverythingOutOfStock,
|
|
52
|
+
outOfStockVariants,
|
|
53
|
+
isAddToCartDisabled,
|
|
54
|
+
isSupportedProductType,
|
|
55
|
+
mediaGalleryEntries,
|
|
56
|
+
productDetails,
|
|
57
|
+
customAttributes,
|
|
58
|
+
wishlistButtonProps
|
|
59
|
+
} = talonProps;
|
|
60
|
+
|
|
61
|
+
const { formatMessage } = useIntl();
|
|
62
|
+
|
|
63
|
+
const classes = useStyle(defaultClasses, props.classes);
|
|
64
|
+
|
|
65
|
+
const options = isProductConfigurable(product) ? (
|
|
66
|
+
<Suspense fallback={<ProductOptionsShimmer />}>
|
|
67
|
+
<Options
|
|
68
|
+
onSelectionChange={handleSelectionChange}
|
|
69
|
+
options={product.configurable_options}
|
|
70
|
+
isEverythingOutOfStock={isEverythingOutOfStock}
|
|
71
|
+
outOfStockVariants={outOfStockVariants}
|
|
72
|
+
/>
|
|
73
|
+
</Suspense>
|
|
74
|
+
) : null;
|
|
75
|
+
|
|
76
|
+
const breadcrumbs = breadcrumbCategoryId ? (
|
|
77
|
+
<Breadcrumbs
|
|
78
|
+
categoryId={breadcrumbCategoryId}
|
|
79
|
+
currentProduct={productDetails.name}
|
|
80
|
+
/>
|
|
81
|
+
) : null;
|
|
82
|
+
|
|
83
|
+
// Fill a map with field/section -> error.
|
|
84
|
+
const errors = new Map();
|
|
85
|
+
if (errorMessage) {
|
|
86
|
+
Object.keys(ERROR_MESSAGE_TO_FIELD_MAPPING).forEach(key => {
|
|
87
|
+
if (errorMessage.includes(key)) {
|
|
88
|
+
const target = ERROR_MESSAGE_TO_FIELD_MAPPING[key];
|
|
89
|
+
const message = ERROR_FIELD_TO_MESSAGE_MAPPING[target];
|
|
90
|
+
errors.set(target, message);
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
// Handle cases where a user token is invalid or expired. Preferably
|
|
95
|
+
// this would be handled elsewhere with an error code and not a string.
|
|
96
|
+
if (errorMessage.includes('The current user cannot')) {
|
|
97
|
+
errors.set('form', [
|
|
98
|
+
new Error(
|
|
99
|
+
formatMessage({
|
|
100
|
+
id: 'productFullDetail.errorToken',
|
|
101
|
+
defaultMessage:
|
|
102
|
+
'There was a problem with your cart. Please sign in again and try adding the item once more.'
|
|
103
|
+
})
|
|
104
|
+
)
|
|
105
|
+
]);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// Handle cases where a cart wasn't created properly.
|
|
109
|
+
if (
|
|
110
|
+
errorMessage.includes('Variable "$cartId" got invalid value null')
|
|
111
|
+
) {
|
|
112
|
+
errors.set('form', [
|
|
113
|
+
new Error(
|
|
114
|
+
formatMessage({
|
|
115
|
+
id: 'productFullDetail.errorCart',
|
|
116
|
+
defaultMessage:
|
|
117
|
+
'There was a problem with your cart. Please refresh the page and try adding the item once more.'
|
|
118
|
+
})
|
|
119
|
+
)
|
|
120
|
+
]);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// An unknown error should still present a readable message.
|
|
124
|
+
if (!errors.size) {
|
|
125
|
+
errors.set('form', [
|
|
126
|
+
new Error(
|
|
127
|
+
formatMessage({
|
|
128
|
+
id: 'productFullDetail.errorUnknown',
|
|
129
|
+
defaultMessage:
|
|
130
|
+
'Could not add item to cart. Please check required options and try again.'
|
|
131
|
+
})
|
|
132
|
+
)
|
|
133
|
+
]);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const customAttributesDetails = useMemo(() => {
|
|
138
|
+
const list = [];
|
|
139
|
+
const pagebuilder = [];
|
|
140
|
+
const skuAttribute = {
|
|
141
|
+
attribute_metadata: {
|
|
142
|
+
uid: 'attribute_sku',
|
|
143
|
+
used_in_components: ['PRODUCT_DETAILS_PAGE'],
|
|
144
|
+
ui_input: {
|
|
145
|
+
ui_input_type: 'TEXT'
|
|
146
|
+
},
|
|
147
|
+
label: formatMessage({
|
|
148
|
+
id: 'global.sku',
|
|
149
|
+
defaultMessage: 'SKU'
|
|
150
|
+
})
|
|
151
|
+
},
|
|
152
|
+
entered_attribute_value: {
|
|
153
|
+
value: productDetails.sku
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
if (Array.isArray(customAttributes)) {
|
|
157
|
+
customAttributes.forEach(customAttribute => {
|
|
158
|
+
if (
|
|
159
|
+
customAttribute.attribute_metadata.ui_input
|
|
160
|
+
.ui_input_type === 'PAGEBUILDER'
|
|
161
|
+
) {
|
|
162
|
+
pagebuilder.push(customAttribute);
|
|
163
|
+
} else {
|
|
164
|
+
list.push(customAttribute);
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
list.unshift(skuAttribute);
|
|
169
|
+
return {
|
|
170
|
+
list: list,
|
|
171
|
+
pagebuilder: pagebuilder
|
|
172
|
+
};
|
|
173
|
+
}, [customAttributes, productDetails.sku, formatMessage]);
|
|
174
|
+
|
|
175
|
+
const cartCallToActionText =
|
|
176
|
+
!isEverythingOutOfStock || !isOutOfStock ? (
|
|
177
|
+
<FormattedMessage
|
|
178
|
+
id="productFullDetail.addItemToCart"
|
|
179
|
+
defaultMessage="Add to Cart"
|
|
180
|
+
/>
|
|
181
|
+
) : (
|
|
182
|
+
<FormattedMessage
|
|
183
|
+
id="productFullDetail.itemOutOfStock"
|
|
184
|
+
defaultMessage="Out of Stock"
|
|
185
|
+
/>
|
|
186
|
+
);
|
|
187
|
+
// Error message for screen reader
|
|
188
|
+
const cartActionContent = isSupportedProductType ? (
|
|
189
|
+
<section className={classes.actButton}>
|
|
190
|
+
<Button
|
|
191
|
+
data-cy="ProductFullDetail-addToCartButton"
|
|
192
|
+
disabled={isAddToCartDisabled}
|
|
193
|
+
aria-disabled={isAddToCartDisabled}
|
|
194
|
+
aria-label={
|
|
195
|
+
isEverythingOutOfStock
|
|
196
|
+
? formatMessage({
|
|
197
|
+
id: 'productFullDetail.outOfStockProduct',
|
|
198
|
+
defaultMessage:
|
|
199
|
+
'This item is currently out of stock'
|
|
200
|
+
})
|
|
201
|
+
: ''
|
|
202
|
+
}
|
|
203
|
+
priority="high"
|
|
204
|
+
type="submit"
|
|
205
|
+
>
|
|
206
|
+
{cartCallToActionText}
|
|
207
|
+
</Button>
|
|
208
|
+
</section>
|
|
209
|
+
) : (
|
|
210
|
+
<div className={classes.unavailableContainer}>
|
|
211
|
+
<Info />
|
|
212
|
+
<p>
|
|
213
|
+
<FormattedMessage
|
|
214
|
+
id={'productFullDetail.unavailableProduct'}
|
|
215
|
+
defaultMessage={
|
|
216
|
+
'This product is currently unavailable for purchase.'
|
|
217
|
+
}
|
|
218
|
+
/>
|
|
219
|
+
</p>
|
|
220
|
+
</div>
|
|
221
|
+
);
|
|
222
|
+
|
|
223
|
+
const shortDescription = productDetails.shortDescription ? (
|
|
224
|
+
<RichContent html={productDetails.shortDescription.html} />
|
|
225
|
+
) : null;
|
|
226
|
+
|
|
227
|
+
const pageBuilderAttributes = customAttributesDetails.pagebuilder.length ? (
|
|
228
|
+
<section className={classes.detailsPageBuilder}>
|
|
229
|
+
<CustomAttributes
|
|
230
|
+
classes={{ list: classes.detailsPageBuilderList }}
|
|
231
|
+
customAttributes={customAttributesDetails.pagebuilder}
|
|
232
|
+
showLabels={false}
|
|
233
|
+
/>
|
|
234
|
+
</section>
|
|
235
|
+
) : null;
|
|
236
|
+
|
|
237
|
+
const review_count = 0;
|
|
238
|
+
const rating_value = 0;
|
|
239
|
+
|
|
240
|
+
return (
|
|
241
|
+
<Fragment>
|
|
242
|
+
{breadcrumbs}
|
|
243
|
+
<Form
|
|
244
|
+
className={classes.root}
|
|
245
|
+
data-cy="ProductFullDetail-root"
|
|
246
|
+
onSubmit={handleAddToCart}
|
|
247
|
+
>
|
|
248
|
+
<section className={classes.leftContainer}>
|
|
249
|
+
<Carousel images={mediaGalleryEntries} />
|
|
250
|
+
</section>
|
|
251
|
+
<section className={classes.rightContainer}>
|
|
252
|
+
<div
|
|
253
|
+
className={cn(
|
|
254
|
+
classes.title
|
|
255
|
+
)}
|
|
256
|
+
>
|
|
257
|
+
<h1
|
|
258
|
+
aria-live="polite"
|
|
259
|
+
className={cn(
|
|
260
|
+
classes.productName,
|
|
261
|
+
'!font-semibold leading-[normal] mb-4 line-clamp-2'
|
|
262
|
+
)}
|
|
263
|
+
data-cy="ProductFullDetail-productName"
|
|
264
|
+
>
|
|
265
|
+
{productDetails.name}
|
|
266
|
+
</h1>
|
|
267
|
+
<div className='product_review-container flex items-center gap-x-2'>
|
|
268
|
+
<div className='product_rating leading-[14px]'>
|
|
269
|
+
<span className='text-gray-200 text-sm'>
|
|
270
|
+
{rating_value}
|
|
271
|
+
</span>
|
|
272
|
+
</div>
|
|
273
|
+
<div className='before_block before_w-[1px] before_bg-gray-200 before_h-full before_relative w-[1px] h-[14px]'></div>
|
|
274
|
+
<span className='review_count text-gray-200 text-sm leading-[14px]'>
|
|
275
|
+
{review_count} Reviews
|
|
276
|
+
</span>
|
|
277
|
+
</div>
|
|
278
|
+
</div>
|
|
279
|
+
<div
|
|
280
|
+
className={cn(
|
|
281
|
+
'product_short_description'
|
|
282
|
+
)}
|
|
283
|
+
>
|
|
284
|
+
{shortDescription}
|
|
285
|
+
</div>
|
|
286
|
+
<div
|
|
287
|
+
className={cn(
|
|
288
|
+
'product_price_container'
|
|
289
|
+
)}
|
|
290
|
+
>
|
|
291
|
+
<p
|
|
292
|
+
data-cy="ProductFullDetail-productPrice"
|
|
293
|
+
className={classes.productPrice}
|
|
294
|
+
>
|
|
295
|
+
<Price
|
|
296
|
+
currencyCode={productDetails.price.currency}
|
|
297
|
+
value={productDetails.price.value}
|
|
298
|
+
/>
|
|
299
|
+
</p>
|
|
300
|
+
</div>
|
|
301
|
+
<FormError
|
|
302
|
+
classes={{
|
|
303
|
+
root: classes.formErrors
|
|
304
|
+
}}
|
|
305
|
+
errors={errors.get('form') || []}
|
|
306
|
+
/>
|
|
307
|
+
<section className={classes.options}>{options}</section>
|
|
308
|
+
<section className={classes.quantity}>
|
|
309
|
+
<span
|
|
310
|
+
data-cy="ProductFullDetail-quantityTitle"
|
|
311
|
+
className={classes.quantityTitle}
|
|
312
|
+
>
|
|
313
|
+
<FormattedMessage
|
|
314
|
+
id={'global.quantity'}
|
|
315
|
+
defaultMessage={'Quantity'}
|
|
316
|
+
/>
|
|
317
|
+
</span>
|
|
318
|
+
<QuantityStepper
|
|
319
|
+
classes={{ root: classes.quantityRoot }}
|
|
320
|
+
min={1}
|
|
321
|
+
message={errors.get('quantity')}
|
|
322
|
+
/>
|
|
323
|
+
</section>
|
|
324
|
+
<section className={classes.actions}>
|
|
325
|
+
{cartActionContent}
|
|
326
|
+
<Suspense fallback={null}>
|
|
327
|
+
<WishlistButton {...wishlistButtonProps} />
|
|
328
|
+
</Suspense>
|
|
329
|
+
</section>
|
|
330
|
+
</section>
|
|
331
|
+
<section className={classes.description}>
|
|
332
|
+
<span
|
|
333
|
+
data-cy="ProductFullDetail-descriptionTitle"
|
|
334
|
+
className={classes.descriptionTitle}
|
|
335
|
+
>
|
|
336
|
+
<FormattedMessage
|
|
337
|
+
id={'productFullDetail.description'}
|
|
338
|
+
defaultMessage={'Description'}
|
|
339
|
+
/>
|
|
340
|
+
</span>
|
|
341
|
+
<RichContent html={productDetails.description} />
|
|
342
|
+
</section>
|
|
343
|
+
<section className={classes.details}>
|
|
344
|
+
<span
|
|
345
|
+
data-cy="ProductFullDetail-detailsTitle"
|
|
346
|
+
className={classes.detailsTitle}
|
|
347
|
+
>
|
|
348
|
+
<FormattedMessage
|
|
349
|
+
id={'productFullDetail.details'}
|
|
350
|
+
defaultMessage={'Details'}
|
|
351
|
+
/>
|
|
352
|
+
</span>
|
|
353
|
+
<CustomAttributes
|
|
354
|
+
customAttributes={customAttributesDetails.list}
|
|
355
|
+
/>
|
|
356
|
+
</section>
|
|
357
|
+
{pageBuilderAttributes}
|
|
358
|
+
</Form>
|
|
359
|
+
</Fragment>
|
|
360
|
+
);
|
|
361
|
+
};
|
|
362
|
+
|
|
363
|
+
ProductFullDetail.propTypes = {
|
|
364
|
+
classes: shape({
|
|
365
|
+
cartActions: string,
|
|
366
|
+
description: string,
|
|
367
|
+
descriptionTitle: string,
|
|
368
|
+
details: string,
|
|
369
|
+
detailsPageBuilder: string,
|
|
370
|
+
detailsPageBuilderList: string,
|
|
371
|
+
detailsTitle: string,
|
|
372
|
+
imageCarousel: string,
|
|
373
|
+
options: string,
|
|
374
|
+
productName: string,
|
|
375
|
+
productPrice: string,
|
|
376
|
+
quantity: string,
|
|
377
|
+
quantityTitle: string,
|
|
378
|
+
quantityRoot: string,
|
|
379
|
+
root: string,
|
|
380
|
+
title: string,
|
|
381
|
+
unavailableContainer: string
|
|
382
|
+
}),
|
|
383
|
+
product: shape({
|
|
384
|
+
__typename: string,
|
|
385
|
+
id: number,
|
|
386
|
+
stock_status: string,
|
|
387
|
+
sku: string.isRequired,
|
|
388
|
+
price: shape({
|
|
389
|
+
regularPrice: shape({
|
|
390
|
+
amount: shape({
|
|
391
|
+
currency: string.isRequired,
|
|
392
|
+
value: number.isRequired
|
|
393
|
+
})
|
|
394
|
+
}).isRequired
|
|
395
|
+
}).isRequired,
|
|
396
|
+
media_gallery_entries: arrayOf(
|
|
397
|
+
shape({
|
|
398
|
+
uid: string,
|
|
399
|
+
label: string,
|
|
400
|
+
position: number,
|
|
401
|
+
disabled: bool,
|
|
402
|
+
file: string.isRequired
|
|
403
|
+
})
|
|
404
|
+
),
|
|
405
|
+
description: string,
|
|
406
|
+
short_description: shape({
|
|
407
|
+
html: string,
|
|
408
|
+
__typename: string
|
|
409
|
+
})
|
|
410
|
+
}).isRequired
|
|
411
|
+
};
|
|
412
|
+
|
|
413
|
+
export default ProductFullDetail;
|