add tag spefiction

This commit is contained in:
hamid zarghami
2025-12-30 12:33:20 +03:30
parent 5be1c24bc2
commit 1081cd5f71
2 changed files with 19 additions and 16 deletions
+17 -14
View File
@@ -205,16 +205,23 @@ const BaseInformation: FC<BaseInformationProps> = ({ product, stats }) => {
{/* themeValue ها - نمایش داینامیک */} {/* themeValue ها - نمایش داینامیک */}
{hasThemeValue && (() => { {hasThemeValue && (() => {
// تابع برای تبدیل theme به string
const getThemeKey = (theme: Record<string, unknown> | string | null): string => {
if (typeof theme === 'string') return theme
if (theme === null) return 'default'
return JSON.stringify(theme)
}
// گروه‌بندی variant‌ها بر اساس theme // گروه‌بندی variant‌ها بر اساس theme
const themeGroups = new Map<string, typeof product.variants>() const themeGroups = new Map<string, typeof product.variants>()
product.variants.forEach(variant => { product.variants.forEach(variant => {
if (variant.themeValue) { if (variant.themeValue) {
const theme = variant.themeValue.theme const themeKey = getThemeKey(variant.themeValue.theme)
if (!themeGroups.has(theme)) { if (!themeGroups.has(themeKey)) {
themeGroups.set(theme, []) themeGroups.set(themeKey, [])
} }
themeGroups.get(theme)!.push(variant) themeGroups.get(themeKey)!.push(variant)
} }
}) })
@@ -282,27 +289,23 @@ const BaseInformation: FC<BaseInformationProps> = ({ product, stats }) => {
})()} })()}
{ {
product.specifications.length > 0 ? product.tags.length > 0 ?
<div className='mt-6 sm:mt-7 text-base sm:text-lg text-[#333333]'> <div className='mt-6 sm:mt-7 text-base sm:text-lg text-[#333333]'>
ویژگی های کلیدی ویژگی های کلیدی
</div> </div>
: null : null
} }
{product.specifications.length === 0 && shortDescription && ( {product.tags.length === 0 && shortDescription && (
<p className='mt-4 sm:mt-6 line-clamp-3 text-xs sm:text-sm text-[#4B4B4B] leading-7'> <p className='mt-4 sm:mt-6 line-clamp-3 text-xs sm:text-sm text-[#4B4B4B] leading-7'>
{shortDescription} {shortDescription}
</p> </p>
)} )}
<div className='mt-6 sm:mt-10 flex flex-col gap-4 sm:gap-8'> <div className='mt-6 flex flex-wrap gap-4 sm:gap-4'>
{product.specifications.slice(0, 3).map((spec, index) => ( {product.tags.slice(0, 10).map((spec) => (
<div key={index} className='flex flex-col sm:flex-row sm:gap-3 items-start sm:items-center text-xs sm:text-sm'> <div key={spec} className='px-5 h-10 bg-gray-50 text-gray-500 w-fit flex text-xs whitespace-nowrap items-center justify-center rounded-full'>
<div className='flex items-center gap-2'> {spec}
<div className='size-2 rounded-full bg-[#7F7F7F]'></div>
<div className='text-[#7F7F7F]'>{spec.title} :</div>
</div>
<div className='mt-1 sm:mt-0'>{spec.values.join(', ')}</div>
</div> </div>
))} ))}
</div> </div>
+2 -2
View File
@@ -58,7 +58,7 @@ export interface SaleFormat {
export interface ThemeValue { export interface ThemeValue {
_id: string; _id: string;
theme: string; theme: Record<string, unknown> | string | null;
name: string; name: string;
value: number | string; value: number | string;
} }
@@ -96,7 +96,7 @@ export interface ProductCategory {
title_en: string; title_en: string;
icon: string; icon: string;
imageUrl: string; imageUrl: string;
theme: string; theme: string | null;
description: string; description: string;
leaf: boolean; leaf: boolean;
parent: string | null; parent: string | null;