@shopbite-de/storefront 1.24.0 → 1.26.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.
Files changed (96) hide show
  1. package/.env.example +3 -0
  2. package/CLAUDE.md +10 -3
  3. package/README.md +0 -1
  4. package/app/app.config.ts +3 -2
  5. package/app/app.vue +4 -1
  6. package/app/assets/css/main.css +16 -0
  7. package/app/components/AddToWishlist.vue +13 -6
  8. package/app/components/Cart/Bar.vue +102 -0
  9. package/app/components/Cart/QuickView.vue +4 -0
  10. package/app/components/Cart/Upsell.vue +106 -0
  11. package/app/components/Category/Listing.vue +11 -3
  12. package/app/components/Checkout/DeliveryTimeSelect.vue +28 -2
  13. package/app/components/Checkout/Summary.vue +25 -3
  14. package/app/components/DemoBanner.vue +13 -0
  15. package/app/components/Feature/Card.vue +121 -0
  16. package/app/components/Features.vue +14 -9
  17. package/app/components/Footer/Contact.vue +5 -1
  18. package/app/components/Header/Right.vue +44 -15
  19. package/app/components/Hero.vue +126 -36
  20. package/app/components/Product/Card.vue +102 -50
  21. package/app/components/Product/CardCompact.vue +72 -0
  22. package/app/components/Product/CardDietBadges.vue +38 -31
  23. package/app/components/Product/CardIngredients.vue +35 -0
  24. package/app/components/Product/CardSkeleton.vue +10 -18
  25. package/app/components/Product/Category.vue +9 -2
  26. package/app/components/Product/Configurator.vue +11 -7
  27. package/app/components/Product/CrossSelling.vue +45 -34
  28. package/app/components/Product/DeselectIngredient.vue +37 -31
  29. package/app/components/Product/Detail.vue +73 -13
  30. package/app/components/Product/QuickView.vue +77 -0
  31. package/app/components/Topseller.vue +44 -34
  32. package/app/composables/useAddToCart.ts +3 -30
  33. package/app/composables/useBusinessHours.ts +10 -3
  34. package/app/composables/useCartQuickView.ts +19 -0
  35. package/app/composables/useCartUpsell.ts +100 -0
  36. package/app/composables/useCategorySeo.ts +5 -4
  37. package/app/composables/useHolidays.ts +7 -3
  38. package/app/composables/useOpeningHoursData.ts +53 -0
  39. package/app/composables/useProductCartQuantity.ts +15 -0
  40. package/app/composables/useProductCrossSelling.ts +1 -0
  41. package/app/composables/useProductDetail.ts +15 -1
  42. package/app/composables/useProductEvents.ts +30 -0
  43. package/app/composables/useProductQuickView.ts +65 -0
  44. package/app/composables/useTopSellers.ts +22 -0
  45. package/app/composables/useTrackEvent.ts +7 -0
  46. package/app/pages/bestellung/bestaetigen.vue +0 -3
  47. package/app/pages/bestellung/warenkorb.vue +0 -3
  48. package/app/pages/bestellung/zahlung-versand.vue +0 -3
  49. package/app/pages/bestellung.vue +22 -14
  50. package/app/pages/index.vue +3 -1
  51. package/app/pages/suche.vue +18 -5
  52. package/app/types/Association.d.ts +1 -0
  53. package/app/utils/openingHours.ts +31 -8
  54. package/app/utils/product.ts +31 -0
  55. package/app/utils/retry.ts +17 -0
  56. package/content/index.yml +16 -11
  57. package/content.config.ts +13 -0
  58. package/docs/notes/2026-09-12-issue-319-stylesheet-cost.md +154 -0
  59. package/docs/notes/2026-09-12-issue-325-product-card.md +100 -0
  60. package/docs/notes/2026-09-12-issue-327-home-hero.md +64 -0
  61. package/docs/notes/2026-09-13-demo-banner.md +32 -0
  62. package/docs/notes/2026-09-13-issue-332-home-info-cards.md +46 -0
  63. package/docs/notes/2026-09-13-quick-view-flicker.md +65 -0
  64. package/docs/notes/2026-09-14-cart-upsell.md +105 -0
  65. package/docs/notes/2026-09-14-demo-noindex.md +57 -0
  66. package/docs/notes/2026-09-16-issue-339-checkout-hydration.md +49 -0
  67. package/docs/notes/2026-09-16-issue-349-order-button-loading.md +39 -0
  68. package/docs/notes/2026-09-16-issue-350-remove-pinia.md +41 -0
  69. package/docs/notes/2026-09-16-issue-355-opening-hours-error.md +57 -0
  70. package/nuxt.config.ts +25 -2
  71. package/package.json +2 -3
  72. package/scripts/perf/first-render.mjs +30 -0
  73. package/scripts/perf/h2-proxy.cjs +49 -0
  74. package/scripts/perf/lighthouse.sh +22 -0
  75. package/scripts/perf/quick-view-layout.mjs +126 -0
  76. package/server/api/listing/[categoryId].get.ts +2 -0
  77. package/server/api/search.get.ts +2 -0
  78. package/test/e2e/simple-checkout-as-recurring-customer.test.ts +13 -17
  79. package/test/nuxt/CartBar.test.ts +110 -0
  80. package/test/nuxt/CartUpsell.test.ts +125 -0
  81. package/test/nuxt/CheckoutSummary.test.ts +127 -0
  82. package/test/nuxt/DemoBanner.test.ts +12 -0
  83. package/test/nuxt/useAddToCart.test.ts +6 -19
  84. package/test/nuxt/useCartUpsell.test.ts +126 -0
  85. package/test/nuxt/useOpeningHoursData.test.ts +120 -0
  86. package/test/nuxt/useTrackEvent.test.ts +15 -0
  87. package/test/unit/openingHours.spec.ts +32 -1
  88. package/test/unit/product.spec.ts +72 -0
  89. package/test/unit/retry.spec.ts +58 -0
  90. package/test/unit/useCategorySeo.spec.ts +2 -1
  91. package/test/visual/playwright.config.ts +33 -0
  92. package/test/visual/visual.spec.ts +87 -0
  93. package/app/components/Product/CardDescription.vue +0 -27
  94. package/app/components/Product/CardFooter.vue +0 -61
  95. package/app/composables/useCheckoutStore.ts +0 -1
  96. package/app/stores/checkout.ts +0 -22
@@ -0,0 +1,72 @@
1
+ <script setup lang="ts">
2
+ import type { Schemas } from "#shopware";
3
+
4
+ // Compact card for horizontal rows (top sellers, #327): cover or placeholder,
5
+ // number, name, price and a plus. The whole card opens the quick view.
6
+ const props = defineProps<{
7
+ product: Schemas["Product"];
8
+ }>();
9
+
10
+ const emit = defineEmits<{
11
+ select: [product: Schemas["Product"]];
12
+ }>();
13
+
14
+ const { getFormattedPrice } = useCommercePrice();
15
+
16
+ const coverMedia = computed(() => props.product.cover?.media);
17
+ const name = computed(
18
+ () => props.product.translated?.name ?? props.product.name,
19
+ );
20
+ </script>
21
+
22
+ <template>
23
+ <article
24
+ class="flex w-44 shrink-0 cursor-pointer snap-start flex-col overflow-hidden rounded-xl bg-default shadow-md ring ring-default transition-shadow hover:shadow-lg hover:ring-primary/40 focus-visible:outline-2 focus-visible:outline-primary"
25
+ role="button"
26
+ tabindex="0"
27
+ aria-haspopup="dialog"
28
+ :aria-label="`${name} auswählen`"
29
+ @click="emit('select', product)"
30
+ @keydown.enter.prevent="emit('select', product)"
31
+ @keydown.space.prevent="emit('select', product)"
32
+ >
33
+ <img
34
+ v-if="coverMedia?.url"
35
+ :src="coverMedia.url"
36
+ :srcset="mediaSrcSet(coverMedia)"
37
+ sizes="176px"
38
+ :width="mediaSize(coverMedia)?.width"
39
+ :height="mediaSize(coverMedia)?.height"
40
+ :alt="name"
41
+ loading="lazy"
42
+ decoding="async"
43
+ class="h-28 w-full object-cover"
44
+ />
45
+ <div
46
+ v-else
47
+ class="flex h-28 w-full items-center justify-center bg-gradient-to-b from-brand-100 to-brand-200 text-brand-600"
48
+ aria-hidden="true"
49
+ >
50
+ <UIcon name="i-lucide-utensils-crossed" class="size-8" />
51
+ </div>
52
+ <div class="flex flex-1 flex-col gap-1.5 p-3">
53
+ <span class="text-xs font-semibold text-primary">
54
+ #{{ product.productNumber }}
55
+ </span>
56
+ <span class="line-clamp-2 text-base leading-5 font-bold text-highlighted">
57
+ {{ name }}
58
+ </span>
59
+ <div class="mt-auto flex items-center justify-between pt-1">
60
+ <span class="font-bold text-highlighted">
61
+ {{ getFormattedPrice(product.calculatedPrice.totalPrice) }}
62
+ </span>
63
+ <span
64
+ class="flex size-8 items-center justify-center rounded-full bg-primary/10 text-primary ring ring-inset ring-primary/25"
65
+ aria-hidden="true"
66
+ >
67
+ <UIcon name="i-lucide-plus" class="size-4" />
68
+ </span>
69
+ </div>
70
+ </div>
71
+ </article>
72
+ </template>
@@ -1,42 +1,49 @@
1
1
  <script setup lang="ts">
2
2
  import type { Schemas } from "#shopware";
3
3
 
4
- const props = defineProps<{
5
- sortedProperties: Schemas["PropertyGroup"][] | undefined;
6
- }>();
4
+ const props = withDefaults(
5
+ defineProps<{
6
+ sortedProperties: Schemas["PropertyGroup"][] | undefined;
7
+ // `chip` sits in the ingredient row, `overlay` on the cover image (#325).
8
+ variant?: "chip" | "overlay";
9
+ }>(),
10
+ { variant: "chip" },
11
+ );
12
+
13
+ const hasYesOption = (groupName: string) =>
14
+ props.sortedProperties?.some(
15
+ (group) =>
16
+ group.translated.name === groupName &&
17
+ group.options?.some((option) => option.translated.name === "Ja"),
18
+ ) ?? false;
7
19
 
8
- const isVegi = computed<boolean>(
9
- () =>
10
- props.sortedProperties?.some(
11
- (group) =>
12
- group.translated.name === "Vegetarisch" &&
13
- group.options?.some((option) => option.translated.name === "Ja"),
14
- ) ?? false,
20
+ const badges = computed(() =>
21
+ [
22
+ {
23
+ label: "Vegetarisch",
24
+ icon: "i-lucide-leaf",
25
+ show: hasYesOption("Vegetarisch"),
26
+ },
27
+ { label: "Vegan", icon: "i-lucide-vegan", show: hasYesOption("Vegan") },
28
+ ].filter((badge) => badge.show),
15
29
  );
16
30
 
17
- const isVegan = computed<boolean>(
18
- () =>
19
- props.sortedProperties?.some(
20
- (group) =>
21
- group.translated.name === "Vegan" &&
22
- group.options?.some((option) => option.translated.name === "Ja"),
23
- ) ?? false,
31
+ // Static spans with the UBadge classes, see CardIngredients.vue.
32
+ const badgeClass = computed(() =>
33
+ props.variant === "overlay"
34
+ ? "rounded-md bg-default ring ring-inset ring-success/50"
35
+ : "rounded-full bg-success/10",
24
36
  );
25
37
  </script>
26
38
 
27
39
  <template>
28
- <LazyUBadge
29
- v-if="isVegi"
30
- icon="i-lucide-leaf"
31
- color="success"
32
- variant="outline"
33
- label="Vegetarisch"
34
- />
35
- <LazyUBadge
36
- v-if="isVegan"
37
- icon="i-lucide-vegan"
38
- color="success"
39
- variant="outline"
40
- label="Vegan"
41
- />
40
+ <span
41
+ v-for="badge in badges"
42
+ :key="badge.label"
43
+ class="inline-flex items-center gap-1 px-2 py-1 text-xs font-medium text-success"
44
+ :class="badgeClass"
45
+ >
46
+ <UIcon :name="badge.icon" class="size-4 shrink-0" />
47
+ {{ badge.label }}
48
+ </span>
42
49
  </template>
@@ -0,0 +1,35 @@
1
+ <script setup lang="ts">
2
+ import type { Schemas } from "#shopware";
3
+
4
+ const props = defineProps<{
5
+ sortedProperties: Schemas["PropertyGroup"][] | undefined;
6
+ withDietBadges: boolean;
7
+ }>();
8
+
9
+ const mainIngredients = computed(() =>
10
+ getMainIngredients(props.sortedProperties),
11
+ );
12
+ </script>
13
+
14
+ <template>
15
+ <!-- Plain spans with the UBadge "soft" classes: a listing hydrates up to
16
+ ten cards with several chips each, and every UBadge instance costs a
17
+ tailwind-variants merge (#325). -->
18
+ <div
19
+ v-if="withDietBadges || mainIngredients.length > 0"
20
+ class="flex flex-wrap gap-1.5"
21
+ >
22
+ <ProductCardDietBadges
23
+ v-if="withDietBadges"
24
+ :sorted-properties="sortedProperties"
25
+ variant="chip"
26
+ />
27
+ <span
28
+ v-for="ingredient in mainIngredients"
29
+ :key="ingredient.id"
30
+ class="inline-flex items-center rounded-full bg-elevated px-2 py-1 text-xs font-medium text-default"
31
+ >
32
+ {{ ingredient.translated.name }}
33
+ </span>
34
+ </div>
35
+ </template>
@@ -1,26 +1,18 @@
1
1
  <template>
2
2
  <div
3
- class="ring-1 ring-accented rounded-xl shadow-lg p-4 flex flex-row gap-4"
3
+ class="flex flex-col gap-3 rounded-xl bg-default p-4 shadow-md ring ring-default"
4
4
  >
5
- <div class="flex flex-col gap-3 flex-1 min-w-0">
6
- <USkeleton class="h-5 w-20 rounded-full" />
7
- <div class="flex items-baseline gap-2">
8
- <USkeleton class="h-3.5 w-7" />
9
- <USkeleton class="h-3.5 w-36" />
10
- </div>
5
+ <div class="flex items-start justify-between gap-3">
11
6
  <div class="flex flex-col gap-2">
12
- <USkeleton class="h-3 w-full" />
13
- <USkeleton class="h-3 w-5/6" />
14
- <USkeleton class="h-3 w-1/2" />
15
- </div>
16
- <div class="flex justify-between items-center mt-auto pt-2">
17
- <USkeleton class="h-4 w-14" />
18
- <div class="flex gap-2">
19
- <USkeleton class="h-8 w-8 rounded-md" />
20
- <USkeleton class="h-8 w-8 rounded-md" />
21
- </div>
7
+ <USkeleton class="h-3 w-8" />
8
+ <USkeleton class="h-5 w-40" />
22
9
  </div>
10
+ <USkeleton class="h-5 w-14" />
11
+ </div>
12
+ <div class="flex gap-1.5">
13
+ <USkeleton class="h-6 w-24 rounded-full" />
14
+ <USkeleton class="h-6 w-20 rounded-full" />
15
+ <USkeleton class="h-6 w-16 rounded-full" />
23
16
  </div>
24
- <USkeleton class="size-28 rounded-md shrink-0" />
25
17
  </div>
26
18
  </template>
@@ -12,6 +12,7 @@ const props = defineProps({
12
12
  const category = toRef(props.category);
13
13
  const { apiClient } = useShopwareContext();
14
14
  const categoryProducts = ref<Schemas["Product"][]>([]);
15
+ const quickView = useProductQuickView(categoryProducts);
15
16
  const isLoading = ref(true);
16
17
 
17
18
  const fetchCategoryProducts = async () => {
@@ -139,15 +140,21 @@ onMounted(() => {
139
140
  :category="child"
140
141
  />
141
142
  </div>
142
- <div v-else class="grid grid-cols-1 gap-4">
143
+ <div v-else class="grid grid-cols-1 gap-4 xl:grid-cols-2">
143
144
  <ProductCard
144
145
  v-for="product in categoryProducts"
145
146
  :key="product.id"
146
147
  :product="product"
147
148
  :with-favorite-button="true"
148
- :with-add-to-cart-button="true"
149
+ :selectable="true"
150
+ @select="quickView.show"
149
151
  />
150
152
  </div>
153
+ <LazyProductQuickView
154
+ v-if="quickView.mounted.value"
155
+ v-model:open="quickView.open.value"
156
+ :product="quickView.product.value"
157
+ />
151
158
  </div>
152
159
  <div v-else-if="isLoading" class="flex flex-col" />
153
160
  </template>
@@ -41,19 +41,23 @@ const emit = defineEmits<{
41
41
  }>();
42
42
  </script>
43
43
  <template>
44
- <div
45
- v-for="(variantGroup, propertyGroupId) in selectableOptions"
46
- :key="propertyGroupId"
47
- class="my-6"
48
- >
49
- <div class="flex flex-row gap-2 items-center">
50
- <div class="basis-1/3">{{ variantGroup.name }}:</div>
44
+ <div class="flex flex-col gap-5">
45
+ <div
46
+ v-for="(variantGroup, propertyGroupId) in selectableOptions"
47
+ :key="propertyGroupId"
48
+ class="flex flex-col gap-2"
49
+ >
50
+ <span class="font-semibold text-highlighted">{{
51
+ variantGroup.name
52
+ }}</span>
51
53
  <USelect
52
54
  v-model="selectedOptions[propertyGroupId]"
53
55
  value-key="productId"
54
56
  :items="variantGroup.options"
57
+ size="lg"
55
58
  class="w-full"
56
59
  icon="i-lucide-square-stack"
60
+ :aria-label="variantGroup.name"
57
61
  />
58
62
  </div>
59
63
  </div>
@@ -1,11 +1,13 @@
1
1
  <script setup lang="ts">
2
- import type { Schemas } from "#shopware";
3
- import type { AssociationItemProduct } from "~/types/Association";
2
+ import type {
3
+ AssociationItem,
4
+ AssociationItemProduct,
5
+ } from "~/types/Association";
4
6
 
5
- const LOADING_ICON = "i-lucide-loader";
6
-
7
- const props = defineProps<{
8
- product: Schemas["Product"];
7
+ // The extras are loaded by useProductDetail together with the product, so
8
+ // the list renders once and stays put when a variant is switched.
9
+ defineProps<{
10
+ associations: AssociationItem[];
9
11
  }>();
10
12
 
11
13
  const emit = defineEmits<{
@@ -14,40 +16,49 @@ const emit = defineEmits<{
14
16
 
15
17
  const selectedExtras = ref<AssociationItemProduct[]>([]);
16
18
 
17
- const { associationItems, isAssociationsLoading } = useProductCrossSelling(
18
- () => props.product.id,
19
- );
19
+ const isSelected = (extra: AssociationItemProduct) =>
20
+ selectedExtras.value.some((selected) => selected.value === extra.value);
21
+
22
+ function toggle(extra: AssociationItemProduct) {
23
+ selectedExtras.value = isSelected(extra)
24
+ ? selectedExtras.value.filter((selected) => selected.value !== extra.value)
25
+ : [...selectedExtras.value, extra];
26
+ }
20
27
 
21
- watch(selectedExtras, () => emit("extras-selected", selectedExtras.value), {
22
- deep: true,
23
- });
28
+ watch(selectedExtras, () => emit("extras-selected", selectedExtras.value));
24
29
  </script>
25
30
 
26
31
  <template>
27
- <div v-if="!isAssociationsLoading" class="my-4">
32
+ <div
33
+ v-for="association in associations"
34
+ :key="association.label"
35
+ class="flex flex-col gap-2"
36
+ >
37
+ <div class="flex items-baseline justify-between">
38
+ <span class="font-semibold text-highlighted">{{
39
+ association.label
40
+ }}</span>
41
+ <span class="text-xs text-muted">optional</span>
42
+ </div>
28
43
  <div
29
- v-for="association in associationItems"
30
- :key="association.label"
31
- class=""
44
+ class="flex flex-wrap gap-2"
45
+ role="group"
46
+ :aria-label="association.label"
32
47
  >
33
- <div class="flex flex-row gap-2 items-center">
34
- <div class="basis-1/3">{{ association.label }}:</div>
35
- <UInputMenu
36
- v-model="selectedExtras"
37
- class="w-full"
38
- :loading="isAssociationsLoading"
39
- :loading-icon="LOADING_ICON"
40
- multiple
41
- :items="association.products"
42
- icon="i-lucide-plus"
43
- >
44
- <template #item-trailing="{ item }">
45
- <span class="">
46
- {{ item.price }}
47
- </span>
48
- </template>
49
- </UInputMenu>
50
- </div>
48
+ <UButton
49
+ v-for="extra in association.products"
50
+ :key="extra.value"
51
+ size="lg"
52
+ class="rounded-full"
53
+ :color="isSelected(extra) ? 'primary' : 'neutral'"
54
+ :variant="isSelected(extra) ? 'subtle' : 'outline'"
55
+ :icon="isSelected(extra) ? 'i-lucide-check' : 'i-lucide-plus'"
56
+ :aria-pressed="isSelected(extra)"
57
+ @click="toggle(extra)"
58
+ >
59
+ {{ extra.label }}
60
+ <span class="font-normal opacity-80">+{{ extra.price }}</span>
61
+ </UButton>
51
62
  </div>
52
63
  </div>
53
64
  </template>
@@ -1,46 +1,52 @@
1
1
  <script setup lang="ts">
2
2
  import type { Schemas } from "#shopware";
3
- import { toRefs, watch } from "vue";
4
3
 
5
4
  const props = defineProps<{
6
5
  product: Schemas["Product"];
7
6
  }>();
8
- const { product } = toRefs(props);
9
-
10
- const deselected = ref([]);
11
-
12
- const list = computed(() => {
13
- const propsList = product.value?.properties ?? [];
14
- return propsList
15
- .filter(
16
- (propertyGroupOption: Schemas["PropertyGroupOption"]) =>
17
- propertyGroupOption.group.name === "Hauptzutaten",
18
- )
19
- .map(
20
- (propertyGroupOption: Schemas["PropertyGroupOption"]) =>
21
- propertyGroupOption.translated.name,
22
- );
23
- });
24
-
25
- watch(deselected, () => emit("ingredients-deselected", deselected.value), {
26
- deep: true,
27
- });
28
7
 
29
8
  const emit = defineEmits<{
30
9
  "ingredients-deselected": [deselected: string[]];
31
10
  }>();
11
+
12
+ const deselected = ref<string[]>([]);
13
+
14
+ const ingredients = computed<string[]>(() =>
15
+ ((props.product.properties ?? []) as Schemas["PropertyGroupOption"][])
16
+ .filter((option) => option.group?.name === "Hauptzutaten")
17
+ .map((option) => option.translated.name),
18
+ );
19
+
20
+ function toggle(ingredient: string) {
21
+ deselected.value = deselected.value.includes(ingredient)
22
+ ? deselected.value.filter((name) => name !== ingredient)
23
+ : [...deselected.value, ingredient];
24
+ }
25
+
26
+ watch(deselected, () => emit("ingredients-deselected", deselected.value));
32
27
  </script>
33
28
 
34
29
  <template>
35
- <div v-if="list.length > 0" class="flex flex-row gap-2 my-6 items-center">
36
- <div class="basis-1/3">Aber ohne:</div>
37
- <USelect
38
- v-model="deselected"
39
- value-key="productId"
40
- :items="list"
41
- class="w-full"
42
- icon="i-lucide-minus"
43
- multiple
44
- />
30
+ <div v-if="ingredients.length > 0" class="flex flex-col gap-2">
31
+ <span class="font-semibold text-highlighted">Ohne</span>
32
+ <div
33
+ class="flex flex-wrap gap-2"
34
+ role="group"
35
+ aria-label="Zutaten abwählen"
36
+ >
37
+ <UButton
38
+ v-for="ingredient in ingredients"
39
+ :key="ingredient"
40
+ size="lg"
41
+ class="rounded-full"
42
+ :class="{ 'line-through': deselected.includes(ingredient) }"
43
+ :color="deselected.includes(ingredient) ? 'error' : 'neutral'"
44
+ :variant="deselected.includes(ingredient) ? 'subtle' : 'outline'"
45
+ :icon="deselected.includes(ingredient) ? 'i-lucide-x' : undefined"
46
+ :aria-pressed="deselected.includes(ingredient)"
47
+ :label="ingredient"
48
+ @click="toggle(ingredient)"
49
+ />
50
+ </div>
45
51
  </div>
46
52
  </template>
@@ -1,5 +1,6 @@
1
1
  <script setup lang="ts">
2
2
  import type { Schemas } from "#shopware";
3
+ import type { AssociationItemProduct } from "~/types/Association";
3
4
 
4
5
  const props = defineProps<{
5
6
  productId: string;
@@ -9,6 +10,7 @@ const emit = defineEmits(["product-added", "variant-selected"]);
9
10
 
10
11
  const {
11
12
  productDetails,
13
+ associationItems,
12
14
  pending,
13
15
  selectedProduct,
14
16
  selectedQuantity,
@@ -19,6 +21,29 @@ const {
19
21
  onIngredientsDeselected,
20
22
  } = useProductDetail(() => props.productId);
21
23
 
24
+ const { getFormattedPrice } = useCommercePrice();
25
+
26
+ const selectedExtras = ref<AssociationItemProduct[]>([]);
27
+
28
+ function onExtras(extras: AssociationItemProduct[]) {
29
+ selectedExtras.value = extras;
30
+ onExtrasSelected(extras);
31
+ }
32
+
33
+ // Unit price plus extras, times the quantity: what the button will add.
34
+ const total = computed(() => {
35
+ const unitPrice = selectedProduct.value?.calculatedPrice.unitPrice ?? 0;
36
+ const extrasPrice = selectedExtras.value.reduce(
37
+ (sum, extra) => sum + (extra.unitPrice ?? 0),
38
+ 0,
39
+ );
40
+ return (unitPrice + extrasPrice) * selectedQuantity.value;
41
+ });
42
+
43
+ const isAvailable = computed(() =>
44
+ selectedProduct.value ? productIsAvailable(selectedProduct.value) : true,
45
+ );
46
+
22
47
  const onVariantSwitched = (variant: Schemas["Product"]) => {
23
48
  setSelectedProduct(variant);
24
49
  emit("variant-selected", variant);
@@ -28,41 +53,76 @@ const onAddToCart = () => emit("product-added");
28
53
  </script>
29
54
 
30
55
  <template>
31
- <div v-if="!pending">
32
- <div v-if="productDetails?.configurator">
56
+ <div class="flex flex-col gap-5">
57
+ <!-- One placeholder in the shape of the loaded body (options, extras,
58
+ ingredients), shown until product and extras are both loaded. -->
59
+ <div v-if="pending" class="flex flex-col gap-5" aria-busy="true">
60
+ <div class="flex flex-col gap-2">
61
+ <USkeleton class="h-5 w-24" />
62
+ <USkeleton class="h-11 w-full" />
63
+ </div>
64
+ <div class="flex flex-col gap-2">
65
+ <USkeleton class="h-5 w-20" />
66
+ <div class="flex flex-wrap gap-2">
67
+ <USkeleton class="h-10 w-32 rounded-full" />
68
+ <USkeleton class="h-10 w-28 rounded-full" />
69
+ <USkeleton class="h-10 w-36 rounded-full" />
70
+ <USkeleton class="h-10 w-24 rounded-full" />
71
+ </div>
72
+ </div>
73
+ <div class="flex flex-col gap-2">
74
+ <USkeleton class="h-5 w-16" />
75
+ <div class="flex flex-wrap gap-2">
76
+ <USkeleton class="h-10 w-28 rounded-full" />
77
+ <USkeleton class="h-10 w-24 rounded-full" />
78
+ </div>
79
+ </div>
80
+ </div>
81
+ <template v-else-if="productDetails?.configurator">
33
82
  <ProductConfigurator
34
- v-if="productDetails?.configurator"
35
83
  :p="productDetails.product"
36
84
  :c="productDetails.configurator"
37
85
  @variant-switched="onVariantSwitched"
38
86
  />
39
87
  <ProductCrossSelling
40
- v-if="selectedProduct"
41
- :product="selectedProduct"
42
- @extras-selected="onExtrasSelected"
88
+ v-if="associationItems.length > 0"
89
+ :associations="associationItems"
90
+ @extras-selected="onExtras"
43
91
  />
44
92
  <ProductDeselectIngredient
45
93
  v-if="selectedProduct"
46
94
  :product="selectedProduct"
47
95
  @ingredients-deselected="onIngredientsDeselected"
48
96
  />
49
- </div>
50
- <div class="flex flex-row gap-4 mt-8">
97
+ </template>
98
+
99
+ <div
100
+ class="sticky bottom-0 mt-auto flex items-center gap-3 border-t border-default bg-default pt-4"
101
+ >
51
102
  <UInputNumber
52
103
  v-model="selectedQuantity"
53
104
  size="xl"
54
- placeholder="Anzahl"
105
+ aria-label="Anzahl"
55
106
  :min="1"
56
107
  :max="100"
108
+ :disabled="pending"
109
+ class="w-28 shrink-0"
57
110
  />
111
+ <!-- Short label: "In den Warenkorb" wrapped next to the total on phones. -->
58
112
  <UButton
59
- :disabled="isLoading"
113
+ class="flex-1 justify-between whitespace-nowrap"
60
114
  size="xl"
61
- label="In den Warenkorb"
62
115
  icon="i-lucide-shopping-cart"
63
- block
116
+ :disabled="isLoading || pending || !isAvailable"
117
+ :loading="isLoading"
118
+ aria-label="In den Warenkorb"
64
119
  @click="addToCart(onAddToCart)"
65
- />
120
+ >
121
+ <span>{{ isAvailable ? "Hinzufügen" : "Ausverkauft" }}</span>
122
+ <span v-if="isAvailable && !pending" class="font-bold">
123
+ {{ getFormattedPrice(total) }}
124
+ </span>
125
+ </UButton>
66
126
  </div>
67
127
  </div>
68
128
  </template>