fix bug when don't exsist variant
This commit is contained in:
@@ -75,17 +75,26 @@ const BaseInformation: FC<BaseInformationProps> = ({ product, stats }) => {
|
||||
</div>
|
||||
|
||||
{/* نمایش variant ها */}
|
||||
{product.variants.length > 0 && (
|
||||
<div className='mt-4 sm:mt-6'>
|
||||
{/* بررسی وجود فیلدهای خاص در variant ها */}
|
||||
{(() => {
|
||||
if (product.variants.length === 0) return null
|
||||
|
||||
const hasMeterage = product.variants.some(v => v.meterage)
|
||||
const hasColor = product.variants.some(v => v.color)
|
||||
const hasSize = product.variants.some(v => v.size)
|
||||
const hasThemeValue = product.variants.some(v => v.themeValue)
|
||||
const hasAnySpecificField = hasMeterage || hasColor || hasSize || hasThemeValue
|
||||
|
||||
// اگر فقط یک variant وجود دارد و هیچ فیلد خاصی ندارد، نمایش نده
|
||||
if (product.variants.length === 1 && !hasAnySpecificField) {
|
||||
return null
|
||||
}
|
||||
|
||||
return (
|
||||
<div className='mt-4 sm:mt-6'>
|
||||
{/* بررسی وجود فیلدهای خاص در variant ها */}
|
||||
{(() => {
|
||||
// اگر هیچ فیلد خاصی وجود نداشت، نمایش عمومی
|
||||
if (!hasMeterage && !hasColor && !hasSize && !hasThemeValue) {
|
||||
if (!hasAnySpecificField) {
|
||||
return (
|
||||
<div className='flex flex-wrap items-center gap-1.5'>
|
||||
{product.variants.map((variant, index) => {
|
||||
@@ -261,7 +270,8 @@ const BaseInformation: FC<BaseInformationProps> = ({ product, stats }) => {
|
||||
)
|
||||
})()}
|
||||
</div>
|
||||
)}
|
||||
)
|
||||
})()}
|
||||
|
||||
{
|
||||
product.specifications.length > 0 ?
|
||||
|
||||
Reference in New Issue
Block a user