@shopbite-de/storefront 2.6.1 → 2.7.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 (469) hide show
  1. package/.env.example +13 -0
  2. package/.github/workflows/ci.yaml +2 -0
  3. package/CLAUDE.md +54 -30
  4. package/GLOSSARY.md +327 -0
  5. package/README.md +5 -6
  6. package/app/app.vue +50 -40
  7. package/app/components/Address/Card.vue +2 -2
  8. package/app/components/Address/Detail.vue +17 -45
  9. package/app/components/Address/Form.vue +38 -26
  10. package/app/components/BranchSwitch.vue +40 -0
  11. package/app/components/Cart/Bar.vue +9 -9
  12. package/app/components/Cart/Item.vue +27 -36
  13. package/app/components/Cart/QuickView.vue +17 -16
  14. package/app/components/Cart/Upsell.vue +19 -27
  15. package/app/components/Category/Breadcrumb.vue +3 -8
  16. package/app/components/Category/FilterGroup.vue +6 -6
  17. package/app/components/Category/Listing.vue +44 -66
  18. package/app/components/Checkout/DeliveryTimeSelect.vue +21 -48
  19. package/app/components/Checkout/OrderMessage.vue +29 -0
  20. package/app/components/Checkout/OrdererAddress.vue +40 -0
  21. package/app/components/Checkout/PaymentAndDelivery.vue +40 -35
  22. package/app/components/Checkout/Summary.vue +89 -74
  23. package/app/components/Checkout/VoucherInput.vue +8 -8
  24. package/app/components/Contact/Form.vue +97 -13
  25. package/app/components/Footer.vue +2 -2
  26. package/app/components/Header.vue +9 -9
  27. package/app/components/Home/Categories.vue +13 -17
  28. package/app/components/Home/Facts.vue +6 -4
  29. package/app/components/Home/Hero.vue +1 -1
  30. package/app/components/Home/Highlights.vue +8 -8
  31. package/app/components/Home/Restaurant.vue +2 -2
  32. package/app/components/Menu/BonCard.vue +21 -37
  33. package/app/components/Menu/CartPanel.vue +2 -2
  34. package/app/components/Menu/CategoryIndex.vue +8 -12
  35. package/app/components/Menu/OrderMode.vue +2 -2
  36. package/app/components/Menu/SectionHeader.vue +6 -10
  37. package/app/components/Navigation/MobileTop.vue +12 -20
  38. package/app/components/Order/Confirmation.vue +10 -10
  39. package/app/components/Order/Detail.vue +47 -49
  40. package/app/components/Product/Configurator.vue +46 -30
  41. package/app/components/Product/CrossSelling.vue +56 -71
  42. package/app/components/Product/DeselectIngredient.vue +10 -11
  43. package/app/components/Product/Detail.vue +62 -55
  44. package/app/components/Product/FoodLabels.vue +4 -9
  45. package/app/components/Product/QuickView.vue +22 -30
  46. package/app/components/User/Detail.vue +20 -43
  47. package/app/components/User/LoginForm.vue +11 -17
  48. package/app/components/User/RegistrationForm.vue +3 -3
  49. package/app/components/Wishlist.vue +99 -106
  50. package/app/components/WishlistSaveButton.vue +17 -9
  51. package/app/composables/useAccountAddresses.ts +89 -0
  52. package/app/composables/useAccountOrders.ts +35 -0
  53. package/app/composables/useAddToCart.ts +63 -139
  54. package/app/composables/useCartData.ts +55 -0
  55. package/app/composables/useCartMutations.ts +93 -85
  56. package/app/composables/useCartUpsell.ts +27 -71
  57. package/app/composables/useCategoryListing.ts +36 -59
  58. package/app/composables/useCategorySeo.ts +11 -16
  59. package/app/composables/useCheckoutMethodGuard.ts +22 -46
  60. package/app/composables/useCheckoutMethods.ts +89 -0
  61. package/app/composables/useCheckoutOrderMessage.ts +19 -0
  62. package/app/composables/useCheckoutOrderer.ts +69 -0
  63. package/app/composables/useCommercePrice.ts +46 -9
  64. package/app/composables/useContactForm.ts +25 -32
  65. package/app/composables/useCustomer.ts +169 -0
  66. package/app/composables/useDeliveryTime.ts +112 -122
  67. package/app/composables/useHolidays.ts +12 -62
  68. package/app/composables/useHomeMenuCategories.ts +5 -5
  69. package/app/composables/useListingSearch.ts +9 -8
  70. package/app/composables/useLiveShopData.ts +15 -9
  71. package/app/composables/useMenuRootId.ts +3 -6
  72. package/app/composables/useMenuSection.ts +14 -0
  73. package/app/composables/useMenuSectionSchema.ts +23 -30
  74. package/app/composables/useNavigation.ts +24 -29
  75. package/app/composables/useOpeningHours.ts +21 -0
  76. package/app/composables/useOpeningHoursData.ts +9 -9
  77. package/app/composables/useOrder.ts +37 -0
  78. package/app/composables/useOrderMode.ts +18 -16
  79. package/app/composables/usePlaceOrder.ts +37 -0
  80. package/app/composables/useProductCartQuantity.ts +6 -6
  81. package/app/composables/useProductDetail.ts +28 -53
  82. package/app/composables/useProductEvents.ts +6 -5
  83. package/app/composables/useProductQuickView.ts +35 -68
  84. package/app/composables/useRegistrationForm.ts +85 -34
  85. package/app/composables/useRestaurantSchema.ts +7 -7
  86. package/app/composables/useSearchTracking.ts +6 -6
  87. package/app/composables/useSectionRoute.ts +48 -0
  88. package/app/composables/useServiceSchedule.ts +23 -0
  89. package/app/composables/useShippingLeadTime.ts +8 -6
  90. package/app/composables/useShippingMethodChoice.ts +13 -23
  91. package/app/composables/useShippingMethods.ts +31 -0
  92. package/app/composables/useShopConfig.ts +60 -0
  93. package/app/composables/useShopData.ts +20 -0
  94. package/app/composables/useSortingSelection.ts +5 -8
  95. package/app/composables/useStoreStatus.ts +13 -37
  96. package/app/composables/useTopSellers.ts +3 -3
  97. package/app/composables/useTrackEvent.ts +29 -24
  98. package/app/composables/useVoucherCode.ts +47 -12
  99. package/app/composables/useWishlistEntries.ts +233 -177
  100. package/app/error.vue +3 -2
  101. package/app/layouts/account.vue +4 -3
  102. package/app/pages/[...all].vue +6 -16
  103. package/app/pages/account/recover/password/index.vue +6 -14
  104. package/app/pages/anmelden.vue +1 -1
  105. package/app/pages/bestellung/[id]/erfolg.vue +3 -3
  106. package/app/pages/bestellung/[id]/fehler.vue +18 -29
  107. package/app/pages/bestellung/kasse.vue +24 -7
  108. package/app/pages/konto/adressen.vue +95 -40
  109. package/app/pages/konto/bestellungen.vue +10 -13
  110. package/app/pages/konto/index.vue +12 -2
  111. package/app/pages/konto/profil.vue +241 -42
  112. package/app/pages/passwort-vergessen.vue +5 -10
  113. package/app/pages/registrierung/bestaetigen.vue +9 -23
  114. package/app/pages/registrierung/index.vue +19 -11
  115. package/app/pages/suche.vue +29 -29
  116. package/app/plugins/shopware-layer-offline.ts +38 -0
  117. package/app/plugins/visitor-has-session.server.ts +19 -0
  118. package/app/utils/accountMessages.ts +74 -0
  119. package/app/utils/accountReads.ts +34 -0
  120. package/app/utils/bffWrite.ts +89 -0
  121. package/app/utils/dish.ts +121 -0
  122. package/app/utils/leadTime.ts +25 -29
  123. package/app/utils/media.ts +11 -17
  124. package/app/utils/menuGroups.ts +22 -35
  125. package/app/utils/money.ts +41 -0
  126. package/app/utils/openingHours.ts +30 -30
  127. package/app/utils/orderStatus.ts +17 -0
  128. package/app/utils/productUrl.ts +14 -31
  129. package/app/utils/restaurantTime.ts +326 -0
  130. package/app/utils/schema.ts +39 -42
  131. package/app/utils/wishlist.ts +139 -0
  132. package/docs/adr/0001-backend-agnostic-storefront.md +409 -0
  133. package/eslint.config.mjs +42 -2
  134. package/nuxt.config.ts +28 -0
  135. package/package.json +1 -1
  136. package/server/adapters/memory/cart.ts +370 -0
  137. package/server/adapters/memory/catalog.ts +367 -0
  138. package/server/adapters/memory/contact.ts +89 -0
  139. package/server/adapters/memory/customer.ts +458 -0
  140. package/server/adapters/memory/demo-menu.json +1190 -0
  141. package/server/adapters/memory/demoImages.ts +13 -0
  142. package/server/adapters/memory/demoMenu.ts +234 -0
  143. package/server/adapters/memory/demoNavigation.ts +71 -0
  144. package/server/adapters/memory/index.ts +122 -0
  145. package/server/adapters/memory/navigation.ts +168 -0
  146. package/server/adapters/memory/ordering.ts +379 -0
  147. package/server/adapters/memory/seed.ts +136 -0
  148. package/server/adapters/memory/wishlist.ts +166 -0
  149. package/server/adapters/notImplemented.ts +67 -0
  150. package/server/adapters/registry.ts +32 -0
  151. package/server/adapters/runtimeConfig.ts +14 -0
  152. package/server/adapters/shopware/cart.ts +792 -0
  153. package/server/adapters/shopware/catalog.ts +850 -0
  154. package/server/adapters/shopware/checkout.ts +138 -0
  155. package/server/adapters/shopware/contact.ts +255 -0
  156. package/server/adapters/shopware/customer.ts +460 -0
  157. package/server/adapters/shopware/index.ts +165 -0
  158. package/server/adapters/shopware/menuRoot.ts +24 -0
  159. package/server/adapters/shopware/navigation.ts +426 -0
  160. package/server/adapters/shopware/ordering.ts +1185 -0
  161. package/server/adapters/shopware/request.ts +67 -0
  162. package/server/adapters/shopware/shop.ts +249 -0
  163. package/server/adapters/shopware/storeApi.ts +62 -0
  164. package/server/adapters/shopware/wishlist.ts +473 -0
  165. package/server/api/__sitemap__/urls.get.ts +10 -38
  166. package/server/api/account/addresses/[addressId]/default.post.ts +13 -0
  167. package/server/api/account/addresses/[addressId].delete.ts +14 -0
  168. package/server/api/account/addresses/[addressId].patch.ts +15 -0
  169. package/server/api/account/addresses/index.get.ts +6 -0
  170. package/server/api/account/addresses/index.post.ts +9 -0
  171. package/server/api/account/email.post.ts +10 -0
  172. package/server/api/account/index.delete.ts +11 -0
  173. package/server/api/account/index.get.ts +9 -0
  174. package/server/api/account/login.post.ts +14 -0
  175. package/server/api/account/logout.post.ts +11 -0
  176. package/server/api/account/orders.get.ts +13 -0
  177. package/server/api/account/password-reset/confirm.post.ts +13 -0
  178. package/server/api/account/password-reset.post.ts +16 -0
  179. package/server/api/account/password.post.ts +18 -0
  180. package/server/api/account/profile.patch.ts +6 -0
  181. package/server/api/account/register/confirm.post.ts +13 -0
  182. package/server/api/account/register.post.ts +15 -0
  183. package/server/api/breadcrumb/[sectionId].get.ts +33 -0
  184. package/server/api/cart/index.get.ts +4 -0
  185. package/server/api/cart/lines/[lineId].delete.ts +6 -0
  186. package/server/api/cart/lines/[lineId].patch.ts +10 -0
  187. package/server/api/cart/lines.post.ts +10 -0
  188. package/server/api/cart/vouchers/[code].delete.ts +9 -0
  189. package/server/api/cart/vouchers.post.ts +12 -0
  190. package/server/api/checkout/guest.post.ts +13 -0
  191. package/server/api/checkout/orderer/addresses/[addressId].patch.ts +16 -0
  192. package/server/api/checkout/orderer.get.ts +10 -0
  193. package/server/api/checkout/orders.post.ts +60 -0
  194. package/server/api/checkout/payment-methods.get.ts +9 -0
  195. package/server/api/checkout/selection.get.ts +10 -0
  196. package/server/api/checkout/selection.post.ts +14 -0
  197. package/server/api/checkout/shipping-methods.get.ts +9 -0
  198. package/server/api/contact/form.get.ts +13 -0
  199. package/server/api/contact/index.post.ts +24 -0
  200. package/server/api/listing/[sectionId].get.ts +33 -0
  201. package/server/api/menu/dishes/[dishId]/variant.get.ts +29 -0
  202. package/server/api/menu/dishes/[dishId].get.ts +19 -0
  203. package/server/api/menu/dishes/index.get.ts +26 -0
  204. package/server/api/menu/media/[name].get.ts +18 -0
  205. package/server/api/menu/root.get.ts +12 -0
  206. package/server/api/menu/sections/[sectionId].get.ts +18 -0
  207. package/server/api/menu/upsell.get.ts +12 -0
  208. package/server/api/navigation/[kind].get.ts +75 -0
  209. package/server/api/orders/[orderId]/payment.post.ts +24 -0
  210. package/server/api/orders/[orderId].get.ts +13 -0
  211. package/server/api/payment-methods.get.ts +11 -15
  212. package/server/api/resolve-path.get.ts +20 -0
  213. package/server/api/search.get.ts +16 -80
  214. package/server/api/session.post.ts +18 -0
  215. package/server/api/shop/branches.get.ts +9 -0
  216. package/server/api/shop/config.get.ts +9 -0
  217. package/server/api/shop/holidays.get.ts +9 -0
  218. package/server/api/shop/opening-hours.get.ts +9 -0
  219. package/server/api/top-sellers.get.ts +14 -50
  220. package/server/api/wishlist/entries/[entryId].delete.ts +8 -0
  221. package/server/api/wishlist/entries.post.ts +13 -0
  222. package/server/api/wishlist/index.get.ts +13 -0
  223. package/server/api/wishlist/merge.post.ts +12 -0
  224. package/server/plugins/visitor-session.ts +35 -0
  225. package/server/ports/CartPort.ts +48 -0
  226. package/server/ports/CatalogPort.ts +66 -0
  227. package/server/ports/CheckoutPort.ts +128 -0
  228. package/server/ports/ContactPort.ts +38 -0
  229. package/server/ports/CustomerPort.ts +154 -0
  230. package/server/ports/NavigationPort.ts +58 -0
  231. package/server/ports/OrderPort.ts +31 -0
  232. package/server/ports/ShopPort.ts +29 -0
  233. package/server/ports/WishlistPort.ts +47 -0
  234. package/server/ports/index.ts +42 -0
  235. package/server/ports/session.ts +22 -0
  236. package/server/routes/llms.txt.ts +28 -154
  237. package/server/session/forwardedFor.ts +24 -0
  238. package/server/session/sameOrigin.ts +47 -0
  239. package/server/session/seal.ts +147 -0
  240. package/server/session/visitorSession.ts +288 -0
  241. package/server/utils/accountRoutes.ts +173 -0
  242. package/server/utils/backend.ts +21 -0
  243. package/server/utils/backoff.ts +18 -5
  244. package/server/utils/cacheKeys.ts +11 -0
  245. package/server/utils/cachePurge.ts +47 -27
  246. package/server/utils/cartRoutes.ts +124 -0
  247. package/server/utils/catalogData.ts +24 -0
  248. package/server/utils/checkoutRoutes.ts +326 -0
  249. package/server/utils/contactRoutes.ts +86 -0
  250. package/server/utils/domainHttp.ts +73 -0
  251. package/server/utils/listingParams.ts +49 -20
  252. package/server/utils/llmsTxt.ts +64 -19
  253. package/server/utils/navigationData.ts +14 -0
  254. package/server/utils/orderPlacement.ts +322 -0
  255. package/server/utils/outageBreaker.ts +126 -0
  256. package/server/utils/pathRoutes.ts +160 -0
  257. package/server/utils/requestBody.ts +43 -0
  258. package/server/utils/shopData.ts +132 -0
  259. package/server/utils/sitemap.ts +14 -36
  260. package/server/utils/storeApi.ts +71 -23
  261. package/server/utils/visitorSession.ts +209 -0
  262. package/server/utils/wishlistRoutes.ts +55 -0
  263. package/shared/domain/customer/index.ts +2 -0
  264. package/shared/domain/customer/types.ts +88 -0
  265. package/shared/domain/discoverability/index.ts +4 -0
  266. package/shared/domain/discoverability/paths.ts +93 -0
  267. package/shared/domain/discoverability/route.ts +32 -0
  268. package/shared/domain/discoverability/types.ts +75 -0
  269. package/shared/domain/index.ts +11 -0
  270. package/shared/domain/kernel/calendar.ts +88 -0
  271. package/shared/domain/kernel/errors.ts +100 -0
  272. package/shared/domain/kernel/freeze.ts +13 -0
  273. package/shared/domain/kernel/ids.ts +6 -0
  274. package/shared/domain/kernel/index.ts +8 -0
  275. package/shared/domain/kernel/media.ts +17 -0
  276. package/shared/domain/kernel/money.ts +104 -0
  277. package/shared/domain/kernel/timeOfDay.ts +39 -0
  278. package/shared/domain/menu/dishConfiguration.ts +72 -0
  279. package/shared/domain/menu/index.ts +3 -0
  280. package/shared/domain/menu/types.ts +185 -0
  281. package/shared/domain/ordering/index.ts +3 -0
  282. package/shared/domain/ordering/time.ts +114 -0
  283. package/shared/domain/ordering/types.ts +195 -0
  284. package/shared/domain/restaurant/holiday.ts +38 -0
  285. package/shared/domain/restaurant/index.ts +4 -0
  286. package/shared/domain/restaurant/openingInterval.ts +97 -0
  287. package/shared/domain/restaurant/types.ts +75 -0
  288. package/test/a11y/presets.test.ts +49 -31
  289. package/test/contract/cart.contract.ts +592 -0
  290. package/test/contract/cart.spec.ts +5 -0
  291. package/test/contract/cartFixtures.ts +573 -0
  292. package/test/contract/catalog.contract.ts +714 -0
  293. package/test/contract/catalog.spec.ts +5 -0
  294. package/test/contract/catalogFixtures.ts +572 -0
  295. package/test/contract/checkout.contract.ts +123 -0
  296. package/test/contract/checkout.spec.ts +5 -0
  297. package/test/contract/contact.contract.ts +149 -0
  298. package/test/contract/contact.spec.ts +4 -0
  299. package/test/contract/contactFixtures.ts +148 -0
  300. package/test/contract/customer.contract.ts +831 -0
  301. package/test/contract/customer.spec.ts +4 -0
  302. package/test/contract/customerFixtures.ts +468 -0
  303. package/test/contract/fixtures.ts +260 -0
  304. package/test/contract/harness.ts +45 -0
  305. package/test/contract/navigation.contract.ts +336 -0
  306. package/test/contract/navigation.spec.ts +5 -0
  307. package/test/contract/navigationFixtures.ts +311 -0
  308. package/test/contract/ordering.contract.ts +655 -0
  309. package/test/contract/ordering.spec.ts +4 -0
  310. package/test/contract/orderingFixtures.ts +498 -0
  311. package/test/contract/shop.contract.ts +164 -0
  312. package/test/contract/shop.spec.ts +5 -0
  313. package/test/contract/wishlist.contract.ts +375 -0
  314. package/test/contract/wishlist.spec.ts +4 -0
  315. package/test/contract/wishlistFixtures.ts +199 -0
  316. package/test/nuxt/AccountPagesPreset.test.ts +320 -83
  317. package/test/nuxt/AuthPagesPreset.test.ts +17 -24
  318. package/test/nuxt/CartBar.test.ts +12 -8
  319. package/test/nuxt/CartCheckoutPreset.test.ts +36 -33
  320. package/test/nuxt/CartItem.test.ts +39 -20
  321. package/test/nuxt/CartQuickView.test.ts +106 -0
  322. package/test/nuxt/CartUpsell.test.ts +37 -39
  323. package/test/nuxt/CategoryBreadcrumb.test.ts +26 -0
  324. package/test/nuxt/CheckoutFormsPreset.test.ts +92 -13
  325. package/test/nuxt/CheckoutOnePage.test.ts +28 -21
  326. package/test/nuxt/CheckoutPageMessage.test.ts +31 -0
  327. package/test/nuxt/CheckoutSummary.test.ts +163 -48
  328. package/test/nuxt/CheckoutVoucherInput.test.ts +77 -80
  329. package/test/nuxt/ContactFormPreset.test.ts +97 -36
  330. package/test/nuxt/DeliveryTimeSelect.test.ts +72 -45
  331. package/test/nuxt/FooterStoreStatus.test.ts +2 -2
  332. package/test/nuxt/HeaderFooterPreset.test.ts +11 -19
  333. package/test/nuxt/HomeCategories.test.ts +47 -0
  334. package/test/nuxt/HomeLeadTimes.test.ts +3 -3
  335. package/test/nuxt/MenuBonCard.test.ts +45 -32
  336. package/test/nuxt/NavigationMobileTop.test.ts +30 -28
  337. package/test/nuxt/OrderPagesPreset.test.ts +83 -52
  338. package/test/nuxt/PaymentAndDelivery.test.ts +25 -26
  339. package/test/nuxt/ProductConfigurator.test.ts +81 -0
  340. package/test/nuxt/ProductCrossSelling.test.ts +23 -20
  341. package/test/nuxt/ProductDeselectIngredient.test.ts +6 -9
  342. package/test/nuxt/ProductFoodLabels.test.ts +7 -24
  343. package/test/nuxt/ProductSheetPreset.test.ts +24 -24
  344. package/test/nuxt/RegisterConfirmPage.test.ts +26 -45
  345. package/test/nuxt/RegistrationForm.test.ts +57 -53
  346. package/test/nuxt/RegistrationPage.test.ts +37 -0
  347. package/test/nuxt/WishlistPage.test.ts +119 -43
  348. package/test/nuxt/WishlistSaveButton.test.ts +39 -12
  349. package/test/nuxt/accountSwitch.test.ts +106 -0
  350. package/test/nuxt/bffWrite.test.ts +41 -0
  351. package/test/nuxt/liveShopData.test.ts +36 -68
  352. package/test/nuxt/shopwareLayerOffline.test.ts +32 -0
  353. package/test/nuxt/useAddToCart.test.ts +116 -174
  354. package/test/nuxt/useCartMutations.test.ts +165 -113
  355. package/test/nuxt/useCartUpsell.test.ts +36 -63
  356. package/test/nuxt/useCategoryListing.test.ts +75 -118
  357. package/test/nuxt/useCheckoutMethodGuard.test.ts +54 -105
  358. package/test/nuxt/useCustomer.test.ts +127 -0
  359. package/test/nuxt/useDeliveryTime.test.ts +169 -157
  360. package/test/nuxt/useNavigation.test.ts +81 -0
  361. package/test/nuxt/useOpeningHoursData.test.ts +18 -18
  362. package/test/nuxt/useOrder.test.ts +38 -0
  363. package/test/nuxt/usePlaceOrder.test.ts +88 -0
  364. package/test/nuxt/useSearchTracking.test.ts +2 -2
  365. package/test/nuxt/useSectionRoute.test.ts +86 -0
  366. package/test/nuxt/useShippingLeadTime.test.ts +17 -17
  367. package/test/nuxt/useShippingMethodChoice.test.ts +22 -22
  368. package/test/nuxt/useShippingMethods.test.ts +71 -0
  369. package/test/nuxt/useShopConfig.test.ts +64 -0
  370. package/test/nuxt/useStoreStatus.test.ts +34 -50
  371. package/test/nuxt/useTopSellers.test.ts +6 -5
  372. package/test/nuxt/useTrackEvent.test.ts +68 -6
  373. package/test/nuxt/useWishlistEntries.test.ts +392 -128
  374. package/test/support/cart.ts +43 -0
  375. package/test/support/dishes.ts +116 -0
  376. package/test/support/navigation.ts +17 -0
  377. package/test/unit/accountMessages.spec.ts +53 -0
  378. package/test/unit/accountRoutes.spec.ts +637 -0
  379. package/test/unit/adapters/memoryCustomer.spec.ts +67 -0
  380. package/test/unit/adapters/memoryDemoMenu.spec.ts +174 -0
  381. package/test/unit/adapters/registry.spec.ts +100 -0
  382. package/test/unit/adapters/shopwareCart.spec.ts +636 -0
  383. package/test/unit/adapters/shopwareCatalog.spec.ts +486 -0
  384. package/test/unit/adapters/shopwareCheckout.spec.ts +197 -0
  385. package/test/unit/adapters/shopwareContact.spec.ts +296 -0
  386. package/test/unit/adapters/shopwareCustomer.spec.ts +256 -0
  387. package/test/unit/adapters/shopwareNavigation.spec.ts +594 -0
  388. package/test/unit/adapters/shopwareOrdering.spec.ts +620 -0
  389. package/test/unit/adapters/shopwareShop.spec.ts +259 -0
  390. package/test/unit/adapters/shopwareWishlist.spec.ts +306 -0
  391. package/test/unit/adapters/useBackend.spec.ts +41 -0
  392. package/test/unit/backoff.spec.ts +47 -0
  393. package/test/unit/boundedCache.spec.ts +59 -59
  394. package/test/unit/cacheKeys.spec.ts +44 -0
  395. package/test/unit/cachePurge.spec.ts +44 -19
  396. package/test/unit/cartRoutes.spec.ts +567 -0
  397. package/test/unit/catalogRoutes.spec.ts +287 -0
  398. package/test/unit/checkoutRoutes.spec.ts +545 -0
  399. package/test/unit/dish.spec.ts +128 -0
  400. package/test/unit/domain/discoverability.spec.ts +154 -0
  401. package/test/unit/domain/dishConfiguration.spec.ts +85 -0
  402. package/test/unit/domain/money.spec.ts +102 -0
  403. package/test/unit/domain/time.spec.ts +336 -0
  404. package/test/unit/domainHttp.spec.ts +74 -0
  405. package/test/unit/forwardedFor.spec.ts +24 -0
  406. package/test/unit/layoutCacheRoutes.spec.ts +47 -471
  407. package/test/unit/leadTime.spec.ts +28 -23
  408. package/test/unit/llmsTxt.spec.ts +120 -9
  409. package/test/unit/media.spec.ts +25 -26
  410. package/test/unit/menuGroups.spec.ts +31 -21
  411. package/test/unit/navigationRoutes.spec.ts +648 -0
  412. package/test/unit/nitroStubs.ts +6 -1
  413. package/test/unit/openingHours.spec.ts +57 -34
  414. package/test/unit/orderPlacement.spec.ts +362 -0
  415. package/test/unit/outageBreaker.spec.ts +213 -0
  416. package/test/unit/productUrl.spec.ts +10 -28
  417. package/test/unit/requestBody.spec.ts +56 -0
  418. package/test/unit/restaurantTime.spec.ts +295 -0
  419. package/test/unit/schema.spec.ts +58 -26
  420. package/test/unit/session/sameOrigin.spec.ts +76 -0
  421. package/test/unit/session/seal.spec.ts +128 -0
  422. package/test/unit/session/visitorSession.spec.ts +439 -0
  423. package/test/unit/shopRoutes.spec.ts +257 -0
  424. package/test/unit/sitemap.spec.ts +11 -47
  425. package/test/unit/storeApiForVisitor.spec.ts +109 -0
  426. package/test/unit/useCategorySeo.spec.ts +57 -31
  427. package/test/unit/wishlistContactRoutes.spec.ts +607 -0
  428. package/vitest.config.ts +5 -1
  429. package/app/components/SalesChannelSwitch.vue +0 -73
  430. package/app/composables/useBusinessHours.ts +0 -192
  431. package/app/composables/useCategoryById.ts +0 -10
  432. package/app/composables/useNavigationSearch.ts +0 -45
  433. package/app/composables/useProductConfigurator.ts +0 -70
  434. package/app/composables/useProductCrossSelling.ts +0 -42
  435. package/app/composables/useProductVariants.ts +0 -61
  436. package/app/composables/useProductVariantsZwei.ts +0 -62
  437. package/app/composables/useSeoUrlRoute.ts +0 -124
  438. package/app/composables/useShopBiteConfig.ts +0 -69
  439. package/app/composables/useSyncWishlist.ts +0 -119
  440. package/app/types/Association.d.ts +0 -14
  441. package/app/utils/product.ts +0 -139
  442. package/app/utils/seoPath.ts +0 -68
  443. package/app/utils/time.ts +0 -20
  444. package/server/api/breadcrumb/[categoryId].get.ts +0 -31
  445. package/server/api/category/[categoryId].get.ts +0 -37
  446. package/server/api/listing/[categoryId].get.ts +0 -102
  447. package/server/api/navigation/[type].get.ts +0 -97
  448. package/server/api/product/[productId]/cross-selling.get.ts +0 -26
  449. package/server/api/product/[productId].get.ts +0 -76
  450. package/server/api/product/variant.get.ts +0 -98
  451. package/server/api/seo-url/index.get.ts +0 -17
  452. package/server/api/seo-url/known.get.ts +0 -33
  453. package/server/api/shopbite/business-hours.get.ts +0 -22
  454. package/server/api/shopbite/config.get.ts +0 -6
  455. package/server/api/shopbite/holidays.get.ts +0 -20
  456. package/server/utils/menuRoot.ts +0 -31
  457. package/server/utils/seoPaths.ts +0 -130
  458. package/server/utils/seoUrlCache.ts +0 -98
  459. package/server/utils/shopBiteConfig.ts +0 -30
  460. package/test/nuxt/useBusinessHours.test.ts +0 -106
  461. package/test/nuxt/useProductConfigurator.test.ts +0 -87
  462. package/test/nuxt/useProductVariants.test.ts +0 -95
  463. package/test/nuxt/useProductVariantsZwei.test.ts +0 -52
  464. package/test/nuxt/useSeoUrlRoute.test.ts +0 -176
  465. package/test/nuxt/useShopBiteConfig.test.ts +0 -131
  466. package/test/nuxt/useSyncWishlist.test.ts +0 -85
  467. package/test/unit/product.spec.ts +0 -160
  468. package/test/unit/seoPath.spec.ts +0 -161
  469. package/test/unit/seoPaths.spec.ts +0 -117
package/GLOSSARY.md ADDED
@@ -0,0 +1,327 @@
1
+ # Glossary
2
+
3
+ The ubiquitous language of the ShopBite storefront: an online ordering storefront for restaurants that works against any shop backend. Code, docs and tests use these terms in English; the German word in quotes is what guests see in the UI. The terms are grouped by bounded context; how the contexts relate is in [ADR 0001](docs/adr/0001-backend-agnostic-storefront.md).
4
+
5
+ ## Storefront
6
+
7
+ **Restaurant**:
8
+ The business that sells through the storefront: its menu, hours, branches and orders.
9
+ _Avoid_: merchant, store owner
10
+
11
+ **Shop**:
12
+ One restaurant's storefront as it is deployed (a shop extends the storefront layer).
13
+ _Avoid_: site, instance
14
+
15
+ **Shop backend**:
16
+ The system that owns the restaurant's data and orders (Shopware today); the storefront reaches it only through its ports.
17
+ _Avoid_: API, commerce engine
18
+
19
+ ## Menu
20
+
21
+ **Menu** ("Speisekarte"):
22
+ Everything the restaurant offers, as a tree of menu sections.
23
+ _Avoid_: catalog (except in the port's name), assortment
24
+
25
+ **Menu section** ("Pizza", "Nudeln"):
26
+ A named group of dishes on the menu; a section can have sub-sections.
27
+ _Avoid_: category, collection, taxon
28
+
29
+ **Dish**:
30
+ Something on the menu that can be ordered, with a menu number, a price and its main ingredients. Drinks and side orders are dishes too.
31
+ _Avoid_: product, article, item
32
+
33
+ **Menu number** ("Nr. 21"):
34
+ The number of a dish on the printed menu; guests and the kitchen use it to name the dish.
35
+ _Avoid_: SKU, product number (outside the Shopware adapter)
36
+
37
+ **Variant** ("Groß 40 cm", "Pommes frites"):
38
+ One orderable form of a dish, chosen by one option per variant group; it has its own menu number and price.
39
+ _Avoid_: child product, SKU
40
+
41
+ **Variant group** ("Größe", "Beilage", "Garstufe"):
42
+ A choice that tells the variants of a dish apart.
43
+ _Avoid_: property group, option set
44
+
45
+ **Main ingredient**:
46
+ An ingredient listed with the dish; each one is a removable ingredient.
47
+ _Avoid_: property, attribute
48
+
49
+ **Removable ingredient** ("ohne Zwiebeln"):
50
+ A main ingredient the guest can leave out at no charge.
51
+ _Avoid_: deselected ingredient, modifier
52
+
53
+ **Extra** ("Extra Käse"):
54
+ An optional addition to a dish with its own price.
55
+ _Avoid_: topping (too narrow), add-on, cross-selling
56
+
57
+ **Extra group** ("Extras", "Beilagen"):
58
+ A named list of extras offered for a dish.
59
+ _Avoid_: cross-selling, association
60
+
61
+ **Dish configuration** ("Anpassen"):
62
+ A dish (or variant) together with its chosen extras and removed ingredients; two configurations with the same parts are the same.
63
+ _Avoid_: product configuration, customisation
64
+
65
+ **Dish sheet**:
66
+ The panel in which a guest configures a dish before adding it to the cart; its configuration is part of the dish's link.
67
+ _Avoid_: quick view, product page
68
+
69
+ **Diet** ("Vegetarisch", "Vegan"):
70
+ A badge that tells which diet a dish suits.
71
+ _Avoid_: tag
72
+
73
+ **Allergen** ("Allergene", A–R) and **Additive** ("Zusatzstoffe", 1–12):
74
+ Food labels the law requires; a dish's lists are either checked (complete) or the guest is asked to call.
75
+ _Avoid_: property
76
+
77
+ **Top seller** ("Oft bestellt"):
78
+ A dish the restaurant marks for the home page.
79
+ _Avoid_: highlight, bestseller
80
+
81
+ **Upsell dish** ("Dazu passt"):
82
+ A dish suggested on the confirmation step before the order is placed.
83
+ _Avoid_: cross-sell
84
+
85
+ ## Ordering
86
+
87
+ **Cart** ("Warenkorb"):
88
+ The dishes a visitor is about to order, priced by the shop backend.
89
+ _Avoid_: basket, bag
90
+
91
+ **Cart line**:
92
+ One dish configuration in the cart with its quantity; a dish with extras and removed ingredients is one line, priced as a whole. Adding the same configuration again raises the quantity; configurations that differ in anything, also only in their removed ingredients, are two lines.
93
+ _Avoid_: line item, container, position
94
+
95
+ **Cart message**:
96
+ What the shop backend says about the cart ("nicht mehr verfügbar"); an error message blocks the order.
97
+ _Avoid_: error, notice
98
+
99
+ **Discount**:
100
+ A price reduction of the cart, either from a voucher or applied automatically by the restaurant's rules.
101
+ _Avoid_: promotion, rebate
102
+
103
+ **Voucher** ("Gutschein"):
104
+ A code the guest enters to get a discount.
105
+ _Avoid_: promotion, coupon
106
+
107
+ **Fulfillment** ("Lieferung oder Abholung"):
108
+ How the order reaches the guest: delivery or pickup.
109
+ _Avoid_: shipping, order mode
110
+
111
+ **Delivery** ("Lieferung"):
112
+ The restaurant brings the order to the guest's delivery address.
113
+
114
+ **Pickup** ("Abholung"):
115
+ The guest collects the order at the restaurant.
116
+ _Avoid_: collection, takeaway
117
+
118
+ **Shipping method** ("Lieferung", "Abholung"):
119
+ A way to get the order, with its fulfillment and lead time; a shop can have several per fulfillment.
120
+ _Avoid_: delivery option
121
+
122
+ **Lead time** ("Lieferzeit ca. 30 Minuten", "Abholbereit in ca. 15 Minuten"):
123
+ The minutes the kitchen needs before an order is delivered or ready for pickup; set per shipping method.
124
+ _Avoid_: delivery time (the backend's entity of that name is something else), preparation time
125
+
126
+ **Wished time** ("Wunschlieferzeit", "Wunschabholzeit"):
127
+ The service date and time at which the guest wants the order, on the 5-minute grid; shortly after midnight is the next service date.
128
+ _Avoid_: slot, requested time, delivery time
129
+
130
+ **Ordering window** ("Wann"):
131
+ The wished times a guest can choose now: from now plus the lead time to the end of the current or next opening interval within the next 24 hours, never on a holiday.
132
+ _Avoid_: delivery window, time range
133
+
134
+ **Checkout** ("Kasse"):
135
+ The page on which the guest chooses fulfillment, wished time, details and payment, and places the order.
136
+ _Avoid_: checkout steps
137
+
138
+ **Payment method** ("Zahlungsart", "Barzahlung"):
139
+ A way to pay; some send the guest to another site after the order.
140
+
141
+ **Order** ("Bestellung"):
142
+ A placed cart with the guest's details, fulfillment and wished time.
143
+ _Avoid_: purchase, transaction
144
+
145
+ **Order attempt**:
146
+ One press of the order button; sent again unchanged when the answer does not come, so it never places two orders.
147
+ _Avoid_: idempotency key (outside the code), retry
148
+
149
+ **Order number** ("Bestellnummer"):
150
+ The number of an order shown to the guest and the restaurant.
151
+
152
+ **Order status**:
153
+ Where the order stands for the restaurant: open, in progress, completed or cancelled.
154
+ _Avoid_: state, state machine state
155
+
156
+ **Payment status**:
157
+ Where the payment stands: open, paid, failed, cancelled or refunded.
158
+
159
+ **Note**:
160
+ The guest's free text to the restaurant on an order (the checkout does not ask for one yet).
161
+ _Avoid_: customer comment, remark
162
+
163
+ ## Guest & Account
164
+
165
+ **Visitor**:
166
+ Anyone using the storefront, before they identify themselves.
167
+ _Avoid_: user, session
168
+
169
+ **Guest** ("Als Gast bestellen"):
170
+ A visitor who orders with their details but without an account.
171
+ _Avoid_: anonymous customer
172
+
173
+ **Customer** ("Kundenkonto"):
174
+ A person with an account: login, saved addresses, order history, wishlist.
175
+ _Avoid_: user, account holder, member
176
+
177
+ **Orderer** ("Ihre Angaben"):
178
+ The guest or customer who orders in this session, with the billing and delivery address the order uses.
179
+ _Avoid_: buyer, checkout customer
180
+
181
+ **Business** ("Geschäftskunde"):
182
+ A guest or customer who orders for a company; the billing address names it.
183
+ _Avoid_: B2B customer, commercial account
184
+
185
+ **Address**:
186
+ A postal address of a guest or customer, used as billing address ("Rechnungsadresse") or delivery address ("Lieferadresse").
187
+ _Avoid_: shipping address
188
+
189
+ **Registration** ("Registrierung"):
190
+ Creating an account; with double opt-in the customer confirms the email first.
191
+ _Avoid_: sign-up
192
+
193
+ **Registration confirmation** ("Registrierung bestätigen"):
194
+ The link in the e-mail of a registration with double opt-in; the account opens with it.
195
+ _Avoid_: opt-in, activation
196
+
197
+ **Login** ("Anmelden") and **Logout** ("Abmelden"):
198
+ The customer opens and closes the account in the session; the visitor's cart joins the customer's on login.
199
+ _Avoid_: sign-in, authentication
200
+
201
+ **Password reset** ("Passwort vergessen", "Neues Passwort"):
202
+ A link by e-mail that sets a new password; the storefront answers the same whether the e-mail has an account.
203
+ _Avoid_: password recovery (outside the Shopware adapter)
204
+
205
+ **Default address** ("Lieferadresse", "Rechnungsadresse" of the account):
206
+ The address of the account an order uses for billing or delivery unless the customer changes it.
207
+ _Avoid_: default shipping address, active address
208
+
209
+ **Wishlist** ("Merkliste"):
210
+ The configured dishes a guest or customer keeps for later; the same dish can be kept twice with different configurations. A guest's stays in the browser, a customer's in the shop backend; on login the guest's joins the customer's.
211
+ _Avoid_: favourites, wish list (two words)
212
+
213
+ **Wishlist entry**:
214
+ One dish configuration on the wishlist.
215
+ _Avoid_: wishlist item
216
+
217
+ **Session**:
218
+ The storefront's own record of a visitor (cart, login) in its HttpOnly cookie; what the shop backend needs to recognise the visitor travels inside it sealed, so the browser can neither read nor change it.
219
+ _Avoid_: context, context token
220
+
221
+ ## Restaurant operations
222
+
223
+ **Restaurant time zone**:
224
+ The time zone in which opening hours, holidays and wished times are meant, whatever the visitor's or server's clock says.
225
+ _Avoid_: server time, local time
226
+
227
+ **Opening hours** ("Öffnungszeiten"):
228
+ The weekly times the restaurant is open and takes orders.
229
+ _Avoid_: business hours, service hours
230
+
231
+ **Opening interval** ("11:30–14:30"):
232
+ One span of a weekday in the opening hours, at the latest until 24:00 (the end of the day); a late-night opening is two intervals, one until 24:00 and one from 00:00 of the next weekday.
233
+ _Avoid_: shift, service interval
234
+
235
+ **Weekly closing day** ("Ruhetag"):
236
+ A weekday without opening intervals.
237
+ _Avoid_: day off
238
+
239
+ **Holiday** ("Betriebsferien"):
240
+ Whole days, from a first to a last day, on which the restaurant stays closed although the opening hours say open.
241
+ _Avoid_: closing day, vacation, exception
242
+
243
+ **Store status** ("Geöffnet", "Geschlossen"):
244
+ Whether the restaurant is open right now, with the closing time or the next opening.
245
+ _Avoid_: shop state
246
+
247
+ **Accepts orders**:
248
+ The restaurant's switch to take online orders at all; when it is off, nothing can be ordered even within the opening hours.
249
+ _Avoid_: checkout enabled
250
+
251
+ **Branch** ("Filiale"):
252
+ Another location of the same restaurant with its own shop; guests switch between branches.
253
+ _Avoid_: sales channel, store, channel
254
+
255
+ **Contact message** ("Kontakt"):
256
+ A message from a visitor to the restaurant through the contact form; the restaurant may answer it with its own confirmation text. The backend may limit messages per visitor address.
257
+
258
+ ## Discoverability
259
+
260
+ **Path**:
261
+ A URL path of the storefront, such as `/Speisekarte/Pizza/`; paths belong to the storefront, the shop backend only says what they name.
262
+ _Avoid_: SEO URL, slug, route
263
+
264
+ **Canonical path**:
265
+ The one path a menu section is linked and indexed under; other spellings and old paths redirect to it.
266
+ _Avoid_: canonical URL
267
+
268
+ **Former path**:
269
+ A path a menu section had before it was renamed or moved; it redirects to the canonical path.
270
+ _Avoid_: old SEO URL, alias
271
+
272
+ **Menu root** ("Speisekarte"):
273
+ The menu section the menu hangs from; its page lists every dish, its sub-sections are the menu's sections.
274
+ _Avoid_: navigation root, menu category
275
+
276
+ **Navigation** (main, footer, menu, home):
277
+ A list of links in the header, the footer, the menu index or on the home page; an entry is a menu section, a content page, a link or a group (a footer column that heads its links).
278
+ _Avoid_: navigation tree, main-navigation, folder
279
+
280
+ **Breadcrumb**:
281
+ The menu sections above the current one ("Speisekarte › Pizza").
282
+
283
+ **Content page**:
284
+ A page the storefront writes itself (imprint, delivery area); never a shop backend matter.
285
+ _Avoid_: CMS page, landing page
286
+
287
+ **Sitemap** and **llms.txt**:
288
+ The lists of paths for search engines and of shop facts for AI assistants.
289
+
290
+ ## Backend words that must not leak
291
+
292
+ These Shopware words stay inside the Shopware adapter. Code outside it, the UI and the docs use the term on the right.
293
+
294
+ | Shopware | Storefront term |
295
+ | ----------------------------------------------------- | ------------------------------------------------- |
296
+ | sales channel | shop; branch (multi-channel group) |
297
+ | category, navigation root, main-navigation | menu section, menu, navigation |
298
+ | product, product number | dish, menu number |
299
+ | child product, variant product | variant |
300
+ | property group / option (`Hauptzutaten`) | main ingredient, variant group, diet, filter |
301
+ | cross-selling (`productList`) | extra group |
302
+ | line item, `container` line item, children, payload | cart line with extras and removed ingredients |
303
+ | context token (`sw-context-token`) | session |
304
+ | SEO URL, `seoPathInfo`, `pathInfo` | path, canonical path |
305
+ | old SEO URL (`isCanonical: null`), technical URL | former path, a path that redirects |
306
+ | `menuCategoryId`, navigation category | menu root |
307
+ | folder category, link category | navigation group, navigation link |
308
+ | delivery time (entity) | lead time |
309
+ | customer comment | note (and the wished time it carries) |
310
+ | state machine state | order status, payment status |
311
+ | business hour, holiday (plugin entities) | opening interval, holiday |
312
+ | promotion, promotion line item | discount, voucher |
313
+ | `isCheckoutEnabled` | accepts orders |
314
+ | custom fields `shopbite_*`, criteria, includes | named fields of the domain types |
315
+ | `countryId`, salutation entity | country code, salutation (`mr`, `mrs`, not given) |
316
+ | guest customer (`guest: true`) | guest |
317
+ | `accountType: business` | business |
318
+ | sales channel context (selected methods) | checkout selection |
319
+ | `deepLinkCode`, `/account/order/…` | the order's e-mail link (not served yet) |
320
+ | customer address, `defaultShippingAddress` | address, default delivery address |
321
+ | `doubleOptInRegistration`, `register-confirm` | registration confirmation |
322
+ | recovery hash, `recovery-password` | password reset (token) |
323
+ | `CUSTOMER_AUTH_THROTTLED`, rate limiter | `rate_limited` |
324
+ | `shopbite_wishlist_item`, `without`, `extras` | wishlist entry with its dish configuration |
325
+ | Shopware wishlist (`/customer/wishlist`) | (moved into the wishlist on a read) |
326
+ | `contact-form`, `comment`, `individualSuccessMessage` | contact message, its message, the confirmation |
327
+ | `/context` currency, `languageInfo.localeCode` | `ShopConfig.currency`, `ShopConfig.locale` |
package/README.md CHANGED
@@ -117,7 +117,7 @@ pnpm generate-types # Regenerate Store API types after plugin changes
117
117
  Run a single test:
118
118
 
119
119
  ```bash
120
- pnpm vitest run test/nuxt/useBusinessHours.test.ts
120
+ pnpm vitest run test/nuxt/useDeliveryTime.test.ts
121
121
  pnpm playwright test test/e2e/simple-checkout-as-recurring-customer.test.ts
122
122
  ```
123
123
 
@@ -126,11 +126,11 @@ pnpm playwright test test/e2e/simple-checkout-as-recurring-customer.test.ts
126
126
  ```
127
127
  app/
128
128
  ├── components/ Cart, Checkout, Product, Food, Navigation, Header, …
129
- ├── composables/ Business logic — useBusinessHours, useDeliveryTime, useAddToCart, …
129
+ ├── composables/ Business logic — useOpeningHours, useDeliveryTime, useAddToCart, …
130
130
  ├── pages/ German routes: /speisekarte, /warenkorb, /konto, /bestellung
131
131
  ├── validation/ Zod schemas for forms
132
132
  └── assets/css/ Tailwind v4 theme tokens
133
- server/api/ Cached Store API proxies + the Geoapify key guard
133
+ server/api/ BFF routes (domain types from the ports), cached Store API proxies, the Geoapify key guard
134
134
  api-types/ Auto-generated Store API types (pnpm generate-types)
135
135
  content/ Legal pages as Markdown (@nuxt/content)
136
136
  test/ unit · nuxt · e2e
@@ -142,10 +142,9 @@ API responses are validated with Zod before they reach a component.
142
142
 
143
143
  Key ones worth knowing:
144
144
 
145
- - **`useBusinessHours`** — opening hours with multiple intervals per day (Sunday is day 7)
146
- - **`useDeliveryTime`** — slot validation in 5-minute steps, prep time and holiday aware
145
+ - **`useOpeningHours`**, **`useHolidays`**, **`useShopConfig`**, **`useShippingMethods`** — restaurant operations from the storefront's own routes (`/api/shop/*`, `/api/checkout/shipping-methods`), in the restaurant's time zone
146
+ - **`useDeliveryTime`** — the wished time window in 5-minute steps, lead time and holiday aware
147
147
  - **`useAddToCart`** — extras/toppings become a container line item keyed by UUID v5
148
- - **`useShopBiteConfig`** — delivery config and checkout state from the plugin
149
148
  - **`useAddressAutocomplete`** — Geoapify behind `/api/address/autocomplete`
150
149
 
151
150
  ## Docker
package/app/app.vue CHANGED
@@ -1,61 +1,73 @@
1
1
  <script setup lang="ts">
2
2
  import Footer from "~/components/Footer.vue";
3
3
 
4
- const { apiClient } = useShopwareContext();
5
-
6
4
  // The footer is below the fold on every page; its hydration waits until it
7
5
  // scrolls into view (#314).
8
6
  const FooterWhenVisible = hydrateWhenVisible(Footer);
9
7
 
10
- const { data: sessionContextData } = await useAsyncData(
11
- "sessionContext",
12
- async () => {
13
- try {
14
- const { data } = await apiClient.invoke("readContext get /context");
15
- return data;
16
- } catch (error) {
17
- console.error("Failed to load session context", error);
18
- return null;
19
- }
20
- },
21
- {
22
- default: () => null,
23
- },
8
+ // The session's customer (ADR 0001, step 6), rendered on the server so the
9
+ // header knows the login on the first paint. The price format (currency,
10
+ // locale) is the shop's configuration (`useShopConfig` below, step 7); the
11
+ // page reads no backend context of the visitor any more.
12
+ const { isLoggedIn, refresh: refreshCustomer } = useCustomer();
13
+ await useAsyncData("customer", () =>
14
+ refreshCustomer().catch((error) => {
15
+ // the code only: the error of a request carries its options
16
+ console.error("[account] customer", domainErrorCode(error) ?? "no answer");
17
+ return null;
18
+ }),
24
19
  );
25
20
 
26
- const { setPriceConfig } = useCommercePrice();
27
-
28
- if (sessionContextData.value) {
29
- setPriceConfig({
30
- currencyCode: sessionContextData.value.currency?.isoCode,
31
- localeCode: sessionContextData.value.languageInfo?.localeCode,
32
- });
33
- useSessionContext(sessionContextData.value);
34
- }
35
-
36
- // Business hours, holidays and the checkout switch feed the store status
37
- // (HeaderStoreStatus), the delivery time selection and the order buttons.
38
- // The server renders them from its caches; after hydration the browser
39
- // loads them from Shopware (useLiveShopData).
40
- useBusinessHours();
21
+ // Opening hours, holidays, the switch that accepts orders and the lead
22
+ // times feed the store status (HeaderStoreStatus), the wished time choice
23
+ // and the order buttons. The server renders them from its caches; after
24
+ // hydration the browser loads their live values (useLiveShopData).
25
+ useOpeningHours();
41
26
  useHolidays();
42
- useShopBiteConfig();
27
+ const { config: shopConfig } = useShopConfig();
28
+ useShippingMethods();
43
29
  useLiveShopData();
44
30
 
45
- const { refreshCart } = useCart();
46
- // Wishlist entries (#467): loaded in the browser, not during SSR. A login
47
- // moves the guest entries into the account, a logout shows the guest's.
48
- const { isLoggedIn } = useUser();
31
+ // The cart (ADR 0001, step 4) is loaded in the browser; a login or logout
32
+ // changes the visitor's session (Shopware merges the guest's cart into the
33
+ // customer's), so the cart is loaded again.
34
+ const { refresh: refreshCart } = useCartData();
35
+ const loadCart = () =>
36
+ refreshCart().catch((error) => console.error("[cart] refresh", error));
37
+ // Wishlist entries (#467, ADR 0001 step 7): loaded in the browser, not
38
+ // during SSR. A login moves the guest entries into the account, a logout
39
+ // shows the guest's.
49
40
  const { load: loadWishlist, mergeGuestEntries } = useWishlistEntries();
50
41
  onMounted(loadWishlist);
42
+ // a login or logout replaces the visitor's backend context: the methods
43
+ // of the next order may change with it
44
+ const { selection, refreshSelection } = useCheckoutMethods();
51
45
  watch(isLoggedIn, (loggedIn, before) => {
52
46
  if (loggedIn === before) return;
53
47
  if (loggedIn) mergeGuestEntries();
54
48
  else loadWishlist();
49
+ loadCart();
50
+ if (selection.value) {
51
+ refreshSelection().catch((error) =>
52
+ console.error("[checkout] selection", error),
53
+ );
54
+ }
55
55
  });
56
56
 
57
+ onMounted(loadCart);
58
+
59
+ // A new visitor gets the storefront session before the first write (ADR
60
+ // 0001, step 5): a write cut off by a navigation still lands in it. The
61
+ // server render tells whether the request brought a session (the
62
+ // browser cannot read it, it is HttpOnly; `plugins/visitor-has-session`
63
+ // asks whether it unseals).
64
+ const hasSession = useState("visitor-has-session", () => !import.meta.server);
57
65
  onMounted(() => {
58
- refreshCart();
66
+ if (hasSession.value) return;
67
+ hasSession.value = true;
68
+ queuedWrite(() => $fetch("/api/session", { method: "POST" })).catch((error) =>
69
+ console.error("[session] start", error),
70
+ );
59
71
  });
60
72
 
61
73
  const route = useRoute();
@@ -89,9 +101,7 @@ useSeoMeta({
89
101
  ogUrl: canonicalUrl,
90
102
  ogType: "website",
91
103
  ogSiteName: site.name,
92
- ogLocale: (
93
- sessionContextData.value?.languageInfo?.localeCode ?? "de-DE"
94
- ).replace("-", "_"),
104
+ ogLocale: () => (shopConfig.value?.locale ?? "de-DE").replace("-", "_"),
95
105
  ogImage: site.ogImage
96
106
  ? toAbsoluteUrl(siteConfig.url, site.ogImage)
97
107
  : undefined,
@@ -1,9 +1,9 @@
1
1
  <script setup lang="ts">
2
- import type { Schemas } from "#shopware";
2
+ import type { Address } from "../../../shared/domain";
3
3
 
4
4
  const props = withDefaults(
5
5
  defineProps<{
6
- address?: Schemas["CustomerAddress"] | null;
6
+ address?: Address | null;
7
7
  title?: string;
8
8
  }>(),
9
9
  {
@@ -1,51 +1,23 @@
1
1
  <script setup lang="ts">
2
- import type { Schemas } from "#shopware";
2
+ import type { Address } from "../../../shared/domain";
3
3
 
4
- defineProps<{
5
- address: Schemas["CustomerAddress"] | undefined | null;
6
- withEditButton?: boolean;
7
- }>();
8
-
9
- const emit = defineEmits<{
10
- "update:address": [address: Schemas["CustomerAddress"]];
11
- }>();
12
-
13
- const editMode = ref(false);
14
-
15
- function onSubmit(updatedAddress: Schemas["CustomerAddress"] | undefined) {
16
- if (!updatedAddress) return;
17
-
18
- emit("update:address", updatedAddress);
19
- editMode.value = false;
20
- }
4
+ /** The lines of a domain `Address` (account, checkout, order pages). */
5
+ defineProps<{ address: Address | null | undefined }>();
21
6
  </script>
22
7
 
23
8
  <template>
24
- <div v-if="address" class="font-body text-sb-ink">
25
- <div v-if="!editMode" class="flex flex-col items-start gap-3">
26
- <address class="flex flex-col not-italic">
27
- <span>{{ address.firstName }} {{ address.lastName }}</span>
28
- <span v-if="address.company">{{ address.company }}</span>
29
- <span v-if="address.department">{{ address.department }}</span>
30
- <span>{{ address.street }}</span>
31
- <span v-if="address.additionalAddressLine1">{{
32
- address.additionalAddressLine1
33
- }}</span>
34
- <span v-if="address.additionalAddressLine2">{{
35
- address.additionalAddressLine2
36
- }}</span>
37
- <span>{{ address.zipcode }} {{ address.city }}</span>
38
- <span v-if="address.phoneNumber" class="text-sb-ink-muted"
39
- >Tel. {{ address.phoneNumber }}</span
40
- >
41
- </address>
42
- <SbButton
43
- v-if="withEditButton"
44
- variant="secondary"
45
- @click="editMode = true"
46
- >Adresse bearbeiten</SbButton
47
- >
48
- </div>
49
- <AddressForm v-else :address="address" @submit-success="onSubmit" />
50
- </div>
9
+ <address
10
+ v-if="address"
11
+ class="flex flex-col font-body text-sb-ink not-italic"
12
+ >
13
+ <span>{{ address.firstName }} {{ address.lastName }}</span>
14
+ <span v-if="address.company">{{ address.company }}</span>
15
+ <span v-if="address.department">{{ address.department }}</span>
16
+ <span>{{ address.street }}</span>
17
+ <span v-if="address.additionalLine">{{ address.additionalLine }}</span>
18
+ <span>{{ address.postalCode }} {{ address.city }}</span>
19
+ <span v-if="address.phone" class="text-sb-ink-muted"
20
+ >Tel. {{ address.phone }}</span
21
+ >
22
+ </address>
51
23
  </template>
@@ -1,40 +1,42 @@
1
1
  <script setup lang="ts">
2
2
  import * as z from "zod";
3
- import type { Schemas } from "#shopware";
4
- import { useAddress } from "@shopware/composables";
3
+ import type { Address } from "../../../shared/domain";
4
+ import type { AccountAddressInput } from "~/composables/useAccountAddresses";
5
5
  import {
6
6
  baseAddressSchema,
7
7
  type AddressSchema,
8
8
  } from "~/validation/registrationSchema";
9
9
 
10
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.
11
+ * The one address form (ADR 0001, step 6) of the account's address book
12
+ * and the checkout's "Adresse bearbeiten": the fields of the checkout
13
+ * (`AddressFields`) on the domain `Address`, checked with the same rules
14
+ * on submit. Errors show at the fields, the first one gets focus. The
15
+ * caller saves (`save`): the account through `/api/account/addresses`,
16
+ * the checkout through `/api/checkout/orderer/addresses/[addressId]`. A
17
+ * new address has no country (the shop's), a changed one keeps its own.
14
18
  */
15
19
  const props = defineProps<{
16
- address?: Schemas["CustomerAddress"];
20
+ address?: Address | null;
21
+ save: (address: AccountAddressInput) => Promise<unknown>;
17
22
  }>();
18
23
 
19
- const emit = defineEmits<{
20
- "submit-success": [data: Schemas["CustomerAddress"]];
21
- }>();
22
-
23
- const { site } = useRuntimeConfig().public;
24
- const { updateCustomerAddress, createCustomerAddress } = useAddress();
24
+ const emit = defineEmits<{ "submit-success": [] }>();
25
25
 
26
26
  const isBusiness = ref(Boolean(props.address?.company));
27
+ // the form's own field names; the country is not asked
27
28
  const model = ref<AddressSchema>({
28
29
  firstName: props.address?.firstName ?? "",
29
30
  lastName: props.address?.lastName ?? "",
30
31
  company: props.address?.company ?? "",
31
32
  department: props.address?.department ?? "",
32
33
  street: props.address?.street ?? "",
33
- additionalAddressLine1: props.address?.additionalAddressLine1 ?? "",
34
- zipcode: props.address?.zipcode ?? "",
34
+ additionalAddressLine1: props.address?.additionalLine ?? "",
35
+ zipcode: props.address?.postalCode ?? "",
35
36
  city: props.address?.city ?? "",
36
- countryId: props.address?.countryId ?? site.countryId,
37
- phoneNumber: props.address?.phoneNumber ?? "",
37
+ // checked as filled only
38
+ countryId: "shop",
39
+ phoneNumber: props.address?.phone ?? "",
38
40
  });
39
41
 
40
42
  const schema = computed(() =>
@@ -79,17 +81,27 @@ async function onSubmit() {
79
81
  errors.value = {};
80
82
  saving.value = true;
81
83
  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);
84
+ const data = result.data;
85
+ await props.save({
86
+ id: props.address?.id ?? null,
87
+ salutation: props.address?.salutation ?? null,
88
+ firstName: data.firstName ?? "",
89
+ lastName: data.lastName ?? "",
90
+ company: (isBusiness.value && data.company) || null,
91
+ department: (isBusiness.value && data.department) || null,
92
+ street: data.street,
93
+ additionalLine: data.additionalAddressLine1 || null,
94
+ postalCode: data.zipcode ?? "",
95
+ city: data.city,
96
+ country: props.address?.country || null,
97
+ phone: data.phoneNumber || null,
98
+ });
99
+ emit("submit-success");
91
100
  } catch (error) {
92
- console.error("Address save failed:", error);
101
+ console.error(
102
+ "Address save failed:",
103
+ domainErrorCode(error) ?? "no answer",
104
+ );
93
105
  saveError.value = true;
94
106
  } finally {
95
107
  saving.value = false;