|
62 | 62 | </VcWidget> |
63 | 63 |
|
64 | 64 | <CartForLater |
65 | | - v-if="savedForLaterList?.items?.length && !shouldHide('cart-for-later')" |
| 65 | + v-if="!shouldHideSavedForLater && savedForLaterList?.items?.length" |
66 | 66 | :saved-for-later-list="savedForLaterList" |
67 | 67 | class="mt-5" |
68 | 68 | @add-to-cart="(lineItemId) => handleMoveToCart([lineItemId])" |
69 | 69 | /> |
70 | 70 |
|
71 | 71 | <RecentlyBrowsedProducts |
72 | | - v-if="recentlyBrowsedProducts.length && !shouldHide('recently-browsed-products')" |
| 72 | + v-if="recentlyBrowsedProducts.length && !shouldHideRecentlyBrowsed" |
73 | 73 | :products="recentlyBrowsedProducts" |
74 | 74 | class="mt-5" |
75 | 75 | /> |
|
111 | 111 | </template> |
112 | 112 |
|
113 | 113 | <CartForLater |
114 | | - v-if="savedForLaterList?.items?.length && !shouldHide('cart-for-later')" |
| 114 | + v-if="!shouldHideSavedForLater && savedForLaterList?.items?.length" |
115 | 115 | :saved-for-later-list="savedForLaterList" |
116 | 116 | class="mt-5" |
117 | 117 | @add-to-cart="(lineItemId) => handleMoveToCart([lineItemId])" |
118 | 118 | /> |
119 | 119 |
|
120 | 120 | <RecentlyBrowsedProducts |
121 | | - v-if="recentlyBrowsedProducts.length && !shouldHide('recently-browsed-products')" |
| 121 | + v-if="recentlyBrowsedProducts.length && !shouldHideRecentlyBrowsed" |
122 | 122 | :products="recentlyBrowsedProducts" |
123 | 123 | class="mt-5" |
124 | 124 | /> |
@@ -366,6 +366,10 @@ function selectItemEvent(item: LineItemType | undefined): void { |
366 | 366 | }); |
367 | 367 | } |
368 | 368 |
|
| 369 | +const shouldHideSavedForLater = computed(() => !isAuthenticated.value || shouldHide("cart-for-later")); |
| 370 | +
|
| 371 | +const shouldHideRecentlyBrowsed = computed(() => shouldHide("recently-browsed-products")); |
| 372 | +
|
369 | 373 | function shouldHide(id: string) { |
370 | 374 | return props.blocksToHide?.includes(id); |
371 | 375 | } |
@@ -427,10 +431,10 @@ void (async () => { |
427 | 431 | } |
428 | 432 |
|
429 | 433 | const isXRecommendModuleEnabled = isEnabledXRecommend(XRECOMMEND_ENABLED_KEY); |
430 | | - if (isAuthenticated.value && isXRecommendModuleEnabled && !shouldHide("recently-browsed-products")) { |
| 434 | + if (isAuthenticated.value && isXRecommendModuleEnabled && !shouldHideRecentlyBrowsed.value) { |
431 | 435 | recentlyBrowsedProducts.value = (await recentlyBrowsed())?.products || []; |
432 | 436 | } |
433 | | - if (isAuthenticated.value && !shouldHide("cart-for-later")) { |
| 437 | + if (!shouldHideSavedForLater.value) { |
434 | 438 | await getSavedForLater(); |
435 | 439 | } |
436 | 440 | })(); |
|
0 commit comments