@shopbite-de/storefront 1.5.2 → 1.6.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/.env.example +3 -1
- package/app/components/Address/Fields.vue +128 -0
- package/app/components/Checkout/PaymentAndDelivery.vue +49 -27
- package/app/components/Header.vue +26 -13
- package/app/components/User/LoginForm.vue +32 -11
- package/app/components/User/RegistrationForm.vue +105 -180
- package/app/composables/useAddressAutocomplete.ts +84 -0
- package/app/composables/useAddressValidation.ts +95 -0
- package/app/composables/useBusinessHours.ts +2 -1
- package/app/composables/useValidCitiesForDelivery.ts +12 -0
- package/app/validation/registrationSchema.ts +105 -124
- package/content/unternehmen/zahlung-und-versand.md +29 -0
- package/nuxt.config.ts +1 -0
- package/package.json +1 -1
- package/server/api/address/autocomplete.get.ts +33 -0
- package/test/nuxt/AddressFields.test.ts +284 -0
- package/test/nuxt/Header.test.ts +124 -0
- package/test/nuxt/LoginForm.test.ts +141 -0
- package/test/nuxt/PaymentAndDelivery.test.ts +78 -0
- package/test/nuxt/RegistrationForm.test.ts +255 -0
- package/test/nuxt/RegistrationValidation.test.ts +39 -0
- package/test/nuxt/registrationSchema.test.ts +242 -0
- package/test/nuxt/useAddressAutocomplete.test.ts +161 -0
- package/test/nuxt/useBusinessHours.test.ts +48 -0
package/.env.example
CHANGED
|
@@ -8,4 +8,6 @@ NUXT_PUBLIC_SHOPWARE_ACCESS_TOKEN="TOKEN"
|
|
|
8
8
|
NUXT_PUBLIC_SHOPWARE_COUNTRY_ID=019a17a0f67b706a8ec9ead3059e12ba
|
|
9
9
|
|
|
10
10
|
OPENAPI_ACCESS_KEY=key
|
|
11
|
-
OPENAPI_JSON_URL="https://shopware.shopbite.net"
|
|
11
|
+
OPENAPI_JSON_URL="https://shopware.shopbite.net"
|
|
12
|
+
|
|
13
|
+
NUXT_GEOAPIFY_API_KEY=
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { AddressSchema } from "~/validation/registrationSchema";
|
|
3
|
+
|
|
4
|
+
const model = defineModel<AddressSchema>({ required: true });
|
|
5
|
+
|
|
6
|
+
const props = defineProps<{
|
|
7
|
+
prefix: string;
|
|
8
|
+
accountType?: string;
|
|
9
|
+
showNames?: boolean;
|
|
10
|
+
isShipping?: boolean;
|
|
11
|
+
}>();
|
|
12
|
+
|
|
13
|
+
const { getSuggestions } = useAddressAutocomplete();
|
|
14
|
+
const { validCities } = useValidCitiesForDelivery();
|
|
15
|
+
|
|
16
|
+
const {
|
|
17
|
+
showCorrection,
|
|
18
|
+
correction,
|
|
19
|
+
isInvalidCity,
|
|
20
|
+
checkAddress,
|
|
21
|
+
applyCorrection,
|
|
22
|
+
} = useAddressValidation(model, {
|
|
23
|
+
isShipping: props.isShipping,
|
|
24
|
+
getSuggestions,
|
|
25
|
+
validCities,
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
defineExpose({
|
|
29
|
+
checkAddress,
|
|
30
|
+
showCorrection,
|
|
31
|
+
});
|
|
32
|
+
</script>
|
|
33
|
+
|
|
34
|
+
<template>
|
|
35
|
+
<div class="space-y-4">
|
|
36
|
+
<UFormField
|
|
37
|
+
v-if="accountType === 'business'"
|
|
38
|
+
label="Unternehmen"
|
|
39
|
+
:name="`${prefix}.company`"
|
|
40
|
+
>
|
|
41
|
+
<UInput v-model="model.company" type="text" class="w-full" />
|
|
42
|
+
</UFormField>
|
|
43
|
+
|
|
44
|
+
<UFormField
|
|
45
|
+
v-if="accountType === 'business'"
|
|
46
|
+
label="Abteilung"
|
|
47
|
+
:name="`${prefix}.department`"
|
|
48
|
+
>
|
|
49
|
+
<UInput v-model="model.department" type="text" class="w-full" />
|
|
50
|
+
</UFormField>
|
|
51
|
+
|
|
52
|
+
<div v-if="showNames" class="flex flex-row justify-between gap-4">
|
|
53
|
+
<UFormField
|
|
54
|
+
label="Vorname"
|
|
55
|
+
:name="`${prefix}.firstName`"
|
|
56
|
+
required
|
|
57
|
+
class="w-full"
|
|
58
|
+
>
|
|
59
|
+
<UInput v-model="model.firstName" type="text" class="w-full" />
|
|
60
|
+
</UFormField>
|
|
61
|
+
|
|
62
|
+
<UFormField
|
|
63
|
+
label="Nachname"
|
|
64
|
+
:name="`${prefix}.lastName`"
|
|
65
|
+
required
|
|
66
|
+
class="w-full"
|
|
67
|
+
>
|
|
68
|
+
<UInput v-model="model.lastName" type="text" class="w-full" />
|
|
69
|
+
</UFormField>
|
|
70
|
+
</div>
|
|
71
|
+
|
|
72
|
+
<UFormField label="Straße und Hausnr." :name="`${prefix}.street`" required>
|
|
73
|
+
<UInput v-model="model.street" type="text" class="w-full" />
|
|
74
|
+
</UFormField>
|
|
75
|
+
|
|
76
|
+
<div class="flex flex-row gap-4">
|
|
77
|
+
<UFormField label="PLZ" :name="`${prefix}.zipcode`" class="w-24">
|
|
78
|
+
<UInput v-model="model.zipcode" type="text" class="w-full" />
|
|
79
|
+
</UFormField>
|
|
80
|
+
|
|
81
|
+
<UFormField label="Ort" :name="`${prefix}.city`" required class="flex-1">
|
|
82
|
+
<UInput v-model="model.city" type="text" class="w-full" />
|
|
83
|
+
</UFormField>
|
|
84
|
+
</div>
|
|
85
|
+
|
|
86
|
+
<div v-if="showCorrection" class="flex flex-col items-center gap-2">
|
|
87
|
+
<UAlert
|
|
88
|
+
color="info"
|
|
89
|
+
variant="soft"
|
|
90
|
+
icon="i-lucide-info"
|
|
91
|
+
:title="`Meinten Sie: ${correction?.label}?`"
|
|
92
|
+
class="flex-1"
|
|
93
|
+
/>
|
|
94
|
+
<UButton
|
|
95
|
+
label="Korrigieren"
|
|
96
|
+
color="info"
|
|
97
|
+
variant="solid"
|
|
98
|
+
size="sm"
|
|
99
|
+
block
|
|
100
|
+
@click="applyCorrection"
|
|
101
|
+
/>
|
|
102
|
+
</div>
|
|
103
|
+
|
|
104
|
+
<UAlert
|
|
105
|
+
v-if="isInvalidCity"
|
|
106
|
+
color="warning"
|
|
107
|
+
variant="soft"
|
|
108
|
+
icon="i-lucide-triangle-alert"
|
|
109
|
+
>
|
|
110
|
+
<template #title>
|
|
111
|
+
An diese Adresse können wir leider nicht liefern.
|
|
112
|
+
<ULink to="/unternehmen/zahlung-und-versand">Weitere Infos.</ULink>
|
|
113
|
+
</template>
|
|
114
|
+
</UAlert>
|
|
115
|
+
|
|
116
|
+
<UFormField label="Adresszusatz" :name="`${prefix}.additionalAddressLine1`">
|
|
117
|
+
<UInput
|
|
118
|
+
v-model="model.additionalAddressLine1"
|
|
119
|
+
type="text"
|
|
120
|
+
class="w-full"
|
|
121
|
+
/>
|
|
122
|
+
</UFormField>
|
|
123
|
+
|
|
124
|
+
<UFormField label="Telefon" :name="`${prefix}.phoneNumber`" required>
|
|
125
|
+
<UInput v-model="model.phoneNumber" type="text" class="w-full" />
|
|
126
|
+
</UFormField>
|
|
127
|
+
</div>
|
|
128
|
+
</template>
|
|
@@ -41,43 +41,59 @@ const selectableShippingMethods = computed<RadioGroupItem[]>(() => {
|
|
|
41
41
|
}));
|
|
42
42
|
});
|
|
43
43
|
|
|
44
|
-
const selectedPaymentMethodId = ref<RadioGroupValue>(
|
|
45
|
-
selectedPaymentMethod.value
|
|
44
|
+
const selectedPaymentMethodId = ref<RadioGroupValue | undefined>(
|
|
45
|
+
selectedPaymentMethod.value?.id,
|
|
46
46
|
);
|
|
47
|
-
const selectedShippingMethodId = ref<RadioGroupValue>(
|
|
48
|
-
selectedShippingMethod.value
|
|
47
|
+
const selectedShippingMethodId = ref<RadioGroupValue | undefined>(
|
|
48
|
+
selectedShippingMethod.value?.id,
|
|
49
49
|
);
|
|
50
50
|
|
|
51
|
-
watch(
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
51
|
+
watch(
|
|
52
|
+
selectedPaymentMethodId,
|
|
53
|
+
async (newValue: RadioGroupValue | undefined) => {
|
|
54
|
+
if (newValue === undefined) return;
|
|
55
|
+
if (selectedPaymentMethod.value === null) return;
|
|
56
|
+
await setPaymentMethod({ id: newValue as string });
|
|
57
|
+
toast.add({
|
|
58
|
+
title: "Zahlart geändert",
|
|
59
|
+
description:
|
|
60
|
+
selectedPaymentMethod.value.distinguishableName + " ausgewählt",
|
|
61
|
+
color: "success",
|
|
62
|
+
progress: false,
|
|
63
|
+
});
|
|
64
|
+
},
|
|
65
|
+
);
|
|
61
66
|
|
|
62
|
-
watch(
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
67
|
+
watch(
|
|
68
|
+
selectedShippingMethodId,
|
|
69
|
+
async (newValue: RadioGroupValue | undefined) => {
|
|
70
|
+
if (newValue === undefined) return;
|
|
71
|
+
if (selectedShippingMethod.value === null) return;
|
|
72
|
+
await setShippingMethod({ id: newValue as string });
|
|
73
|
+
await refreshCart();
|
|
74
|
+
toast.add({
|
|
75
|
+
title: "Versandart geändert",
|
|
76
|
+
description: selectedShippingMethod.value.name + " ausgewählt",
|
|
77
|
+
color: "success",
|
|
78
|
+
progress: false,
|
|
79
|
+
});
|
|
80
|
+
},
|
|
81
|
+
);
|
|
72
82
|
</script>
|
|
73
83
|
|
|
74
84
|
<template>
|
|
75
85
|
<UContainer>
|
|
76
|
-
<div class="flex flex-col md:flex-row justify-between">
|
|
77
|
-
<div>
|
|
86
|
+
<div class="flex flex-col md:flex-row justify-between gap-4">
|
|
87
|
+
<div class="basis-1/2">
|
|
78
88
|
<div class="flex flex-row items-center gap-4">
|
|
79
89
|
<UIcon name="i-lucide-badge-euro" class="size-8" />
|
|
80
90
|
<h2 class="text-2xl text-blackish my-8">Zahlungsarten</h2>
|
|
91
|
+
<UButton
|
|
92
|
+
to="/unternehmen/zahlung-und-versand"
|
|
93
|
+
size="md"
|
|
94
|
+
variant="ghost"
|
|
95
|
+
icon="i-lucide-circle-question-mark"
|
|
96
|
+
/>
|
|
81
97
|
</div>
|
|
82
98
|
<URadioGroup
|
|
83
99
|
v-model="selectedPaymentMethodId"
|
|
@@ -85,10 +101,16 @@ watch(selectedShippingMethodId, async (newValue: RadioGroupValue) => {
|
|
|
85
101
|
variant="card"
|
|
86
102
|
/>
|
|
87
103
|
</div>
|
|
88
|
-
<div>
|
|
104
|
+
<div class="basis-1/2">
|
|
89
105
|
<div class="flex flex-row items-center gap-4">
|
|
90
106
|
<UIcon name="i-lucide-car" class="size-8" />
|
|
91
107
|
<h2 class="text-2xl text-blackish my-8">Versandarten</h2>
|
|
108
|
+
<UButton
|
|
109
|
+
to="/unternehmen/zahlung-und-versand"
|
|
110
|
+
size="md"
|
|
111
|
+
variant="ghost"
|
|
112
|
+
icon="i-lucide-circle-question-mark"
|
|
113
|
+
/>
|
|
92
114
|
</div>
|
|
93
115
|
<URadioGroup
|
|
94
116
|
v-model="selectedShippingMethodId"
|
|
@@ -6,7 +6,7 @@ import { useUser } from "@shopware/composables";
|
|
|
6
6
|
const route = useRoute();
|
|
7
7
|
const toast = useToast();
|
|
8
8
|
|
|
9
|
-
const { isLoggedIn, user, logout } = useUser();
|
|
9
|
+
const { isLoggedIn, isGuestSession, user, logout } = useUser();
|
|
10
10
|
const { isCheckoutEnabled } = useShopBiteConfig();
|
|
11
11
|
const { count } = useCart();
|
|
12
12
|
const runtimeConfig = useRuntimeConfig();
|
|
@@ -34,7 +34,7 @@ const navi = computed<NavigationMenuItem[]>(() => {
|
|
|
34
34
|
});
|
|
35
35
|
|
|
36
36
|
const accountHoverText = computed(() => {
|
|
37
|
-
return isLoggedIn.value
|
|
37
|
+
return isLoggedIn.value || isGuestSession.value
|
|
38
38
|
? `${user.value?.firstName} ${user.value?.lastName}`
|
|
39
39
|
: "Hallo";
|
|
40
40
|
});
|
|
@@ -51,15 +51,24 @@ const logoutHandler = () => {
|
|
|
51
51
|
const loggedInDropDown = computed<DropdownMenuItem[][]>(() => {
|
|
52
52
|
if (!navigationData.value?.account.loggedIn) return [];
|
|
53
53
|
|
|
54
|
-
return navigationData.value.account.loggedIn
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
54
|
+
return navigationData.value.account.loggedIn
|
|
55
|
+
.map((group) =>
|
|
56
|
+
group
|
|
57
|
+
.filter((item) => {
|
|
58
|
+
if (isGuestSession.value) {
|
|
59
|
+
return item.type === "label" || item.action === "logout";
|
|
60
|
+
}
|
|
61
|
+
return true;
|
|
62
|
+
})
|
|
63
|
+
.map((item) => ({
|
|
64
|
+
label: item.type === "label" ? accountHoverText.value : item.label,
|
|
65
|
+
type: item.type,
|
|
66
|
+
icon: item.icon,
|
|
67
|
+
to: item.to,
|
|
68
|
+
onSelect: item.action === "logout" ? logoutHandler : undefined,
|
|
69
|
+
})),
|
|
70
|
+
)
|
|
71
|
+
.filter((group) => group.length > 0);
|
|
63
72
|
});
|
|
64
73
|
|
|
65
74
|
const loggedOutDropDown = computed<DropdownMenuItem[][]>(() => {
|
|
@@ -103,8 +112,12 @@ const cartQuickViewOpen = ref(false);
|
|
|
103
112
|
icon="i-lucide-phone"
|
|
104
113
|
aria-label="Anrufen"
|
|
105
114
|
/>
|
|
106
|
-
<UDropdownMenu
|
|
107
|
-
|
|
115
|
+
<UDropdownMenu
|
|
116
|
+
:items="
|
|
117
|
+
isLoggedIn || isGuestSession ? loggedInDropDown : loggedOutDropDown
|
|
118
|
+
"
|
|
119
|
+
>
|
|
120
|
+
<UChip v-if="isLoggedIn || isGuestSession" size="3xl" text="✓">
|
|
108
121
|
<UButton icon="i-lucide-user" color="neutral" variant="outline" />
|
|
109
122
|
</UChip>
|
|
110
123
|
<UButton
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import * as z from "zod";
|
|
3
3
|
import { useWishlist, useUser } from "@shopware/composables";
|
|
4
|
+
import { ApiClientError } from "@shopware/api-client";
|
|
4
5
|
import type { FormSubmitEvent } from "@nuxt/ui";
|
|
5
6
|
|
|
6
7
|
const { isLoggedIn, login, user } = useUser();
|
|
@@ -55,17 +56,37 @@ const schema = z.object({
|
|
|
55
56
|
type Schema = z.output<typeof schema>;
|
|
56
57
|
|
|
57
58
|
async function onSubmit(payload: FormSubmitEvent<Schema>) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
59
|
+
try {
|
|
60
|
+
await login({
|
|
61
|
+
username: payload.data.email,
|
|
62
|
+
password: payload.data.password,
|
|
63
|
+
});
|
|
64
|
+
toast.add({
|
|
65
|
+
title:
|
|
66
|
+
"Hallo " + user.value?.firstName + " " + user.value?.lastName + "!",
|
|
67
|
+
description: "Erfolreich angemeldet.",
|
|
68
|
+
color: "success",
|
|
69
|
+
});
|
|
70
|
+
mergeWishlistProducts();
|
|
71
|
+
emit("login-success", payload.data.email);
|
|
72
|
+
} catch (error) {
|
|
73
|
+
console.error("Login failed:", error);
|
|
74
|
+
let description = "Bitte überprüfen Sie Ihre Zugangsdaten.";
|
|
75
|
+
if (error instanceof ApiClientError) {
|
|
76
|
+
const errors = error.details?.errors;
|
|
77
|
+
if (Array.isArray(errors) && errors.length > 0) {
|
|
78
|
+
description = errors
|
|
79
|
+
.map((e) => e.detail || e.title)
|
|
80
|
+
.filter(Boolean)
|
|
81
|
+
.join("\n");
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
toast.add({
|
|
85
|
+
title: "Login fehlgeschlagen",
|
|
86
|
+
description,
|
|
87
|
+
color: "error",
|
|
88
|
+
});
|
|
89
|
+
}
|
|
69
90
|
}
|
|
70
91
|
</script>
|
|
71
92
|
|