@shopbite-de/storefront 1.31.3 → 2.0.0
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 +54 -0
- package/CLAUDE.md +23 -8
- package/app/app.vue +10 -6
- package/app/assets/css/main.css +100 -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 +15 -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 +115 -0
- package/nuxt.config.ts +27 -15
- 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/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,22 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import type { AddressSchema } from "~/validation/registrationSchema";
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Address fields of the presets (#443): the same model, autocomplete
|
|
6
|
+
* check and correction as Address/Fields.vue, with the base components.
|
|
7
|
+
* `errors` maps "<prefix>.<field>" to the message of the failed check;
|
|
8
|
+
* every input carries its `autocomplete` token, so browsers can fill it.
|
|
9
|
+
*/
|
|
4
10
|
const model = defineModel<AddressSchema>({ required: true });
|
|
5
11
|
|
|
6
|
-
defineProps<{
|
|
12
|
+
const props = defineProps<{
|
|
7
13
|
prefix: string;
|
|
8
14
|
accountType?: string;
|
|
9
15
|
showNames?: boolean;
|
|
16
|
+
errors?: Record<string, string>;
|
|
10
17
|
}>();
|
|
11
18
|
|
|
12
19
|
const { getSuggestions } = useAddressAutocomplete();
|
|
13
|
-
|
|
14
20
|
const {
|
|
15
21
|
showCorrection,
|
|
16
22
|
correction,
|
|
@@ -19,93 +25,189 @@ const {
|
|
|
19
25
|
applyCorrection,
|
|
20
26
|
} = useAddressValidation(model, { getSuggestions });
|
|
21
27
|
|
|
22
|
-
defineExpose({
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
28
|
+
defineExpose({ checkAddress, flushPendingCheck, showCorrection });
|
|
29
|
+
|
|
30
|
+
// The address group for autocomplete: "shipping" or "billing".
|
|
31
|
+
const section = computed(() =>
|
|
32
|
+
props.prefix === "shippingAddress" ? "shipping" : "billing",
|
|
33
|
+
);
|
|
34
|
+
const fieldId = (name: string) => `${props.prefix}-${name}`;
|
|
35
|
+
const error = (name: string) => props.errors?.[`${props.prefix}.${name}`];
|
|
27
36
|
</script>
|
|
28
37
|
|
|
29
38
|
<template>
|
|
30
|
-
<div class="
|
|
31
|
-
<
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
39
|
+
<div class="grid grid-cols-1 gap-4 sm:grid-cols-6">
|
|
40
|
+
<template v-if="accountType === 'business'">
|
|
41
|
+
<SbField
|
|
42
|
+
:id="fieldId('company')"
|
|
43
|
+
v-slot="{ id, describedBy, invalid }"
|
|
44
|
+
label="Unternehmen"
|
|
45
|
+
:error="error('company')"
|
|
46
|
+
class="sm:col-span-3"
|
|
47
|
+
>
|
|
48
|
+
<SbInput
|
|
49
|
+
:id="id"
|
|
50
|
+
v-model="model.company"
|
|
51
|
+
:name="`${prefix}.company`"
|
|
52
|
+
:autocomplete="`${section} organization`"
|
|
53
|
+
:aria-describedby="describedBy"
|
|
54
|
+
:invalid="invalid"
|
|
55
|
+
/>
|
|
56
|
+
</SbField>
|
|
57
|
+
<SbField
|
|
58
|
+
:id="fieldId('department')"
|
|
59
|
+
v-slot="{ id, describedBy, invalid }"
|
|
60
|
+
label="Abteilung"
|
|
61
|
+
optional
|
|
62
|
+
:error="error('department')"
|
|
63
|
+
class="sm:col-span-3"
|
|
64
|
+
>
|
|
65
|
+
<SbInput
|
|
66
|
+
:id="id"
|
|
67
|
+
v-model="model.department"
|
|
68
|
+
:name="`${prefix}.department`"
|
|
69
|
+
:aria-describedby="describedBy"
|
|
70
|
+
:invalid="invalid"
|
|
71
|
+
/>
|
|
72
|
+
</SbField>
|
|
73
|
+
</template>
|
|
46
74
|
|
|
47
|
-
<
|
|
48
|
-
<
|
|
75
|
+
<template v-if="showNames">
|
|
76
|
+
<SbField
|
|
77
|
+
:id="fieldId('firstName')"
|
|
78
|
+
v-slot="{ id, describedBy, invalid }"
|
|
49
79
|
label="Vorname"
|
|
50
|
-
:
|
|
51
|
-
|
|
52
|
-
class="w-full"
|
|
80
|
+
:error="error('firstName')"
|
|
81
|
+
class="sm:col-span-3"
|
|
53
82
|
>
|
|
54
|
-
<
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
83
|
+
<SbInput
|
|
84
|
+
:id="id"
|
|
85
|
+
v-model="model.firstName"
|
|
86
|
+
:name="`${prefix}.firstName`"
|
|
87
|
+
:autocomplete="`${section} given-name`"
|
|
88
|
+
:aria-describedby="describedBy"
|
|
89
|
+
:invalid="invalid"
|
|
90
|
+
/>
|
|
91
|
+
</SbField>
|
|
92
|
+
<SbField
|
|
93
|
+
:id="fieldId('lastName')"
|
|
94
|
+
v-slot="{ id, describedBy, invalid }"
|
|
58
95
|
label="Nachname"
|
|
59
|
-
:
|
|
60
|
-
|
|
61
|
-
class="w-full"
|
|
96
|
+
:error="error('lastName')"
|
|
97
|
+
class="sm:col-span-3"
|
|
62
98
|
>
|
|
63
|
-
<
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
99
|
+
<SbInput
|
|
100
|
+
:id="id"
|
|
101
|
+
v-model="model.lastName"
|
|
102
|
+
:name="`${prefix}.lastName`"
|
|
103
|
+
:autocomplete="`${section} family-name`"
|
|
104
|
+
:aria-describedby="describedBy"
|
|
105
|
+
:invalid="invalid"
|
|
106
|
+
/>
|
|
107
|
+
</SbField>
|
|
108
|
+
</template>
|
|
70
109
|
|
|
71
|
-
<
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
110
|
+
<SbField
|
|
111
|
+
:id="fieldId('street')"
|
|
112
|
+
v-slot="{ id, describedBy, invalid }"
|
|
113
|
+
label="Straße und Hausnummer"
|
|
114
|
+
:error="error('street')"
|
|
115
|
+
class="sm:col-span-6"
|
|
116
|
+
>
|
|
117
|
+
<SbInput
|
|
118
|
+
:id="id"
|
|
119
|
+
v-model="model.street"
|
|
120
|
+
:name="`${prefix}.street`"
|
|
121
|
+
:autocomplete="`${section} address-line1`"
|
|
122
|
+
:aria-describedby="describedBy"
|
|
123
|
+
:invalid="invalid"
|
|
124
|
+
/>
|
|
125
|
+
</SbField>
|
|
80
126
|
|
|
81
|
-
<
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
127
|
+
<SbField
|
|
128
|
+
:id="fieldId('zipcode')"
|
|
129
|
+
v-slot="{ id, describedBy, invalid }"
|
|
130
|
+
label="PLZ"
|
|
131
|
+
:error="error('zipcode')"
|
|
132
|
+
class="sm:col-span-2"
|
|
133
|
+
>
|
|
134
|
+
<SbInput
|
|
135
|
+
:id="id"
|
|
136
|
+
v-model="model.zipcode"
|
|
137
|
+
:name="`${prefix}.zipcode`"
|
|
138
|
+
inputmode="numeric"
|
|
139
|
+
:autocomplete="`${section} postal-code`"
|
|
140
|
+
:aria-describedby="describedBy"
|
|
141
|
+
:invalid="invalid"
|
|
88
142
|
/>
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
143
|
+
</SbField>
|
|
144
|
+
<SbField
|
|
145
|
+
:id="fieldId('city')"
|
|
146
|
+
v-slot="{ id, describedBy, invalid }"
|
|
147
|
+
label="Ort"
|
|
148
|
+
:error="error('city')"
|
|
149
|
+
class="sm:col-span-4"
|
|
150
|
+
>
|
|
151
|
+
<SbInput
|
|
152
|
+
:id="id"
|
|
153
|
+
v-model="model.city"
|
|
154
|
+
:name="`${prefix}.city`"
|
|
155
|
+
:autocomplete="`${section} address-level2`"
|
|
156
|
+
:aria-describedby="describedBy"
|
|
157
|
+
:invalid="invalid"
|
|
96
158
|
/>
|
|
159
|
+
</SbField>
|
|
160
|
+
|
|
161
|
+
<div
|
|
162
|
+
v-if="showCorrection"
|
|
163
|
+
role="status"
|
|
164
|
+
class="flex flex-col gap-3 rounded-sb-control bg-sb-primary-tint p-4 font-body text-sb-ink sm:col-span-6 sm:flex-row sm:items-center sm:justify-between"
|
|
165
|
+
>
|
|
166
|
+
<span>
|
|
167
|
+
Meinten Sie: <strong>{{ correction?.label }}</strong
|
|
168
|
+
>?
|
|
169
|
+
</span>
|
|
170
|
+
<SbButton variant="secondary" @click="applyCorrection"
|
|
171
|
+
>Übernehmen</SbButton
|
|
172
|
+
>
|
|
97
173
|
</div>
|
|
98
174
|
|
|
99
|
-
<
|
|
100
|
-
|
|
175
|
+
<SbField
|
|
176
|
+
:id="fieldId('additionalAddressLine1')"
|
|
177
|
+
v-slot="{ id, describedBy, invalid }"
|
|
178
|
+
label="Adresszusatz"
|
|
179
|
+
hint="z. B. Hinterhaus, 2. Stock, Name am Klingelschild"
|
|
180
|
+
optional
|
|
181
|
+
:error="error('additionalAddressLine1')"
|
|
182
|
+
class="sm:col-span-6"
|
|
183
|
+
>
|
|
184
|
+
<SbInput
|
|
185
|
+
:id="id"
|
|
101
186
|
v-model="model.additionalAddressLine1"
|
|
102
|
-
|
|
103
|
-
|
|
187
|
+
:name="`${prefix}.additionalAddressLine1`"
|
|
188
|
+
:autocomplete="`${section} address-line2`"
|
|
189
|
+
:aria-describedby="describedBy"
|
|
190
|
+
:invalid="invalid"
|
|
104
191
|
/>
|
|
105
|
-
</
|
|
192
|
+
</SbField>
|
|
106
193
|
|
|
107
|
-
<
|
|
108
|
-
|
|
109
|
-
|
|
194
|
+
<SbField
|
|
195
|
+
:id="fieldId('phoneNumber')"
|
|
196
|
+
v-slot="{ id, describedBy, invalid }"
|
|
197
|
+
label="Telefon"
|
|
198
|
+
hint="Nur für Rückfragen zur Bestellung"
|
|
199
|
+
:error="error('phoneNumber')"
|
|
200
|
+
class="sm:col-span-6"
|
|
201
|
+
>
|
|
202
|
+
<SbInput
|
|
203
|
+
:id="id"
|
|
204
|
+
v-model="model.phoneNumber"
|
|
205
|
+
:name="`${prefix}.phoneNumber`"
|
|
206
|
+
type="tel"
|
|
207
|
+
:autocomplete="`${section} tel`"
|
|
208
|
+
:aria-describedby="describedBy"
|
|
209
|
+
:invalid="invalid"
|
|
210
|
+
/>
|
|
211
|
+
</SbField>
|
|
110
212
|
</div>
|
|
111
213
|
</template>
|
|
@@ -1,128 +1,129 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
import * as z from "zod";
|
|
2
3
|
import type { Schemas } from "#shopware";
|
|
3
4
|
import { useAddress } from "@shopware/composables";
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
import {
|
|
6
|
+
baseAddressSchema,
|
|
7
|
+
type AddressSchema,
|
|
8
|
+
} from "~/validation/registrationSchema";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Create or edit a customer address in the presets (#445): the address
|
|
12
|
+
* fields of the checkout (`AddressFields`), checked with the same
|
|
13
|
+
* rules on submit. Errors show at the fields, the first one gets focus.
|
|
14
|
+
*/
|
|
9
15
|
const props = defineProps<{
|
|
10
|
-
address?: Schemas["CustomerAddress"]
|
|
16
|
+
address?: Schemas["CustomerAddress"];
|
|
11
17
|
}>();
|
|
12
18
|
|
|
13
|
-
const
|
|
19
|
+
const emit = defineEmits<{
|
|
20
|
+
"submit-success": [data: Schemas["CustomerAddress"]];
|
|
21
|
+
}>();
|
|
22
|
+
|
|
23
|
+
const { site } = useRuntimeConfig().public;
|
|
14
24
|
const { updateCustomerAddress, createCustomerAddress } = useAddress();
|
|
15
25
|
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
firstName: props.address?.firstName ??
|
|
19
|
-
lastName: props.address?.lastName ??
|
|
20
|
-
company: props.address?.company ??
|
|
21
|
-
department: props.address?.department ??
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
const isBusiness = ref(Boolean(props.address?.company));
|
|
27
|
+
const model = ref<AddressSchema>({
|
|
28
|
+
firstName: props.address?.firstName ?? "",
|
|
29
|
+
lastName: props.address?.lastName ?? "",
|
|
30
|
+
company: props.address?.company ?? "",
|
|
31
|
+
department: props.address?.department ?? "",
|
|
32
|
+
street: props.address?.street ?? "",
|
|
33
|
+
additionalAddressLine1: props.address?.additionalAddressLine1 ?? "",
|
|
34
|
+
zipcode: props.address?.zipcode ?? "",
|
|
35
|
+
city: props.address?.city ?? "",
|
|
36
|
+
countryId: props.address?.countryId ?? site.countryId,
|
|
37
|
+
phoneNumber: props.address?.phoneNumber ?? "",
|
|
28
38
|
});
|
|
29
39
|
|
|
30
|
-
const schema = computed(() =>
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
40
|
+
const schema = computed(() =>
|
|
41
|
+
baseAddressSchema
|
|
42
|
+
.extend({
|
|
43
|
+
firstName: z
|
|
44
|
+
.string()
|
|
45
|
+
.min(1, { message: "Bitte geben Sie den Vornamen an." }),
|
|
46
|
+
lastName: z
|
|
47
|
+
.string()
|
|
48
|
+
.min(1, { message: "Bitte geben Sie den Nachnamen an." }),
|
|
49
|
+
zipcode: z
|
|
50
|
+
.string()
|
|
51
|
+
.min(1, { message: "Bitte geben Sie die Postleitzahl an." }),
|
|
52
|
+
})
|
|
53
|
+
.refine((data) => !isBusiness.value || Boolean(data.company), {
|
|
54
|
+
message: "Bitte geben Sie den Firmennamen an.",
|
|
55
|
+
path: ["company"],
|
|
56
|
+
}),
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
const PREFIX = "shippingAddress";
|
|
60
|
+
const errors = ref<Record<string, string>>({});
|
|
61
|
+
const saveError = ref(false);
|
|
62
|
+
const saving = ref(false);
|
|
63
|
+
const form = ref<HTMLFormElement | null>(null);
|
|
64
|
+
|
|
65
|
+
async function onSubmit() {
|
|
66
|
+
saveError.value = false;
|
|
67
|
+
const result = schema.value.safeParse(model.value);
|
|
68
|
+
if (!result.success) {
|
|
69
|
+
const next: Record<string, string> = {};
|
|
70
|
+
for (const issue of result.error.issues) {
|
|
71
|
+
const key = `${PREFIX}.${issue.path.join(".")}`;
|
|
72
|
+
next[key] ??= issue.message;
|
|
44
73
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
74
|
+
errors.value = next;
|
|
75
|
+
await nextTick();
|
|
76
|
+
form.value?.querySelector<HTMLElement>('[aria-invalid="true"]')?.focus();
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
errors.value = {};
|
|
80
|
+
saving.value = true;
|
|
81
|
+
try {
|
|
82
|
+
const data = {
|
|
83
|
+
...result.data,
|
|
84
|
+
company: isBusiness.value ? result.data.company : "",
|
|
85
|
+
department: isBusiness.value ? result.data.department : "",
|
|
86
|
+
} as unknown as Parameters<typeof updateCustomerAddress>[0];
|
|
87
|
+
const saved = props.address?.id
|
|
88
|
+
? await updateCustomerAddress({ ...data, id: props.address.id })
|
|
89
|
+
: await createCustomerAddress(data);
|
|
90
|
+
emit("submit-success", saved);
|
|
51
91
|
} catch (error) {
|
|
52
92
|
console.error("Address save failed:", error);
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
color: "error",
|
|
57
|
-
});
|
|
93
|
+
saveError.value = true;
|
|
94
|
+
} finally {
|
|
95
|
+
saving.value = false;
|
|
58
96
|
}
|
|
59
97
|
}
|
|
60
|
-
|
|
61
|
-
const accountType = ref("privat");
|
|
62
|
-
|
|
63
|
-
const emit = defineEmits<{
|
|
64
|
-
"submit-success": [data: Schemas["CustomerAddress"]];
|
|
65
|
-
}>();
|
|
66
98
|
</script>
|
|
67
99
|
|
|
68
100
|
<template>
|
|
69
|
-
<
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
class="
|
|
73
|
-
@submit="onSubmit"
|
|
74
|
-
@error="(error) => console.log('Form validation error:', error)"
|
|
101
|
+
<form
|
|
102
|
+
ref="form"
|
|
103
|
+
novalidate
|
|
104
|
+
class="flex flex-col gap-4 font-body text-sb-ink"
|
|
105
|
+
@submit.prevent="onSubmit"
|
|
75
106
|
>
|
|
76
|
-
<
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
</UFormField>
|
|
81
|
-
|
|
82
|
-
<UFormField label="Nachname" name="lastName">
|
|
83
|
-
<UInput v-model="state.lastName" type="text" class="w-full" />
|
|
84
|
-
</UFormField>
|
|
85
|
-
|
|
86
|
-
<UFormField
|
|
87
|
-
v-if="accountType === 'commercial'"
|
|
88
|
-
label="Unternehmen"
|
|
89
|
-
name="company"
|
|
107
|
+
<div
|
|
108
|
+
v-if="saveError"
|
|
109
|
+
role="alert"
|
|
110
|
+
class="rounded-sb-control border-[1.5px] border-sb-danger p-4 text-sm"
|
|
90
111
|
>
|
|
91
|
-
<
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
112
|
+
<strong class="block"
|
|
113
|
+
>Die Adresse konnte nicht gespeichert werden.</strong
|
|
114
|
+
>
|
|
115
|
+
Bitte versuchen Sie es noch einmal.
|
|
116
|
+
</div>
|
|
117
|
+
<SbCheckbox v-model="isBusiness" label="Firmenadresse" plain />
|
|
118
|
+
<AddressFields
|
|
119
|
+
v-model="model"
|
|
120
|
+
:prefix="PREFIX"
|
|
121
|
+
:account-type="isBusiness ? 'business' : 'private'"
|
|
122
|
+
show-names
|
|
123
|
+
:errors="errors"
|
|
124
|
+
/>
|
|
125
|
+
<SbButton type="submit" size="lg" block :loading="saving"
|
|
126
|
+
>Adresse speichern</SbButton
|
|
98
127
|
>
|
|
99
|
-
|
|
100
|
-
</UFormField>
|
|
101
|
-
|
|
102
|
-
<UFormField label="Straße und Hausnr." name="street">
|
|
103
|
-
<UInput v-model="state.street" type="text" class="w-full" />
|
|
104
|
-
</UFormField>
|
|
105
|
-
|
|
106
|
-
<UFormField label="Zusatz" name="additionalAddressLine1">
|
|
107
|
-
<UInput
|
|
108
|
-
v-model="state.additionalAddressLine1"
|
|
109
|
-
type="text"
|
|
110
|
-
class="w-full"
|
|
111
|
-
/>
|
|
112
|
-
</UFormField>
|
|
113
|
-
|
|
114
|
-
<UFormField label="Postleitzahl" name="zipcode">
|
|
115
|
-
<UInput v-model="state.zipcode" type="text" class="w-full" />
|
|
116
|
-
</UFormField>
|
|
117
|
-
|
|
118
|
-
<UFormField label="Ort" name="city">
|
|
119
|
-
<UInput v-model="state.city" type="text" class="w-full" />
|
|
120
|
-
</UFormField>
|
|
121
|
-
|
|
122
|
-
<UFormField label="Telefon" name="phoneNumber">
|
|
123
|
-
<UInput v-model="state.phoneNumber" type="phone" class="w-full" />
|
|
124
|
-
</UFormField>
|
|
125
|
-
|
|
126
|
-
<UButton type="submit" block label="Speichern" />
|
|
127
|
-
</UForm>
|
|
128
|
+
</form>
|
|
128
129
|
</template>
|
|
@@ -59,14 +59,14 @@ onBeforeUnmount(() => clearTimeout(addedTimer));
|
|
|
59
59
|
<button
|
|
60
60
|
:key="popKey"
|
|
61
61
|
type="button"
|
|
62
|
-
class="flex h-14 w-full items-center gap-3 rounded-
|
|
62
|
+
class="flex h-14 w-full items-center gap-3 rounded-sb-card bg-sb-primary px-4 font-body text-sb-on-primary shadow-lg transition-colors hover:bg-sb-primary-hover focus-visible:outline-3 focus-visible:outline-offset-2 focus-visible:outline-sb-focus"
|
|
63
63
|
:class="{ 'motion-safe:animate-cart-pop': popKey > 0 }"
|
|
64
64
|
aria-haspopup="dialog"
|
|
65
65
|
aria-live="polite"
|
|
66
66
|
data-testid="cart-bar"
|
|
67
67
|
@click="show"
|
|
68
68
|
>
|
|
69
|
-
<
|
|
69
|
+
<SbIcon name="bag" :size="24" />
|
|
70
70
|
<span class="flex min-w-0 flex-1 items-baseline gap-2 text-left">
|
|
71
71
|
<Transition
|
|
72
72
|
mode="out-in"
|
|
@@ -80,22 +80,19 @@ onBeforeUnmount(() => clearTimeout(addedTimer));
|
|
|
80
80
|
key="added"
|
|
81
81
|
class="flex min-w-0 items-baseline gap-2"
|
|
82
82
|
>
|
|
83
|
-
<
|
|
84
|
-
name="i-lucide-check"
|
|
85
|
-
class="size-4 shrink-0 self-center"
|
|
86
|
-
/>
|
|
83
|
+
<SbIcon name="check" :size="16" class="self-center" />
|
|
87
84
|
<span class="truncate font-semibold">{{ addedLabel }}</span>
|
|
88
|
-
<span class="shrink-0 text-sm
|
|
85
|
+
<span class="shrink-0 text-sm">hinzugefügt</span>
|
|
89
86
|
</span>
|
|
90
87
|
<span v-else key="cart" class="flex min-w-0 items-baseline gap-2">
|
|
91
88
|
<span class="font-semibold">Warenkorb</span>
|
|
92
|
-
<span class="truncate text-sm
|
|
89
|
+
<span class="truncate text-sm">
|
|
93
90
|
{{ itemsLabel }} · {{ getFormattedPrice(subtotal) }}
|
|
94
91
|
</span>
|
|
95
92
|
</span>
|
|
96
93
|
</Transition>
|
|
97
94
|
</span>
|
|
98
|
-
<
|
|
95
|
+
<SbIcon name="chevron-up" :size="20" />
|
|
99
96
|
</button>
|
|
100
97
|
</div>
|
|
101
98
|
</Transition>
|