瀏覽代碼

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

master
nadia 11 小時之前
父節點
當前提交
05ef9347f4
共有 2 個文件被更改,包括 37 次插入4 次删除
  1. 35
    3
      src/components/ProductDetails/ProductDetails.jsx
  2. 2
    1
      src/services/ProductService.js

+ 35
- 3
src/components/ProductDetails/ProductDetails.jsx 查看文件

@@ -399,7 +399,9 @@ const ProductDetails = () => {
399 399
   )
400 400
 
401 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 405
   const materialPanel = (
404 406
     <Box
405 407
       sx={{
@@ -425,6 +427,32 @@ const ProductDetails = () => {
425 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 456
   const productDetailsPanel = (
429 457
     <Box
430 458
       sx={{
@@ -834,7 +862,6 @@ const ProductDetails = () => {
834 862
             onClick={() => toggleInfoRow("material")}
835 863
             sx={{
836 864
               ...infoRowSx(expandedInfoRows.material),
837
-              pb: expandedInfoRows.material ? 5 : 2,
838 865
               pb: 2,
839 866
               borderBottom: "none"
840 867
             }}
@@ -849,14 +876,19 @@ const ProductDetails = () => {
849 876
           {/* Care Instruction */}
850 877
           <Box
851 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 885
             <Typography variant="body2" sx={{ textTransform: "uppercase", fontWeight: "400", fontSize: { xs: "0.875rem", md: "1.1rem" } }}>
855 886
               Care Instruction
856 887
             </Typography>
857 888
             {expandedInfoRows.careInstruction ? <RemoveIcon sx={{ fontSize: 18 }} /> : <AddIcon sx={{ fontSize: 18 }} />}
858 889
           </Box>
859
-          {emptyInfoPanel("careInstruction")}
890
+          {careInstructionPanel}
891
+          
860 892
           {/* Shipping Information */}
861 893
           <Box
862 894
             onClick={() => toggleInfoRow("shippingInformation")}

+ 2
- 1
src/services/ProductService.js 查看文件

@@ -167,7 +167,8 @@ const getProduct = async (handle = "") => {
167 167
         identifiers: [
168 168
           {key: "published_date", namespace: "custom"},
169 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 174
         namespace

Loading…
取消
儲存