@shopbite-de/storefront 2.0.3 → 2.1.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/CLAUDE.md CHANGED
@@ -91,7 +91,8 @@ Key custom composables:
91
91
  - **`useAddToCart`** – products with extras/toppings use UUID v5 (product ID + sorted extras) as container item reference; simple products bypass the container
92
92
  - **`useAddressAutocomplete`** – proxies Geoapify through `/api/address/autocomplete` to avoid exposing the API key client-side
93
93
  - **`useShopBiteConfig`** – fetches delivery config and checkout state from the custom Shopware plugin
94
- - **`useSyncWishlist`** – deliberate override of the layer composable (copy of `@shopware/composables` 1.13.0) that does not log the expected 404/403 of a missing or disabled wishlist (#366); compare with the layer source when Renovate bumps `@shopware/composables`
94
+ - **`useWishlistEntries`** – the wishlist (#467): an entry is a configured dish (product/variant id + number, `without`, `extras`, the quick view configuration of #411). Customers keep entries in the ShopBite plugin (`/store-api/shopbite/wishlist`, `/add`, `/merge`, `DELETE /{id}`, entity `shopbite_wishlist_item`, shopware-plugin#30), guests in localStorage `shopbite-wishlist` (old `sw-wishlist-items` ids are taken over). `app.vue` loads it on mount and on login merges the guest entries into the account (logout reloads the guest's); a backend without the routes (404) keeps customers in localStorage. On the first load a customer's Shopware core wishlist moves into the plugin and is deleted there. `WishlistSaveButton` (heart in the product sheet header, `aria-pressed` for the current configuration) gets the selection from `ProductDetail` (`selection-changed`); `Wishlist.vue` adds rows with `useAddToCart` (same container line item as the sheet) and opens the sheet on the wishlist page with the saved configuration ("Anpassen").
95
+ - **`useSyncWishlist`** – deliberate override of the layer composable (copy of `@shopware/composables` 1.13.0) that does not log the expected 404/403 of a missing or disabled wishlist (#366); only the layer's own `useWishlist` still uses it since #467; compare with the layer source when Renovate bumps `@shopware/composables`
95
96
 
96
97
  ### Product data model (what Shopware must contain)
97
98
 
@@ -133,10 +134,10 @@ Pages without content throw `createNotFoundError()` (`app/utils/notFound.ts`): f
133
134
  - Components style only with the `--sb-*` colour tokens and `--font-sb-display`/`--font-sb-body` (the `--font` prefix makes @nuxt/fonts resolve the family and add metric fallbacks) through the `sb-*` utilities (`bg-sb-surface`, `text-sb-ink-muted`, `font-display`, `rounded-sb-control`). No colour mode switch: the preset fixes light or dark.
134
135
  - Base components live in `app/components/Sb/` (`SbButton`, `SbIconButton`, `SbSegmentedControl`, `SbSheet`, `SbChoiceGroup`, `SbCheckbox`, `SbField` + `SbInput`, `SbSelect` (native), `SbStepper`, `SbChip`, `SbStatusPill`, `SbStars`, `SbConfirmDialog`, `SbIcon` with inline stroke icons). Behaviour and accessibility come from Reka UI (radio groups, checkbox, dialog and alert dialog with focus trap). Every control is at least 44 px and has a visible focus ring; icon-only buttons need a `label`; toggles use `aria-pressed` with a stable name. Hide a base component responsively with a wrapper (`<span class="hidden sm:block">`): its own `inline-flex` wins over a `hidden` passed as class. Elements focused only by script (`tabindex="-1"`) get no focus ring. Entry animations go behind `motion-safe:` (a `motion-reduce:animate-none` loses against `data-[state=open]:animate-…`).
135
136
  - No toasts (removed in #445, other responses to be designed): results and errors show where they happen, e.g. `role="alert"` boxes in forms and the checkout, `role="status"` regions, the voucher error at its field.
136
- - Menu (#441): `Category/Listing.vue` has three columns from `lg` (`MenuCategoryIndex` word list, the list, `MenuCartPanel`), `NavigationMobileTop` below `lg`; `MenuSectionHeader` and `MenuBonCard` (one column, number strip, `photo` for the `bonPhoto` view). The card's button adds a product straight to the cart unless `productNeedsChoice()` (a parent with variants, `childCount` in the listing projection), which opens the quick view; extras stay optional. Cards hydrate on approach (`hydrateWhenVisible`), so a click on a card that has not hydrated yet is lost. Filters live in an `SbSheet`, sorting is an `SbSelect` (`toSortingOptions()`).
137
- - Product sheet (#442): `SbSheet` with a bon header (number strip, name as `DialogTitle`, diet and description as `DialogDescription`); `Configurator` shows variants as `SbChoiceGroup` (required), `DeselectIngredient` as `SbChip` ingredient chips (pressed = included), `CrossSelling` as `SbCheckbox` rows with a search, `Detail` a sticky footer with `SbStepper` and the add button.
137
+ - Menu (#441): `Category/Listing.vue` has three columns from `lg` (`MenuCategoryIndex` word list, the list, `MenuCartPanel`), `NavigationMobileTop` below `lg` (section chips; the open section's sub-categories as a second chip row led by "Alle", the current chip scrolls into view); `MenuSectionHeader` and `MenuBonCard` (one column, number strip, `photo` for the `bonPhoto` view). The card's button adds a product straight to the cart unless `productNeedsChoice()` (a parent with variants, `childCount` in the listing projection), which opens the quick view; extras stay optional. Cards hydrate on approach (`hydrateWhenVisible`), so a click on a card that has not hydrated yet is lost. Filters live in an `SbSheet`, sorting is an `SbSelect` (`toSortingOptions()`).
138
+ - Product sheet (#442): `SbSheet` with a bon header (a custom `#header` gets the full width below a toolbar with the `#actions` and the close button; next to the buttons a long name broke after four letters on a 393 px phone) (number strip, name as `DialogTitle`, diet and description as `DialogDescription`); `Configurator` shows variants as `SbChoiceGroup` (required), `DeselectIngredient` as `SbChip` ingredient chips (pressed = included), `CrossSelling` as `SbCheckbox` rows with a search, `Detail` a sticky footer with `SbStepper` and the add button.
138
139
  - Cart and checkout (#443): `MenuOrderMode` (`useOrderMode`) and the checkout's shipping section list ALL active shipping methods (`useShippingMethodChoice`, `onlyAvailable: false`), because a delivery-area rule on the shipping city never matches before the guest has an address (La Fattoria, fixed in 2.0.3); `useCheckoutMethodGuard` switches only a blocked payment method, a blocked shipping method is reported in the checkout and never switched to pickup. It shows the shipping methods as an `SbSegmentedControl` only when there are two to four. The header cart opens an `SbSheet`; `Cart/Item` uses `SbStepper` (remove at 1). The checkout is one page, `/bestellung/kasse` (the old step routes 301 there, `routeRules`): numbered sections Lieferung oder Abholung (`CheckoutPaymentAndDelivery part="shipping"`), Wann, Ihre Angaben (`CheckoutLoginOrRegister` with Reka tabs, `UserRegistrationForm` (logic in `useRegistrationForm`) / `UserLoginForm`, or `UserDetail`), Bezahlung (`part="payment"`) and the order card in `Checkout/Summary.vue`; the order button says "Zahlungspflichtig bestellen" (§ 312j BGB). Forms validate with Zod on submit and show errors at the fields plus a focused summary in form order; `AddressFields` sets `autocomplete`.
139
- - Order and account (#445): `/bestellung/<id>/erfolg` and `/bestellung/<id>` render `OrderConfirmation` (`OrderDetail`: facts incl. the wished time from the `customerComment`, receipt lines, totals; call card), `/bestellung/<id>/fehler` a payment retry. Login, registration, password pages and the registration confirmation render in `UserAuthPanel`; the account pages in `layouts/account.vue` (link navigation with `aria-current`) with `UserAccountHeader`; `AddressForm` (also used when an address is edited in the checkout). Irreversible actions confirm with `SbConfirmDialog` (focus starts on "Abbrechen"). Search, contact (`useContactForm`), wishlist (`AddToWishlist`), content pages and `error.vue` (with its own `Header`/`Footer`, because the error page replaces `app.vue`) use the same pieces.
140
+ - Order and account (#445): `/bestellung/<id>/erfolg` and `/bestellung/<id>` render `OrderConfirmation` (`OrderDetail`: facts incl. the wished time from the `customerComment`, receipt lines, totals; call card), `/bestellung/<id>/fehler` a payment retry. Login, registration, password pages and the registration confirmation render in `UserAuthPanel`; the account pages in `layouts/account.vue` (link navigation with `aria-current`) with `UserAccountHeader`; `AddressForm` (also used when an address is edited in the checkout). Irreversible actions confirm with `SbConfirmDialog` (focus starts on "Abbrechen"). Search, contact (`useContactForm`), wishlist (`useWishlistEntries`, #467), content pages and `error.vue` (with its own `Header`/`Footer`, because the error page replaces `app.vue`) use the same pieces.
140
141
  - Home page (#444): `pages/index.vue` renders `HomeHero` (kicker, `[highlight]{.text-primary}` part in the accent colour via `splitHighlight()`, buttons from `hero.links`, live status, rating card from the Google `usp`; the photo is `hero.image` with the blurred video `hero.poster` as fallback, cropped 4:5 at `hero.imagePosition` (object-position); it sits in a `<picture>` with a `min-width: 640px` source, so phones load a 1 px GIF), `HomeFacts` (`features`), `HomeCategories` (word list, `useHomeMenuCategories`; a wide first category image switches to a full-width photo below the words, and `sizes` asks for the width the crop needs, since thumbnails are picked by width), `HomeHighlights` (top sellers as bon cards), `HomeRestaurant` (`gallery` + opening hours in the SSR HTML) and the two-column `HomeFaq`; `cta` and `mittagstisch` in `content/index.yml` are not shown.
141
142
  - Header and footer (#455): `Header.vue` (logo, main nav, status pill, phone, account, wishlist, cart button opening the cart `SbSheet`, menu `SbSheet` on phones), `Footer.vue` (address, hours, footer navigation columns). `app.vue` has the skip link to `main#inhalt`.
142
143
  - Every colour pair a component renders must be in `CONTRAST_PAIRS`; `test/unit/themePresets.spec.ts` fails if a preset misses WCAG AA. Accent red is for headlines only, never on controls (reads as negative).
@@ -10637,6 +10637,44 @@
10637
10637
  "type": "array",
10638
10638
  "items": { "$ref": "#/components/schemas/Breadcrumb" }
10639
10639
  },
10640
+ "ShopBiteWishlistItem": {
10641
+ "type": "object",
10642
+ "required": [
10643
+ "id",
10644
+ "productId",
10645
+ "productNumber",
10646
+ "without",
10647
+ "extras",
10648
+ "createdAt"
10649
+ ],
10650
+ "properties": {
10651
+ "id": {
10652
+ "type": "string"
10653
+ },
10654
+ "productId": {
10655
+ "type": "string"
10656
+ },
10657
+ "productNumber": {
10658
+ "type": "string"
10659
+ },
10660
+ "without": {
10661
+ "type": "array",
10662
+ "items": {
10663
+ "type": "string"
10664
+ }
10665
+ },
10666
+ "extras": {
10667
+ "type": "array",
10668
+ "items": {
10669
+ "type": "string"
10670
+ }
10671
+ },
10672
+ "createdAt": {
10673
+ "type": "string",
10674
+ "format": "date-time"
10675
+ }
10676
+ }
10677
+ },
10640
10678
  "ShopBiteConfig": {
10641
10679
  "type": "object",
10642
10680
  "description": "ShopBite configuration data",
@@ -11409,6 +11447,195 @@
11409
11447
  },
11410
11448
  "security": [{ "ApiKey": [] }],
11411
11449
  "paths": {
11450
+ "/shopbite/wishlist": {
11451
+ "post": {
11452
+ "tags": ["ShopBite"],
11453
+ "summary": "Wishlist with configured dishes",
11454
+ "description": "Entries of the logged-in customer (sw-context-token) in this sales channel, newest first.",
11455
+ "operationId": "shopbite.wishlist.list",
11456
+ "parameters": [],
11457
+ "responses": {
11458
+ "200": {
11459
+ "description": "Wishlist entries",
11460
+ "content": {
11461
+ "application/json": {
11462
+ "schema": {
11463
+ "type": "object",
11464
+ "required": ["elements"],
11465
+ "properties": {
11466
+ "elements": {
11467
+ "type": "array",
11468
+ "items": {
11469
+ "$ref": "#/components/schemas/ShopBiteWishlistItem"
11470
+ }
11471
+ }
11472
+ }
11473
+ }
11474
+ }
11475
+ }
11476
+ }
11477
+ },
11478
+ "security": [
11479
+ {
11480
+ "StoreApiKey": []
11481
+ }
11482
+ ]
11483
+ }
11484
+ },
11485
+ "/shopbite/wishlist/add": {
11486
+ "post": {
11487
+ "tags": ["ShopBite"],
11488
+ "summary": "Save a configured dish",
11489
+ "description": "Saves a product with deselected ingredients and extras for the logged-in customer. Returns the existing entry when the same configuration is saved already.",
11490
+ "operationId": "shopbite.wishlist.add",
11491
+ "parameters": [],
11492
+ "requestBody": {
11493
+ "required": true,
11494
+ "content": {
11495
+ "application/json": {
11496
+ "schema": {
11497
+ "type": "object",
11498
+ "required": ["productId"],
11499
+ "properties": {
11500
+ "productId": {
11501
+ "type": "string"
11502
+ },
11503
+ "without": {
11504
+ "type": "array",
11505
+ "items": {
11506
+ "type": "string"
11507
+ }
11508
+ },
11509
+ "extras": {
11510
+ "type": "array",
11511
+ "items": {
11512
+ "type": "string"
11513
+ }
11514
+ }
11515
+ }
11516
+ }
11517
+ }
11518
+ }
11519
+ },
11520
+ "responses": {
11521
+ "200": {
11522
+ "description": "The entry",
11523
+ "content": {
11524
+ "application/json": {
11525
+ "schema": {
11526
+ "$ref": "#/components/schemas/ShopBiteWishlistItem"
11527
+ }
11528
+ }
11529
+ }
11530
+ }
11531
+ },
11532
+ "security": [
11533
+ {
11534
+ "StoreApiKey": []
11535
+ }
11536
+ ]
11537
+ }
11538
+ },
11539
+ "/shopbite/wishlist/{id}": {
11540
+ "delete": {
11541
+ "tags": ["ShopBite"],
11542
+ "summary": "Remove a wishlist entry",
11543
+ "description": "Removes an entry of the logged-in customer.",
11544
+ "operationId": "shopbite.wishlist.delete",
11545
+ "parameters": [
11546
+ {
11547
+ "name": "id",
11548
+ "in": "path",
11549
+ "required": true,
11550
+ "schema": {
11551
+ "type": "string"
11552
+ }
11553
+ }
11554
+ ],
11555
+ "responses": {
11556
+ "204": {
11557
+ "description": "Removed"
11558
+ }
11559
+ },
11560
+ "security": [
11561
+ {
11562
+ "StoreApiKey": []
11563
+ }
11564
+ ]
11565
+ }
11566
+ },
11567
+ "/shopbite/wishlist/merge": {
11568
+ "post": {
11569
+ "tags": ["ShopBite"],
11570
+ "summary": "Merge guest wishlist entries",
11571
+ "description": "Adds entries saved as a guest to the logged-in customer's wishlist and returns the full list.",
11572
+ "operationId": "shopbite.wishlist.merge",
11573
+ "parameters": [],
11574
+ "requestBody": {
11575
+ "required": true,
11576
+ "content": {
11577
+ "application/json": {
11578
+ "schema": {
11579
+ "type": "object",
11580
+ "required": ["items"],
11581
+ "properties": {
11582
+ "items": {
11583
+ "type": "array",
11584
+ "items": {
11585
+ "type": "object",
11586
+ "required": ["productId"],
11587
+ "properties": {
11588
+ "productId": {
11589
+ "type": "string"
11590
+ },
11591
+ "without": {
11592
+ "type": "array",
11593
+ "items": {
11594
+ "type": "string"
11595
+ }
11596
+ },
11597
+ "extras": {
11598
+ "type": "array",
11599
+ "items": {
11600
+ "type": "string"
11601
+ }
11602
+ }
11603
+ }
11604
+ }
11605
+ }
11606
+ }
11607
+ }
11608
+ }
11609
+ }
11610
+ },
11611
+ "responses": {
11612
+ "200": {
11613
+ "description": "Wishlist entries",
11614
+ "content": {
11615
+ "application/json": {
11616
+ "schema": {
11617
+ "type": "object",
11618
+ "required": ["elements"],
11619
+ "properties": {
11620
+ "elements": {
11621
+ "type": "array",
11622
+ "items": {
11623
+ "$ref": "#/components/schemas/ShopBiteWishlistItem"
11624
+ }
11625
+ }
11626
+ }
11627
+ }
11628
+ }
11629
+ }
11630
+ }
11631
+ },
11632
+ "security": [
11633
+ {
11634
+ "StoreApiKey": []
11635
+ }
11636
+ ]
11637
+ }
11638
+ },
11412
11639
  "/cms/{id}": {
11413
11640
  "post": {
11414
11641
  "tags": ["Content"],
@@ -5363,6 +5363,15 @@ export type Schemas = {
5363
5363
  /** Whether checkout is enabled for ShopBite */
5364
5364
  isCheckoutEnabled: boolean;
5365
5365
  };
5366
+ ShopBiteWishlistItem: {
5367
+ /** Format: date-time */
5368
+ createdAt: string;
5369
+ extras: string[];
5370
+ id: string;
5371
+ productId: string;
5372
+ productNumber: string;
5373
+ without: string[];
5374
+ };
5366
5375
  ShopbiteBusinessHour: {
5367
5376
  closingTime: string;
5368
5377
  /** Format: date-time */
@@ -6631,8 +6640,10 @@ export type operations = {
6631
6640
  firstName?: string;
6632
6641
  /** Lastname. This field may be required depending on the system settings. */
6633
6642
  lastName?: string;
6634
- /** Identifier of the navigation page. Can be used to override the configuration.
6635
- * Take a look at the settings of a category containing a concat form in the administration. */
6643
+ /**
6644
+ * Identifier of the navigation page. Can be used to override the configuration.
6645
+ * Take a look at the settings of a category containing a concat form in the administration.
6646
+ */
6636
6647
  navigationId?: string;
6637
6648
  /** Phone. This field may be required depending on the system settings. */
6638
6649
  phone?: string;
@@ -8430,6 +8441,49 @@ export type operations = {
8430
8441
  response: components["schemas"]["MultiChannelGroupStruct"];
8431
8442
  responseCode: 200;
8432
8443
  };
8444
+ "shopbite.wishlist.list post /shopbite/wishlist": {
8445
+ contentType?: "application/json";
8446
+ accept?: "application/json";
8447
+ response: {
8448
+ elements: components["schemas"]["ShopBiteWishlistItem"][];
8449
+ };
8450
+ responseCode: 200;
8451
+ };
8452
+ "shopbite.wishlist.delete delete /shopbite/wishlist/{id}": {
8453
+ contentType?: "application/json";
8454
+ accept?: "application/json";
8455
+ pathParams: {
8456
+ id: string;
8457
+ };
8458
+ response: never;
8459
+ responseCode: 204;
8460
+ };
8461
+ "shopbite.wishlist.add post /shopbite/wishlist/add": {
8462
+ contentType?: "application/json";
8463
+ accept?: "application/json";
8464
+ body: {
8465
+ extras?: string[];
8466
+ productId: string;
8467
+ without?: string[];
8468
+ };
8469
+ response: components["schemas"]["ShopBiteWishlistItem"];
8470
+ responseCode: 200;
8471
+ };
8472
+ "shopbite.wishlist.merge post /shopbite/wishlist/merge": {
8473
+ contentType?: "application/json";
8474
+ accept?: "application/json";
8475
+ body: {
8476
+ items: {
8477
+ extras?: string[];
8478
+ productId: string;
8479
+ without?: string[];
8480
+ }[];
8481
+ };
8482
+ response: {
8483
+ elements: components["schemas"]["ShopBiteWishlistItem"][];
8484
+ };
8485
+ responseCode: 200;
8486
+ };
8433
8487
  "readSitemap get /sitemap": {
8434
8488
  contentType?: "application/json";
8435
8489
  accept?: "application/json";
package/app/app.vue CHANGED
@@ -2,7 +2,6 @@
2
2
  import Footer from "~/components/Footer.vue";
3
3
 
4
4
  const { apiClient } = useShopwareContext();
5
- const router = useRouter();
6
5
 
7
6
  // The footer is below the fold on every page; its hydration waits until it
8
7
  // scrolls into view (#314).
@@ -40,17 +39,16 @@ const { refresh: refreshBusinessHours } = useBusinessHours();
40
39
  const { refresh: refreshHolidays } = useHolidays();
41
40
 
42
41
  const { refreshCart } = useCart();
43
- const { getWishlistProducts } = useWishlist();
44
-
45
- // The wishlist page (app/pages/merkliste.vue) loads the products itself.
46
- const WISHLIST_ROUTE_NAME = "merkliste";
47
-
48
- if (import.meta.client) {
49
- // getting the wishlist products should not block SSR
50
- if (router.currentRoute.value.name !== WISHLIST_ROUTE_NAME) {
51
- getWishlistProducts(); // initial page loading
52
- }
53
- }
42
+ // Wishlist entries (#467): loaded in the browser, not during SSR. A login
43
+ // moves the guest entries into the account, a logout shows the guest's.
44
+ const { isLoggedIn } = useUser();
45
+ const { load: loadWishlist, mergeGuestEntries } = useWishlistEntries();
46
+ onMounted(loadWishlist);
47
+ watch(isLoggedIn, (loggedIn, before) => {
48
+ if (loggedIn === before) return;
49
+ if (loggedIn) mergeGuestEntries();
50
+ else loadWishlist();
51
+ });
54
52
 
55
53
  onMounted(async () => {
56
54
  await Promise.all([refreshHolidays(), refreshBusinessHours()]);
@@ -3,12 +3,6 @@ import { TabsContent, TabsList, TabsRoot, TabsTrigger } from "reka-ui";
3
3
 
4
4
  // Reka tabs with the base forms (#443).
5
5
  const presetTab = ref<"neu" | "kunde">("neu");
6
-
7
- const { mergeWishlistProducts } = useWishlist();
8
-
9
- async function handleLoginSuccess() {
10
- mergeWishlistProducts();
11
- }
12
6
  </script>
13
7
 
14
8
  <template>
@@ -31,10 +25,10 @@ async function handleLoginSuccess() {
31
25
  </TabsTrigger>
32
26
  </TabsList>
33
27
  <TabsContent value="neu" class="focus-visible:outline-none">
34
- <UserRegistrationForm @registration-success="handleLoginSuccess" />
28
+ <UserRegistrationForm />
35
29
  </TabsContent>
36
30
  <TabsContent value="kunde" class="focus-visible:outline-none">
37
- <UserLoginForm @login-success="handleLoginSuccess" />
31
+ <UserLoginForm />
38
32
  </TabsContent>
39
33
  </TabsRoot>
40
34
  </template>
@@ -25,7 +25,7 @@ const {
25
25
  show: openCart,
26
26
  } = useCartQuickView();
27
27
  const { count: cartCount } = useCart();
28
- const { count: wishlistCount } = useWishlist();
28
+ const { count: wishlistCount } = useWishlistEntries();
29
29
  const { isCheckoutEnabled } = useShopBiteConfig();
30
30
  const { isLoggedIn, isGuestSession, logout } = useUser();
31
31
  const { status } = useStoreStatus();
@@ -1,30 +1,119 @@
1
1
  <script setup lang="ts">
2
+ import type { Schemas } from "#shopware";
2
3
  import { useNavigation } from "~/composables/useNavigation";
3
4
 
4
5
  /**
5
- * Menu categories as a horizontally scrolling row on phones and tablets
6
+ * Menu categories as horizontally scrolling rows on phones and tablets
6
7
  * (#445); the desktop menu has the word-list index (MenuCategoryIndex).
8
+ * The first row holds the menu sections. When the open section has
9
+ * sub-categories (La Fattoria: Fleischgerichte → Vom Rind, Hähnchen …),
10
+ * a second row lists them, led by "Alle" for the section itself; deeper
11
+ * levels follow in the same row. The current chip scrolls into view.
7
12
  */
8
- const { menuCardMenu } = useNavigation(true);
13
+ const { menuCardNavigation } = useNavigation(true);
9
14
  const route = useRoute();
10
15
 
16
+ type Chip = { label: string; to: string };
17
+
18
+ const normalize = (path: string) =>
19
+ decodeURI(path).replace(/\/+$/, "").toLowerCase();
20
+
11
21
  const isCurrent = (to?: string) =>
12
- !!to && decodeURI(route.path).toLowerCase() === decodeURI(to).toLowerCase();
22
+ !!to && normalize(route.path) === normalize(to);
23
+
24
+ function toChip(category: Schemas["Category"]): Chip {
25
+ return {
26
+ label: category.translated?.name ?? category.name ?? "",
27
+ to: category.seoUrl ?? "",
28
+ };
29
+ }
30
+
31
+ function descendants(category: Schemas["Category"]): Schemas["Category"][] {
32
+ return (category.children ?? []).flatMap((child) => [
33
+ child,
34
+ ...descendants(child),
35
+ ]);
36
+ }
37
+
38
+ const sections = computed(() => menuCardNavigation.value ?? []);
39
+
40
+ // The section the current page belongs to: itself or one of its children.
41
+ const activeSection = computed(() =>
42
+ sections.value.find(
43
+ (section) =>
44
+ isCurrent(section.seoUrl ?? undefined) ||
45
+ descendants(section).some((child) =>
46
+ isCurrent(child.seoUrl ?? undefined),
47
+ ),
48
+ ),
49
+ );
50
+
51
+ const subChips = computed<Chip[]>(() => {
52
+ const section = activeSection.value;
53
+ if (!section) return [];
54
+ const children = descendants(section).map(toChip);
55
+ if (!children.length) return [];
56
+ return [{ label: "Alle", to: section.seoUrl ?? "" }, ...children];
57
+ });
58
+
59
+ const nav = ref<HTMLElement | null>(null);
60
+
61
+ // Long rows scroll sideways: bring the current chips into view.
62
+ function revealCurrent() {
63
+ nav.value
64
+ ?.querySelectorAll<HTMLElement>('[aria-current="page"], [data-section]')
65
+ .forEach((chip) =>
66
+ chip.scrollIntoView({ block: "nearest", inline: "center" }),
67
+ );
68
+ }
69
+
70
+ onMounted(revealCurrent);
71
+ watch(
72
+ () => route.path,
73
+ () => nextTick(revealCurrent),
74
+ );
75
+
76
+ const chipClass =
77
+ "flex min-h-11 items-center rounded-sb-control px-3.5 font-semibold whitespace-nowrap focus-visible:outline-3 focus-visible:-outline-offset-3 focus-visible:outline-sb-focus";
13
78
  </script>
14
79
 
15
80
  <template>
16
81
  <nav
17
- v-if="menuCardMenu.length"
82
+ v-if="sections.length"
83
+ ref="nav"
18
84
  aria-label="Kategorien der Speisekarte"
19
85
  class="border-b border-sb-line bg-sb-bg/95 font-body backdrop-blur-sm"
20
86
  >
21
87
  <ul class="flex gap-1 overflow-x-auto px-4 py-2 sm:px-6">
22
- <li v-for="item in menuCardMenu" :key="item.to ?? item.label">
88
+ <li v-for="section in sections" :key="section.id">
89
+ <NuxtLink
90
+ :to="section.seoUrl ?? ''"
91
+ :aria-current="isCurrent(section.seoUrl ?? '') ? 'page' : undefined"
92
+ :data-section="section === activeSection ? '' : undefined"
93
+ :class="[
94
+ chipClass,
95
+ section === activeSection
96
+ ? 'bg-sb-ink text-sb-bg'
97
+ : 'text-sb-ink hover:bg-sb-muted',
98
+ ]"
99
+ >{{ toChip(section).label }}</NuxtLink
100
+ >
101
+ </li>
102
+ </ul>
103
+ <ul
104
+ v-if="subChips.length"
105
+ :aria-label="`Unterkategorien von ${toChip(activeSection!).label}`"
106
+ class="flex gap-1 overflow-x-auto border-t border-sb-line px-4 py-2 text-[15px] sm:px-6"
107
+ >
108
+ <li v-for="chip in subChips" :key="chip.to">
23
109
  <NuxtLink
24
- :to="item.to"
25
- :aria-current="isCurrent(item.to) ? 'page' : undefined"
26
- class="flex min-h-11 items-center rounded-sb-control px-3.5 font-semibold whitespace-nowrap text-sb-ink hover:bg-sb-muted focus-visible:outline-3 focus-visible:-outline-offset-3 focus-visible:outline-sb-focus aria-[current=page]:bg-sb-ink aria-[current=page]:text-sb-bg"
27
- >{{ item.label }}</NuxtLink
110
+ :to="chip.to"
111
+ :aria-current="isCurrent(chip.to) ? 'page' : undefined"
112
+ :class="[
113
+ chipClass,
114
+ 'border border-sb-line text-sb-ink hover:bg-sb-muted aria-[current=page]:border-sb-ink aria-[current=page]:bg-sb-muted',
115
+ ]"
116
+ >{{ chip.label }}</NuxtLink
28
117
  >
29
118
  </li>
30
119
  </ul>
@@ -2,6 +2,7 @@
2
2
  import type { Schemas } from "#shopware";
3
3
  import type { AssociationItemProduct } from "~/types/Association";
4
4
  import type { QuickViewConfiguration } from "~/utils/productUrl";
5
+ import type { WishlistConfiguration } from "~/composables/useWishlistEntries";
5
6
 
6
7
  const props = defineProps<{
7
8
  productId: string;
@@ -14,6 +15,8 @@ const emit = defineEmits<{
14
15
  "product-added": [];
15
16
  "variant-selected": [variant: Schemas["Product"]];
16
17
  "configuration-changed": [configuration: QuickViewConfiguration];
18
+ // The dish as configured right now, for the save button (#467).
19
+ "selection-changed": [selection: WishlistConfiguration];
17
20
  }>();
18
21
 
19
22
  const {
@@ -58,6 +61,25 @@ function emitConfiguration() {
58
61
  });
59
62
  }
60
63
 
64
+ watch(
65
+ () => {
66
+ const product = selectedProduct.value;
67
+ if (!product?.productNumber) return undefined;
68
+ return {
69
+ productId: product.id,
70
+ productNumber: product.productNumber,
71
+ without: [...deselectedIngredients.value],
72
+ extras: selectedExtras.value
73
+ .map((extra) => extra.productNumber)
74
+ .filter((number): number is string => !!number),
75
+ };
76
+ },
77
+ (selection) => {
78
+ if (selection) emit("selection-changed", selection);
79
+ },
80
+ { immediate: true, deep: true },
81
+ );
82
+
61
83
  // Unit price plus extras, times the quantity: what the button will add.
62
84
  const total = computed(() => {
63
85
  const unitPrice = selectedProduct.value?.calculatedPrice.unitPrice ?? 0;
@@ -1,6 +1,7 @@
1
1
  <script setup lang="ts">
2
2
  import type { Schemas } from "#shopware";
3
3
  import { DialogDescription, DialogTitle } from "reka-ui";
4
+ import type { WishlistConfiguration } from "~/composables/useWishlistEntries";
4
5
 
5
6
  const props = defineProps<{
6
7
  product: Schemas["Product"] | undefined;
@@ -19,6 +20,8 @@ const label = ref(props.product?.translated.name ?? props.product?.name ?? "");
19
20
  const description = ref(props.product?.description);
20
21
  // Follows the selected variant, like the URL (#411).
21
22
  const productNumber = ref(props.product?.productNumber);
23
+ // The dish as configured right now, for the save button (#467).
24
+ const selection = ref<WishlistConfiguration>();
22
25
  // Built in script: a trailing space in the template would be condensed away.
23
26
  const numberLabel = computed(() => `Nr. ${productNumber.value} `);
24
27
 
@@ -29,6 +32,7 @@ watch(
29
32
  label.value = product.translated.name ?? product.name;
30
33
  description.value = product.description;
31
34
  productNumber.value = product.productNumber;
35
+ selection.value = undefined;
32
36
  },
33
37
  );
34
38
 
@@ -89,6 +93,7 @@ function onVariantSelected(variant: Schemas["Product"]) {
89
93
  </div>
90
94
  </template>
91
95
  <template #actions>
96
+ <WishlistSaveButton :selection="selection" :name="label" />
92
97
  <SbIconButton
93
98
  :label="canShare ? 'Teilen' : 'Link kopieren'"
94
99
  @click="share({ title: label, productNumber })"
@@ -118,6 +123,7 @@ function onVariantSelected(variant: Schemas["Product"]) {
118
123
  @product-added="open = false"
119
124
  @variant-selected="onVariantSelected"
120
125
  @configuration-changed="updateConfiguration"
126
+ @selection-changed="selection = $event"
121
127
  />
122
128
  </SbSheet>
123
129
  <!-- Only the body scrolls: header and footer stay in place without sticky