@riosst100/pwa-marketplace 3.0.8 → 3.0.9

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@riosst100/pwa-marketplace",
3
3
  "author": "riosst100@gmail.com",
4
- "version": "3.0.8",
4
+ "version": "3.0.9",
5
5
  "main": "src/index.js",
6
6
  "pwa-studio": {
7
7
  "targets": {
@@ -302,12 +302,36 @@ const getCustomAttributes = (product, optionCodes, optionSelections) => {
302
302
  });
303
303
 
304
304
  return item && item.product
305
- ? [...item.product.custom_attributes].sort(attributeLabelCompare)
305
+ ? [...item.product.custom_attributes]
306
306
  : [];
307
307
  }
308
308
 
309
309
  return custom_attributes
310
- ? [...custom_attributes].sort(attributeLabelCompare)
310
+ ? [...custom_attributes]
311
+ : [];
312
+ };
313
+
314
+ const getProductDetailsAttributes = (product, optionCodes, optionSelections) => {
315
+ const { product_details, variants } = product;
316
+ const isConfigurable = isProductConfigurable(product);
317
+ const optionsSelected =
318
+ Array.from(optionSelections.values()).filter(value => !!value).length >
319
+ 0;
320
+
321
+ if (isConfigurable && optionsSelected) {
322
+ const item = findMatchingVariant({
323
+ optionCodes,
324
+ optionSelections,
325
+ variants
326
+ });
327
+
328
+ return item && item.product
329
+ ? [...item.product.product_details]
330
+ : [];
331
+ }
332
+
333
+ return product_details
334
+ ? [...product_details]
311
335
  : [];
312
336
  };
313
337
 
@@ -529,6 +553,11 @@ export const useProductFullDetail = props => {
529
553
  [product, optionCodes, optionSelections]
530
554
  );
531
555
 
556
+ const productDetailsAttributes = useMemo(
557
+ () => getProductDetailsAttributes(product, optionCodes, optionSelections),
558
+ [product, optionCodes, optionSelections]
559
+ );
560
+
532
561
  const productPrice = useMemo(
533
562
  () => getConfigPrice(product, optionCodes, optionSelections),
534
563
  [product, optionCodes, optionSelections]
@@ -817,6 +846,7 @@ export const useProductFullDetail = props => {
817
846
  !!storeConfigData.storeConfig.magento_wishlist_general_is_enabled,
818
847
  productDetails,
819
848
  customAttributes,
849
+ productDetailsAttributes,
820
850
  wishlistButtonProps,
821
851
  wishlistItemOptions,
822
852
  sellerDetails,
@@ -141,9 +141,9 @@ export const useCategoryContent = props => {
141
141
  // Construct the filter arg object.
142
142
  const newFilters = {};
143
143
  filters.forEach((values, key) => {
144
- if (masterAttributes.includes(key)) {
144
+ // if (masterAttributes.includes(key)) {
145
145
  newFilters[key] = getFilterInput(values, filterTypeMap.get(key));
146
- }
146
+ // }
147
147
  });
148
148
 
149
149
  // console.log('newFilters',newFilters)
@@ -131,6 +131,37 @@ export const ProductDetailsFragment = gql`
131
131
  }
132
132
  }
133
133
  }
134
+ product_details {
135
+ selected_attribute_options {
136
+ attribute_option {
137
+ uid
138
+ label
139
+ is_default
140
+ }
141
+ }
142
+ entered_attribute_value {
143
+ value
144
+ }
145
+ attribute_metadata {
146
+ uid
147
+ code
148
+ label
149
+ attribute_labels {
150
+ store_code
151
+ label
152
+ }
153
+ data_type
154
+ is_system
155
+ entity_type
156
+ ui_input {
157
+ ui_input_type
158
+ is_html_allowed
159
+ }
160
+ ... on ProductAttributeMetadata {
161
+ used_in_components
162
+ }
163
+ }
164
+ }
134
165
  ... on ConfigurableProduct {
135
166
  # eslint-disable-next-line @graphql-eslint/require-id-when-available
136
167
  configurable_options {
@@ -22,7 +22,6 @@ const CustomAttributes = props => {
22
22
  const list = useMemo(
23
23
  () =>
24
24
  customAttributes.reduce((previousAttribute, currentAttribute) => {
25
- console.log('currentAttribute',currentAttribute)
26
25
  const attrCode = currentAttribute.attribute_metadata?.code;
27
26
  const usedInComponents =
28
27
  currentAttribute.attribute_metadata?.used_in_components ||
@@ -0,0 +1 @@
1
+ export { default } from './productCardDetails';
@@ -0,0 +1,63 @@
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
+ import defaultClasses from './productCardDetails.module.css';
6
+ import cn from 'classnames';
7
+
8
+ export const IS_VISIBLE_ON_FRONT = 'PRODUCT_DETAILS_PAGE';
9
+
10
+ const ProductCardDetails = props => {
11
+ const { customAttributes, showLabels } = props;
12
+ const classes = useStyle(defaultClasses, props.classes);
13
+
14
+ const getAttributeValue = (currentAttribute, key, useSuffix = false) => {
15
+ if (!currentAttribute) return "";
16
+
17
+ if (currentAttribute.selected_attribute_options?.attribute_option?.length) {
18
+ return currentAttribute.selected_attribute_options.attribute_option
19
+ .map(opt => opt.label)
20
+ .join(", ");
21
+ }
22
+ return currentAttribute.entered_attribute_value?.value || "";
23
+ };
24
+
25
+ const list = useMemo(
26
+ () =>
27
+ customAttributes.reduce((previousAttribute, currentAttribute) => {
28
+ const attrCode = currentAttribute.attribute_metadata?.code;
29
+ const usedInComponents =
30
+ currentAttribute.attribute_metadata?.used_in_components ||
31
+ [];
32
+ // Visible on front attributes only
33
+ if (usedInComponents.includes(IS_VISIBLE_ON_FRONT)) {
34
+ const attributeContent = (
35
+ <p key={currentAttribute.attribute_metadata.uid}><strong>{currentAttribute.attribute_metadata.label}:</strong> {getAttributeValue(currentAttribute)}</p>
36
+ );
37
+
38
+ previousAttribute.push(attributeContent);
39
+ }
40
+
41
+ return previousAttribute;
42
+ }, []),
43
+ [classes, customAttributes, showLabels]
44
+ );
45
+
46
+ if (list.length === 0) {
47
+ return null;
48
+ }
49
+
50
+ return list;
51
+ };
52
+
53
+ ProductCardDetails.propTypes = {
54
+ classes: shape({
55
+ root: string,
56
+ title: string,
57
+ list: string,
58
+ listItem: string
59
+ }),
60
+ customAttributes: array.isRequired
61
+ };
62
+
63
+ export default ProductCardDetails;
@@ -0,0 +1,8 @@
1
+ .root {}
2
+
3
+ .list {
4
+ composes: list-none from global;
5
+ composes: mb-2 from global;
6
+ composes: mt-2 from global;
7
+ composes: pl-2 from global;
8
+ }
@@ -19,6 +19,7 @@ import RichContent from '@magento/venia-ui/lib/components/RichContent/richConten
19
19
  import QuantityStepper from '../QuantityStepper';
20
20
  import { ProductOptionsShimmer } from '@magento/venia-ui/lib/components/ProductOptions';
21
21
  import CustomAttributes from './CustomAttributes';
22
+ import ProductCardDetails from './ProductCardDetails';
22
23
  import defaultClasses from './productFullDetail.module.css';
23
24
  import cn from 'classnames';
24
25
  import Tabs from '@riosst100/pwa-marketplace/src/components/commons/Tabs';
@@ -102,6 +103,7 @@ const ProductFullDetail = props => {
102
103
  selectedMedia,
103
104
  productDetails,
104
105
  customAttributes,
106
+ productDetailsAttributes,
105
107
  wishlistButtonProps,
106
108
  sellerDetails,
107
109
  handleToastAction,
@@ -231,6 +233,28 @@ const ProductFullDetail = props => {
231
233
  };
232
234
  }, [customAttributes, productDetails.sku, formatMessage]);
233
235
 
236
+ const productCardDetailsAttributes = useMemo(() => {
237
+ const list = [];
238
+ const pagebuilder = [];
239
+ if (Array.isArray(productDetailsAttributes)) {
240
+ productDetailsAttributes.forEach(customAttribute => {
241
+ if (
242
+ customAttribute.attribute_metadata.ui_input
243
+ .ui_input_type === 'PAGEBUILDER'
244
+ ) {
245
+ pagebuilder.push(customAttribute);
246
+ } else {
247
+ list.push(customAttribute);
248
+ }
249
+ });
250
+ }
251
+ // list.unshift(skuAttribute);
252
+ return {
253
+ list: list,
254
+ pagebuilder: pagebuilder
255
+ };
256
+ }, [productDetailsAttributes, productDetails.sku, formatMessage]);
257
+
234
258
  const shortDescription = productDetails.shortDescription ? (
235
259
  <RichText
236
260
  rootClassName="px-0"
@@ -356,19 +380,19 @@ const ProductFullDetail = props => {
356
380
  return attr.entered_attribute_value?.value || "";
357
381
  };
358
382
 
359
- const preOrder = getAttributeValue(customAttributesDetails, "card_pre_orders", true);
360
- const preOrderDate = getAttributeValue(customAttributesDetails, "pre_order_date", true);
361
- const preOrderDeposite = getAttributeValue(customAttributesDetails, "pre_order_deposit", true);
362
- const preOrderNote = getAttributeValue(customAttributesDetails, "pre_order_notes", true);
363
- const preOrderPaymentType = getAttributeValue(customAttributesDetails, "pre_order_payment_type", true);
364
- const releaseDate = getAttributeValue(customAttributesDetails, "release_date", true);
365
- const setNameValue = getAttributeValue(customAttributesDetails, "card_set", true);
366
- const cardNameValue = getAttributeValue(customAttributesDetails, "card_name", true);
367
- const cardNumberValue = getAttributeValue(customAttributesDetails, "card_number", true);
368
- const rarityValue = getAttributeValue(customAttributesDetails, "card_rarity", true);
369
- const featureValue = getAttributeValue(customAttributesDetails, "card_feature", true);
370
- const conditionValue = getAttributeValue(customAttributesDetails, "card_condition", true);
371
- const foilValue = getAttributeValue(customAttributesDetails, "card_foil", true);
383
+ const preOrder = getAttributeValue(productCardDetailsAttributes, "card_pre_orders", true);
384
+ const preOrderDate = getAttributeValue(productCardDetailsAttributes, "pre_order_date", true);
385
+ const preOrderDeposite = getAttributeValue(productCardDetailsAttributes, "pre_order_deposit", true);
386
+ const preOrderNote = getAttributeValue(productCardDetailsAttributes, "pre_order_notes", true);
387
+ const preOrderPaymentType = getAttributeValue(productCardDetailsAttributes, "pre_order_payment_type", true);
388
+ const releaseDate = getAttributeValue(productCardDetailsAttributes, "release_date", true);
389
+ const setNameValue = getAttributeValue(productCardDetailsAttributes, "card_set", true);
390
+ const cardNameValue = getAttributeValue(productCardDetailsAttributes, "card_name", true);
391
+ const cardNumberValue = getAttributeValue(productCardDetailsAttributes, "card_number", true);
392
+ const rarityValue = getAttributeValue(productCardDetailsAttributes, "card_rarity", true);
393
+ const featureValue = getAttributeValue(productCardDetailsAttributes, "card_feature", true);
394
+ const conditionValue = getAttributeValue(productCardDetailsAttributes, "card_condition", true);
395
+ const foilValue = getAttributeValue(productCardDetailsAttributes, "card_foil", true);
372
396
 
373
397
  const isPreOrderProduct = typeof preOrder === 'string'
374
398
  ? preOrder.trim().toLowerCase() === 'pre orders'
@@ -729,7 +753,7 @@ const ProductFullDetail = props => {
729
753
  <section className='right_left-container w-full'>
730
754
  <ExpandableSection>
731
755
  <div className="text-sm leading-6 leading-[2.5rem]">
732
- {setNameValue && (
756
+ {/* {setNameValue && (
733
757
  <p><strong>Set Name:</strong> {setNameValue}</p>
734
758
  )}
735
759
  {cardNameValue && (
@@ -749,7 +773,12 @@ const ProductFullDetail = props => {
749
773
  )}
750
774
  {foilValue && (
751
775
  <p><strong>Foil/Non Foil:</strong> {foilValue}</p>
752
- )}
776
+ )} */}
777
+ {/* <div className={cn(contentContainerClass, classes.contentContainerTabOverride)}> */}
778
+ <ProductCardDetails
779
+ customAttributes={productCardDetailsAttributes.list}
780
+ />
781
+ {/* </div> */}
753
782
  </div>
754
783
  </ExpandableSection>
755
784
  </section>