Преглед изворни кода

feat module 6, 7 : pull Product Details data from shopify, include Product Details identifiers in product service

master
nadia пре 10 часа
родитељ
комит
b5cc811b79
2 измењених фајлова са 9 додато и 24 уклоњено
  1. 7
    23
      src/components/ProductDetails/ProductDetails.jsx
  2. 2
    1
      src/services/ProductService.js

+ 7
- 23
src/components/ProductDetails/ProductDetails.jsx Прегледај датотеку

@@ -386,22 +386,11 @@ const ProductDetails = () => {
386 386
     transition: "padding-bottom 0.25s ease-in-out"
387 387
   })
388 388
 
389
-  // Old empty expanded panel kept for reference.
390
-  // const emptyInfoPanel = (row) => (
391
-  //   expandedInfoRows[row] && (
392
-  //     <Box
393
-  //       sx={{
394
-  //         minHeight: 28,
395
-  //         borderBottom: "1px solid #DDD"
396
-  //       }}
397
-  //     />
398
-  //   )
399
-  // )
400
-
401 389
   const materialMetafield = product?.metafields?.material
402 390
   const careInstructionMetafield = product?.metafields?.care_instruction
403 391
   const shippingInformationMetafield = product?.metafields?.shipping_information
404 392
   const returnExchangeMetafield = product?.metafields?.return_exchange
393
+  const productDetailsMetafield = product?.metafields?.product_details
405 394
 
406 395
   // Renders Shopify product metafield custom.material inside the Material row.
407 396
   const materialPanel = (
@@ -467,8 +456,6 @@ const ProductDetails = () => {
467 456
     >
468 457
       <Box
469 458
         sx={{
470
-          // Old extra panel spacing kept for reference:
471
-          // pb: 3,
472 459
           color: "text.secondary",
473 460
           minHeight: shippingInformationMetafield?.value ? 0 : 28,
474 461
           fontSize: {
@@ -495,8 +482,6 @@ const ProductDetails = () => {
495 482
     >
496 483
       <Box
497 484
         sx={{
498
-          // Old extra panel spacing kept for reference:
499
-          // pb: 3,
500 485
           color: "text.secondary",
501 486
           minHeight: returnExchangeMetafield?.value ? 0 : 28,
502 487
           fontSize: {
@@ -511,19 +496,20 @@ const ProductDetails = () => {
511 496
     </Box>
512 497
   )
513 498
 
499
+  // Renders Shopify product metafield custom.product_details inside the Product Details row.
514 500
   const productDetailsPanel = (
515 501
     <Box
516 502
       sx={{
517 503
         maxHeight: expandedInfoRows.productDetails ? 1200 : 0,
518 504
         overflow: "hidden",
519
-        borderBottom: expandedInfoRows.productDetails ? "1px solid #DDD" : "none",
505
+        borderBottom: "1px solid #DDD",
520 506
         transition: "max-height 0.25s ease-in-out"
521 507
       }}
522 508
     >
523 509
       <Box
524 510
         sx={{
525
-          pb: 3,
526 511
           color: "text.secondary",
512
+          minHeight: productDetailsMetafield?.value ? 0 : 28,
527 513
           fontSize: {
528 514
             xs: "0.875rem",
529 515
             md: "1rem"
@@ -554,7 +540,7 @@ const ProductDetails = () => {
554 540
           }
555 541
         }}
556 542
       >
557
-        <div dangerouslySetInnerHTML={{ __html: product?.descriptionHtml }}></div>
543
+        {renderShopifyRichText(productDetailsMetafield?.value)}
558 544
       </Box>
559 545
     </Box>
560 546
   )
@@ -905,7 +891,8 @@ const ProductDetails = () => {
905 891
             onClick={() => toggleInfoRow("productDetails")}
906 892
             sx={{
907 893
               ...infoRowSx(expandedInfoRows.productDetails),
908
-              borderBottom: expandedInfoRows.productDetails ? "none" : "1px solid #DDD"
894
+              pb: 2,
895
+              borderBottom: "none"
909 896
             }}
910 897
           >
911 898
             <Typography variant="body2" sx={{ textTransform: "uppercase", fontWeight: "400", fontSize: { xs: "0.875rem", md: "1.1rem" } }}>
@@ -968,8 +955,6 @@ const ProductDetails = () => {
968 955
             onClick={() => toggleInfoRow("returnExchanges")}
969 956
             sx={{
970 957
               ...infoRowSx(expandedInfoRows.returnExchanges),
971
-              // Old expanded spacing kept for reference:
972
-              // pb: expandedInfoRows.returnExchanges ? 5 : 2,
973 958
               pb: 2,
974 959
               borderBottom: "none"
975 960
             }}
@@ -979,7 +964,6 @@ const ProductDetails = () => {
979 964
             </Typography>
980 965
             {expandedInfoRows.returnExchanges ? <RemoveIcon sx={{ fontSize: 18 }} /> : <AddIcon sx={{ fontSize: 18 }} />}
981 966
           </Box>
982
-          {/* Old empty panel kept for reference: {emptyInfoPanel("returnExchanges")} */}
983 967
           {returnExchangesPanel}
984 968
         </Box>
985 969
       </Box>

+ 2
- 1
src/services/ProductService.js Прегледај датотеку

@@ -170,7 +170,8 @@ const getProduct = async (handle = "") => {
170 170
           {key: "material", namespace: "custom"},
171 171
           {key: "care_instruction", namespace: "custom"},
172 172
           {key: "shipping_information", namespace: "custom"},
173
-          {key: "return_exchange", namespace: "custom"}
173
+          {key: "return_exchange", namespace: "custom"},
174
+          {key: "product_details", namespace: "custom"}
174 175
         ]
175 176
       ) {
176 177
         namespace

Loading…
Откажи
Сачувај