diff --git a/src/app/product/components/BaseInformation.tsx b/src/app/product/components/BaseInformation.tsx index c7f960f..b0b511c 100644 --- a/src/app/product/components/BaseInformation.tsx +++ b/src/app/product/components/BaseInformation.tsx @@ -205,16 +205,23 @@ const BaseInformation: FC = ({ product, stats }) => { {/* themeValue ها - نمایش داینامیک */} {hasThemeValue && (() => { + // تابع برای تبدیل theme به string + const getThemeKey = (theme: Record | string | null): string => { + if (typeof theme === 'string') return theme + if (theme === null) return 'default' + return JSON.stringify(theme) + } + // گروه‌بندی variant‌ها بر اساس theme const themeGroups = new Map() product.variants.forEach(variant => { if (variant.themeValue) { - const theme = variant.themeValue.theme - if (!themeGroups.has(theme)) { - themeGroups.set(theme, []) + const themeKey = getThemeKey(variant.themeValue.theme) + if (!themeGroups.has(themeKey)) { + themeGroups.set(themeKey, []) } - themeGroups.get(theme)!.push(variant) + themeGroups.get(themeKey)!.push(variant) } }) @@ -282,27 +289,23 @@ const BaseInformation: FC = ({ product, stats }) => { })()} { - product.specifications.length > 0 ? + product.tags.length > 0 ?
ویژگی های کلیدی
: null } - {product.specifications.length === 0 && shortDescription && ( + {product.tags.length === 0 && shortDescription && (

{shortDescription}

)} -
- {product.specifications.slice(0, 3).map((spec, index) => ( -
-
-
-
{spec.title} :
-
-
{spec.values.join(', ')}
+
+ {product.tags.slice(0, 10).map((spec) => ( +
+ {spec}
))}
diff --git a/src/types/product.types.ts b/src/types/product.types.ts index eeb664c..629cfa2 100644 --- a/src/types/product.types.ts +++ b/src/types/product.types.ts @@ -58,7 +58,7 @@ export interface SaleFormat { export interface ThemeValue { _id: string; - theme: string; + theme: Record | string | null; name: string; value: number | string; } @@ -96,7 +96,7 @@ export interface ProductCategory { title_en: string; icon: string; imageUrl: string; - theme: string; + theme: string | null; description: string; leaf: boolean; parent: string | null;