@shopbite-de/storefront 1.31.3 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/ci.yaml +87 -0
- package/.gitignore +5 -0
- package/CLAUDE.md +27 -8
- package/app/app.vue +10 -6
- package/app/assets/css/main.css +103 -61
- package/app/components/AddToWishlist.vue +15 -25
- package/app/components/Address/Card.vue +6 -11
- package/app/components/Address/Detail.vue +23 -23
- package/app/components/Address/Fields.vue +175 -73
- package/app/components/Address/Form.vue +107 -106
- package/app/components/Cart/Bar.vue +6 -9
- package/app/components/Cart/Item.vue +48 -63
- package/app/components/Cart/QuickView.vue +38 -25
- package/app/components/Cart/Upsell.vue +24 -62
- package/app/components/Category/Breadcrumb.vue +29 -3
- package/app/components/Category/FilterGroup.vue +20 -41
- package/app/components/Category/Listing.vue +100 -130
- package/app/components/Category/SearchInput.vue +22 -19
- package/app/components/Checkout/DeliveryTimeSelect.vue +55 -77
- package/app/components/Checkout/LoginOrRegister.vue +28 -29
- package/app/components/Checkout/PaymentAndDelivery.vue +114 -86
- package/app/components/Checkout/Summary.vue +90 -60
- package/app/components/Checkout/VoucherInput.vue +40 -27
- package/app/components/Contact/Form.vue +164 -192
- package/app/components/DemoBanner.vue +5 -5
- package/app/components/Footer/StoreStatus.vue +2 -2
- package/app/components/Footer.vue +125 -57
- package/app/components/Header.vue +283 -18
- package/app/components/Home/Categories.vue +116 -0
- package/app/components/Home/Facts.vue +71 -0
- package/app/components/Home/Faq.vue +34 -16
- package/app/components/Home/Hero.vue +172 -0
- package/app/components/Home/Highlights.vue +29 -37
- package/app/components/Home/Restaurant.vue +102 -0
- package/app/components/Menu/BonCard.vue +180 -0
- package/app/components/Menu/CartPanel.vue +24 -0
- package/app/components/Menu/CategoryIndex.vue +54 -0
- package/app/components/Menu/OrderMode.vue +20 -0
- package/app/components/Menu/SectionHeader.vue +38 -0
- package/app/components/Navigation/MobileTop.vue +23 -15
- package/app/components/Order/Confirmation.vue +119 -0
- package/app/components/Order/Detail.vue +80 -88
- package/app/components/Product/CardSkeleton.vue +8 -12
- package/app/components/Product/Configurator.vue +8 -16
- package/app/components/Product/CrossSelling.vue +75 -83
- package/app/components/Product/DeselectIngredient.vue +17 -22
- package/app/components/Product/Detail.vue +35 -27
- package/app/components/Product/QuickView.vue +80 -51
- package/app/components/SalesChannelSwitch.vue +14 -28
- package/app/components/Sb/Button.vue +70 -0
- package/app/components/Sb/Checkbox.vue +73 -0
- package/app/components/Sb/Chip.vue +51 -0
- package/app/components/Sb/ChoiceGroup.vue +82 -0
- package/app/components/Sb/ConfirmDialog.vue +60 -0
- package/app/components/Sb/Field.vue +77 -0
- package/app/components/Sb/Icon.vue +66 -0
- package/app/components/Sb/IconButton.vue +55 -0
- package/app/components/Sb/Input.vue +23 -0
- package/app/components/Sb/SegmentedControl.vue +34 -0
- package/app/components/Sb/Select.vue +49 -0
- package/app/components/Sb/Sheet.vue +83 -0
- package/app/components/Sb/Stars.vue +60 -0
- package/app/components/Sb/StatusPill.vue +38 -0
- package/app/components/Sb/Stepper.vue +72 -0
- package/app/components/User/AccountHeader.vue +16 -0
- package/app/components/User/AuthPanel.vue +41 -0
- package/app/components/User/Detail.vue +32 -29
- package/app/components/User/LoginForm.vue +92 -98
- package/app/components/User/RegistrationForm.vue +285 -249
- package/app/components/Wishlist.vue +55 -155
- package/app/composables/useCartMutations.ts +9 -27
- package/app/composables/useCheckoutMethodGuard.ts +2 -24
- package/app/composables/useContactForm.ts +66 -0
- package/app/composables/useHomeMenuCategories.ts +41 -0
- package/app/composables/useNavigation.ts +10 -2
- package/app/composables/useOrderMode.ts +65 -0
- package/app/composables/useRegistrationForm.ts +161 -0
- package/app/composables/useRestaurantSchema.ts +1 -1
- package/app/composables/useShareLink.ts +3 -13
- package/app/composables/useSortingSelection.ts +13 -0
- package/app/composables/useThemePreset.ts +24 -0
- package/app/composables/useVoucherCode.ts +7 -16
- package/app/composables/useWishlistActions.ts +0 -51
- package/app/error.vue +31 -9
- package/app/layouts/account.vue +45 -50
- package/app/layouts/default.vue +2 -3
- package/app/layouts/listing.vue +3 -5
- package/app/pages/[...all].vue +8 -4
- package/app/pages/account/recover/password/index.vue +113 -80
- package/app/pages/anmelden.vue +11 -10
- package/app/pages/bestellung/[id]/erfolg.vue +1 -15
- package/app/pages/bestellung/[id]/fehler.vue +63 -51
- package/app/pages/bestellung/[id]/index.vue +3 -85
- package/app/pages/bestellung/kasse.vue +29 -0
- package/app/pages/bestellung.vue +8 -60
- package/app/pages/index.vue +12 -52
- package/app/pages/kontakt.vue +27 -7
- package/app/pages/konto/adressen.vue +106 -102
- package/app/pages/konto/bestellung/[id].vue +9 -43
- package/app/pages/konto/bestellungen.vue +55 -33
- package/app/pages/konto/index.vue +47 -62
- package/app/pages/konto/profil.vue +162 -100
- package/app/pages/maintenance.vue +8 -6
- package/app/pages/merkliste.vue +7 -8
- package/app/pages/passwort-vergessen.vue +92 -75
- package/app/pages/registrierung/bestaetigen.vue +20 -48
- package/app/pages/registrierung/index.vue +16 -7
- package/app/pages/suche.vue +94 -95
- package/app/plugins/theme-preset.ts +9 -0
- package/app/utils/highlight.ts +25 -0
- package/app/utils/product.ts +9 -0
- package/app/validation/registrationSchema.ts +1 -1
- package/modules/theme.ts +123 -0
- package/nuxt.config.ts +30 -16
- package/package.json +6 -8
- package/playwright.config.ts +11 -0
- package/server/api/listing/[categoryId].get.ts +3 -0
- package/shared/theme/presets.ts +303 -0
- package/test/a11y/presets.test.ts +225 -0
- package/test/layer/nuxt.config.ts +8 -0
- package/test/nuxt/AccountPagesPreset.test.ts +191 -0
- package/test/nuxt/AuthPagesPreset.test.ts +87 -0
- package/test/nuxt/CartCheckoutPreset.test.ts +154 -0
- package/test/nuxt/CartItem.test.ts +18 -3
- package/test/nuxt/CartUpsell.test.ts +1 -2
- package/test/nuxt/CheckoutFormsPreset.test.ts +120 -0
- package/test/nuxt/CheckoutOnePage.test.ts +115 -0
- package/test/nuxt/CheckoutSummary.test.ts +6 -6
- package/test/nuxt/CheckoutVoucherInput.test.ts +20 -32
- package/test/nuxt/ContactFormPreset.test.ts +115 -0
- package/test/nuxt/FooterStoreStatus.test.ts +2 -2
- package/test/nuxt/HeaderFooterPreset.test.ts +134 -0
- package/test/nuxt/HomeFaq.test.ts +3 -2
- package/test/nuxt/MenuBonCard.test.ts +122 -0
- package/test/nuxt/OrderPagesPreset.test.ts +132 -0
- package/test/nuxt/PaymentAndDelivery.test.ts +0 -4
- package/test/nuxt/ProductCrossSelling.test.ts +2 -1
- package/test/nuxt/ProductDeselectIngredient.test.ts +5 -3
- package/test/nuxt/ProductSheetPreset.test.ts +105 -0
- package/test/nuxt/RegisterConfirmPage.test.ts +0 -8
- package/test/nuxt/RegistrationForm.test.ts +89 -270
- package/test/nuxt/SbBaseComponents.test.ts +170 -0
- package/test/nuxt/SbStars.test.ts +25 -0
- package/test/nuxt/useCartMutations.test.ts +3 -17
- package/test/nuxt/useCartUpsell.test.ts +1 -1
- package/test/nuxt/useCheckoutMethodGuard.test.ts +0 -27
- package/test/nuxt/useShareLink.test.ts +1 -9
- package/test/nuxt/useWishlistActions.test.ts +3 -26
- package/test/unit/highlight.spec.ts +31 -0
- package/test/unit/product.spec.ts +12 -0
- package/test/unit/themePresets.spec.ts +61 -0
- package/app/app.config.ts +0 -19
- package/app/components/AnimatedSection.vue +0 -74
- package/app/components/BottomNavi.vue +0 -70
- package/app/components/Category/Header.vue +0 -48
- package/app/components/Checkout/PaymentMethod.vue +0 -30
- package/app/components/Checkout/ShippingMethod.vue +0 -30
- package/app/components/Cta.vue +0 -30
- package/app/components/Feature/Card.vue +0 -121
- package/app/components/Features.vue +0 -42
- package/app/components/Footer/Contact.vue +0 -82
- package/app/components/Header/Body.vue +0 -82
- package/app/components/Header/Right.vue +0 -187
- package/app/components/Header/Title.vue +0 -10
- package/app/components/Hero.vue +0 -233
- package/app/components/Home/MenuCategories.vue +0 -148
- package/app/components/ImageGallery.vue +0 -63
- package/app/components/Loading.vue +0 -29
- package/app/components/Navigation/DesktopLeft.vue +0 -39
- package/app/components/Product/Card.vue +0 -177
- package/app/components/Product/CardCompact.vue +0 -72
- package/app/components/Product/CardDietBadges.vue +0 -43
- package/app/components/Product/CardIngredients.vue +0 -35
- package/app/components/Product/CardKitchen.vue +0 -34
- package/app/components/Product/SearchBar.vue +0 -95
- package/app/components/PublicAnnouncement.vue +0 -17
- package/app/pages/bestellung/bestaetigen.vue +0 -16
- package/app/pages/bestellung/warenkorb.vue +0 -49
- package/app/pages/bestellung/zahlung-versand.vue +0 -25
- package/test/nuxt/AddressFields.test.ts +0 -222
- package/test/nuxt/AnimatedSection.test.ts +0 -67
- package/test/nuxt/ContactForm.test.ts +0 -207
- package/test/nuxt/FooterContact.test.ts +0 -102
- package/test/nuxt/HeaderRight.test.ts +0 -142
- package/test/nuxt/Hero.test.ts +0 -126
- package/test/nuxt/HomeMenuCategories.test.ts +0 -94
- package/test/nuxt/LoginForm.test.ts +0 -159
|
@@ -1,16 +1,9 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import type { Schemas } from "#shopware";
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
useGridLayout?: boolean;
|
|
8
|
-
}>(),
|
|
9
|
-
{
|
|
10
|
-
showMenuButton: false,
|
|
11
|
-
useGridLayout: false,
|
|
12
|
-
},
|
|
13
|
-
);
|
|
4
|
+
withDefaults(defineProps<{ showMenuButton?: boolean }>(), {
|
|
5
|
+
showMenuButton: false,
|
|
6
|
+
});
|
|
14
7
|
|
|
15
8
|
const { getWishlistProducts, items } = useWishlist();
|
|
16
9
|
const { apiClient } = useShopwareContext();
|
|
@@ -68,157 +61,64 @@ onMounted(async () => {
|
|
|
68
61
|
</script>
|
|
69
62
|
|
|
70
63
|
<template>
|
|
71
|
-
<div class="flex flex-col gap-6">
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
64
|
+
<div class="flex flex-col gap-6 font-body text-sb-ink">
|
|
65
|
+
<p
|
|
66
|
+
v-if="isLoading && !products.length"
|
|
67
|
+
role="status"
|
|
68
|
+
class="text-sb-ink-muted"
|
|
69
|
+
>
|
|
70
|
+
Merkliste wird geladen …
|
|
71
|
+
</p>
|
|
72
|
+
<div
|
|
73
|
+
v-else-if="!products.length"
|
|
74
|
+
class="flex flex-col items-start gap-4 rounded-sb-card border border-sb-line bg-sb-surface p-6"
|
|
75
|
+
>
|
|
76
|
+
<p>Ihre Merkliste ist leer.</p>
|
|
77
|
+
<SbButton v-if="showMenuButton" to="/speisekarte/"
|
|
78
|
+
>Zur Speisekarte</SbButton
|
|
83
79
|
>
|
|
84
|
-
Alle in den Warenkorb ({{ products.length }})
|
|
85
|
-
</UButton>
|
|
86
80
|
</div>
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
<
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
<p class="
|
|
97
|
-
|
|
98
|
-
|
|
81
|
+
<template v-else>
|
|
82
|
+
<ul
|
|
83
|
+
class="flex flex-col overflow-hidden rounded-sb-card border border-sb-line bg-sb-surface"
|
|
84
|
+
>
|
|
85
|
+
<li
|
|
86
|
+
v-for="product in products"
|
|
87
|
+
:key="product.id"
|
|
88
|
+
class="grid grid-cols-[minmax(0,1fr)_auto] items-center gap-x-3 gap-y-2 border-b border-sb-line p-4 last:border-b-0 sm:grid-cols-[minmax(0,1fr)_auto_auto]"
|
|
89
|
+
>
|
|
90
|
+
<p class="min-w-0">
|
|
91
|
+
<span
|
|
92
|
+
class="block font-bold [overflow-wrap:anywhere] hyphens-auto"
|
|
93
|
+
>{{ product.translated?.name ?? product.name }}</span
|
|
94
|
+
>
|
|
95
|
+
<span class="text-sm text-sb-ink-muted tabular-nums"
|
|
96
|
+
>Nr. {{ product.productNumber }} ·
|
|
97
|
+
{{ getFormattedPrice(product.calculatedPrice?.totalPrice) }}</span
|
|
98
|
+
>
|
|
99
99
|
</p>
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
size="lg"
|
|
100
|
+
<AddToWishlist :product="product" />
|
|
101
|
+
<SbButton
|
|
102
|
+
variant="tint"
|
|
103
|
+
class="col-span-full sm:col-span-1"
|
|
104
|
+
:loading="addingItemId === product.id"
|
|
105
|
+
@click="addSingleItemToCart(product)"
|
|
107
106
|
>
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
</div>
|
|
112
|
-
</UPageCard>
|
|
113
|
-
|
|
114
|
-
<!-- Loading State -->
|
|
115
|
-
<div v-if="isLoading" class="flex flex-col gap-4">
|
|
116
|
-
<USkeleton class="h-32 w-full" />
|
|
117
|
-
<USkeleton class="h-32 w-full" />
|
|
118
|
-
</div>
|
|
119
|
-
|
|
120
|
-
<!-- Products List -->
|
|
121
|
-
<div v-if="products.length > 0" class="flex flex-col gap-4">
|
|
122
|
-
<!-- Product Items -->
|
|
123
|
-
<div
|
|
124
|
-
:class="
|
|
125
|
-
props.useGridLayout
|
|
126
|
-
? 'grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4'
|
|
127
|
-
: 'flex flex-col gap-4'
|
|
128
|
-
"
|
|
129
|
-
>
|
|
130
|
-
<div v-for="product in products" :key="product.id">
|
|
131
|
-
<div class="relative">
|
|
132
|
-
<UPageCard
|
|
133
|
-
variant="outline"
|
|
134
|
-
:ui="{ root: 'shadow-sm hover:shadow-md transition-shadow' }"
|
|
107
|
+
In den Warenkorb
|
|
108
|
+
<span class="sr-only"
|
|
109
|
+
>: {{ product.translated?.name ?? product.name }}</span
|
|
135
110
|
>
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
:src="product.cover.media.url"
|
|
146
|
-
class="rounded-md w-full h-full object-cover"
|
|
147
|
-
sizes="64px"
|
|
148
|
-
/>
|
|
149
|
-
</div>
|
|
150
|
-
<div class="flex-1 min-w-0">
|
|
151
|
-
<div class="flex flex-col gap-1">
|
|
152
|
-
<span class="text-xs text-primary font-medium">
|
|
153
|
-
#{{ product.productNumber }}
|
|
154
|
-
</span>
|
|
155
|
-
<h3
|
|
156
|
-
class="text-sm font-semibold text-highlighted line-clamp-2 leading-tight"
|
|
157
|
-
>
|
|
158
|
-
{{ product.translated.name }}
|
|
159
|
-
</h3>
|
|
160
|
-
<p class="text-base font-bold text-primary">
|
|
161
|
-
{{
|
|
162
|
-
getFormattedPrice(
|
|
163
|
-
product.calculatedPrice.totalPrice,
|
|
164
|
-
)
|
|
165
|
-
}}
|
|
166
|
-
</p>
|
|
167
|
-
</div>
|
|
168
|
-
</div>
|
|
169
|
-
</div>
|
|
170
|
-
<!-- Heart Button -->
|
|
171
|
-
<div class="flex-shrink-0">
|
|
172
|
-
<AddToWishlist :product="product" />
|
|
173
|
-
</div>
|
|
174
|
-
</div>
|
|
175
|
-
|
|
176
|
-
<!-- Add to Cart Button -->
|
|
177
|
-
<UButton
|
|
178
|
-
icon="i-lucide-shopping-cart"
|
|
179
|
-
color="primary"
|
|
180
|
-
variant="solid"
|
|
181
|
-
size="md"
|
|
182
|
-
block
|
|
183
|
-
:loading="addingItemId === product.id"
|
|
184
|
-
@click="addSingleItemToCart(product)"
|
|
185
|
-
>
|
|
186
|
-
In den Warenkorb
|
|
187
|
-
</UButton>
|
|
188
|
-
</div>
|
|
189
|
-
</UPageCard>
|
|
190
|
-
</div>
|
|
191
|
-
</div>
|
|
192
|
-
</div>
|
|
193
|
-
|
|
194
|
-
<!-- Secondary Actions -->
|
|
195
|
-
<div
|
|
196
|
-
class="pt-4 border-t border-gray-200 dark:border-gray-800 flex flex-col sm:flex-row gap-2"
|
|
197
|
-
>
|
|
198
|
-
<UButton
|
|
199
|
-
icon="i-lucide-trash-2"
|
|
200
|
-
color="neutral"
|
|
201
|
-
variant="ghost"
|
|
202
|
-
size="md"
|
|
203
|
-
class="flex-1"
|
|
204
|
-
:disabled="isLoading"
|
|
205
|
-
@click="clearWishlistHandler"
|
|
111
|
+
</SbButton>
|
|
112
|
+
</li>
|
|
113
|
+
</ul>
|
|
114
|
+
<div class="flex flex-col gap-3 sm:flex-row">
|
|
115
|
+
<SbButton :loading="isAddingToCart" @click="addAllItemsToCart(products)"
|
|
116
|
+
>Alle in den Warenkorb</SbButton
|
|
117
|
+
>
|
|
118
|
+
<SbButton variant="ghost" @click="clearWishlistHandler"
|
|
119
|
+
>Merkliste leeren</SbButton
|
|
206
120
|
>
|
|
207
|
-
Merkliste leeren
|
|
208
|
-
</UButton>
|
|
209
|
-
|
|
210
|
-
<NuxtLink v-if="showMenuButton" to="/speisekarte" class="flex-1">
|
|
211
|
-
<UButton
|
|
212
|
-
icon="i-lucide-utensils"
|
|
213
|
-
color="neutral"
|
|
214
|
-
variant="outline"
|
|
215
|
-
size="md"
|
|
216
|
-
block
|
|
217
|
-
>
|
|
218
|
-
Zur Speisekarte
|
|
219
|
-
</UButton>
|
|
220
|
-
</NuxtLink>
|
|
221
121
|
</div>
|
|
222
|
-
</
|
|
122
|
+
</template>
|
|
223
123
|
</div>
|
|
224
124
|
</template>
|
|
@@ -38,13 +38,12 @@ const queuedQuantityTasks = new Map<string, Promise<void>>();
|
|
|
38
38
|
* concurrently (e.g. quick +/- clicks) yields `CHECKOUT__CART_LOCKED`
|
|
39
39
|
* conflicts. Every write goes through one queue, a quantity change made
|
|
40
40
|
* while another is in flight only sends the latest value, a lock conflict
|
|
41
|
-
* is retried once, and a final failure
|
|
42
|
-
*
|
|
41
|
+
* is retried once, and a final failure leaves the cart as it was:
|
|
42
|
+
* it is re-synced. See issue #241.
|
|
43
43
|
*/
|
|
44
44
|
export function useCartMutations() {
|
|
45
45
|
const { cart, refreshCart, addProducts, changeProductQuantity, removeItem } =
|
|
46
46
|
useCart();
|
|
47
|
-
const toast = useToast();
|
|
48
47
|
|
|
49
48
|
const pendingCount = useState("cart-mutations-pending", () => 0);
|
|
50
49
|
const isMutating = computed(() => pendingCount.value > 0);
|
|
@@ -75,25 +74,15 @@ export function useCartMutations() {
|
|
|
75
74
|
|
|
76
75
|
/**
|
|
77
76
|
* Runs `task` after every previously queued cart write. Resolves with
|
|
78
|
-
* `undefined` when the write failed
|
|
77
|
+
* `undefined` when the write failed.
|
|
79
78
|
*/
|
|
80
|
-
function enqueue<T>(
|
|
81
|
-
task: () => Promise<T>,
|
|
82
|
-
failureTitle: string,
|
|
83
|
-
): Promise<T | undefined> {
|
|
79
|
+
function enqueue<T>(task: () => Promise<T>): Promise<T | undefined> {
|
|
84
80
|
pendingCount.value++;
|
|
85
81
|
const run = async (): Promise<T | undefined> => {
|
|
86
82
|
try {
|
|
87
83
|
return await task();
|
|
88
84
|
} catch (error) {
|
|
89
85
|
console.error("[cart][mutation]", error);
|
|
90
|
-
toast.add({
|
|
91
|
-
title: failureTitle,
|
|
92
|
-
description: "Bitte versuche es erneut.",
|
|
93
|
-
color: "error",
|
|
94
|
-
icon: "i-lucide-x-circle",
|
|
95
|
-
progress: false,
|
|
96
|
-
});
|
|
97
86
|
await refreshCart().catch(() => {});
|
|
98
87
|
return undefined;
|
|
99
88
|
} finally {
|
|
@@ -115,9 +104,8 @@ export function useCartMutations() {
|
|
|
115
104
|
*/
|
|
116
105
|
function setQuantity(lineItemId: string, quantity: number): Promise<void> {
|
|
117
106
|
if (import.meta.server) {
|
|
118
|
-
return enqueue(
|
|
119
|
-
|
|
120
|
-
"Menge konnte nicht geändert werden",
|
|
107
|
+
return enqueue(() =>
|
|
108
|
+
write(() => changeProductQuantity({ id: lineItemId, quantity })),
|
|
121
109
|
).then(() => undefined);
|
|
122
110
|
}
|
|
123
111
|
|
|
@@ -139,24 +127,18 @@ export function useCartMutations() {
|
|
|
139
127
|
await write(() =>
|
|
140
128
|
changeProductQuantity({ id: lineItemId, quantity: target }),
|
|
141
129
|
);
|
|
142
|
-
}
|
|
130
|
+
}).then(() => undefined);
|
|
143
131
|
|
|
144
132
|
queuedQuantityTasks.set(lineItemId, task);
|
|
145
133
|
return task;
|
|
146
134
|
}
|
|
147
135
|
|
|
148
136
|
function removeLineItem(lineItem: Schemas["LineItem"]) {
|
|
149
|
-
return enqueue(
|
|
150
|
-
() => write(() => removeItem(lineItem)),
|
|
151
|
-
"Artikel konnte nicht entfernt werden",
|
|
152
|
-
);
|
|
137
|
+
return enqueue(() => write(() => removeItem(lineItem)));
|
|
153
138
|
}
|
|
154
139
|
|
|
155
140
|
function addLineItems(items: LineItems) {
|
|
156
|
-
return enqueue(
|
|
157
|
-
() => write(() => addProducts(items)),
|
|
158
|
-
"Artikel konnte nicht in den Warenkorb gelegt werden",
|
|
159
|
-
);
|
|
141
|
+
return enqueue(() => write(() => addProducts(items)));
|
|
160
142
|
}
|
|
161
143
|
|
|
162
144
|
return {
|
|
@@ -33,15 +33,11 @@ export function hasBlockedPaymentMethod(cart?: Schemas["Cart"]): boolean {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
type MethodGuardConfig<M extends CheckoutMethod> = {
|
|
36
|
-
/** Human readable label, e.g. "Versandart" */
|
|
37
|
-
label: string;
|
|
38
|
-
icon: string;
|
|
39
36
|
isBlocked: () => boolean;
|
|
40
37
|
selected: () => M | null;
|
|
41
38
|
loadAvailable: () => Promise<M[]>;
|
|
42
39
|
defaultId: () => string | undefined;
|
|
43
40
|
select: (id: string) => Promise<void>;
|
|
44
|
-
displayName: (method: M) => string | undefined;
|
|
45
41
|
};
|
|
46
42
|
|
|
47
43
|
/**
|
|
@@ -64,7 +60,6 @@ export function useCheckoutMethodGuard() {
|
|
|
64
60
|
selectedPaymentMethod,
|
|
65
61
|
} = useCheckout();
|
|
66
62
|
const { sessionContext } = useSessionContext();
|
|
67
|
-
const toast = useToast();
|
|
68
63
|
|
|
69
64
|
const isShippingMethodBlocked = computed(() =>
|
|
70
65
|
hasBlockedShippingMethod(cart.value),
|
|
@@ -76,27 +71,21 @@ export function useCheckoutMethodGuard() {
|
|
|
76
71
|
const isResolving = ref(false);
|
|
77
72
|
|
|
78
73
|
const shippingConfig: MethodGuardConfig<Schemas["ShippingMethod"]> = {
|
|
79
|
-
label: "Versandart",
|
|
80
|
-
icon: "i-lucide-truck",
|
|
81
74
|
isBlocked: () => isShippingMethodBlocked.value,
|
|
82
75
|
selected: () => selectedShippingMethod.value,
|
|
83
76
|
loadAvailable: async () =>
|
|
84
77
|
(await getShippingMethods({ forceReload: true })).value,
|
|
85
78
|
defaultId: () => sessionContext.value?.salesChannel?.shippingMethodId,
|
|
86
79
|
select: (id) => setShippingMethod({ id }),
|
|
87
|
-
displayName: (method) => method.name,
|
|
88
80
|
};
|
|
89
81
|
|
|
90
82
|
const paymentConfig: MethodGuardConfig<Schemas["PaymentMethod"]> = {
|
|
91
|
-
label: "Zahlart",
|
|
92
|
-
icon: "i-lucide-badge-euro",
|
|
93
83
|
isBlocked: () => isPaymentMethodBlocked.value,
|
|
94
84
|
selected: () => selectedPaymentMethod.value,
|
|
95
85
|
loadAvailable: async () =>
|
|
96
86
|
(await getPaymentMethods({ forceReload: true })).value,
|
|
97
87
|
defaultId: () => sessionContext.value?.salesChannel?.paymentMethodId,
|
|
98
88
|
select: (id) => setPaymentMethod({ id }),
|
|
99
|
-
displayName: (method) => method.distinguishableName ?? method.name,
|
|
100
89
|
};
|
|
101
90
|
|
|
102
91
|
/**
|
|
@@ -122,22 +111,11 @@ export function useCheckoutMethodGuard() {
|
|
|
122
111
|
await refreshCart();
|
|
123
112
|
if (config.isBlocked()) return false;
|
|
124
113
|
|
|
125
|
-
const blockedName = blocked ? config.displayName(blocked) : undefined;
|
|
126
|
-
const targetName = config.displayName(target) ?? config.label;
|
|
127
|
-
toast.add({
|
|
128
|
-
title: `${config.label} geändert`,
|
|
129
|
-
description: blockedName
|
|
130
|
-
? `${blockedName} ist nicht mehr verfügbar. ${targetName} wurde ausgewählt.`
|
|
131
|
-
: `${targetName} wurde ausgewählt.`,
|
|
132
|
-
color: "warning",
|
|
133
|
-
icon: config.icon,
|
|
134
|
-
progress: false,
|
|
135
|
-
});
|
|
136
114
|
return true;
|
|
137
115
|
}
|
|
138
116
|
|
|
139
117
|
// Calls are serialized: the guard performs side effects (cart refresh,
|
|
140
|
-
// method switch
|
|
118
|
+
// method switch), so overlapping runs (e.g. the mount-time check
|
|
141
119
|
// plus a quick click on the order button) must not race each other.
|
|
142
120
|
// A call made while another one is in flight waits for it and then
|
|
143
121
|
// re-checks the latest cart state.
|
|
@@ -179,7 +157,7 @@ export function useCheckoutMethodGuard() {
|
|
|
179
157
|
* Shipping is handled first because payment availability rules may
|
|
180
158
|
* depend on the shipping method. If shipping cannot be resolved the
|
|
181
159
|
* checkout stays blocked anyway, so payment is left untouched to avoid
|
|
182
|
-
* a pointless switch
|
|
160
|
+
* a pointless switch.
|
|
183
161
|
*
|
|
184
162
|
* @returns `true` when both methods are available afterwards.
|
|
185
163
|
*/
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { useSalutations } from "@shopware/composables";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Contact form logic shared by the Nuxt UI form and the preset form
|
|
6
|
+
* (#445): salutation options, the checks and the Store API call.
|
|
7
|
+
*/
|
|
8
|
+
export const contactFormSchema = z.object({
|
|
9
|
+
salutationId: z.string().optional(),
|
|
10
|
+
firstName: z.string().optional(),
|
|
11
|
+
lastName: z.string().optional(),
|
|
12
|
+
email: z.string().email("Ungültige E-Mail-Adresse"),
|
|
13
|
+
phone: z.string().optional(),
|
|
14
|
+
subject: z.string().min(3, "Bitte gib einen Betreff an"),
|
|
15
|
+
comment: z
|
|
16
|
+
.string()
|
|
17
|
+
.min(10, "Die Nachricht muss mindestens 10 Zeichen lang sein"),
|
|
18
|
+
hp: z.string().optional(),
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
export type ContactFormData = z.output<typeof contactFormSchema>;
|
|
22
|
+
|
|
23
|
+
export function useContactForm() {
|
|
24
|
+
const { apiClient } = useShopwareContext();
|
|
25
|
+
const { getSalutations } = useSalutations();
|
|
26
|
+
|
|
27
|
+
const salutations = computed(() =>
|
|
28
|
+
getSalutations.value.map((salutation) => ({
|
|
29
|
+
label: salutation.displayName ?? "",
|
|
30
|
+
value: salutation.id,
|
|
31
|
+
})),
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Sends the message and returns the success text of the shop. A filled
|
|
36
|
+
* honeypot pretends success without sending anything.
|
|
37
|
+
*/
|
|
38
|
+
async function send(data: ContactFormData, fallbackMessage: string) {
|
|
39
|
+
if (data.hp) {
|
|
40
|
+
console.warn("Honeypot filled, submission ignored.");
|
|
41
|
+
return fallbackMessage;
|
|
42
|
+
}
|
|
43
|
+
const result = await apiClient.invoke(
|
|
44
|
+
"sendContactMail post /contact-form",
|
|
45
|
+
{
|
|
46
|
+
body: {
|
|
47
|
+
salutationId: data.salutationId || salutations.value.at(-1)?.value,
|
|
48
|
+
firstName: data.firstName,
|
|
49
|
+
lastName: data.lastName,
|
|
50
|
+
email: data.email,
|
|
51
|
+
phone: data.phone,
|
|
52
|
+
subject: data.subject,
|
|
53
|
+
comment: data.comment,
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
);
|
|
57
|
+
const resultData = result?.data as Record<string, unknown> | undefined;
|
|
58
|
+
const message =
|
|
59
|
+
typeof resultData?.individualSuccessMessage === "string"
|
|
60
|
+
? resultData.individualSuccessMessage.trim()
|
|
61
|
+
: "";
|
|
62
|
+
return message || fallbackMessage;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return { salutations, send };
|
|
66
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The menu sections of the home page (#388, #444): the children of the menu
|
|
3
|
+
* root (`menuCategoryId`, else the navigation root) with their photo
|
|
4
|
+
* (`category.media`). Shared by the tiles and the word list of the presets.
|
|
5
|
+
*/
|
|
6
|
+
export async function useHomeMenuCategories() {
|
|
7
|
+
const { apiClient } = useShopwareContext();
|
|
8
|
+
const config = useRuntimeConfig();
|
|
9
|
+
const rootId = config.public.shopBite.menuCategoryId || "main-navigation";
|
|
10
|
+
|
|
11
|
+
const { data: categories } = await useAsyncData(
|
|
12
|
+
"home-menu-categories",
|
|
13
|
+
async () => {
|
|
14
|
+
const response = await apiClient.invoke(
|
|
15
|
+
"readNavigation post /navigation/{activeId}/{rootId}",
|
|
16
|
+
{
|
|
17
|
+
body: {
|
|
18
|
+
depth: 1,
|
|
19
|
+
// Sent as a POST body so the projection is honoured (#312).
|
|
20
|
+
includes: {
|
|
21
|
+
category: [
|
|
22
|
+
"id",
|
|
23
|
+
"name",
|
|
24
|
+
"translated",
|
|
25
|
+
"seoUrl",
|
|
26
|
+
"customFields",
|
|
27
|
+
"media",
|
|
28
|
+
],
|
|
29
|
+
media: ["url", "thumbnails", "metaData"],
|
|
30
|
+
media_thumbnail: ["url", "width"],
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
pathParams: { activeId: "main-navigation", rootId },
|
|
34
|
+
},
|
|
35
|
+
);
|
|
36
|
+
return response.data;
|
|
37
|
+
},
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
return { categories };
|
|
41
|
+
}
|
|
@@ -1,6 +1,14 @@
|
|
|
1
|
-
import type { NavigationMenuItem } from "@nuxt/ui";
|
|
2
1
|
import type { Schemas } from "#shopware";
|
|
3
2
|
|
|
3
|
+
/** A navigation entry of the header, footer and menu navigation. */
|
|
4
|
+
export interface NavigationMenuItem {
|
|
5
|
+
label?: string;
|
|
6
|
+
to?: string;
|
|
7
|
+
target?: "_blank";
|
|
8
|
+
icon?: string;
|
|
9
|
+
children?: NavigationMenuItem[];
|
|
10
|
+
}
|
|
11
|
+
|
|
4
12
|
export function useNavigation(withChildren: boolean | undefined) {
|
|
5
13
|
const { apiClient } = useShopwareContext();
|
|
6
14
|
const config = useRuntimeConfig();
|
|
@@ -44,7 +52,7 @@ export function useNavigation(withChildren: boolean | undefined) {
|
|
|
44
52
|
category: Schemas["Category"],
|
|
45
53
|
): NavigationMenuItem => ({
|
|
46
54
|
label: category.translated?.name ?? category.name,
|
|
47
|
-
to: category.translated?.seoUrl ?? category.seoUrl,
|
|
55
|
+
to: category.translated?.seoUrl ?? category.seoUrl ?? undefined,
|
|
48
56
|
target: category.linkNewTab ? "_blank" : undefined,
|
|
49
57
|
icon: (category.customFields as Record<string, string> | null)
|
|
50
58
|
?.shopbite_category_icon,
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { Schemas } from "#shopware";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Delivery or pickup on the menu page (#443): the shipping methods of the
|
|
5
|
+
* sales channel as a choice before the customer starts ordering. Which
|
|
6
|
+
* methods exist and which payment methods they allow is decided by the
|
|
7
|
+
* Shopware rules; after a switch the guard moves a payment method the new
|
|
8
|
+
* shipping method blocks.
|
|
9
|
+
*/
|
|
10
|
+
export function useOrderMode() {
|
|
11
|
+
const {
|
|
12
|
+
shippingMethods,
|
|
13
|
+
getShippingMethods,
|
|
14
|
+
selectedShippingMethod,
|
|
15
|
+
setShippingMethod,
|
|
16
|
+
} = useCheckout();
|
|
17
|
+
const { refreshCart } = useCart();
|
|
18
|
+
const { ensureAvailableCheckoutMethods } = useCheckoutMethodGuard();
|
|
19
|
+
|
|
20
|
+
const switching = ref(false);
|
|
21
|
+
|
|
22
|
+
const options = computed(() =>
|
|
23
|
+
(shippingMethods.value ?? []).map((method: Schemas["ShippingMethod"]) => ({
|
|
24
|
+
value: method.id,
|
|
25
|
+
label: method.translated?.name ?? method.name,
|
|
26
|
+
})),
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
// A segmented control fits two to four methods; with one there is
|
|
30
|
+
// nothing to choose.
|
|
31
|
+
const selectable = computed(
|
|
32
|
+
() => options.value.length >= 2 && options.value.length <= 4,
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
const selectedId = computed({
|
|
36
|
+
get: () => selectedShippingMethod.value?.id ?? "",
|
|
37
|
+
set: (id: string) => {
|
|
38
|
+
void select(id);
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
async function select(id: string) {
|
|
43
|
+
if (!id || id === selectedShippingMethod.value?.id || switching.value) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
switching.value = true;
|
|
47
|
+
try {
|
|
48
|
+
await setShippingMethod({ id });
|
|
49
|
+
await ensureAvailableCheckoutMethods();
|
|
50
|
+
await refreshCart();
|
|
51
|
+
} finally {
|
|
52
|
+
switching.value = false;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
async function load() {
|
|
57
|
+
try {
|
|
58
|
+
await getShippingMethods();
|
|
59
|
+
} catch (error) {
|
|
60
|
+
console.error("[menu][useOrderMode] shipping methods", error);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return { options, selectable, selectedId, switching, load };
|
|
65
|
+
}
|