From 58bf66dd9574094fe49435bcf7d480f574d15b56 Mon Sep 17 00:00:00 2001 From: Bartosz Herba Date: Mon, 25 Apr 2022 09:54:12 +0200 Subject: [PATCH] fix: wishlist sidebar - fix issue with refreshig sidebar wishlist - fix issue with wishlist sidebar transition - fix issue with cart sidebar transition M2-539 --- packages/theme/components/AppHeader.vue | 16 +-- packages/theme/components/CartSidebar.vue | 1 + packages/theme/components/WishlistSidebar.vue | 122 ++++++++++-------- .../theme/composables/useWishlist/index.ts | 10 +- .../composables/useWishlist/useWishlist.ts | 4 +- packages/theme/getters/productGetters.ts | 2 +- 6 files changed, 82 insertions(+), 73 deletions(-) diff --git a/packages/theme/components/AppHeader.vue b/packages/theme/components/AppHeader.vue index 797332f50..d3ed18f55 100644 --- a/packages/theme/components/AppHeader.vue +++ b/packages/theme/components/AppHeader.vue @@ -136,6 +136,7 @@ import CurrencySelector from '~/components/CurrencySelector.vue'; import HeaderLogo from '~/components/HeaderLogo.vue'; import SvgImage from '~/components/General/SvgImage.vue'; import StoreSwitcher from '~/components/StoreSwitcher.vue'; +import { useCustomerStore } from '~/stores/customer'; export default defineComponent({ components: { @@ -161,12 +162,12 @@ export default defineComponent({ const { isAuthenticated } = useUser(); const { loadTotalQty: loadCartTotalQty, cart } = useCart(); const { loadItemsCount: loadWishlistItemsCount } = useWishlist(); - const { categories: categoryList, load: categoriesListLoad } = useCategory(); + const customerStore = useCustomerStore(); const isSearchOpen = ref(false); const result = ref(null); - const wishlistItemsQty = ref(null); + const wishlistItemsQty = computed(() => customerStore.wishlist?.items_count ?? 0); const wishlistHasProducts = computed(() => wishlistItemsQty.value > 0); const accountIcon = computed(() => (isAuthenticated.value ? 'profile_fill' : 'profile')); @@ -187,16 +188,11 @@ export default defineComponent({ .filter((category) => category.include_in_menu); }); - onMounted(() => { + onMounted(async () => { if (app.$device.isDesktop) { - loadCartTotalQty(); + await loadCartTotalQty(); // eslint-disable-next-line promise/catch-or-return - loadWishlistItemsCount({}) - .then((response) => { - wishlistItemsQty.value = response; - - return response; - }); + await loadWishlistItemsCount({}); } }); diff --git a/packages/theme/components/CartSidebar.vue b/packages/theme/components/CartSidebar.vue index 81f899fbf..a97e8c38d 100644 --- a/packages/theme/components/CartSidebar.vue +++ b/packages/theme/components/CartSidebar.vue @@ -4,6 +4,7 @@ v-e2e="'sidebar-cart'" :visible="isCartSidebarOpen" :title="$t('My Cart')" + position="right" class="sf-sidebar--right" @close="toggleCartSidebar" > diff --git a/packages/theme/components/WishlistSidebar.vue b/packages/theme/components/WishlistSidebar.vue index bb684d1c1..899360520 100644 --- a/packages/theme/components/WishlistSidebar.vue +++ b/packages/theme/components/WishlistSidebar.vue @@ -3,6 +3,7 @@