Browse Source

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

master
nadia 11 hours ago
parent
commit
b5cc811b79
2 changed files with 9 additions and 24 deletions
  1. 7
    23
      src/components/ProductDetails/ProductDetails.jsx
  2. 2
    1
      src/services/ProductService.js

+ 7
- 23
src/components/ProductDetails/ProductDetails.jsx View File

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

+ 2
- 1
src/services/ProductService.js View File

170
           {key: "material", namespace: "custom"},
170
           {key: "material", namespace: "custom"},
171
           {key: "care_instruction", namespace: "custom"},
171
           {key: "care_instruction", namespace: "custom"},
172
           {key: "shipping_information", namespace: "custom"},
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
         namespace
177
         namespace

Loading…
Cancel
Save