Skip to content

Commit 30cf12e

Browse files
Alexander Devitskybartoszherba
authored andcommitted
fix: empty wishlist implementation
1 parent 53abd90 commit 30cf12e

File tree

6 files changed

+117
-65
lines changed

6 files changed

+117
-65
lines changed

packages/theme/lang/de.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ export default {
8787
"Login": "Anmeldung",
8888
"login in to your account": "Anmelden bei Ihrem Konto",
8989
"Looks like you haven’t added any items to the bag yet. Start shopping to fill it in.": "Sieht so aus, als hätten Sie der Tasche noch keine Artikel hinzugefügt. Beginnen Sie mit dem Einkaufen, um es auszufüllen.",
90+
"Looks like you haven’t added any items to the Wishlist.": "Sieht so aus, als hätten Sie keine Artikel zur Wunschliste hinzugefügt.",
9091
"Make an order": "Bestellung aufgeben",
9192
"Manage addresses": "Verwalten Sie alle gewünschten Adressen (Arbeitsplatz, Privatadresse...) Auf diese Weise müssen Sie die Adresse nicht bei jeder Bestellung manuell eingeben.",
9293
"Manage billing addresses": "Alle gewünschten Rechnungsadressen verwalten (Arbeitsplatz, Privatadresse ...) Auf diese Weise müssen Sie die Rechnungsadresse nicht bei jeder Bestellung manuell eingeben.",

packages/theme/lang/en.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ export default {
8585
"Login": "Login",
8686
"login in to your account": "login in to your account",
8787
"Looks like you haven’t added any items to the bag yet. Start shopping to fill it in.": "Looks like you haven’t added any items to the bag yet. Start shopping to fill it in.",
88+
"Looks like you haven’t added any items to the Wishlist.": "Looks like you haven’t added any items to the Wishlist.",
8889
"Make an order": "Make an order",
8990
"Manage addresses": "Manage all the addresses you want (work place, home address...) This way you won\"t have to enter the address manually with each order.",
9091
"Manage billing addresses": "Manage all the billing addresses you want (work place, home address...) This way you won\"t have to enter the billing address manually with each order.",

packages/theme/modules/customer/pages/MyAccount/MyWishlist.vue

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,22 @@
77
<div v-if="loading">
88
<SfLoader />
99
</div>
10-
<div v-else>
10+
<div v-else-if="products && products.length > 0">
1111
<div class="navbar section">
1212
<div class="navbar__main">
1313
<div class="navbar__counter">
14-
<span class="navbar__label desktop-only">{{
15-
$t('Products found')
16-
}}</span>
14+
<span class="navbar__label desktop-only">
15+
{{ $t('Products found') }}
16+
</span>
1717
<span class="desktop-only">{{ pagination.totalItems }}</span>
1818
<span class="navbar__label smartphone-only">
1919
{{ pagination.totalItems }} {{ $t('Items') }}</span>
2020
</div>
2121

2222
<div class="navbar__view">
23-
<span class="navbar__view-label desktop-only">{{
24-
$t('View')
25-
}}</span>
23+
<span class="navbar__view-label desktop-only">
24+
{{ $t('View') }}
25+
</span>
2626
<SvgImage
2727
icon="tiles"
2828
:label="$t('Change to grid view')"
@@ -80,7 +80,6 @@
8080
fit: 'cover',
8181
}"
8282
:is-added-to-cart="isInCart({ product: product.product })"
83-
:is-in-wishlist="true"
8483
:link="
8584
localePath(
8685
`/p/${productGetters.getProductSku(
@@ -100,14 +99,15 @@
10099
:score-rating="
101100
productGetters.getAverageRating(product.product)
102101
"
103-
:show-add-to-cart-button="true"
104102
:special-price="
105103
productGetters.getPrice(product.product).special &&
106104
$fc(productGetters.getPrice(product.product).special)
107105
"
108106
:style="{ '--index': i }"
109107
:title="productGetters.getName(product.product)"
110108
wishlist-icon
109+
is-in-wishlist
110+
show-add-to-cart-button
111111
@click:wishlist="removeItemFromWishlist(product.product)"
112112
@click:add-to-cart="
113113
addItemToCart({ product: product.product, quantity: 1 })
@@ -137,7 +137,6 @@
137137
:nuxt-img-config="{
138138
fit: 'cover',
139139
}"
140-
:is-in-wishlist="true"
141140
:link="
142141
localePath(
143142
`/p/${productGetters.getProductSku(
@@ -164,6 +163,7 @@
164163
:style="{ '--index': i }"
165164
:title="productGetters.getName(product.product)"
166165
wishlist-icon
166+
is-in-wishlist
167167
@click:wishlist="removeItemFromWishlist(product.product)"
168168
@click:add-to-cart="
169169
addItemToCart({ product: product.product, quantity: 1 })
@@ -209,9 +209,9 @@
209209
v-show="pagination.totalPages > 1"
210210
class="products__show-on-page"
211211
>
212-
<span class="products__show-on-page__label">{{
213-
$t('Show on page')
214-
}}</span>
212+
<span class="products__show-on-page__label">
213+
{{ $t('Show on page') }}
214+
</span>
215215
<LazyHydrate on-interaction>
216216
<SfSelect
217217
:value="pagination.itemsPerPage.toString()"
@@ -233,6 +233,7 @@
233233
</SfLoader>
234234
</div>
235235
</div>
236+
<EmptyWishlist v-else />
236237
</SfTab>
237238
</SfTabs>
238239
</template>
@@ -263,6 +264,7 @@ import { useWishlist } from '~/modules/wishlist/composables/useWishlist';
263264
import wishlistGetters from '~/modules/wishlist/getters/wishlistGetters';
264265
import { useCart } from '~/modules/checkout/composables/useCart';
265266
import { useWishlistStore } from '~/modules/wishlist/store/wishlistStore';
267+
import EmptyWishlist from '~/modules/wishlist/components/EmptyWishlist.vue';
266268
267269
import {
268270
useUiHelpers,
@@ -282,6 +284,7 @@ export default defineComponent({
282284
SfPagination,
283285
SfSelect,
284286
SfProperty,
287+
EmptyWishlist,
285288
LazyHydrate,
286289
SvgImage,
287290
},
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<template>
2+
<div class="empty-wishlist">
3+
<slot>
4+
<div class="empty-wishlist__banner">
5+
<SvgImage
6+
icon="empty_cart_image"
7+
:label="$t('Empty bag')"
8+
width="211"
9+
height="143"
10+
class="empty-wishlist__icon"
11+
data-testid="icon"
12+
/>
13+
<SfHeading
14+
:title="$t('Your bag is empty')"
15+
:description="$t('Looks like you haven’t added any items to the Wishlist.')"
16+
class="empty-wishlist__label"
17+
data-testid="label"
18+
/>
19+
</div>
20+
</slot>
21+
</div>
22+
</template>
23+
24+
<script lang="ts">
25+
import { defineComponent } from '@nuxtjs/composition-api';
26+
import { SfHeading } from '@storefront-ui/vue';
27+
import SvgImage from '~/components/General/SvgImage.vue';
28+
29+
export default defineComponent({
30+
name: 'EmptyWishlist',
31+
components: {
32+
SfHeading,
33+
SvgImage,
34+
},
35+
});
36+
</script>
37+
38+
<style lang="scss" scoped>
39+
.empty-wishlist {
40+
display: flex;
41+
flex: 1;
42+
align-items: center;
43+
flex-direction: column;
44+
height: 100%;
45+
46+
&__banner {
47+
flex: 1;
48+
display: flex;
49+
align-items: center;
50+
justify-content: center;
51+
flex-direction: column;
52+
}
53+
54+
&__icon {
55+
--image-width: 16rem;
56+
margin: 0 0 var(--spacer-2xl) 7.5rem;
57+
}
58+
59+
&__label {
60+
--heading-description-margin: 0 0 var(--spacer-xl) 0;
61+
--heading-title-margin: 0 0 var(--spacer-xl) 0;
62+
--heading-title-color: var(--c-primary);
63+
--heading-title-font-weight: var(--font-weight--semibold);
64+
text-align: center;
65+
66+
@include for-desktop {
67+
--heading-title-font-size: var(--font-size--xl);
68+
--heading-title-margin: 0 0 var(--spacer-sm) 0;
69+
}
70+
}
71+
}
72+
</style>

packages/theme/modules/wishlist/components/WishlistSidebar.vue

Lines changed: 4 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -128,26 +128,7 @@
128128
</SfProperty>
129129
</div>
130130
</div>
131-
<div
132-
v-else
133-
key="empty-wishlist"
134-
class="empty-wishlist"
135-
>
136-
<div class="empty-wishlist__banner">
137-
<SvgImage
138-
icon="empty_cart_image"
139-
:label="$t('Empty bag')"
140-
width="211"
141-
height="143"
142-
class="empty-wishlist__icon"
143-
/>
144-
<SfHeading
145-
title="Your bag is empty"
146-
description="Looks like you haven’t added any items to the Wishlist."
147-
class="empty-wishlist__label"
148-
/>
149-
</div>
150-
</div>
131+
<EmptyWishlist v-else />
151132
</SfLoader>
152133
<template #content-bottom>
153134
<SfButton
@@ -182,6 +163,7 @@ import {
182163
import { useWishlist } from '~/modules/wishlist/composables/useWishlist';
183164
import { useUser } from '~/modules/customer/composables/useUser';
184165
import { useWishlistStore } from '~/modules/wishlist/store/wishlistStore';
166+
import EmptyWishlist from '~/modules/wishlist/components/EmptyWishlist.vue';
185167
186168
import SvgImage from '~/components/General/SvgImage.vue';
187169
@@ -199,6 +181,7 @@ export default defineComponent({
199181
SfLink,
200182
SfLoader,
201183
SfImage,
184+
EmptyWishlist,
202185
SvgImage,
203186
},
204187
setup() {
@@ -306,38 +289,7 @@ export default defineComponent({
306289
}
307290
}
308291
}
309-
.empty-wishlist {
310-
display: flex;
311-
flex: 1;
312-
align-items: center;
313-
flex-direction: column;
314-
height: 100%;
315-
&__banner {
316-
flex: 1;
317-
display: flex;
318-
align-items: center;
319-
justify-content: center;
320-
flex-direction: column;
321-
}
322-
&__label,
323-
&__description {
324-
text-align: center;
325-
}
326-
&__label {
327-
--heading-description-margin: 0 0 var(--spacer-xl) 0;
328-
--heading-title-margin: 0 0 var(--spacer-xl) 0;
329-
--heading-title-color: var(--c-primary);
330-
--heading-title-font-weight: var(--font-weight--semibold);
331-
@include for-desktop {
332-
--heading-title-font-size: var(--font-size--xl);
333-
--heading-title-margin: 0 0 var(--spacer-sm) 0;
334-
}
335-
}
336-
&__icon {
337-
--image-width: 16rem;
338-
margin: 0 0 var(--spacer-2xl) 7.5rem;
339-
}
340-
}
292+
341293
.heading {
342294
&__wrapper {
343295
--heading-title-color: var(--c-link);
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { render } from '~/test-utils';
2+
import EmptyWishlist from '~/modules/wishlist/components/EmptyWishlist.vue';
3+
4+
describe('EmptyWishlist.vue', () => {
5+
it('Renders with a default value', () => {
6+
const { getByTestId } = render(EmptyWishlist);
7+
8+
const icon = getByTestId('icon');
9+
const label = getByTestId('label');
10+
11+
expect(icon).toBeDefined();
12+
expect(label).toBeDefined();
13+
});
14+
15+
it('Renders content from the "default" slot', () => {
16+
const wrapper = render(EmptyWishlist, {
17+
slots: {
18+
default: '<div id="testSlot"></div>',
19+
},
20+
});
21+
expect(wrapper.html()).toContain('<div id="testSlot"></div>');
22+
});
23+
});

0 commit comments

Comments
 (0)