From 117caf32e23c1fcf0cd203877e16a05d1f966ca0 Mon Sep 17 00:00:00 2001 From: marzban-dev Date: Wed, 16 Apr 2025 23:27:38 +0330 Subject: [PATCH 1/3] Fix functionality --- .../global/product-detail/RemainQuantity.vue | 9 ++++--- .../global/product-detail/UpdateQuantity.vue | 24 ++++++++++++------- frontend/components/product/ProductHero.vue | 12 ++++------ 3 files changed, 24 insertions(+), 21 deletions(-) diff --git a/frontend/components/global/product-detail/RemainQuantity.vue b/frontend/components/global/product-detail/RemainQuantity.vue index b47a72b..957e966 100644 --- a/frontend/components/global/product-detail/RemainQuantity.vue +++ b/frontend/components/global/product-detail/RemainQuantity.vue @@ -1,16 +1,15 @@ \ No newline at end of file + diff --git a/frontend/components/global/product-detail/UpdateQuantity.vue b/frontend/components/global/product-detail/UpdateQuantity.vue index 6b4102c..b399800 100644 --- a/frontend/components/global/product-detail/UpdateQuantity.vue +++ b/frontend/components/global/product-detail/UpdateQuantity.vue @@ -7,9 +7,7 @@ import type { ProductVariantProvideType } from "~/pages/product/[id].vue"; // provide / inject -const { selectedVariant } = inject( - "productVariant" -) as ProductVariantProvideType; +const { selectedVariant } = inject("productVariant") as ProductVariantProvideType; // state @@ -46,15 +44,14 @@ watch( ); watch(selectedVariant, (newValue) => { - quantity.value = newValue!.cart_quantity; + quantity.value = newValue!.cart_quantity === 0 ? 1 : newValue!.cart_quantity; }); // lifecycle onMounted(() => { - quantity.value = selectedVariant.value!.cart_quantity; + quantity.value = selectedVariant.value!.cart_quantity === 0 ? 1 : selectedVariant.value!.cart_quantity; }); - diff --git a/frontend/components/product/ProductHero.vue b/frontend/components/product/ProductHero.vue index 4322663..66b6fcf 100644 --- a/frontend/components/product/ProductHero.vue +++ b/frontend/components/product/ProductHero.vue @@ -37,13 +37,10 @@ const addItemToCart = async () => { // watch -watch( - () => selectedVariantId.value, - (newId) => { - const newVariant = product.value!.variants.find((variant) => variant.id === newId)!; - changeSelectedVariant(newVariant); - } -); +watch([selectedVariantId, product], ([selectedVariantId, product]) => { + const newVariant = product!.variants.find((variant) => variant.id === selectedVariantId)!; + changeSelectedVariant(newVariant); +}); watch( () => selectedColor.value, @@ -193,6 +190,7 @@ watch(
From 9bfbaf5d72e423d6c049cb7616d74b2344a610af Mon Sep 17 00:00:00 2001 From: marzban-dev Date: Thu, 17 Apr 2025 00:12:36 +0330 Subject: [PATCH 2/3] Updated --- frontend/components/home/Preview.vue | 2 +- .../{heymlz-pulling.gif => heymlz-pullingg.gif} | Bin 2 files changed, 1 insertion(+), 1 deletion(-) rename frontend/public/img/heymlz/{heymlz-pulling.gif => heymlz-pullingg.gif} (100%) diff --git a/frontend/components/home/Preview.vue b/frontend/components/home/Preview.vue index 66168b6..bdaa9bf 100644 --- a/frontend/components/home/Preview.vue +++ b/frontend/components/home/Preview.vue @@ -139,7 +139,7 @@ watch( - // types type Props = { @@ -7,33 +6,49 @@ type Props = { title: string; color: string; price: string; -} +}; // props const props = defineProps(); const { picture, price, title, color } = toRefs(props); +// methods + +const scrollToTop = () => { + window.scrollTo({ top: 0, behavior: "smooth" }); +}; \ No newline at end of file +