|
@@ -4,17 +4,20 @@
|
4
|
4
|
export const formatProductData = (product) => {
|
5
|
5
|
|
6
|
6
|
if(!product) return
|
7
|
|
-
|
|
7
|
+
|
|
8
|
+ let publishedDate = product?.metafields[0]?.value
|
|
9
|
+ let selected = product?.metafields[1]?.value
|
|
10
|
+
|
8
|
11
|
return {
|
9
|
12
|
id: product?.id || null,
|
10
|
13
|
handle: product?.handle || "",
|
11
|
14
|
title: product?.title || "",
|
12
|
|
- createdAt: product?.createdAt,
|
|
15
|
+ createdAt: publishedDate || product?.createdAt,
|
13
|
16
|
collections: product?.collections?.nodes || null,
|
14
|
17
|
descriptionHtml: product?.descriptionHtml || "",
|
15
|
18
|
tags:product?.tags || null,
|
16
|
19
|
images: product?.images?.nodes || null,
|
17
|
|
- selected: (product?.metafield?.key == "selected") ? product?.metafield?.value == "true" : false, // cause I want to have a true false value, somehow BE return text value "true", thus == used to convert it to proper boolean value
|
|
20
|
+ selected: (selected === "true") || false, // cause I want to have a true false value, somehow BE return text value "true", thus == used to convert it to proper boolean value
|
18
|
21
|
minVariantPrice: product?.priceRange?.minVariantPrice || {amount:0 , currencyCode:''},
|
19
|
22
|
maxVariantPrice: product?.priceRange?.maxVariantPrice || {amount:0 , currencyCode:''},
|
20
|
23
|
compareAtPriceRangeMinVariantPrice: product?.compareAtPriceRange?.minVariantPrice || {amount:0 , currencyCode:''},
|