increable offers + fix bugs

This commit is contained in:
hamid zarghami
2025-10-16 11:23:38 +03:30
parent 0a3b819a7e
commit 225329f342
13 changed files with 291 additions and 163 deletions
+7 -37
View File
@@ -30,10 +30,10 @@ const ProductCard: FC<Props> = ({ item }) => {
if (!item?._id || !item?.variants[0]?._id) return
if (isWished) {
removeWishlist({ productId: item._id.toString(), variantId: item.variants[0]._id })
removeWishlist({ productId: String(item._id), variantId: item.variants[0]._id })
setIsWished(false)
} else {
addWishlist({ productId: item._id.toString(), variantId: item.variants[0]._id })
addWishlist({ productId: String(item._id), variantId: item.variants[0]._id })
setIsWished(true)
}
}
@@ -53,54 +53,24 @@ const ProductCard: FC<Props> = ({ item }) => {
<h4 className='line-clamp-2 text-[#383E43] mt-4 sm:mt-6 text-xs sm:text-sm text-center leading-4 sm:leading-5 h-10 sm:h-12'>
{item.title_fa}
</h4>
{/* <div className='flex flex-wrap justify-end items-center gap-1.5 mt-4'>
{
item.variants.map((variant) => {
if (variant.meterage) {
return <div className='text-[10px] px-4 border border-border rounded-lg whitespace-nowrap' key={variant._id}>{variant?.meterage?.value}</div>
}
})
}
</div>
<div className='flex flex-wrap justify-end items-center gap-1.5 mt-4'>
{
item.variants.map((variant) => {
if (variant.color) {
return <div className='text-[10px] px-4 border border-border rounded-lg whitespace-nowrap' key={variant._id}>
<div className='size-2 rounded-full' style={{ backgroundColor: variant?.color?.value }}></div>
</div>
}
})
}
{
item.variants.map((variant) => {
if (variant.size) {
return <div className='text-[10px] px-4 border border-border rounded-lg whitespace-nowrap' key={variant._id}>{variant?.size?.value}</div>
}
})
}
</div> */}
<div className='flex items-center justify-between mt-4 sm:mt-5'>
<div className='flex flex-col gap-1'>
<div className='text-xs sm:text-sm font-bold'>
{item.default_variant.price.selling_price && item.default_variant.price.selling_price > 0
{item?.default_variant?.price?.selling_price && item.default_variant.price.selling_price > 0
? `${NumberFormat(item.default_variant.price.selling_price)} تومان`
: 'بدون قیمت'
}
</div>
{((item.default_variant.price.discount_percent > 0 && item.default_variant.price.selling_price > 0) ||
(item.default_variant.price.is_specialSale && item.default_variant.price.selling_price > 0)) && (
{((item?.default_variant?.price?.discount_percent > 0 && item.default_variant.price.selling_price > 0) ||
(item?.default_variant?.price?.is_specialSale && item.default_variant.price.selling_price > 0)) && (
<div className='text-xs sm:text-sm text-[#7F7F7F] line-through'>
{NumberFormat(item.default_variant.price.retailPrice)}
</div>
)}
</div>
{((item.default_variant.price.discount_percent > 0 && item.default_variant.price.selling_price > 0) ||
(item.default_variant.price.is_specialSale && item.default_variant.price.selling_price > 0)) && (
{((item?.default_variant?.price?.discount_percent > 0 && item.default_variant.price.selling_price > 0) ||
(item?.default_variant?.price?.is_specialSale && item.default_variant.price.selling_price > 0)) && (
<div className='bg-red-500 text-white text-xs px-2 py-1 rounded-full'>
{item.default_variant.price.discount_percent > 0
? `${item.default_variant.price.discount_percent}%`