@revenexx/cover 0.7.1 → 0.11.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 (175) hide show
  1. package/app/api/account.ts +4 -0
  2. package/app/api/forms.ts +1 -0
  3. package/app/app.config.ts +17 -12
  4. package/app/assets/css/cover.css +9 -0
  5. package/app/components/RevenexxForm.vue +84 -12
  6. package/app/components/account/AccountShell.vue +18 -0
  7. package/app/components/account/AccountSidebar.vue +2 -5
  8. package/app/components/account/approvals/AccountPendingApprovals.vue +178 -0
  9. package/app/components/account/dashboard/AccountDashboardKpis.vue +74 -34
  10. package/app/components/account/dashboard/AccountDashboardQuickActions.vue +24 -6
  11. package/app/components/account/orderlists/AccountOrderListDetail.vue +47 -4
  12. package/app/components/account/orders/AccountOrderDetail.vue +186 -1
  13. package/app/components/account/organization/AccountOrganization.vue +3 -1
  14. package/app/components/account/payments/AccountPayments.vue +129 -0
  15. package/app/components/account/quotes/AccountQuoteDetail.vue +48 -16
  16. package/app/components/account/team/AccountTeam.vue +32 -7
  17. package/app/components/auth/AuthForgotPasswordPanel.vue +9 -4
  18. package/app/components/auth/AuthLoginPanel.vue +136 -18
  19. package/app/components/auth/AuthMagicLinkPanel.vue +70 -0
  20. package/app/components/cart/actions/CartSaveToListModal.vue +5 -0
  21. package/app/components/cart/item/CartItem.vue +17 -75
  22. package/app/components/cart/position/CartPosition.vue +17 -30
  23. package/app/components/cart/quote/CartQuoteRequestModal.vue +9 -1
  24. package/app/components/cart/view/CartSummaryPanel.vue +54 -0
  25. package/app/components/category/view/GridView.vue +10 -1
  26. package/app/components/category/view/ListView.vue +10 -1
  27. package/app/components/checkout/confirmation/CheckoutConfirmationActions.vue +2 -0
  28. package/app/components/checkout/onepage/CheckoutAddressSection.vue +4 -4
  29. package/app/components/checkout/onepage/CheckoutDeliverySection.vue +31 -3
  30. package/app/components/checkout/onepage/CheckoutGate.vue +10 -7
  31. package/app/components/checkout/onepage/CheckoutOnePageView.vue +1 -1
  32. package/app/components/checkout/onepage/CheckoutPaymentSection.vue +10 -0
  33. package/app/components/checkout/onepage/CheckoutSummarySection.vue +7 -1
  34. package/app/components/form/FormPage.vue +40 -0
  35. package/app/components/layout/Region.vue +13 -0
  36. package/app/components/layout/footer/Footer.vue +8 -0
  37. package/app/components/layout/header/AppBar.vue +11 -4
  38. package/app/components/layout/header/MainNav.vue +26 -4
  39. package/app/components/layout/header/MobileMenu.vue +12 -0
  40. package/app/components/listing/ListingResults.vue +3 -1
  41. package/app/components/product/card/Compact.vue +10 -1
  42. package/app/components/product/detail/ProductDetailAddToCart.vue +51 -18
  43. package/app/components/product/detail/ProductDetailIdentity.vue +1 -1
  44. package/app/components/product/detail/ProductDetailPriceRequest.vue +39 -0
  45. package/app/components/product/detail/ProductDetailSaveToList.vue +10 -0
  46. package/app/components/product/detail/ProductDetailView.vue +57 -0
  47. package/app/composables/useAccountDashboard.ts +0 -10
  48. package/app/composables/useAccountHold.ts +45 -0
  49. package/app/composables/useAccountNavigation.ts +35 -0
  50. package/app/composables/useAccountPayments.ts +21 -0
  51. package/app/composables/useAccountQuotes.ts +15 -2
  52. package/app/composables/useAuthStore.ts +84 -2
  53. package/app/composables/useAuthoredForms.ts +26 -0
  54. package/app/composables/useAvailableOffers.ts +42 -0
  55. package/app/composables/useCategoryListing.ts +6 -0
  56. package/app/composables/useCheckoutOnePage.ts +21 -2
  57. package/app/composables/useGuestOrdering.ts +28 -0
  58. package/app/composables/useMasterDataEditable.ts +45 -7
  59. package/app/composables/useOrderListRules.ts +21 -1
  60. package/app/composables/usePendingApprovals.ts +37 -0
  61. package/app/composables/useProductCard.ts +29 -2
  62. package/app/composables/useProductListing.ts +79 -0
  63. package/app/composables/useQuantityStepper.ts +90 -0
  64. package/app/composables/useQuickActions.ts +35 -0
  65. package/app/composables/useRoleGrants.ts +32 -0
  66. package/app/composables/useSearchListing.ts +4 -0
  67. package/app/composables/useThemeEvents.ts +144 -0
  68. package/app/config/accountDashboard.ts +26 -0
  69. package/app/config/icons.ts +2 -0
  70. package/app/config/navigation.ts +2 -2
  71. package/app/config/quickActions.ts +40 -5
  72. package/app/formkit.config.ts +14 -0
  73. package/app/interfaces/account/approvals.ts +37 -0
  74. package/app/interfaces/account/dashboard.ts +2 -0
  75. package/app/interfaces/account/order-list.ts +29 -0
  76. package/app/interfaces/account/order-lists.ts +9 -0
  77. package/app/interfaces/account/payments.ts +48 -0
  78. package/app/interfaces/auth.ts +24 -2
  79. package/app/interfaces/b2b.ts +8 -8
  80. package/app/interfaces/offers.ts +35 -0
  81. package/app/interfaces/quantity-stepper.ts +17 -0
  82. package/app/interfaces/shopSettings.ts +77 -0
  83. package/app/layouts/default.vue +19 -10
  84. package/app/layouts/focus.vue +28 -7
  85. package/app/middleware/checkout-guard.ts +7 -1
  86. package/app/pages/punchout/transfer.vue +22 -0
  87. package/app/plugins/account-hold.client.ts +20 -0
  88. package/app/plugins/shop-settings.ts +27 -12
  89. package/app/plugins/theme-events.client.ts +132 -0
  90. package/app/shared/themeEvents.ts +445 -0
  91. package/i18n/locales/de/account.json +87 -0
  92. package/i18n/locales/de/auth.json +30 -0
  93. package/i18n/locales/de/cart.json +9 -1
  94. package/i18n/locales/de/checkout.json +4 -2
  95. package/i18n/locales/de/common.json +4 -0
  96. package/i18n/locales/de/cover.json +44 -0
  97. package/i18n/locales/de/editor.json +47 -1
  98. package/i18n/locales/de/forms.json +27 -0
  99. package/i18n/locales/en/account.json +87 -0
  100. package/i18n/locales/en/auth.json +30 -0
  101. package/i18n/locales/en/cart.json +9 -1
  102. package/i18n/locales/en/checkout.json +4 -2
  103. package/i18n/locales/en/common.json +4 -0
  104. package/i18n/locales/en/cover.json +44 -0
  105. package/i18n/locales/en/editor.json +47 -1
  106. package/i18n/locales/en/forms.json +27 -0
  107. package/nuxt.config.ts +15 -1
  108. package/package.json +6 -2
  109. package/server/api/account/address/[id].delete.ts +1 -1
  110. package/server/api/account/address/[id].put.ts +1 -1
  111. package/server/api/account/address/index.post.ts +1 -1
  112. package/server/api/account/order-lists/[id].get.ts +37 -3
  113. package/server/api/account/orders/[id]/cancel.post.ts +54 -0
  114. package/server/api/account/orders/[id]/messages.get.ts +63 -0
  115. package/server/api/account/orders/[id]/messages.post.ts +44 -0
  116. package/server/api/account/orders/[id]/return.post.ts +1 -0
  117. package/server/api/account/orders/[id].get.ts +1 -1
  118. package/server/api/account/organization.put.ts +1 -1
  119. package/server/api/account/payments.get.ts +54 -0
  120. package/server/api/account/pending-approvals/[id]/approve.post.ts +10 -0
  121. package/server/api/account/pending-approvals/[id]/decline.post.ts +10 -0
  122. package/server/api/account/pending-approvals/index.get.ts +26 -0
  123. package/server/api/account/profile.get.ts +3 -1
  124. package/server/api/account/profile.put.ts +1 -1
  125. package/server/api/account/quotes/[id]/decline.post.ts +35 -6
  126. package/server/api/account/team/[id].put.ts +1 -1
  127. package/server/api/account/team.post.ts +1 -1
  128. package/server/api/auth/login.post.ts +6 -0
  129. package/server/api/auth/magic-link.post.ts +32 -0
  130. package/server/api/auth/magic-link.put.ts +35 -0
  131. package/server/api/auth/otp.post.ts +33 -0
  132. package/server/api/auth/otp.put.ts +33 -0
  133. package/server/api/carts/[id]/activate.post.ts +1 -0
  134. package/server/api/carts/[id]/index.delete.ts +1 -0
  135. package/server/api/carts/[id]/index.put.ts +1 -0
  136. package/server/api/carts/[id]/items.post.ts +1 -0
  137. package/server/api/checkout/profile.get.ts +6 -3
  138. package/server/api/forms/[slug]/submit.post.ts +27 -16
  139. package/server/api/forms/[slug].get.ts +9 -1
  140. package/server/api/forms/index.get.ts +23 -0
  141. package/server/api/orders/index.post.ts +41 -0
  142. package/server/api/promotions/available.post.ts +37 -0
  143. package/server/api/quick-actions.get.ts +6 -38
  144. package/server/config/account/organization.json +0 -4
  145. package/server/config/shop/app-settings.json +4 -0
  146. package/server/data/forms/authored.json +337 -0
  147. package/server/interfaces/forms.ts +51 -0
  148. package/server/middleware/buyer-principal.ts +18 -0
  149. package/server/routes/punchout/start.get.ts +2 -2
  150. package/server/services/ApiAddressBookService.ts +43 -1
  151. package/server/services/ApiAuthService.ts +101 -10
  152. package/server/services/ApiCartService.ts +3 -10
  153. package/server/services/ApiFormsService.ts +56 -0
  154. package/server/services/ApiOrganizationService.ts +7 -2
  155. package/server/services/ApiTeamService.ts +93 -21
  156. package/server/services/MockB2BContextService.ts +1 -5
  157. package/server/services/MockFormsService.ts +63 -0
  158. package/server/utils/accountPayments.ts +45 -0
  159. package/server/utils/appSettings.ts +69 -4
  160. package/server/utils/buyerIdentity.ts +168 -0
  161. package/server/utils/cartOwnership.ts +27 -0
  162. package/server/utils/forms.ts +62 -14
  163. package/server/utils/formsService.ts +29 -0
  164. package/server/utils/liveOrderLists.ts +50 -23
  165. package/server/utils/liveOrders.ts +65 -24
  166. package/server/utils/livePrices.ts +7 -15
  167. package/server/utils/masterData.ts +60 -11
  168. package/server/utils/passwordlessSignIn.ts +82 -0
  169. package/server/utils/pendingApprovals.ts +175 -0
  170. package/server/utils/procurementCheckout.ts +2 -0
  171. package/server/utils/promotionsService.ts +90 -0
  172. package/server/utils/quickActionCatalogue.ts +53 -0
  173. package/server/utils/quotesService.ts +15 -0
  174. package/server/utils/revenexxSdk.ts +116 -2
  175. package/server/utils/shopSettings.ts +35 -4
@@ -1,6 +1,12 @@
1
- export default defineNuxtRouteMiddleware(() => {
1
+ export default defineNuxtRouteMiddleware((to, from) => {
2
2
  const localePath = useLocalePath();
3
3
 
4
+ // A new checkout started from the cart must show the account/guest choice
5
+ // again; the selection is intentionally kept only within the current flow.
6
+ if (from.path !== to.path && /\/cart(?:\/|$)/.test(from.path)) {
7
+ useState("checkout-customer-type", () => "account").value = "account";
8
+ }
9
+
4
10
  // Authentication is handled on the page itself (checkout gate with
5
11
  // login + guest ordering per organization flags) — the guard only
6
12
  // ensures there is something to check out.
@@ -1,5 +1,6 @@
1
1
  <script setup lang="ts">
2
2
  import type { PunchoutReturnPayload } from "../../interfaces/punchout";
3
+ import { cartEcommerce } from "../../shared/themeEvents";
3
4
 
4
5
  /**
5
6
  * The interstitial — the buyer is leaving.
@@ -31,6 +32,26 @@ const { t } = useI18n();
31
32
  const { icon } = useIcons();
32
33
  const { to } = useAppUrl();
33
34
  const { protocol } = usePunchoutVisit();
35
+ const cart = useCartStore();
36
+ const themeEvents = useThemeEvents();
37
+
38
+ /**
39
+ * `punchout_transfer` — the cart leaves for the procurement system. Not for a
40
+ * replayed hand-back (the same cart answered again) nor for a back-channel
41
+ * visit, where the browser posts nothing; and only for the two protocols the
42
+ * contract names.
43
+ */
44
+ function reportTransfer(): void {
45
+ const kind = protocol.value;
46
+ if (payload.value?.replayed || isBackChannel.value || (kind !== "oci" && kind !== "cxml") || !cart.items.length) {
47
+ return;
48
+ }
49
+ const ecommerce = cartEcommerce(cart.items);
50
+ themeEvents.emit("punchout_transfer", {
51
+ ecommerce: { ...ecommerce, value_net: ecommerce.value_net ?? 0, value_gross: ecommerce.value_gross ?? 0 },
52
+ punchout: { protocol: kind },
53
+ });
54
+ }
34
55
 
35
56
  definePageMeta({
36
57
  // The buyer is on their way out; this page is not part of the shop's
@@ -72,6 +93,7 @@ onMounted(async () => {
72
93
 
73
94
  // One tick so the form is in the DOM, and a beat so the buyer sees where
74
95
  // they are going rather than a flash of a page they cannot read.
96
+ reportTransfer();
75
97
  await nextTick();
76
98
  window.setTimeout(() => form.value?.submit(), 400);
77
99
  });
@@ -0,0 +1,20 @@
1
+ /**
2
+ * A buyer whose account is on hold stops being offered the cart.
3
+ *
4
+ * The platform refuses their orders — it shapes the permission set by the
5
+ * merchant's choice, and at `catalog_only` there is no ordering permission left.
6
+ * The shop's part is not to enforce that a second time but to stop asking: a
7
+ * quantity stepper that works and a checkout button that does not is worse than
8
+ * a cart that plainly says it is read-only.
9
+ *
10
+ * Where the merchant left the buyer their permissions (`keep`) nothing changes:
11
+ * the hold is a notice, not a lock, and the account area says so.
12
+ */
13
+ export default defineNuxtPlugin(() => {
14
+ const cart = useCartStore();
15
+ const { mayAct } = useAccountHold();
16
+
17
+ watch(mayAct, (allowed) => {
18
+ cart.setReadOnly(!allowed);
19
+ }, { immediate: true });
20
+ });
@@ -1,3 +1,4 @@
1
+ import type { FormSummary } from "../../server/interfaces/forms";
1
2
  import type { ShopSettings } from "../interfaces/shopSettings";
2
3
 
3
4
  /**
@@ -32,21 +33,35 @@ const forwardedHeaders = () =>
32
33
  useRequestHeaders(["cookie", "x-revenexx-tenant", "x-revenexx-context"]);
33
34
 
34
35
  export default defineNuxtPlugin(async () => {
35
- const state = useState<ShopSettings | null>("cover:shop-settings", () => null);
36
+ const settings = useState<ShopSettings | null>("cover:shop-settings", () => null);
37
+ // The forms the merchant published, fetched in the same breath rather than by
38
+ // a plugin of its own: it is the same kind of fact (what this shop HAS, before
39
+ // anything renders), and beside an awaited call it costs no round trip. A link
40
+ // that appeared after the page did would move the buy box under the cursor.
41
+ const forms = useState<FormSummary[] | null>("cover:authored-forms", () => null);
36
42
 
37
- // Hydration: the server already put the answer in the payload.
38
- if (state.value) {
43
+ // Hydration: the server already put the answers in the payload.
44
+ if (settings.value && forms.value) {
39
45
  return;
40
46
  }
41
47
 
42
- try {
43
- state.value = await $fetch<ShopSettings>("/api/shop/settings", {
44
- headers: forwardedHeaders(),
45
- });
46
- }
47
- catch {
48
- // Left null. Every reader falls back to what the layer has always done,
49
- // and a page that cannot learn the merchant's terms states none — which
50
- // is the same thing it does for a merchant who set none.
48
+ // allSettled rather than a .catch() on each call: this must survive a $fetch
49
+ // that does not hand back a thenable at all, which is what a test harness does
50
+ // for an endpoint nobody registered. A TypeError here takes the whole app
51
+ // initialisation down with it, and the router with that.
52
+ const headers = forwardedHeaders();
53
+ const [answered, offered] = await Promise.allSettled([
54
+ $fetch<ShopSettings>("/api/shop/settings", { headers }),
55
+ $fetch<{ forms: FormSummary[] }>("/api/forms", { headers }),
56
+ ]);
57
+ const settled = answered.status === "fulfilled" ? answered.value : null;
58
+ const published = offered.status === "fulfilled" ? offered.value : null;
59
+
60
+ // Left null on failure. Every reader falls back to what the layer has always
61
+ // done, and a page that cannot learn the merchant's terms states none — which
62
+ // is the same thing it does for a merchant who set none.
63
+ if (settled) {
64
+ settings.value = settled;
51
65
  }
66
+ forms.value = published?.forms ?? [];
52
67
  });
@@ -0,0 +1,132 @@
1
+ import type { AuthMethod } from "@revenexx/tag-manager-nuxt/events";
2
+ import type { RouteLocationNormalized } from "vue-router";
3
+
4
+ import {
5
+ browserSession,
6
+ cartEcommerce,
7
+ itemsValue,
8
+ pageTypeOf,
9
+ takePurchase,
10
+ trackCartChanges,
11
+ } from "../shared/themeEvents";
12
+
13
+ /** How long a cart-dependent page event waits for the cart to be restored. */
14
+ const CART_READY_WAIT_MS = 3000;
15
+
16
+ /**
17
+ * The theme events no single component owns (RAD-178).
18
+ *
19
+ * - `page_view`: pages are blökkli-authored, so the router is the only uniform
20
+ * point. Once per path — a query change (a filter, a page of results) is the
21
+ * same page.
22
+ * - `view_cart`, `begin_checkout`, `purchase`: by the page reached, so every
23
+ * theme on this layer reports them whichever pages it ships (the blökkli
24
+ * theme, the custom theme and the demo shop each have their own).
25
+ * - `add_to_cart` / `remove_from_cart`: read off the cart store's actions, so
26
+ * every add-to-cart button in the design system reports without knowing it,
27
+ * and only an add the store accepted counts.
28
+ * - `login` / `sign_up`: read off the auth store's actions, once they resolved.
29
+ *
30
+ * Editor and preview contexts emit nothing (`useThemeEvents`).
31
+ */
32
+ export default defineNuxtPlugin({
33
+ name: "cover:theme-events",
34
+ setup(nuxtApp) {
35
+ const events = useThemeEvents();
36
+ const router = useRouter();
37
+ const cart = useCartStore();
38
+ const auth = useAuthStore();
39
+
40
+ /* ---- the cart is restored asynchronously ----------------------------- */
41
+ // auth-init restores the cart from the server after the session check; a
42
+ // cart page reached on a hard load would otherwise report an empty cart.
43
+ let markCartReady: () => void = () => {};
44
+ const cartReady = new Promise<void>((resolve) => {
45
+ markCartReady = resolve;
46
+ setTimeout(resolve, CART_READY_WAIT_MS);
47
+ });
48
+ cart.$onAction(({ name, after, onError }) => {
49
+ if (name === "initFromServer") {
50
+ after(() => markCartReady());
51
+ onError(() => markCartReady());
52
+ }
53
+ }, true);
54
+
55
+ /* ---- per page ------------------------------------------------------- */
56
+ const localeCodes = (): string[] => {
57
+ const locales = (nuxtApp.$i18n as { locales?: { value: ({ code: string } | string)[] } } | undefined)?.locales?.value ?? [];
58
+ return locales.map(l => (typeof l === "string" ? l : l.code));
59
+ };
60
+
61
+ async function pageEvents(to: RouteLocationNormalized): Promise<void> {
62
+ const type = pageTypeOf(to.path, localeCodes());
63
+ if (type === "cart") {
64
+ await cartReady;
65
+ events.emit("view_cart", { ecommerce: cartEcommerce(cart.items) });
66
+ }
67
+ else if (type === "checkout") {
68
+ await cartReady;
69
+ if (cart.items.length) {
70
+ events.emit("begin_checkout", { ecommerce: cartEcommerce(cart.items) });
71
+ }
72
+ }
73
+ else if (type === "confirmation") {
74
+ purchase(to);
75
+ }
76
+ }
77
+
78
+ /**
79
+ * One `purchase` per order, on the confirmation page. Not for an approval
80
+ * request or a requisition — nothing was bought yet. The order id IS the
81
+ * event id, so the emitter drops a reload of the same confirmation.
82
+ */
83
+ function purchase(to: RouteLocationNormalized): void {
84
+ const id = typeof to.query.id === "string" ? to.query.id.trim() : "";
85
+ const kind = typeof to.query.type === "string" ? to.query.type : "order";
86
+ if (!id || kind !== "order") {
87
+ return;
88
+ }
89
+ const placed = takePurchase(browserSession());
90
+ if (!placed?.items?.length) {
91
+ return;
92
+ }
93
+ events.emit("purchase", { ecommerce: { ...placed, transaction_id: id.slice(0, 128) } });
94
+ }
95
+
96
+ let lastPath: string | null = null;
97
+ const onPage = (to: RouteLocationNormalized) => {
98
+ if (to.path === lastPath) {
99
+ return;
100
+ }
101
+ lastPath = to.path;
102
+ events.emit("page_view");
103
+ void pageEvents(to);
104
+ };
105
+ // The first page once the app is mounted; every later one after its navigation.
106
+ nuxtApp.hook("app:mounted", () => onPage(router.currentRoute.value));
107
+ router.afterEach((to, _from, failure) => {
108
+ if (!failure && nuxtApp.isHydrating !== true) {
109
+ onPage(to);
110
+ }
111
+ });
112
+
113
+ /* ---- cart ----------------------------------------------------------- */
114
+ trackCartChanges(cart, (event, items) => {
115
+ events.emit(event, { ecommerce: { items, ...itemsValue(items) } });
116
+ });
117
+
118
+ /* ---- signing in ----------------------------------------------------- */
119
+ auth.$onAction(({ name, args, after }) => {
120
+ if (name === "login") {
121
+ after(() => events.emit("login", { auth: { method: "password" } }));
122
+ }
123
+ else if (name === "confirmSignInMail") {
124
+ const method: AuthMethod = args[0] === "otp" ? "otp" : "magic_link";
125
+ after(() => events.emit("login", { auth: { method } }));
126
+ }
127
+ else if (name === "register") {
128
+ after(() => events.emit("sign_up", { auth: { method: "password" } }));
129
+ }
130
+ }, true);
131
+ },
132
+ });