@shopbite-de/storefront 1.5.3 → 1.6.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.
Files changed (35) hide show
  1. package/.env.example +6 -1
  2. package/LICENSE +21 -0
  3. package/README.md +81 -0
  4. package/app/components/Address/Fields.vue +128 -0
  5. package/app/components/Checkout/PaymentAndDelivery.vue +49 -27
  6. package/app/components/Header.vue +26 -13
  7. package/app/components/User/LoginForm.vue +32 -11
  8. package/app/components/User/RegistrationForm.vue +105 -180
  9. package/app/composables/useAddressAutocomplete.ts +84 -0
  10. package/app/composables/useAddressValidation.ts +95 -0
  11. package/app/composables/useValidCitiesForDelivery.ts +12 -0
  12. package/app/pages/[...all].vue +28 -0
  13. package/app/pages/index.vue +4 -0
  14. package/app/pages/menu/[...all].vue +52 -0
  15. package/app/validation/registrationSchema.ts +105 -124
  16. package/content/{unternehmen/impressum.md → impressum.md} +5 -0
  17. package/content/index.yml +2 -1
  18. package/content/unternehmen/agb.md +5 -0
  19. package/content/unternehmen/datenschutz.md +5 -0
  20. package/content/unternehmen/zahlung-und-versand.md +34 -0
  21. package/content.config.ts +6 -2
  22. package/eslint.config.mjs +5 -3
  23. package/nuxt.config.ts +33 -22
  24. package/package.json +2 -1
  25. package/public/card.png +0 -0
  26. package/server/api/address/autocomplete.get.ts +33 -0
  27. package/test/nuxt/AddressFields.test.ts +284 -0
  28. package/test/nuxt/Header.test.ts +124 -0
  29. package/test/nuxt/LoginForm.test.ts +141 -0
  30. package/test/nuxt/PaymentAndDelivery.test.ts +78 -0
  31. package/test/nuxt/RegistrationForm.test.ts +255 -0
  32. package/test/nuxt/RegistrationValidation.test.ts +39 -0
  33. package/test/nuxt/registrationSchema.test.ts +242 -0
  34. package/test/nuxt/useAddressAutocomplete.test.ts +161 -0
  35. package/app/pages/unternehmen/[slug].vue +0 -66
package/.env.example CHANGED
@@ -8,4 +8,9 @@ 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=
14
+
15
+ NUXT_PUBLIC_SCRIPTS_MATOMO_ANALYTICS_MATOMO_URL=
16
+ NUXT_PUBLIC_SCRIPTS_MATOMO_ANALYTICS_SITE_ID=
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 @veliu
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,81 @@
1
+ # @shopbite-de/storefront
2
+
3
+ Shopware storefront for food delivery shops, built with Nuxt 4 and Vue 3.
4
+
5
+ This is a Nuxt project based on [shopware/frontends](https://github.com/shopware/frontends) to provide a cutting-edge frontend store based on Shopware 6.
6
+
7
+ ## Features
8
+
9
+ - Built with Nuxt 4 and Vue 3
10
+ - Based on shopware/frontends
11
+ - Integration with Shopware Store API (Shopware 6)
12
+ - Tailwind CSS and Nuxt UI
13
+ - PWA support
14
+
15
+ ## Prerequisites
16
+
17
+ - Node.js (latest LTS recommended)
18
+ - pnpm 10+
19
+ - [Shopbite Shopware Plugin](https://github.com/shopbite-de/shopware-plugin) (required to enable all features)
20
+
21
+ ## Setup
22
+
23
+ Install the dependencies:
24
+
25
+ ```bash
26
+ pnpm install
27
+ ```
28
+
29
+ ## Development
30
+
31
+ Start the development server on `http://localhost:3000`:
32
+
33
+ ```bash
34
+ pnpm dev
35
+ ```
36
+
37
+ ## Production
38
+
39
+ Build the application for production:
40
+
41
+ ```bash
42
+ pnpm build
43
+ ```
44
+
45
+ Locally preview production build:
46
+
47
+ ```bash
48
+ pnpm preview
49
+ ```
50
+
51
+ ## Testing
52
+
53
+ Run unit tests:
54
+
55
+ ```bash
56
+ pnpm test:unit
57
+ ```
58
+
59
+ Run E2E tests:
60
+
61
+ ```bash
62
+ pnpm test:e2e
63
+ ```
64
+
65
+ ## Linting
66
+
67
+ Check code quality:
68
+
69
+ ```bash
70
+ pnpm eslint
71
+ ```
72
+
73
+ Fix linting issues:
74
+
75
+ ```bash
76
+ pnpm lint:fix
77
+ ```
78
+
79
+ ## License
80
+
81
+ [MIT](./LICENSE)
@@ -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.id,
44
+ const selectedPaymentMethodId = ref<RadioGroupValue | undefined>(
45
+ selectedPaymentMethod.value?.id,
46
46
  );
47
- const selectedShippingMethodId = ref<RadioGroupValue>(
48
- selectedShippingMethod.value.id,
47
+ const selectedShippingMethodId = ref<RadioGroupValue | undefined>(
48
+ selectedShippingMethod.value?.id,
49
49
  );
50
50
 
51
- watch(selectedPaymentMethodId, async (newValue: RadioGroupValue) => {
52
- await setPaymentMethod({ id: newValue as string });
53
- toast.add({
54
- title: "Zahlart geändert",
55
- description:
56
- selectedPaymentMethod.value.distinguishableName + " ausgewählt",
57
- color: "success",
58
- progress: false,
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(selectedShippingMethodId, async (newValue: RadioGroupValue) => {
63
- await setShippingMethod({ id: newValue as string });
64
- await refreshCart();
65
- toast.add({
66
- title: "Versandart geändert",
67
- description: selectedShippingMethod.value.name + " ausgewählt",
68
- color: "success",
69
- progress: false,
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.map((group) =>
55
- group.map((item) => ({
56
- label: item.type === "label" ? accountHoverText.value : item.label,
57
- type: item.type,
58
- icon: item.icon,
59
- to: item.to,
60
- onSelect: item.action === "logout" ? logoutHandler : undefined,
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 :items="isLoggedIn ? loggedInDropDown : loggedOutDropDown">
107
- <UChip v-if="isLoggedIn" size="3xl" text="✓">
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
- await login({
59
- username: payload.data.email,
60
- password: payload.data.password,
61
- });
62
- toast.add({
63
- title: "Hallo " + user.value.firstName + " " + user.value.lastName + "!",
64
- description: "Erfolreich angemeldet.",
65
- color: "success",
66
- });
67
- mergeWishlistProducts();
68
- emit("login-success", payload.data.email);
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