Przeglądaj źródła

feat module 6, 7 : pull care instruction data from shopify, include care instruction identifiers in product service

master
nadia 13 godzin temu
rodzic
commit
05ef9347f4

+ 35
- 3
src/components/ProductDetails/ProductDetails.jsx Wyświetl plik

399
   )
399
   )
400
 
400
 
401
   const materialMetafield = product?.metafields?.material
401
   const materialMetafield = product?.metafields?.material
402
+  const careInstructionMetafield = product?.metafields?.care_instruction
402
 
403
 
404
+  // Renders Shopify product metafield custom.material inside the Material row.
403
   const materialPanel = (
405
   const materialPanel = (
404
     <Box
406
     <Box
405
       sx={{
407
       sx={{
425
     </Box>
427
     </Box>
426
   )
428
   )
427
 
429
 
430
+  // Renders Shopify product metafield custom.care_instruction inside the Care Instruction row.
431
+  const careInstructionPanel = (
432
+    <Box
433
+      sx={{
434
+        maxHeight: expandedInfoRows.careInstruction ? 600 : 0,
435
+        overflow: "hidden",
436
+        borderBottom: "1px solid #DDD",
437
+        transition: "max-height 0.25s ease-in-out"
438
+      }}
439
+    >
440
+      <Box
441
+        sx={{
442
+          color: "text.secondary",
443
+          minHeight: careInstructionMetafield?.value ? 0 : 28,
444
+          fontSize: {
445
+            xs: "0.875rem",
446
+            md: "1rem"
447
+          },
448
+          lineHeight: 1.6
449
+        }}
450
+      >
451
+        {renderShopifyRichText(careInstructionMetafield?.value)}
452
+      </Box>
453
+    </Box>
454
+  )
455
+
428
   const productDetailsPanel = (
456
   const productDetailsPanel = (
429
     <Box
457
     <Box
430
       sx={{
458
       sx={{
834
             onClick={() => toggleInfoRow("material")}
862
             onClick={() => toggleInfoRow("material")}
835
             sx={{
863
             sx={{
836
               ...infoRowSx(expandedInfoRows.material),
864
               ...infoRowSx(expandedInfoRows.material),
837
-              pb: expandedInfoRows.material ? 5 : 2,
838
               pb: 2,
865
               pb: 2,
839
               borderBottom: "none"
866
               borderBottom: "none"
840
             }}
867
             }}
849
           {/* Care Instruction */}
876
           {/* Care Instruction */}
850
           <Box
877
           <Box
851
             onClick={() => toggleInfoRow("careInstruction")}
878
             onClick={() => toggleInfoRow("careInstruction")}
852
-            sx={infoRowSx(expandedInfoRows.careInstruction)}
879
+            sx={{
880
+              ...infoRowSx(expandedInfoRows.careInstruction),
881
+              pb: 2,
882
+              borderBottom: "none"
883
+            }}
853
           >
884
           >
854
             <Typography variant="body2" sx={{ textTransform: "uppercase", fontWeight: "400", fontSize: { xs: "0.875rem", md: "1.1rem" } }}>
885
             <Typography variant="body2" sx={{ textTransform: "uppercase", fontWeight: "400", fontSize: { xs: "0.875rem", md: "1.1rem" } }}>
855
               Care Instruction
886
               Care Instruction
856
             </Typography>
887
             </Typography>
857
             {expandedInfoRows.careInstruction ? <RemoveIcon sx={{ fontSize: 18 }} /> : <AddIcon sx={{ fontSize: 18 }} />}
888
             {expandedInfoRows.careInstruction ? <RemoveIcon sx={{ fontSize: 18 }} /> : <AddIcon sx={{ fontSize: 18 }} />}
858
           </Box>
889
           </Box>
859
-          {emptyInfoPanel("careInstruction")}
890
+          {careInstructionPanel}
891
+          
860
           {/* Shipping Information */}
892
           {/* Shipping Information */}
861
           <Box
893
           <Box
862
             onClick={() => toggleInfoRow("shippingInformation")}
894
             onClick={() => toggleInfoRow("shippingInformation")}

+ 2
- 1
src/services/ProductService.js Wyświetl plik

167
         identifiers: [
167
         identifiers: [
168
           {key: "published_date", namespace: "custom"},
168
           {key: "published_date", namespace: "custom"},
169
           {key: "selected", namespace: "custom"},
169
           {key: "selected", namespace: "custom"},
170
-          {key: "material", namespace: "custom"}
170
+          {key: "material", namespace: "custom"},
171
+          {key: "care_instruction", namespace: "custom"}
171
         ]
172
         ]
172
       ) {
173
       ) {
173
         namespace
174
         namespace

Ładowanie…
Anuluj
Zapisz