@revenexx/cover 0.1.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 (408) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +39 -0
  3. package/app/api/account.ts +8 -0
  4. package/app/api/categories.ts +3 -0
  5. package/app/api/checkout.ts +6 -0
  6. package/app/api/images.ts +4 -0
  7. package/app/api/markets.ts +3 -0
  8. package/app/api/product.ts +3 -0
  9. package/app/api/products.ts +4 -0
  10. package/app/api/search.ts +4 -0
  11. package/app/app.config.ts +29 -0
  12. package/app/assets/css/cover.css +25 -0
  13. package/app/components/account/AccountMenu.vue +30 -0
  14. package/app/components/account/AccountShell.vue +18 -0
  15. package/app/components/account/AccountSidebar.vue +90 -0
  16. package/app/components/account/address/AccountAddressCard.vue +287 -0
  17. package/app/components/account/carts/AccountCartsTable.vue +284 -0
  18. package/app/components/account/dashboard/AccountDashboard.vue +351 -0
  19. package/app/components/account/directorder/AccountDirectOrder.vue +512 -0
  20. package/app/components/account/governance/AccountApprovalLimitsTable.vue +221 -0
  21. package/app/components/account/governance/AccountCostCenterDetail.vue +276 -0
  22. package/app/components/account/governance/AccountCostCentersTable.vue +252 -0
  23. package/app/components/account/governance/AccountRequisitionDetail.vue +295 -0
  24. package/app/components/account/governance/AccountRequisitionsTable.vue +255 -0
  25. package/app/components/account/governance/AccountWorkflowDetail.vue +215 -0
  26. package/app/components/account/governance/AccountWorkflowsTable.vue +168 -0
  27. package/app/components/account/governance/GovernanceApprovalLimitModal.vue +183 -0
  28. package/app/components/account/governance/GovernanceCostCenterModal.vue +188 -0
  29. package/app/components/account/governance/GovernanceWorkflowModal.vue +191 -0
  30. package/app/components/account/orderlists/AccountOrderListDetail.vue +349 -0
  31. package/app/components/account/orderlists/AccountOrderListsTable.vue +352 -0
  32. package/app/components/account/orders/AccountOrderDetail.vue +376 -0
  33. package/app/components/account/orders/AccountOrdersTable.vue +281 -0
  34. package/app/components/account/preferences/AccountPreferences.vue +50 -0
  35. package/app/components/auth/AuthForgotPasswordPanel.vue +88 -0
  36. package/app/components/auth/AuthLoginPanel.vue +103 -0
  37. package/app/components/auth/AuthLoginTeaser.vue +24 -0
  38. package/app/components/auth/AuthPageHeader.vue +21 -0
  39. package/app/components/auth/AuthRegisterPanel.vue +431 -0
  40. package/app/components/auth/AuthRegisterTeaser.vue +24 -0
  41. package/app/components/auth/AuthResetPasswordPanel.vue +115 -0
  42. package/app/components/cart/CartButton.vue +42 -0
  43. package/app/components/cart/actions/CartCostCenterModal.vue +110 -0
  44. package/app/components/cart/actions/CartExportModal.vue +82 -0
  45. package/app/components/cart/actions/CartPositionTextsModal.vue +92 -0
  46. package/app/components/cart/actions/CartSaveToListModal.vue +177 -0
  47. package/app/components/cart/actions/CartWorkflowPickerModal.vue +64 -0
  48. package/app/components/cart/drawer/CartDrawer.vue +49 -0
  49. package/app/components/cart/item/CartItem.vue +318 -0
  50. package/app/components/cart/manage/CartNameModal.vue +68 -0
  51. package/app/components/cart/position/CartPosition.vue +369 -0
  52. package/app/components/cart/quickadd/CartQuickAdd.vue +145 -0
  53. package/app/components/cart/recommend/CartCrossSell.vue +102 -0
  54. package/app/components/cart/recommend/CartRecommendCard.vue +59 -0
  55. package/app/components/cart/recommend/CartReorderStrip.vue +108 -0
  56. package/app/components/cart/requisition/CartRequisitionGroup.vue +74 -0
  57. package/app/components/cart/skeleton/CartSkeleton.vue +18 -0
  58. package/app/components/cart/summary/CartSummary.vue +25 -0
  59. package/app/components/cart/summary/CartSummaryBreakdown.vue +35 -0
  60. package/app/components/cart/switcher/CartSwitcher.vue +147 -0
  61. package/app/components/cart/target/CartTargetModal.vue +129 -0
  62. package/app/components/cart/view/CartApprovalsPanel.vue +89 -0
  63. package/app/components/cart/view/CartListHeader.vue +86 -0
  64. package/app/components/cart/view/CartPositionList.vue +94 -0
  65. package/app/components/cart/view/CartSummaryPanel.vue +254 -0
  66. package/app/components/cart/view/CartView.vue +310 -0
  67. package/app/components/category/info/CategoryPrice.vue +47 -0
  68. package/app/components/category/info/CategorySku.vue +15 -0
  69. package/app/components/category/info/CategoryStock.vue +25 -0
  70. package/app/components/category/list/CategoryItemCount.vue +27 -0
  71. package/app/components/category/list/CategoryListPagination.vue +81 -0
  72. package/app/components/category/skeleton/CategoryDetailSkeleton.vue +12 -0
  73. package/app/components/category/skeleton/CategoryListSkeleton.vue +65 -0
  74. package/app/components/category/view/CategoryViewToggle.vue +33 -0
  75. package/app/components/category/view/GridView.vue +78 -0
  76. package/app/components/category/view/ListView.vue +80 -0
  77. package/app/components/checkout/confirmation/CheckoutConfirmationView.vue +289 -0
  78. package/app/components/checkout/form/CheckoutSchemaForm.vue +72 -0
  79. package/app/components/checkout/onepage/CheckoutAddressPickerModal.vue +260 -0
  80. package/app/components/checkout/onepage/CheckoutAddressSection.vue +186 -0
  81. package/app/components/checkout/onepage/CheckoutDeliverySection.vue +158 -0
  82. package/app/components/checkout/onepage/CheckoutGate.vue +67 -0
  83. package/app/components/checkout/onepage/CheckoutGuestDetailsSection.vue +154 -0
  84. package/app/components/checkout/onepage/CheckoutNotesSection.vue +62 -0
  85. package/app/components/checkout/onepage/CheckoutOnePageView.vue +77 -0
  86. package/app/components/checkout/onepage/CheckoutPaymentSection.vue +181 -0
  87. package/app/components/checkout/onepage/CheckoutSectionTitle.vue +18 -0
  88. package/app/components/checkout/onepage/CheckoutSummarySection.vue +211 -0
  89. package/app/components/checkout/onepage/CheckoutWorkflowPanel.vue +38 -0
  90. package/app/components/layout/AppLogo.vue +21 -0
  91. package/app/components/layout/footer/Footer.vue +148 -0
  92. package/app/components/layout/header/AppBar.vue +75 -0
  93. package/app/components/layout/header/CategoryNav.vue +93 -0
  94. package/app/components/layout/header/HeaderActionItem.vue +81 -0
  95. package/app/components/layout/header/LocaleSwitcher.vue +123 -0
  96. package/app/components/layout/header/MainNav.vue +61 -0
  97. package/app/components/layout/header/MobileMenu.vue +81 -0
  98. package/app/components/layout/header/TopBar.vue +63 -0
  99. package/app/components/listing/ListingView.vue +227 -0
  100. package/app/components/product/detail/ProductDetailAddToCart.vue +188 -0
  101. package/app/components/product/detail/ProductDetailDescription.vue +20 -0
  102. package/app/components/product/detail/ProductDetailImageGallery.vue +58 -0
  103. package/app/components/product/detail/ProductDetailPricing.vue +108 -0
  104. package/app/components/product/detail/ProductDetailSaveToList.vue +291 -0
  105. package/app/components/product/detail/ProductDetailSpecifications.vue +33 -0
  106. package/app/components/product/detail/ProductDetailStock.vue +36 -0
  107. package/app/components/search/filter/SearchFacets.vue +256 -0
  108. package/app/components/search/filter/SearchFacetsDrawer.vue +58 -0
  109. package/app/components/ui/AppShell.vue +7 -0
  110. package/app/components/ui/debug/PiniaStateCard.vue +106 -0
  111. package/app/components/ui/feedback/EmptyState.vue +30 -0
  112. package/app/components/ui/feedback/ErrorBoundary.vue +44 -0
  113. package/app/components/ui/feedback/NotFound.vue +34 -0
  114. package/app/components/ui/forms/CountrySelection.vue +14 -0
  115. package/app/components/ui/forms/FormKitDatePicker.vue +124 -0
  116. package/app/components/ui/forms/PasswordInput.vue +136 -0
  117. package/app/components/ui/forms/SearchInput.vue +213 -0
  118. package/app/components/ui/table/TableSortButton.vue +51 -0
  119. package/app/components/ui/table/TableToolbar.vue +66 -0
  120. package/app/composables/useAccount.ts +27 -0
  121. package/app/composables/useAccountAddresses.ts +116 -0
  122. package/app/composables/useAccountOrders.ts +18 -0
  123. package/app/composables/useAppUrl.ts +38 -0
  124. package/app/composables/useAuthStore.ts +202 -0
  125. package/app/composables/useB2BContext.ts +23 -0
  126. package/app/composables/useCartActions.ts +25 -0
  127. package/app/composables/useCartCalculation.ts +90 -0
  128. package/app/composables/useCartSelection.ts +46 -0
  129. package/app/composables/useCartStore.ts +837 -0
  130. package/app/composables/useCartSummaryFormatting.ts +28 -0
  131. package/app/composables/useCategories.ts +29 -0
  132. package/app/composables/useCheckoutOnePage.ts +438 -0
  133. package/app/composables/useCheckoutProfileSource.ts +8 -0
  134. package/app/composables/useCheckoutSchema.ts +28 -0
  135. package/app/composables/useDataTable.ts +14 -0
  136. package/app/composables/useFormValidation.ts +29 -0
  137. package/app/composables/useIcons.ts +17 -0
  138. package/app/composables/useLocalePreferences.ts +45 -0
  139. package/app/composables/useMarkets.ts +15 -0
  140. package/app/composables/useProduct.ts +89 -0
  141. package/app/composables/useProductCard.ts +8 -0
  142. package/app/composables/useProductCardActions.ts +106 -0
  143. package/app/composables/useProductImage.ts +12 -0
  144. package/app/composables/useProductListing.ts +210 -0
  145. package/app/composables/useProductUrl.ts +17 -0
  146. package/app/composables/useProducts.ts +130 -0
  147. package/app/composables/useSearch.ts +12 -0
  148. package/app/composables/useThemeStore.ts +81 -0
  149. package/app/composables/useViewMode.ts +18 -0
  150. package/app/config/countries.ts +74 -0
  151. package/app/config/icons.ts +283 -0
  152. package/app/config/navigation.ts +191 -0
  153. package/app/config/palette.ts +13 -0
  154. package/app/config/themes.ts +20 -0
  155. package/app/formkit.config.ts +50 -0
  156. package/app/interfaces/account/address-list.ts +34 -0
  157. package/app/interfaces/account/order-list.ts +47 -0
  158. package/app/interfaces/account/order-lists.ts +35 -0
  159. package/app/interfaces/account/profile.ts +17 -0
  160. package/app/interfaces/account.ts +3 -0
  161. package/app/interfaces/address.ts +9 -0
  162. package/app/interfaces/auth.ts +104 -0
  163. package/app/interfaces/b2b.ts +234 -0
  164. package/app/interfaces/cart-calculation.ts +131 -0
  165. package/app/interfaces/cart-item.ts +45 -0
  166. package/app/interfaces/checkout-draft.ts +4 -0
  167. package/app/interfaces/checkout.ts +43 -0
  168. package/app/interfaces/delivery.ts +13 -0
  169. package/app/interfaces/market.ts +24 -0
  170. package/app/interfaces/payment.ts +19 -0
  171. package/app/interfaces/persisted-cart.ts +10 -0
  172. package/app/interfaces/product-detail.ts +54 -0
  173. package/app/interfaces/product-list.ts +33 -0
  174. package/app/interfaces/search-facets.ts +14 -0
  175. package/app/interfaces/validation.ts +14 -0
  176. package/app/layouts/default.vue +78 -0
  177. package/app/layouts/focus.vue +80 -0
  178. package/app/plugins/formkit-locale.client.ts +23 -0
  179. package/app/shared/constants.ts +1 -0
  180. package/app/validations/companyName.ts +18 -0
  181. package/app/validations/emailFormat.ts +10 -0
  182. package/app/validations/formValidationConfig.ts +50 -0
  183. package/app/validations/maxLength.ts +12 -0
  184. package/app/validations/minLength.ts +9 -0
  185. package/app/validations/optionalCompanyName.ts +23 -0
  186. package/app/validations/passwordsMatch.ts +5 -0
  187. package/app/validations/phoneNumber.ts +19 -0
  188. package/app/validations/required.ts +11 -0
  189. package/app/validations/termsRequired.ts +4 -0
  190. package/app/validations/types.ts +10 -0
  191. package/app/validations/zipCode.ts +15 -0
  192. package/i18n/locales/de/account.json +458 -0
  193. package/i18n/locales/de/auth.json +155 -0
  194. package/i18n/locales/de/cart.json +263 -0
  195. package/i18n/locales/de/checkout.json +217 -0
  196. package/i18n/locales/de/common.json +80 -0
  197. package/i18n/locales/de/cover.json +33 -0
  198. package/i18n/locales/de/order.json +1 -0
  199. package/i18n/locales/de/product.json +71 -0
  200. package/i18n/locales/de/search.json +54 -0
  201. package/i18n/locales/de/validation.json +12 -0
  202. package/i18n/locales/en/account.json +458 -0
  203. package/i18n/locales/en/auth.json +155 -0
  204. package/i18n/locales/en/cart.json +263 -0
  205. package/i18n/locales/en/checkout.json +217 -0
  206. package/i18n/locales/en/common.json +80 -0
  207. package/i18n/locales/en/cover.json +33 -0
  208. package/i18n/locales/en/order.json +1 -0
  209. package/i18n/locales/en/product.json +71 -0
  210. package/i18n/locales/en/search.json +54 -0
  211. package/i18n/locales/en/validation.json +12 -0
  212. package/nuxt.config.ts +109 -0
  213. package/package.json +65 -0
  214. package/public/img/product-placeholder.svg +8 -0
  215. package/public/templates/direct-order-template.csv +3 -0
  216. package/public/templates/direct-order-template.xlsx +0 -0
  217. package/server/api/account/address/[id].delete.ts +51 -0
  218. package/server/api/account/address/[id].put.ts +83 -0
  219. package/server/api/account/address/index.post.ts +60 -0
  220. package/server/api/account/addresses.get.ts +25 -0
  221. package/server/api/account/context.get.ts +16 -0
  222. package/server/api/account/governance/[domain]/[id].put.ts +57 -0
  223. package/server/api/account/governance/[domain].post.ts +111 -0
  224. package/server/api/account/order-lists/[id].delete.ts +22 -0
  225. package/server/api/account/order-lists/[id].get.ts +17 -0
  226. package/server/api/account/order-lists/[id].put.ts +46 -0
  227. package/server/api/account/order-lists/index.get.ts +14 -0
  228. package/server/api/account/order-lists/index.post.ts +38 -0
  229. package/server/api/account/orders/[id].get.ts +35 -0
  230. package/server/api/account/orders.get.ts +35 -0
  231. package/server/api/account/profile.get.ts +56 -0
  232. package/server/api/account/profile.put.ts +128 -0
  233. package/server/api/account/requisitions/[id].get.ts +15 -0
  234. package/server/api/account/requisitions.get.ts +23 -0
  235. package/server/api/auth/login.post.ts +37 -0
  236. package/server/api/auth/logout.post.ts +4 -0
  237. package/server/api/auth/me.get.ts +3 -0
  238. package/server/api/auth/personas.get.ts +7 -0
  239. package/server/api/auth/recovery.post.ts +32 -0
  240. package/server/api/auth/recovery.put.ts +37 -0
  241. package/server/api/auth/register.post.ts +126 -0
  242. package/server/api/cart/calculate.post.ts +25 -0
  243. package/server/api/cart/export.post.ts +81 -0
  244. package/server/api/cart/index.delete.ts +10 -0
  245. package/server/api/cart/index.get.ts +10 -0
  246. package/server/api/cart/sync.post.ts +14 -0
  247. package/server/api/carts/[id]/activate.post.ts +18 -0
  248. package/server/api/carts/[id]/index.delete.ts +18 -0
  249. package/server/api/carts/[id]/index.put.ts +19 -0
  250. package/server/api/carts/[id]/items.post.ts +21 -0
  251. package/server/api/carts/index.get.ts +14 -0
  252. package/server/api/carts/index.post.ts +14 -0
  253. package/server/api/categories/[slug].get.ts +22 -0
  254. package/server/api/categories/index.get.ts +11 -0
  255. package/server/api/checkout/profile.get.ts +21 -0
  256. package/server/api/checkout/schema/[key].get.ts +19 -0
  257. package/server/api/checkout/session.post.ts +8 -0
  258. package/server/api/images/detail/[filename].get.ts +18 -0
  259. package/server/api/images/list/[filename].get.ts +17 -0
  260. package/server/api/markets.get.ts +9 -0
  261. package/server/api/orders/index.post.ts +376 -0
  262. package/server/api/payment/methods.post.ts +65 -0
  263. package/server/api/product/[id].get.ts +29 -0
  264. package/server/api/products/[id].get.ts +30 -0
  265. package/server/api/products/index.get.ts +21 -0
  266. package/server/api/requisitions/index.post.ts +67 -0
  267. package/server/api/shipping/rates.post.ts +70 -0
  268. package/server/api/themes/index.get.ts +9 -0
  269. package/server/api/typesense/drop.get.ts +22 -0
  270. package/server/api/typesense/health.get.ts +9 -0
  271. package/server/api/typesense/search.post.ts +199 -0
  272. package/server/api/typesense/seed.get.ts +112 -0
  273. package/server/api/typesense/suggest.post.ts +69 -0
  274. package/server/config/account/organization.json +146 -0
  275. package/server/config/account/personas.json +169 -0
  276. package/server/config/account/user.json +8 -0
  277. package/server/config/account/workflows.json +19 -0
  278. package/server/data/account/address-list.json +103 -0
  279. package/server/data/account/order-list.json +491 -0
  280. package/server/data/account/order-lists.json +149 -0
  281. package/server/data/account/profile.json +9 -0
  282. package/server/data/account/registration-requests.json +3 -0
  283. package/server/data/account/requisitions.json +686 -0
  284. package/server/data/categories.json +186 -0
  285. package/server/data/forms/checkout/add-address.json +24 -0
  286. package/server/data/list/5137-1.png +0 -0
  287. package/server/data/list/5498-1.png +0 -0
  288. package/server/data/list/5498-2.png +0 -0
  289. package/server/data/list/5498-3.png +0 -0
  290. package/server/data/list/5498-4.png +0 -0
  291. package/server/data/list/5498-5.png +0 -0
  292. package/server/data/list/5498-6.png +0 -0
  293. package/server/data/list/5519-1.png +0 -0
  294. package/server/data/list/5713-1.png +0 -0
  295. package/server/data/list/5789-1.png +0 -0
  296. package/server/data/list/5930-1.png +0 -0
  297. package/server/data/list/6127-1.png +0 -0
  298. package/server/data/list/6234-1.png +0 -0
  299. package/server/data/list/6238-1.png +0 -0
  300. package/server/data/list/6246-1.png +0 -0
  301. package/server/data/list/6270-1.png +0 -0
  302. package/server/data/list/6330-1.png +0 -0
  303. package/server/data/list/6336-1.png +0 -0
  304. package/server/data/list/6360-1.png +0 -0
  305. package/server/data/list/6363-1.png +0 -0
  306. package/server/data/list/6375-1.png +0 -0
  307. package/server/data/list/6385-1.png +0 -0
  308. package/server/data/list/6413-1.png +0 -0
  309. package/server/data/list/6418-1.png +0 -0
  310. package/server/data/list/6465-1.png +0 -0
  311. package/server/data/list/6477-1.png +0 -0
  312. package/server/data/list/6509-1.png +0 -0
  313. package/server/data/list/6545-1.png +0 -0
  314. package/server/data/list/6548-1.png +0 -0
  315. package/server/data/list/6566-1.png +0 -0
  316. package/server/data/list/6581-1.png +0 -0
  317. package/server/data/list/6609-1.png +0 -0
  318. package/server/data/list/6611-1.png +0 -0
  319. package/server/data/list/6641-1.png +0 -0
  320. package/server/data/list/6659-1.png +0 -0
  321. package/server/data/list/6662-1.png +0 -0
  322. package/server/data/list/6689-1.png +0 -0
  323. package/server/data/list/6698-1.png +0 -0
  324. package/server/data/list/6701-1.png +0 -0
  325. package/server/data/list/6752-1.png +0 -0
  326. package/server/data/list/6755-1.png +0 -0
  327. package/server/data/list/6837-1.png +0 -0
  328. package/server/data/list/6841-1.png +0 -0
  329. package/server/data/list/6844-1.png +0 -0
  330. package/server/data/list/6846-1.png +0 -0
  331. package/server/data/list/6886-1.png +0 -0
  332. package/server/data/list/6895-1.png +0 -0
  333. package/server/data/list/6897-1.png +0 -0
  334. package/server/data/list/6919-1.png +0 -0
  335. package/server/data/list/6977-1.png +0 -0
  336. package/server/data/list/6983-1.png +0 -0
  337. package/server/data/list/6984-1.png +0 -0
  338. package/server/data/list/6985-1.png +0 -0
  339. package/server/data/list/6986-1.png +0 -0
  340. package/server/data/list/6989-1.png +0 -0
  341. package/server/data/list/6995-1.png +0 -0
  342. package/server/data/list/6998-1.png +0 -0
  343. package/server/data/markets.json +24 -0
  344. package/server/data/product-detail.json +2450 -0
  345. package/server/data/product-list.json +2450 -0
  346. package/server/data/themes.json +8 -0
  347. package/server/interfaces/account.ts +20 -0
  348. package/server/interfaces/auth.ts +32 -0
  349. package/server/interfaces/b2bContext.ts +23 -0
  350. package/server/interfaces/cart.ts +46 -0
  351. package/server/interfaces/cartCalculation.ts +17 -0
  352. package/server/interfaces/category.ts +12 -0
  353. package/server/interfaces/checkoutProfile.ts +5 -0
  354. package/server/interfaces/log.ts +3 -0
  355. package/server/interfaces/market.ts +10 -0
  356. package/server/interfaces/product.ts +21 -0
  357. package/server/interfaces/schema.ts +20 -0
  358. package/server/interfaces/theme.ts +10 -0
  359. package/server/services/ApiAuthService.ts +138 -0
  360. package/server/services/ApiCartService.ts +254 -0
  361. package/server/services/ApiCategoryService.ts +25 -0
  362. package/server/services/ApiMarketService.ts +71 -0
  363. package/server/services/ApiProductService.ts +53 -0
  364. package/server/services/LocalFileCategoryService.ts +23 -0
  365. package/server/services/LocalFileCheckoutProfileService.ts +117 -0
  366. package/server/services/LocalFileProductService.ts +128 -0
  367. package/server/services/LocalFileSchemaService.ts +70 -0
  368. package/server/services/LocalFileThemeService.ts +18 -0
  369. package/server/services/LogService.ts +28 -0
  370. package/server/services/MockAccountService.ts +58 -0
  371. package/server/services/MockAuthService.ts +105 -0
  372. package/server/services/MockB2BContextService.ts +149 -0
  373. package/server/services/MockCartCalculationService.ts +395 -0
  374. package/server/services/MockMarketService.ts +18 -0
  375. package/server/services/SdkAccountService.ts +56 -0
  376. package/server/services/SdkAuthService.ts +83 -0
  377. package/server/services/SessionCartService.ts +31 -0
  378. package/server/utils/accountService.ts +30 -0
  379. package/server/utils/authCookie.ts +13 -0
  380. package/server/utils/authService.ts +43 -0
  381. package/server/utils/b2bService.ts +49 -0
  382. package/server/utils/cartService.ts +59 -0
  383. package/server/utils/categoryService.ts +19 -0
  384. package/server/utils/checkoutProfileService.ts +9 -0
  385. package/server/utils/checkoutSession.ts +38 -0
  386. package/server/utils/coverData.ts +84 -0
  387. package/server/utils/governanceStore.ts +38 -0
  388. package/server/utils/i18n.ts +76 -0
  389. package/server/utils/inventoryService.ts +14 -0
  390. package/server/utils/liveCatalog.ts +234 -0
  391. package/server/utils/liveInventories.ts +76 -0
  392. package/server/utils/liveOrders.ts +139 -0
  393. package/server/utils/livePrices.ts +93 -0
  394. package/server/utils/locale.ts +39 -0
  395. package/server/utils/logService.ts +19 -0
  396. package/server/utils/marketService.ts +24 -0
  397. package/server/utils/orderService.ts +14 -0
  398. package/server/utils/paymentService.ts +14 -0
  399. package/server/utils/priceService.ts +14 -0
  400. package/server/utils/productService.ts +28 -0
  401. package/server/utils/productsSchema.ts +30 -0
  402. package/server/utils/revenexxApi.ts +136 -0
  403. package/server/utils/schemaService.ts +25 -0
  404. package/server/utils/serviceMode.ts +70 -0
  405. package/server/utils/shippingService.ts +14 -0
  406. package/server/utils/shopSdk.ts +88 -0
  407. package/server/utils/themeService.ts +16 -0
  408. package/server/utils/typesense.ts +27 -0
@@ -0,0 +1,28 @@
1
+ export const useCartSummaryFormatting = () => {
2
+ const { t } = useI18n();
3
+ const { public: { locale, currency, taxIncludedPrices } } = useRuntimeConfig();
4
+
5
+ const taxLabelKey = computed(() => taxIncludedPrices ? "summary.tax.incl" : "summary.tax.excl");
6
+
7
+ function formatPercent(rate: number): string {
8
+ return `${Math.round(rate * 100)}%`;
9
+ }
10
+
11
+ function taxRateLabel(rate: number): string {
12
+ return t("summary.tax.rateLabel", {
13
+ label: t(taxLabelKey.value),
14
+ percent: formatPercent(rate),
15
+ });
16
+ }
17
+
18
+ function formatCurrency(value: number): string {
19
+ return (value).toLocaleString(locale as string, { style: "currency", currency: currency as string });
20
+ }
21
+
22
+ return {
23
+ taxLabelKey,
24
+ formatPercent,
25
+ taxRateLabel,
26
+ formatCurrency,
27
+ };
28
+ };
@@ -0,0 +1,29 @@
1
+ import type { NavigationMenuItem } from "@nuxt/ui";
2
+
3
+ import { categoriesApi } from "../api/categories";
4
+ import type { ProductCategory } from "../config/navigation";
5
+
6
+ export const useCategories = () => {
7
+ const localePath = useLocalePath();
8
+ const { icon } = useIcons();
9
+ const { locale } = useI18n();
10
+ const { data: categories, status, error } = useFetch<ProductCategory[]>(categoriesApi.list(), {
11
+ headers: computed(() => ({ "x-locale": locale.value })),
12
+ default: () => [] as ProductCategory[],
13
+ });
14
+
15
+ const categoryNavItems = computed<NavigationMenuItem[]>(() =>
16
+ (categories.value ?? []).map((cat: ProductCategory) => ({
17
+ label: cat.label,
18
+ icon: icon(cat.icon),
19
+ to: localePath(`/category/${cat.slug}`),
20
+ children: cat.subcategories.map((sub: ProductCategory["subcategories"][number]) => ({
21
+ label: sub.label,
22
+ icon: icon(sub.icon),
23
+ to: localePath(`/category/${cat.slug}/${sub.slug}`),
24
+ })),
25
+ })),
26
+ );
27
+
28
+ return { categories, categoryNavItems, status, error };
29
+ };
@@ -0,0 +1,438 @@
1
+ import { checkoutApi } from "../api/checkout";
2
+ import type { CheckoutOnePageForm, CheckoutProfile } from "../interfaces/checkout";
3
+
4
+ /**
5
+ * Who is checking out:
6
+ * - `account` — signed-in user with address book and B2B context
7
+ * - `guest-business` — guest business customer (company data required)
8
+ * - `guest-private` — guest private customer (no company data)
9
+ */
10
+ export type CheckoutCustomerType = "account" | "guest-business" | "guest-private";
11
+
12
+ export interface CheckoutGuestAddress {
13
+ companyName: string;
14
+ firstName: string;
15
+ lastName: string;
16
+ street: string;
17
+ postalCode: string;
18
+ city: string;
19
+ country: string;
20
+ }
21
+
22
+ const EMPTY_GUEST_ADDRESS: CheckoutGuestAddress = {
23
+ companyName: "",
24
+ firstName: "",
25
+ lastName: "",
26
+ street: "",
27
+ postalCode: "",
28
+ city: "",
29
+ country: "DE",
30
+ };
31
+
32
+ const EMPTY_FORM: CheckoutOnePageForm = {
33
+ shippingAddressId: "",
34
+ billingSameAsShipping: true,
35
+ billingAddressId: "",
36
+ deliveryMethod: "standard",
37
+ requestedDate: "",
38
+ deliveryNote: "",
39
+ partialDelivery: false,
40
+ paymentMethod: "invoice",
41
+ poNumber: "",
42
+ costCenterId: "",
43
+ orderNumber: "",
44
+ quoteNumber: "",
45
+ noOrderConfirmation: false,
46
+ orderNote: "",
47
+ promoCode: "",
48
+ acceptedTerms: false,
49
+ };
50
+
51
+ /** Latest acceptable requested date: 100 calendar days ahead. */
52
+ const REQUESTED_DATE_MAX_DAYS = 100;
53
+
54
+ export function useCheckoutOnePage() {
55
+ const { t } = useI18n();
56
+ const cart = useCartStore();
57
+ const { settings } = useB2BContext();
58
+ const { data: profile, refresh: refreshProfile } = useCheckoutProfileSource();
59
+ const profileLoading = computed(() => profile.value === null);
60
+
61
+ const customerType = useState<CheckoutCustomerType>("checkout-customer-type", () => "account");
62
+ const isGuest = computed(() => customerType.value !== "account");
63
+
64
+ const form = useState<CheckoutOnePageForm>("checkout-one-page-form", () => ({ ...EMPTY_FORM }));
65
+ const guestContact = useState("checkout-guest-contact", () => ({ email: "", phone: "" }));
66
+ const guestShipping = useState<CheckoutGuestAddress>("checkout-guest-shipping", () => ({ ...EMPTY_GUEST_ADDRESS }));
67
+ const guestBilling = useState<CheckoutGuestAddress>("checkout-guest-billing", () => ({ ...EMPTY_GUEST_ADDRESS }));
68
+ const fieldErrors = useState<Record<string, string | undefined>>("checkout-one-page-field-errors", () => ({}));
69
+ const submitError = useState<string | null>("checkout-one-page-submit-error", () => null);
70
+ const submitting = useState<boolean>("checkout-one-page-submitting", () => false);
71
+ const sessionToken = useState<string | null>("checkout-one-page-session-token", () => null);
72
+
73
+ const orderNumberRequired = computed(() =>
74
+ settings.value?.checkout.orderNumberRequired ?? false,
75
+ );
76
+
77
+ const guestAddressValid = (address: CheckoutGuestAddress): boolean => {
78
+ const base = Boolean(address.firstName && address.lastName && address.street
79
+ && address.postalCode && address.city && address.country);
80
+ return customerType.value === "guest-business"
81
+ ? base && Boolean(address.companyName)
82
+ : base;
83
+ };
84
+
85
+ const requestedDateError = (value: string): string | null => {
86
+ if (!value) {
87
+ return null;
88
+ }
89
+ const date = new Date(value);
90
+ if (isNaN(date.getTime())) {
91
+ return t("onepage.errors.requestedDateInvalid");
92
+ }
93
+ const today = new Date();
94
+ today.setHours(0, 0, 0, 0);
95
+ if (date < today) {
96
+ return t("onepage.errors.requestedDatePast");
97
+ }
98
+ const max = new Date(today);
99
+ max.setDate(max.getDate() + REQUESTED_DATE_MAX_DAYS);
100
+ if (date > max) {
101
+ return t("onepage.errors.requestedDateTooFar", { days: REQUESTED_DATE_MAX_DAYS });
102
+ }
103
+ const weekday = date.getDay();
104
+ if (weekday === 0 || weekday === 6) {
105
+ return t("onepage.errors.requestedDateWeekend");
106
+ }
107
+ return null;
108
+ };
109
+
110
+ const isValid = computed(() => {
111
+ const f = form.value;
112
+ if (isGuest.value) {
113
+ if (!/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(guestContact.value.email)) {
114
+ return false;
115
+ }
116
+ if (!guestAddressValid(guestShipping.value)) {
117
+ return false;
118
+ }
119
+ if (!f.billingSameAsShipping && !guestAddressValid(guestBilling.value)) {
120
+ return false;
121
+ }
122
+ }
123
+ else {
124
+ if (!f.shippingAddressId) {
125
+ return false;
126
+ }
127
+ if (!f.billingSameAsShipping && !f.billingAddressId) {
128
+ return false;
129
+ }
130
+ }
131
+ if (!f.paymentMethod) {
132
+ return false;
133
+ }
134
+ if (orderNumberRequired.value && !f.orderNumber.trim()) {
135
+ return false;
136
+ }
137
+ if (requestedDateError(f.requestedDate)) {
138
+ return false;
139
+ }
140
+ return true;
141
+ });
142
+
143
+ const canSubmit = computed(() => isValid.value && form.value.acceptedTerms && !submitting.value);
144
+
145
+ function initFromProfile(p: CheckoutProfile) {
146
+ form.value = {
147
+ ...EMPTY_FORM,
148
+ shippingAddressId: p.defaultShippingAddressId,
149
+ billingAddressId: p.defaultBillingAddressId,
150
+ deliveryMethod: p.defaultDeliveryMethod,
151
+ paymentMethod: p.defaultPaymentMethod,
152
+ };
153
+ fieldErrors.value = {};
154
+ submitError.value = null;
155
+ }
156
+
157
+ async function fetchSessionToken() {
158
+ const session = await $fetch(checkoutApi.session(), { method: "POST" }) as { checkoutSessionToken: string };
159
+ sessionToken.value = session.checkoutSessionToken;
160
+ }
161
+
162
+ function validateField(name: keyof CheckoutOnePageForm | "guestEmail") {
163
+ const f = form.value;
164
+ const errors = { ...fieldErrors.value };
165
+
166
+ switch (name) {
167
+ case "shippingAddressId":
168
+ errors.shippingAddressId = !isGuest.value && !f.shippingAddressId
169
+ ? t("onepage.errors.shippingAddressRequired")
170
+ : undefined;
171
+ break;
172
+ case "billingAddressId":
173
+ errors.billingAddressId = !isGuest.value && !f.billingSameAsShipping && !f.billingAddressId
174
+ ? t("onepage.errors.billingAddressRequired")
175
+ : undefined;
176
+ break;
177
+ case "paymentMethod":
178
+ errors.paymentMethod = f.paymentMethod
179
+ ? undefined
180
+ : t("onepage.errors.paymentMethodRequired");
181
+ break;
182
+ case "orderNumber":
183
+ errors.orderNumber = orderNumberRequired.value && !f.orderNumber.trim()
184
+ ? t("onepage.errors.orderNumberRequired")
185
+ : undefined;
186
+ break;
187
+ case "requestedDate":
188
+ errors.requestedDate = requestedDateError(f.requestedDate) ?? undefined;
189
+ break;
190
+ case "guestEmail":
191
+ errors.guestEmail = /^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(guestContact.value.email)
192
+ ? undefined
193
+ : t("onepage.errors.guestEmailInvalid");
194
+ break;
195
+ case "acceptedTerms":
196
+ errors.acceptedTerms = f.acceptedTerms
197
+ ? undefined
198
+ : t("onepage.errors.termsRequired");
199
+ break;
200
+ }
201
+
202
+ fieldErrors.value = errors;
203
+ }
204
+
205
+ function validateAll(): boolean {
206
+ const fields: Array<keyof CheckoutOnePageForm | "guestEmail"> = [
207
+ "shippingAddressId", "billingAddressId", "paymentMethod",
208
+ "orderNumber", "requestedDate", "acceptedTerms",
209
+ ];
210
+ if (isGuest.value) {
211
+ fields.push("guestEmail");
212
+ }
213
+ fields.forEach(f => validateField(f));
214
+ return Object.values(fieldErrors.value).every(v => !v) && isValid.value;
215
+ }
216
+
217
+ function guestAddressPayload(address: CheckoutGuestAddress, includeCompany: boolean) {
218
+ return {
219
+ ...(includeCompany && address.companyName ? { companyName: address.companyName } : {}),
220
+ contactName: `${address.firstName} ${address.lastName}`.trim(),
221
+ street: address.street,
222
+ postalCode: address.postalCode,
223
+ city: address.city,
224
+ country: address.country,
225
+ };
226
+ }
227
+
228
+ function buildShippingAddress(): Record<string, unknown> {
229
+ const f = form.value;
230
+ if (isGuest.value) {
231
+ const includeCompany = customerType.value === "guest-business";
232
+ return {
233
+ ...guestAddressPayload(guestShipping.value, includeCompany),
234
+ billingAddressSameAsShipping: f.billingSameAsShipping,
235
+ ...(f.billingSameAsShipping
236
+ ? {}
237
+ : { billing: guestAddressPayload(guestBilling.value, includeCompany) }),
238
+ };
239
+ }
240
+
241
+ const p = profile.value;
242
+ if (!p) {
243
+ throw new Error("Checkout profile not available");
244
+ }
245
+ const shippingAddr = p.addresses.find(a => a.id === f.shippingAddressId);
246
+ const billingAddr = f.billingSameAsShipping
247
+ ? undefined
248
+ : p.addresses.find(a => a.id === f.billingAddressId);
249
+ return {
250
+ ...shippingAddr,
251
+ billingAddressSameAsShipping: f.billingSameAsShipping,
252
+ ...(billingAddr
253
+ ? {
254
+ billing: {
255
+ street: billingAddr.street,
256
+ city: billingAddr.city,
257
+ postalCode: billingAddr.postalCode,
258
+ country: billingAddr.country,
259
+ },
260
+ }
261
+ : {}),
262
+ };
263
+ }
264
+
265
+ function buildOrderPayload() {
266
+ const f = form.value;
267
+ const costCenter = profile.value?.costCenters.find(c => c.id === f.costCenterId);
268
+
269
+ const payment: Record<string, unknown> = { method: f.paymentMethod };
270
+ if (f.paymentMethod === "po_number" && f.poNumber) {
271
+ payment.poNumber = f.poNumber;
272
+ }
273
+ if (f.paymentMethod === "cost_center" && costCenter) {
274
+ payment.costCenter = costCenter.code;
275
+ }
276
+
277
+ return {
278
+ checkoutSessionToken: sessionToken.value ?? "",
279
+ customerType: customerType.value === "guest-private" ? "private" : "business",
280
+ address: buildShippingAddress(),
281
+ payment,
282
+ // Full cart lines: the BFF re-runs the calculation at order time
283
+ // (approval limits, quantity rules) against the same data.
284
+ items: cart.items,
285
+ ...(isGuest.value ? { contactEmail: guestContact.value.email } : {}),
286
+ ...(f.deliveryMethod ? { deliveryMethod: f.deliveryMethod } : {}),
287
+ ...(f.requestedDate ? { requestedDate: f.requestedDate } : {}),
288
+ ...(f.deliveryNote ? { deliveryNote: f.deliveryNote } : {}),
289
+ ...(f.partialDelivery ? { partialDelivery: true } : {}),
290
+ ...(f.orderNumber ? { orderNumber: f.orderNumber } : {}),
291
+ ...(f.quoteNumber ? { quoteNumber: f.quoteNumber } : {}),
292
+ ...(f.noOrderConfirmation ? { noOrderConfirmation: true } : {}),
293
+ ...(f.orderNote ? { orderNote: f.orderNote } : {}),
294
+ ...(f.promoCode ? { promoCode: f.promoCode } : {}),
295
+ };
296
+ }
297
+
298
+ interface SubmitResult {
299
+ orderId: string;
300
+ approvalRequired: boolean;
301
+ approvers: string[];
302
+ }
303
+
304
+ async function submitOrder(): Promise<SubmitResult | null> {
305
+ if (submitting.value) {
306
+ return null;
307
+ }
308
+ if (!validateAll()) {
309
+ return null;
310
+ }
311
+
312
+ submitting.value = true;
313
+ submitError.value = null;
314
+
315
+ try {
316
+ await fetchSessionToken();
317
+
318
+ const order = await $fetch(checkoutApi.orders(), {
319
+ method: "POST",
320
+ body: buildOrderPayload(),
321
+ }) as { orderId: string; approvalRequired?: boolean; approvers?: string[] };
322
+
323
+ cart.clearCart();
324
+ return {
325
+ orderId: order.orderId,
326
+ approvalRequired: order.approvalRequired ?? false,
327
+ approvers: order.approvers ?? [],
328
+ };
329
+ }
330
+ catch (err) {
331
+ submitError.value = err instanceof Error
332
+ ? err.message
333
+ : t("onepage.errors.submitError");
334
+ return null;
335
+ }
336
+ finally {
337
+ submitting.value = false;
338
+ }
339
+ }
340
+
341
+ /**
342
+ * Requester checkout outcome: a requisition entering its workflow
343
+ * instead of an order.
344
+ */
345
+ async function submitRequisition(workflowId: string): Promise<string | null> {
346
+ if (submitting.value) {
347
+ return null;
348
+ }
349
+ submitting.value = true;
350
+ submitError.value = null;
351
+
352
+ try {
353
+ const shipping = profile.value?.addresses.find(a => a.id === form.value.shippingAddressId);
354
+ const result = await $fetch("/api/requisitions", {
355
+ method: "POST",
356
+ body: {
357
+ workflowId,
358
+ items: cart.items.map(i => ({
359
+ id: i.id,
360
+ sku: i.sku,
361
+ name: i.name,
362
+ ...(i.name2 ? { name2: i.name2 } : {}),
363
+ ...(i.image ? { image: i.image } : {}),
364
+ quantity: i.quantity,
365
+ ...(i.unit ? { unit: i.unit } : {}),
366
+ price: i.price,
367
+ taxRate: i.taxRate ?? 19,
368
+ ...(i.costCenterId ? { costCenterId: i.costCenterId } : {}),
369
+ ...(i.positionTexts ? { positionTexts: i.positionTexts } : {}),
370
+ ...(i.customSku ? { customSku: i.customSku } : {}),
371
+ })),
372
+ ...(shipping
373
+ ? {
374
+ deliveryAddress: {
375
+ company: shipping.companyName,
376
+ street: shipping.street,
377
+ postalCode: shipping.postalCode,
378
+ city: shipping.city,
379
+ country: shipping.country,
380
+ },
381
+ }
382
+ : {}),
383
+ ...(form.value.orderNote ? { note: form.value.orderNote } : {}),
384
+ },
385
+ }) as { requisitionId: string };
386
+
387
+ cart.clearCart();
388
+ return result.requisitionId;
389
+ }
390
+ catch (err) {
391
+ submitError.value = err instanceof Error
392
+ ? err.message
393
+ : t("onepage.errors.submitError");
394
+ return null;
395
+ }
396
+ finally {
397
+ submitting.value = false;
398
+ }
399
+ }
400
+
401
+ function reset() {
402
+ form.value = { ...EMPTY_FORM };
403
+ guestContact.value = { email: "", phone: "" };
404
+ guestShipping.value = { ...EMPTY_GUEST_ADDRESS };
405
+ guestBilling.value = { ...EMPTY_GUEST_ADDRESS };
406
+ customerType.value = "account";
407
+ fieldErrors.value = {};
408
+ submitError.value = null;
409
+ submitting.value = false;
410
+ sessionToken.value = null;
411
+ }
412
+
413
+ return {
414
+ form,
415
+ profile,
416
+ profileLoading,
417
+ refreshProfile,
418
+ customerType,
419
+ isGuest,
420
+ guestContact,
421
+ guestShipping,
422
+ guestBilling,
423
+ orderNumberRequired,
424
+ fieldErrors,
425
+ submitError,
426
+ submitting,
427
+ isValid,
428
+ canSubmit,
429
+ initFromProfile,
430
+ fetchSessionToken,
431
+ validateField,
432
+ validateAll,
433
+ buildOrderPayload,
434
+ submitOrder,
435
+ submitRequisition,
436
+ reset,
437
+ };
438
+ }
@@ -0,0 +1,8 @@
1
+ import { checkoutApi } from "../api/checkout";
2
+ import type { CheckoutProfile } from "../interfaces/checkout";
3
+
4
+ export function useCheckoutProfileSource() {
5
+ return useFetch<CheckoutProfile>(checkoutApi.profile(), {
6
+ key: "checkout-profile",
7
+ });
8
+ }
@@ -0,0 +1,28 @@
1
+ import { checkoutApi } from "../api/checkout";
2
+
3
+ type SchemaObject = Record<string, unknown>;
4
+
5
+ const schemaCache = new Map<string, SchemaObject>();
6
+
7
+ export const useCheckoutSchema = () => {
8
+ const { locale } = useI18n();
9
+
10
+ async function fetchSchemaByKey(key: string): Promise<SchemaObject> {
11
+ const cacheKey = `schema:${key}:${locale.value}`;
12
+ const cached = schemaCache.get(cacheKey);
13
+ if (cached) {
14
+ return cached;
15
+ }
16
+ const data = await $fetch<SchemaObject>(checkoutApi.schema(key), {
17
+ headers: { "x-locale": locale.value },
18
+ });
19
+ schemaCache.set(cacheKey, data);
20
+ return data;
21
+ }
22
+
23
+ function clearCache() {
24
+ schemaCache.clear();
25
+ }
26
+
27
+ return { fetchSchemaByKey, clearCache };
28
+ };
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Shared visual baseline for data tables (datatable-ux skill): tinted,
3
+ * uppercase header row that never reads as a data row, light separators
4
+ * and roomy data rows. Spread into UTable's `:ui` prop.
5
+ */
6
+ export function useDataTable() {
7
+ const tableUi = {
8
+ thead: "bg-elevated/60",
9
+ th: "py-3 text-xs font-semibold uppercase tracking-wide text-muted",
10
+ td: "py-3.5 text-sm",
11
+ };
12
+
13
+ return { tableUi };
14
+ }
@@ -0,0 +1,29 @@
1
+ import type { FormError } from "@nuxt/ui";
2
+
3
+ import type { FormKey } from "../interfaces/validation";
4
+ import { formValidationConfig } from "../validations/formValidationConfig";
5
+
6
+ export function useFormValidation<TState extends object>(formKey: FormKey) {
7
+ const { t } = useI18n();
8
+ const config = formValidationConfig[formKey];
9
+
10
+ function validate(state: TState): FormError[] {
11
+ const errors: FormError[] = [];
12
+ const stateRecord = state as Record<string, unknown>;
13
+ for (const fieldConfig of config) {
14
+ const value = stateRecord[fieldConfig.field];
15
+ for (const rule of fieldConfig.rules) {
16
+ const key = rule.kind === "cross"
17
+ ? rule.fn(value, stateRecord, rule.options)
18
+ : rule.fn(value, rule.options);
19
+ if (key !== null) {
20
+ errors.push({ name: fieldConfig.field, message: t(key, rule.options ?? {}) });
21
+ break;
22
+ }
23
+ }
24
+ }
25
+ return errors;
26
+ }
27
+
28
+ return { validate };
29
+ }
@@ -0,0 +1,17 @@
1
+ import { solarIcon } from "../config/icons";
2
+
3
+ /**
4
+ * Resolves cover icon tokens (or raw Solar basenames) to Iconify names in
5
+ * the active theme's icon weight. Reactive — switching the theme or the
6
+ * weight override re-renders every resolved icon.
7
+ *
8
+ * ```ts
9
+ * const { icon } = useIcons();
10
+ * icon("cart"); // "i-solar-cart-3-linear"
11
+ * ```
12
+ */
13
+ export function useIcons() {
14
+ const themeStore = useThemeStore();
15
+ const icon = (name: string) => solarIcon(name, themeStore.iconWeight);
16
+ return { icon, iconWeight: computed(() => themeStore.iconWeight) };
17
+ }
@@ -0,0 +1,45 @@
1
+ import type { Ref } from "vue";
2
+
3
+ import type { ShopMarket } from "../interfaces/market";
4
+
5
+ /**
6
+ * Market-driven locale preferences: the shop's markets (markets app) carry
7
+ * region, currency and the offered locales — the selector picks a market,
8
+ * language stays an independent choice within the market's locales
9
+ * (Smashing Magazine, "Designing A Better Language Selector"). Persisted
10
+ * as a cookie so SSR renders the same selection.
11
+ */
12
+
13
+ const CURRENCY_SYMBOLS: Record<string, string> = {
14
+ EUR: "€",
15
+ CHF: "CHF",
16
+ USD: "$",
17
+ GBP: "£",
18
+ };
19
+
20
+ export function useLocalePreferences(markets: Ref<ShopMarket[]>) {
21
+ const marketCode = useCookie<string>("cover-market", {
22
+ default: () => "",
23
+ watch: true,
24
+ });
25
+
26
+ const market = computed<ShopMarket | null>(() => {
27
+ if (!markets.value.length) {
28
+ return null;
29
+ }
30
+ return markets.value.find(m => m.code === marketCode.value)
31
+ ?? markets.value.find(m => m.isDefault)
32
+ ?? markets.value[0]
33
+ ?? null;
34
+ });
35
+
36
+ const setMarket = (code: string): void => {
37
+ marketCode.value = code;
38
+ };
39
+
40
+ const region = computed(() => market.value?.name ?? "");
41
+ const currency = computed(() => market.value?.currency ?? "EUR");
42
+ const currencySymbol = computed(() => CURRENCY_SYMBOLS[currency.value] ?? currency.value);
43
+
44
+ return { market, setMarket, region, currency, currencySymbol };
45
+ }
@@ -0,0 +1,15 @@
1
+ import { marketsApi } from "../api/markets";
2
+ import type { ShopMarket } from "../interfaces/market";
3
+
4
+ /**
5
+ * Markets from the BFF (markets app live, bundled JSON in mock mode).
6
+ * SSR-fetched once and shared — the locale selector and price/tax surfaces
7
+ * derive region, currency and offered languages from the selected market.
8
+ */
9
+ export function useMarkets() {
10
+ const { data: markets, status, error, refresh } = useFetch<ShopMarket[]>(marketsApi.list(), {
11
+ key: "shop-markets",
12
+ default: () => [] as ShopMarket[],
13
+ });
14
+ return { markets, status, error, refresh };
15
+ }