Skip to content

Commit 7a80dfa

Browse files
refactor: requested changes
1 parent 585c079 commit 7a80dfa

File tree

2 files changed

+24
-54
lines changed

2 files changed

+24
-54
lines changed

client-app/shared/catalog/components/product-sidebar.vue

Lines changed: 22 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -34,27 +34,19 @@
3434
</div>
3535

3636
<div class="mt-4 print:hidden">
37-
<template v-if="variationResult && variationResult.price?.actual?.amount > 0">
38-
<AddToCart v-if="product.isConfigurable" :product="variationResult">
39-
<InStock
40-
:is-in-stock="variationResult.availabilityData?.isInStock"
41-
:is-digital="isDigital"
42-
:quantity="variationResult.availabilityData?.availableQuantity"
43-
/>
44-
45-
<CountInCart :product-id="variationResult.id" />
46-
</AddToCart>
47-
48-
<AddToCartSimple v-else :product="variationResult">
49-
<InStock
50-
:is-in-stock="variationResult.availabilityData?.isInStock"
51-
:is-digital="isDigital"
52-
:quantity="variationResult.availabilityData?.availableQuantity"
53-
/>
54-
55-
<CountInCart :product-id="variationResult.id" />
56-
</AddToCartSimple>
57-
</template>
37+
<component
38+
v-if="variationResult && variationResult.price?.actual?.amount > 0"
39+
:is="product.isConfigurable ? AddToCart : AddToCartSimple"
40+
:product="variationResult"
41+
>
42+
<InStock
43+
:is-in-stock="variationResult.availabilityData?.isInStock"
44+
:is-digital="isDigital"
45+
:quantity="variationResult.availabilityData?.availableQuantity"
46+
/>
47+
48+
<CountInCart :product-id="variationResult.id" />
49+
</component>
5850

5951
<div v-else>
6052
<VcButton
@@ -110,27 +102,15 @@
110102
v-bind="getComponentProps(CUSTOM_PRODUCT_COMPONENT_IDS.PAGE_SIDEBAR_BUTTON)"
111103
/>
112104

113-
<template v-else>
114-
<AddToCart v-if="product.isConfigurable" :product="product">
115-
<InStock
116-
:is-in-stock="product.availabilityData?.isInStock"
117-
:is-digital="isDigital"
118-
:quantity="product.availabilityData?.availableQuantity"
119-
/>
120-
121-
<CountInCart :product-id="product.id" />
122-
</AddToCart>
123-
124-
<AddToCartSimple v-else :product="product">
125-
<InStock
126-
:is-in-stock="product.availabilityData?.isInStock"
127-
:is-digital="isDigital"
128-
:quantity="product.availabilityData?.availableQuantity"
129-
/>
130-
131-
<CountInCart :product-id="product.id" />
132-
</AddToCartSimple>
133-
</template>
105+
<component v-else :is="product.isConfigurable ? AddToCart : AddToCartSimple" :product="product">
106+
<InStock
107+
:is-in-stock="product.availabilityData?.isInStock"
108+
:is-digital="isDigital"
109+
:quantity="product.availabilityData?.availableQuantity"
110+
/>
111+
112+
<CountInCart :product-id="product.id" />
113+
</component>
134114
</div>
135115
</template>
136116
</ProductPriceBlock>

client-app/shared/catalog/components/product/variations-table.vue

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -97,17 +97,15 @@
9797

9898
<script setup lang="ts">
9999
import { flatten, sortBy, uniqBy } from "lodash";
100-
import { computed, watchEffect } from "vue";
100+
import { computed } from "vue";
101101
import { useI18n } from "vue-i18n";
102102
import { PropertyType } from "@/core/api/graphql/types";
103-
import { useErrorsTranslator } from "@/core/composables";
104103
import { MAX_DISPLAY_IN_STOCK_QUANTITY } from "@/core/constants";
105104
import { getPropertyValue, getPropertiesGroupedByName } from "@/core/utilities";
106-
import { useShortCart } from "@/shared/cart/composables";
107105
import { useCustomProductComponents } from "@/shared/common/composables";
108106
import { CUSTOM_PRODUCT_COMPONENT_IDS } from "@/shared/common/constants";
109107
import CountInCart from "../count-in-cart.vue";
110-
import type { Product, ValidationErrorType } from "@/core/api/graphql/types";
108+
import type { Product } from "@/core/api/graphql/types";
111109
import type { ISortInfo } from "@/core/types";
112110
import AddToCartSimple from "@/shared/cart/components/add-to-cart-simple.vue";
113111
@@ -135,8 +133,6 @@ const emit = defineEmits<IEmits>();
135133
const props = defineProps<IProps>();
136134
137135
const { t } = useI18n();
138-
const { cart } = useShortCart();
139-
const { setErrors } = useErrorsTranslator<ValidationErrorType>("validation_error");
140136
141137
const { isComponentRegistered, getComponent, shouldRenderComponent, getComponentProps } = useCustomProductComponents();
142138
@@ -230,12 +226,6 @@ function applySorting(sortInfo: ISortInfo): void {
230226
function changePage(page: number): void {
231227
emit("changePage", page);
232228
}
233-
234-
watchEffect(() => {
235-
if (cart.value?.validationErrors) {
236-
setErrors(cart.value?.validationErrors);
237-
}
238-
});
239229
</script>
240230

241231
<style lang="scss">

0 commit comments

Comments
 (0)