From 11ef24e312b5944f7ffcd82136c26aca7101fac7 Mon Sep 17 00:00:00 2001 From: hamid zarghami Date: Tue, 18 Nov 2025 11:55:05 +0330 Subject: [PATCH] dont show procons if there is nothing + ... --- .../product/components/BaseInformation.tsx | 10 ++- src/app/product/components/ProsCons.tsx | 61 ++++++++++--------- 2 files changed, 39 insertions(+), 32 deletions(-) diff --git a/src/app/product/components/BaseInformation.tsx b/src/app/product/components/BaseInformation.tsx index 12d5460..72d2c90 100644 --- a/src/app/product/components/BaseInformation.tsx +++ b/src/app/product/components/BaseInformation.tsx @@ -147,9 +147,13 @@ const BaseInformation: FC = ({ product, stats }) => { -
- ویژگی های کلیدی -
+ { + product.specifications.length > 0 ? +
+ ویژگی های کلیدی +
+ : null + }
{product.specifications.slice(0, 3).map((spec, index) => ( diff --git a/src/app/product/components/ProsCons.tsx b/src/app/product/components/ProsCons.tsx index 4487c6b..5239f1d 100644 --- a/src/app/product/components/ProsCons.tsx +++ b/src/app/product/components/ProsCons.tsx @@ -8,6 +8,13 @@ interface ProsConsProps { } const ProsCons: FC = ({ product }) => { + const hasAdvantages = product.advantages && product.advantages.length > 0 + const hasDisAdvantages = product.disAdvantages && product.disAdvantages.length > 0 + + if (!hasAdvantages && !hasDisAdvantages) { + return null + } + return (
@@ -16,43 +23,39 @@ const ProsCons: FC = ({ product }) => {
-
-
- نقاط مثبت - -
-
-
- {product.advantages.length > 0 ? ( - product.advantages.map((advantage, index) => ( + {hasAdvantages && ( +
+
+ نقاط مثبت + +
+
+
+ {product.advantages.map((advantage, index) => (
{advantage}
- )) - ) : ( -
نقطه مثبتی ثبت نشده است
- )} + ))} +
-
+ )} - + {hasAdvantages && hasDisAdvantages && } -
-
- نقاط منفی - -
-
-
- {product.disAdvantages.length > 0 ? ( - product.disAdvantages.map((disadvantage, index) => ( + {hasDisAdvantages && ( +
+
+ نقاط منفی + +
+
+
+ {product.disAdvantages.map((disadvantage, index) => (
{disadvantage}
- )) - ) : ( -
نقطه منفی ثبت نشده است
- )} + ))} +
-
+ )}
)