add tag spefiction
This commit is contained in:
@@ -205,16 +205,23 @@ const BaseInformation: FC<BaseInformationProps> = ({ product, stats }) => {
|
||||
|
||||
{/* themeValue ها - نمایش داینامیک */}
|
||||
{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
|
||||
const themeGroups = new Map<string, typeof product.variants>()
|
||||
|
||||
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<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>
|
||||
: 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'>
|
||||
{shortDescription}
|
||||
</p>
|
||||
)}
|
||||
|
||||
<div className='mt-6 sm:mt-10 flex flex-col gap-4 sm:gap-8'>
|
||||
{product.specifications.slice(0, 3).map((spec, index) => (
|
||||
<div key={index} className='flex flex-col sm:flex-row sm:gap-3 items-start sm:items-center text-xs sm:text-sm'>
|
||||
<div className='flex items-center gap-2'>
|
||||
<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 className='mt-6 flex flex-wrap gap-4 sm:gap-4'>
|
||||
{product.tags.slice(0, 10).map((spec) => (
|
||||
<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'>
|
||||
{spec}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
@@ -58,7 +58,7 @@ export interface SaleFormat {
|
||||
|
||||
export interface ThemeValue {
|
||||
_id: string;
|
||||
theme: string;
|
||||
theme: Record<string, unknown> | 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;
|
||||
|
||||
Reference in New Issue
Block a user