From 08794aa4f937337c25b641e53a79366762e73286 Mon Sep 17 00:00:00 2001 From: marzban-dev Date: Fri, 26 Dec 2025 12:03:30 +0330 Subject: [PATCH] Fix product discount bug --- frontend/components/global/ProductsGrid.vue | 5 +++-- .../global/product-detail/ProductsSlider.vue | 6 +++++- .../components/global/product/ProductCard.vue | 9 +++++++-- frontend/types/global.d.ts | 15 ++++++++++++++- 4 files changed, 29 insertions(+), 6 deletions(-) diff --git a/frontend/components/global/ProductsGrid.vue b/frontend/components/global/ProductsGrid.vue index 774de37..c14342e 100644 --- a/frontend/components/global/ProductsGrid.vue +++ b/frontend/components/global/ProductsGrid.vue @@ -47,10 +47,11 @@ withDefaults(defineProps(), { :title="product.name" :picture="product.image ?? product.variants[0].images[0].image" :colors="product.colors" - :price="product.variants[0].price_after_discount ?? product.variants[0].price" + :price="product.best_deal_price_before_discount" :rate="product.rating" :dark-layer="true" - :tag="`${product.variants[0].discount}% تخفیف`" + :tag="product.best_deal_discount > 0 ? `${product.best_deal_discount}% تخفیف` : undefined" + :price-after="product.best_deal_discount > 0 ? product.best_deal_price_after_discount : undefined" /> diff --git a/frontend/components/global/product-detail/ProductsSlider.vue b/frontend/components/global/product-detail/ProductsSlider.vue index f08954a..2c13e33 100644 --- a/frontend/components/global/product-detail/ProductsSlider.vue +++ b/frontend/components/global/product-detail/ProductsSlider.vue @@ -93,9 +93,13 @@ const onSwiper = (swiper: SwiperClass) => { :title="product.name" :picture="product.image ?? product.variants[0].images[0].image" :colors="product.colors" - :price="product.variants[0].price" :rate="product.rating" :dark-layer="true" + :price="product.best_deal_price_before_discount" + :tag="product.best_deal_discount > 0 ? `${product.best_deal_discount}% تخفیف` : undefined" + :price-after=" + product.best_deal_discount > 0 ? product.best_deal_price_after_discount : undefined + " /> diff --git a/frontend/components/global/product/ProductCard.vue b/frontend/components/global/product/ProductCard.vue index 742e8a9..b77c6ca 100644 --- a/frontend/components/global/product/ProductCard.vue +++ b/frontend/components/global/product/ProductCard.vue @@ -22,6 +22,7 @@ type Props = { colors: string[]; price: string; picture: string; + priceAfter?: string; tag?: string; rate?: number; darkLayer?: boolean; @@ -110,10 +111,14 @@ const parallaxStyle = computed(() => { {{ title }} -
- +
+ {{ price }} + {{ priceAfter }}
diff --git a/frontend/types/global.d.ts b/frontend/types/global.d.ts index 241b0a8..1875336 100644 --- a/frontend/types/global.d.ts +++ b/frontend/types/global.d.ts @@ -107,11 +107,24 @@ declare global { colors: string[]; added_to_favorites: boolean; image: string | null; + best_deal_price_before_discount: string; + best_deal_price_after_discount: string; + best_deal_discount: number; }; type ProductListItem = Pick< Product, - "id" | "variants" | "name" | "rating" | "slug" | "category" | "colors" | "image" + | "id" + | "variants" + | "name" + | "rating" + | "slug" + | "category" + | "colors" + | "image" + | "best_deal_discount" + | "best_deal_price_after_discount" + | "best_deal_price_before_discount" >; type Article = {