Skip to content

Commit 199b660

Browse files
committed
Worked on modification
1 parent 09808cd commit 199b660

File tree

7 files changed

+42
-33
lines changed

7 files changed

+42
-33
lines changed

packages/peregrine/lib/talons/Gallery/isSupportedProductType.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
const SUPPORTED_PRODUCT_TYPES = ['SimpleProduct', 'ConfigurableProduct', 'configurable', 'simple'];
1+
const SUPPORTED_PRODUCT_TYPES = [
2+
'SimpleProduct',
3+
'ConfigurableProduct',
4+
'configurable',
5+
'simple'
6+
];
27

38
export const isSupportedProductType = productType => {
49
return SUPPORTED_PRODUCT_TYPES.includes(productType);

packages/peregrine/lib/talons/Gallery/useAddToCartButton.js

+11-4
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,16 @@ export const useAddToCartButton = props => {
3838

3939
const isInStock = item.stock_status === 'IN_STOCK';
4040

41-
const productType = item ? item.__typename !==undefined?item.__typename:item.type : null;
41+
const productType = item
42+
? item.__typename !== undefined
43+
? item.__typename
44+
: item.type
45+
: null;
46+
4247
const isUnsupportedProductType = UNSUPPORTED_PRODUCT_TYPES.includes(
4348
productType
4449
);
50+
4551
const isDisabled = isLoading || !isInStock || isUnsupportedProductType;
4652

4753
const history = useHistory();
@@ -51,9 +57,7 @@ export const useAddToCartButton = props => {
5157
const [addToCart] = useMutation(operations.ADD_ITEM);
5258

5359
const handleAddToCart = useCallback(async () => {
54-
5560
try {
56-
console.log(productType); console.log('sdfsd');
5761
if (productType === 'SimpleProduct' || productType === 'simple') {
5862
setIsLoading(true);
5963

@@ -99,7 +103,10 @@ export const useAddToCartButton = props => {
99103
});
100104

101105
setIsLoading(false);
102-
} else if (productType === 'ConfigurableProduct' || productType === 'configurable') {
106+
} else if (
107+
productType === 'ConfigurableProduct' ||
108+
productType === 'configurable'
109+
) {
103110
const productLink = resourceUrl(
104111
`/${item.url_key}${urlSuffix || ''}`
105112
);

packages/peregrine/lib/talons/Gallery/useGalleryItem.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,12 @@ export const useGalleryItem = (props = {}) => {
8080
intersectionObserver,
8181
item
8282
]);
83-
//
84-
// const productType = item ? item.__typename : null;
85-
const productType = item ? item.__typename !==undefined?item.__typename:item.type : null;
83+
84+
const productType = item
85+
? item.__typename !== undefined
86+
? item.__typename
87+
: item.type
88+
: null;
8689
const isSupportedProductType = isSupported(productType);
8790

8891
const wishlistButtonProps =

packages/venia-ui/lib/RootComponents/Category/categoryContent.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ import defaultClasses from './category.module.css';
2424
import NoProductsFound from './NoProductsFound';
2525
import {
2626
VeniaProductRecommendations,
27-
PageTypes,
28-
} from "@magento/venia-product-recommendations";
27+
PageTypes
28+
} from '@magento/venia-product-recommendations';
2929

3030
const FilterModal = React.lazy(() => import('../../components/FilterModal'));
3131
const FilterSidebar = React.lazy(() =>

packages/venia-ui/lib/components/CartPage/cartPage.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ import ProductListing from './ProductListing';
1515
import defaultClasses from './cartPage.module.css';
1616
import {
1717
VeniaProductRecommendations,
18-
PageTypes,
19-
} from "@magento/venia-product-recommendations";
18+
PageTypes
19+
} from '@magento/venia-product-recommendations';
2020
const CheckIcon = <Icon size={20} src={Check} />;
2121

2222
/**
@@ -123,7 +123,6 @@ const CartPage = props => {
123123
</div>
124124
<VeniaProductRecommendations pageType={PageTypes.CMS} />;
125125
</div>
126-
127126
);
128127
};
129128

packages/venia-ui/lib/components/Gallery/item.js

+13-15
Original file line numberDiff line numberDiff line change
@@ -70,19 +70,20 @@ const GalleryItem = props => {
7070
</p>
7171
</div>
7272
);
73-
const currencyCode= price_range?.maximum_price?.final_price?.currency ||
74-
item.price.regularPrice.amount.currency;
73+
const currencyCode =
74+
price_range?.maximum_price?.final_price?.currency ||
75+
item.price.regularPrice.amount.currency;
7576

7677
// fallback to regular price when final price is unavailable
7778
const priceSource =
78-
(price_range?.maximum_price?.final_price !== undefined &&
79-
price_range?.maximum_price?.final_price !== null
80-
? price_range.maximum_price.final_price
81-
: item.prices.maximum.final) ||
82-
(price_range?.maximum_price?.regular_price !== undefined &&
83-
price_range?.maximum_price?.regular_price !== null
84-
? price_range.maximum_price.regular_price
85-
: item.prices.maximum.regular);
79+
(price_range?.maximum_price?.final_price !== undefined &&
80+
price_range?.maximum_price?.final_price !== null
81+
? price_range.maximum_price.final_price
82+
: item.prices.maximum.final) ||
83+
(price_range?.maximum_price?.regular_price !== undefined &&
84+
price_range?.maximum_price?.regular_price !== null
85+
? price_range.maximum_price.regular_price
86+
: item.prices.maximum.regular);
8687
const priceSourceValue = priceSource.value || priceSource;
8788

8889
// Hide the Rating component until it is updated with the new look and feel (PWA-2512).
@@ -121,12 +122,9 @@ const GalleryItem = props => {
121122
>
122123
<span>{name}</span>
123124
</Link>
124-
125+
125126
<div data-cy="GalleryItem-price" className={classes.price}>
126-
<Price
127-
value={priceSourceValue}
128-
currencyCode={currencyCode}
129-
/>
127+
<Price value={priceSourceValue} currencyCode={currencyCode} />
130128
</div>
131129

132130
<div className={classes.actionsContainer}>

packages/venia-ui/lib/components/ProductFullDetail/productFullDetail.js

+2-5
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ import { Form } from 'informed';
55
import { Info } from 'react-feather';
66
import {
77
VeniaProductRecommendations,
8-
PageTypes,
9-
} from "@magento/venia-product-recommendations";
10-
8+
PageTypes
9+
} from '@magento/venia-product-recommendations';
1110

1211
import Price from '@magento/venia-ui/lib/components/Price';
1312
import { useProductFullDetail } from '@magento/peregrine/lib/talons/ProductFullDetail/useProductFullDetail';
@@ -246,7 +245,6 @@ const ProductFullDetail = props => {
246245
data-cy="ProductFullDetail-root"
247246
onSubmit={handleAddToCart}
248247
>
249-
250248
<section className={classes.imageCarousel}>
251249
<Carousel images={mediaGalleryEntries} />
252250
</section>
@@ -325,7 +323,6 @@ const ProductFullDetail = props => {
325323
/>
326324
</section>
327325
{pageBuilderAttributes}
328-
329326
</Form>
330327
<VeniaProductRecommendations pageType={PageTypes.CMS} />;
331328
</Fragment>

0 commit comments

Comments
 (0)