Explorar el Código

feat module 6, 7 : pull Return & Exchanges data from shopify, include Return & Exchanges identifiers in product service

master
nadia hace 12 horas
padre
commit
5c59b4e330
Se han modificado 2 ficheros con 51 adiciones y 14 borrados
  1. 49
    13
      src/components/ProductDetails/ProductDetails.jsx
  2. 2
    1
      src/services/ProductService.js

+ 49
- 13
src/components/ProductDetails/ProductDetails.jsx Ver fichero

@@ -386,21 +386,22 @@ const ProductDetails = () => {
386 386
     transition: "padding-bottom 0.25s ease-in-out"
387 387
   })
388 388
 
389
-  const emptyInfoPanel = (row) => (
390
-    // expandedInfoRows[row] && (
391
-    //   <Box
392
-    //     sx={{
393
-    //       minHeight: 28,
394
-    //       borderBottom: "1px solid #DDD"
395
-    //     }}
396
-    //   />
397
-    // )
398
-    null
399
-  )
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 400
 
401 401
   const materialMetafield = product?.metafields?.material
402 402
   const careInstructionMetafield = product?.metafields?.care_instruction
403 403
   const shippingInformationMetafield = product?.metafields?.shipping_information
404
+  const returnExchangeMetafield = product?.metafields?.return_exchange
404 405
 
405 406
   // Renders Shopify product metafield custom.material inside the Material row.
406 407
   const materialPanel = (
@@ -482,6 +483,34 @@ const ProductDetails = () => {
482 483
     </Box>
483 484
   )
484 485
 
486
+  // Renders Shopify product metafield custom.return_exchange inside the Return & Exchanges row.
487
+  const returnExchangesPanel = (
488
+    <Box
489
+      sx={{
490
+        maxHeight: expandedInfoRows.returnExchanges ? 600 : 0,
491
+        overflow: "hidden",
492
+        borderBottom: "1px solid #DDD",
493
+        transition: "max-height 0.25s ease-in-out"
494
+      }}
495
+    >
496
+      <Box
497
+        sx={{
498
+          // Old extra panel spacing kept for reference:
499
+          // pb: 3,
500
+          color: "text.secondary",
501
+          minHeight: returnExchangeMetafield?.value ? 0 : 28,
502
+          fontSize: {
503
+            xs: "0.875rem",
504
+            md: "1rem"
505
+          },
506
+          lineHeight: 1.6
507
+        }}
508
+      >
509
+        {renderShopifyRichText(returnExchangeMetafield?.value)}
510
+      </Box>
511
+    </Box>
512
+  )
513
+
485 514
   const productDetailsPanel = (
486 515
     <Box
487 516
       sx={{
@@ -937,14 +966,21 @@ const ProductDetails = () => {
937 966
           {/* Return & Exchanges */}
938 967
           <Box
939 968
             onClick={() => toggleInfoRow("returnExchanges")}
940
-            sx={infoRowSx(expandedInfoRows.returnExchanges)}
969
+            sx={{
970
+              ...infoRowSx(expandedInfoRows.returnExchanges),
971
+              // Old expanded spacing kept for reference:
972
+              // pb: expandedInfoRows.returnExchanges ? 5 : 2,
973
+              pb: 2,
974
+              borderBottom: "none"
975
+            }}
941 976
           >
942 977
             <Typography variant="body2" sx={{ textTransform: "uppercase", fontWeight: "400", fontSize: { xs: "0.875rem", md: "1.1rem" } }}>
943 978
               Return & Exchanges
944 979
             </Typography>
945 980
             {expandedInfoRows.returnExchanges ? <RemoveIcon sx={{ fontSize: 18 }} /> : <AddIcon sx={{ fontSize: 18 }} />}
946 981
           </Box>
947
-          {emptyInfoPanel("returnExchanges")}
982
+          {/* Old empty panel kept for reference: {emptyInfoPanel("returnExchanges")} */}
983
+          {returnExchangesPanel}
948 984
         </Box>
949 985
       </Box>
950 986
 

+ 2
- 1
src/services/ProductService.js Ver fichero

@@ -169,7 +169,8 @@ const getProduct = async (handle = "") => {
169 169
           {key: "selected", namespace: "custom"},
170 170
           {key: "material", namespace: "custom"},
171 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 174
         ]
174 175
       ) {
175 176
         namespace

Loading…
Cancelar
Guardar