@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
@@ -17,6 +17,31 @@ const { members, status, error, inviteMember, updateMemberRole } = useAccountTea
17
17
  // Contacts another system owns are listed, never invited or changed here
18
18
  // (the BFF refuses the write as well — see account.team.editable).
19
19
  const editable = useMasterDataEditable("team");
20
+ // A buyer whose role does not run the company's people is told so, rather than
21
+ // told the merchant maintains them; and nobody is offered a role above their
22
+ // own, their own role, or the role of somebody who outranks them (RAD-155).
23
+ const { lockedByRole, mayGrant, isSelf, outranks } = useRoleGrants();
24
+ const roleLocked = lockedByRole("contacts.manage");
25
+ const canEditMember = (member: AccountTeamMember): boolean =>
26
+ !isSelf(member.id) && !outranks(member.role);
27
+
28
+ /** The sentence for a refused save — the page's own words, keyed by the BFF's reason. */
29
+ function saveErrorTitle(err: unknown): string {
30
+ const failure = err as { statusCode?: number; data?: { data?: { type?: string } } };
31
+ const type = failure?.data?.data?.type;
32
+ if (failure?.statusCode === 404) {
33
+ return t("team.refused.notFound");
34
+ }
35
+ switch (type) {
36
+ case "role_above_own": return t("team.refused.roleAboveOwn");
37
+ case "own_role": return t("team.refused.ownRole");
38
+ case "permission_missing": return t("team.lockedRole");
39
+ case "field_merchant_owned":
40
+ case "not_self_service":
41
+ case "master_data_merchant_owned": return t("team.locked");
42
+ default: return t("team.saveError");
43
+ }
44
+ }
20
45
  const { tableUi } = useDataTable();
21
46
 
22
47
  const ROLES: AccountTeamRole[] = ["buyer", "approver", "admin", "requester"];
@@ -35,7 +60,7 @@ const statusColors: Record<AccountTeamStatus, "success" | "warning" | "error"> =
35
60
  };
36
61
 
37
62
  const roleItems = computed(() =>
38
- ROLES.map(value => ({ value, label: t(`team.roles.${value}`) })),
63
+ ROLES.filter(value => mayGrant(value)).map(value => ({ value, label: t(`team.roles.${value}`) })),
39
64
  );
40
65
 
41
66
  /* ---- search ------------------------------------------------------------ */
@@ -95,8 +120,8 @@ async function saveInvite(): Promise<void> {
95
120
  inviting.value = false;
96
121
  toast.add({ title: t("team.saved"), color: "success", icon: icon("success"), duration: 2000 });
97
122
  }
98
- catch {
99
- toast.add({ title: t("team.saveError"), color: "error", icon: icon("error"), duration: 3000 });
123
+ catch (err) {
124
+ toast.add({ title: saveErrorTitle(err), color: "error", icon: icon("error"), duration: 3000 });
100
125
  }
101
126
  finally {
102
127
  savingInvite.value = false;
@@ -125,8 +150,8 @@ async function saveEdit(): Promise<void> {
125
150
  editing.value = false;
126
151
  toast.add({ title: t("team.saved"), color: "success", icon: icon("success"), duration: 2000 });
127
152
  }
128
- catch {
129
- toast.add({ title: t("team.saveError"), color: "error", icon: icon("error"), duration: 3000 });
153
+ catch (err) {
154
+ toast.add({ title: saveErrorTitle(err), color: "error", icon: icon("error"), duration: 3000 });
130
155
  }
131
156
  finally {
132
157
  savingEdit.value = false;
@@ -149,7 +174,7 @@ async function saveEdit(): Promise<void> {
149
174
  color="info"
150
175
  variant="soft"
151
176
  :icon="icon('info')"
152
- :description="t('team.locked')"
177
+ :description="roleLocked ? t('team.lockedRole') : t('team.locked')"
153
178
  />
154
179
  <UiTableToolbar
155
180
  v-model:search="search"
@@ -218,7 +243,7 @@ async function saveEdit(): Promise<void> {
218
243
  </template>
219
244
  <template #actions-cell="{ row }">
220
245
  <div
221
- v-if="editable"
246
+ v-if="editable && canEditMember(row.original)"
222
247
  class="flex items-center justify-end gap-1"
223
248
  >
224
249
  <UTooltip :text="t('team.editTitle')">
@@ -32,7 +32,7 @@ async function onSubmit(): Promise<void> {
32
32
  </script>
33
33
 
34
34
  <template>
35
- <div class="bg-elevated py-6 px-8 rounded-lg">
35
+ <div class="w-full bg-(--ui-bg) border border-(--ui-border) rounded-xl p-6 space-y-6">
36
36
  <h2 class="text-xl font-semibold text-highlighted">
37
37
  {{ t('auth.forgotPassword.title') }}
38
38
  </h2>
@@ -40,18 +40,23 @@ async function onSubmit(): Promise<void> {
40
40
  <FormKit
41
41
  type="form"
42
42
  :actions="false"
43
- class="space-y-4 pt-6"
43
+ class="space-y-4"
44
44
  @submit="onSubmit"
45
45
  >
46
46
  <FormKit
47
47
  v-model="state.email"
48
48
  type="email"
49
- :label="t('auth.forgotPassword.fields.email')"
50
49
  name="email"
51
50
  validation="required|email"
52
51
  autocomplete="email"
52
+ input-class="h-8 py-1 bg-(--ui-bg)"
53
53
  :placeholder="t('auth.forgotPassword.fields.emailPlaceholder')"
54
- />
54
+ >
55
+ <template #label>
56
+ <span>{{ t('onepage.guest.email') }}</span>
57
+ <span class="text-error-500"> *</span>
58
+ </template>
59
+ </FormKit>
55
60
 
56
61
  <UAlert
57
62
  v-if="error"
@@ -18,19 +18,63 @@ const { loading, error } = storeToRefs(auth);
18
18
  /**
19
19
  * How this merchant lets a buyer sign in, as the customers app decides.
20
20
  *
21
- * Only the password is built here. Where the merchant has switched it off and
22
- * put a mailed link or a mailed code in its place, this form cannot sign anybody
23
- * in — so it says how to get in instead of offering a field whose submission
24
- * the app refuses. Building those two ways in is its own work (RX-798).
21
+ * Three ways, and the shop offers exactly the ones switched on — the app refuses
22
+ * the rest, so offering one would be a field whose submission fails. A merchant
23
+ * who has taken the password away and put a mailed link in its place gets a panel
24
+ * that asks for an address and nothing else.
25
25
  */
26
26
  const { signIn } = useShopSettings();
27
27
  const passwordOffered = computed(() => signIn.value?.password ?? true);
28
- const mailedWayIn = computed(() => {
29
- if (signIn.value?.magicLink) {
30
- return "magicLink" as const;
28
+ const magicLinkOffered = computed(() => signIn.value?.magicLink === true);
29
+ const otpOffered = computed(() => signIn.value?.emailOtp === true);
30
+ const anyMailedWay = computed(() => magicLinkOffered.value || otpOffered.value);
31
+
32
+ /* ---- signing in by mail ------------------------------------------------ */
33
+
34
+ /** Which mailed way the buyer is in the middle of, and how far. */
35
+ const mailedKind = ref<"magic-link" | "otp" | null>(null);
36
+ const mailSent = ref(false);
37
+ /** The id the code's confirmation needs; absent for an address nobody holds. */
38
+ const otpUserId = ref<string | null>(null);
39
+ const otpCode = ref("");
40
+
41
+ async function requestMail(kind: "magic-link" | "otp"): Promise<void> {
42
+ if (!state.email.trim()) {
43
+ return;
31
44
  }
32
- return signIn.value?.emailOtp ? "emailOtp" as const : null;
33
- });
45
+ mailedKind.value = kind;
46
+ try {
47
+ otpUserId.value = await auth.requestSignInMail(kind, state.email.trim());
48
+ mailSent.value = true;
49
+ }
50
+ catch {
51
+ // error is set on the store and rendered by UAlert
52
+ }
53
+ }
54
+
55
+ async function confirmCode(): Promise<void> {
56
+ // Without an id there is nothing to confirm against — which is what an address
57
+ // nobody holds looks like. The message is the same one a wrong code gets, so
58
+ // the form never reveals which of the two happened.
59
+ if (!otpCode.value.trim() || !otpUserId.value) {
60
+ auth.error = "auth.login.mailed.codeRejected";
61
+ return;
62
+ }
63
+ try {
64
+ await auth.confirmSignInMail("otp", { userId: otpUserId.value, secret: otpCode.value.trim() });
65
+ emit("success");
66
+ }
67
+ catch {
68
+ // error is set on the store and rendered by UAlert
69
+ }
70
+ }
71
+
72
+ function startOver(): void {
73
+ mailedKind.value = null;
74
+ mailSent.value = false;
75
+ otpUserId.value = null;
76
+ otpCode.value = "";
77
+ }
34
78
 
35
79
  const state = reactive<LoginFormState>({
36
80
  email: "",
@@ -52,38 +96,111 @@ async function onSubmit(): Promise<void> {
52
96
  </script>
53
97
 
54
98
  <template>
55
- <div class="bg-elevated py-6 px-8 rounded-lg">
99
+ <div class="bg-(--ui-bg) border border-(--ui-border) rounded-xl p-6 space-y-6">
56
100
  <h2 class="text-xl font-semibold text-highlighted">
57
101
  {{ t('auth.login.existingCustomer') }}
58
102
  </h2>
59
103
 
60
- <!-- The merchant signs buyers in some other way. Saying so beats a
61
- password field that cannot work. -->
104
+ <!-- The merchant offers no password and no mailed way either: nothing this
105
+ form can do, so it says whom to ask instead. -->
62
106
  <UAlert
63
- v-if="!passwordOffered"
107
+ v-if="!passwordOffered && !anyMailedWay"
64
108
  class="mt-6"
65
109
  color="info"
66
110
  variant="soft"
67
111
  :title="t('auth.login.passwordDisabled.title')"
68
- :description="mailedWayIn
69
- ? t(`auth.login.passwordDisabled.${mailedWayIn}`)
70
- : t('auth.login.passwordDisabled.contact')"
112
+ :description="t('auth.login.passwordDisabled.contact')"
71
113
  />
72
114
 
115
+ <!-- Signing in by mail. Where the password is gone this is the whole panel;
116
+ beside a password it is the alternative under it. -->
117
+ <div
118
+ v-if="anyMailedWay"
119
+ :class="passwordOffered ? 'mt-6 pt-6 border-t border-(--ui-border) space-y-3' : 'mt-6 space-y-3'"
120
+ >
121
+ <template v-if="!mailSent">
122
+ <p class="text-sm text-muted">
123
+ {{ t(passwordOffered ? 'auth.login.mailed.alternative' : 'auth.login.mailed.only') }}
124
+ </p>
125
+ <UInput
126
+ v-if="!passwordOffered"
127
+ v-model="state.email"
128
+ type="email"
129
+ class="w-full"
130
+ autocomplete="email"
131
+ :placeholder="t('auth.login.fields.emailPlaceholder')"
132
+ />
133
+ <div class="flex flex-wrap gap-2">
134
+ <UButton
135
+ v-if="magicLinkOffered"
136
+ color="neutral"
137
+ :variant="passwordOffered ? 'outline' : 'solid'"
138
+ :disabled="!state.email.trim() || loading"
139
+ :label="t('auth.login.mailed.requestLink')"
140
+ @click="requestMail('magic-link')"
141
+ />
142
+ <UButton
143
+ v-if="otpOffered"
144
+ color="neutral"
145
+ :variant="passwordOffered ? 'outline' : 'solid'"
146
+ :disabled="!state.email.trim() || loading"
147
+ :label="t('auth.login.mailed.requestCode')"
148
+ @click="requestMail('otp')"
149
+ />
150
+ </div>
151
+ </template>
152
+
153
+ <template v-else>
154
+ <UAlert
155
+ color="success"
156
+ variant="soft"
157
+ :title="t('auth.login.mailed.sentTitle')"
158
+ :description="t(mailedKind === 'otp' ? 'auth.login.mailed.sentCode' : 'auth.login.mailed.sentLink', { email: state.email })"
159
+ />
160
+ <!-- The code is typed back here; a link is followed instead. -->
161
+ <div
162
+ v-if="mailedKind === 'otp'"
163
+ class="flex gap-2"
164
+ >
165
+ <UInput
166
+ v-model="otpCode"
167
+ class="flex-1"
168
+ autocomplete="one-time-code"
169
+ :placeholder="t('auth.login.mailed.codePlaceholder')"
170
+ @keyup.enter="confirmCode"
171
+ />
172
+ <UButton
173
+ color="primary"
174
+ :disabled="!otpCode.trim() || loading"
175
+ :label="t('auth.login.mailed.confirmCode')"
176
+ @click="confirmCode"
177
+ />
178
+ </div>
179
+ <UButton
180
+ color="neutral"
181
+ variant="ghost"
182
+ size="xs"
183
+ :label="t('auth.login.mailed.startOver')"
184
+ @click="startOver"
185
+ />
186
+ </template>
187
+ </div>
188
+
73
189
  <FormKit
74
190
  v-if="passwordOffered"
75
191
  type="form"
76
192
  :actions="false"
77
- class="space-y-4 pt-6"
193
+ class="space-y-4"
78
194
  @submit="onSubmit"
79
195
  >
80
196
  <FormKit
81
197
  v-model="state.email"
82
198
  type="email"
83
- :label="t('auth.login.fields.email')"
199
+ :label="t('onepage.guest.email')"
84
200
  name="email"
85
201
  validation="required|email"
86
202
  autocomplete="email"
203
+ input-class="h-8 py-1 bg-(--ui-bg)"
87
204
  :placeholder="t('auth.login.fields.emailPlaceholder')"
88
205
  />
89
206
 
@@ -94,6 +211,7 @@ async function onSubmit(): Promise<void> {
94
211
  name="password"
95
212
  validation="required|length:8"
96
213
  autocomplete="current-password"
214
+ input-class="h-8 py-1 bg-(--ui-bg)"
97
215
  :placeholder="t('auth.login.fields.passwordPlaceholder')"
98
216
  />
99
217
 
@@ -0,0 +1,70 @@
1
+ <script setup lang="ts">
2
+ /**
3
+ * The landing of a mailed sign-in link.
4
+ *
5
+ * The link carries the two things the platform needs, so there is nothing to ask
6
+ * the buyer: the panel confirms on arrival and says which of the three things
7
+ * happened — signed in, the link is spent, or the service could not be reached.
8
+ *
9
+ * A spent link is the ordinary case and not an error to apologise for: links
10
+ * expire, and people open them twice. So it offers the way back rather than a
11
+ * message about what went wrong.
12
+ */
13
+ const props = defineProps<{
14
+ userId: string;
15
+ secret: string;
16
+ }>();
17
+
18
+ const emit = defineEmits<{
19
+ (e: "success"): void;
20
+ }>();
21
+
22
+ const { t } = useI18n();
23
+ const { icon } = useIcons();
24
+ const auth = useAuthStore();
25
+
26
+ type State = "confirming" | "rejected" | "unavailable";
27
+ const state = ref<State>("confirming");
28
+
29
+ onMounted(async () => {
30
+ if (!props.userId || !props.secret) {
31
+ // A link that lost its query, or somebody typing the address by hand.
32
+ state.value = "rejected";
33
+ return;
34
+ }
35
+ try {
36
+ await auth.confirmSignInMail("magic-link", { userId: props.userId, secret: props.secret });
37
+ emit("success");
38
+ }
39
+ catch (err) {
40
+ const status = (err as { status?: number; statusCode?: number })?.status
41
+ ?? (err as { statusCode?: number })?.statusCode;
42
+ state.value = status === 401 ? "rejected" : "unavailable";
43
+ }
44
+ });
45
+ </script>
46
+
47
+ <template>
48
+ <div class="bg-elevated py-6 px-8 rounded-lg space-y-4">
49
+ <template v-if="state === 'confirming'">
50
+ <p class="flex items-center gap-2 text-sm text-muted">
51
+ <UIcon
52
+ :name="icon('loading')"
53
+ class="size-4 animate-spin"
54
+ />
55
+ {{ t('auth.magicLink.confirming') }}
56
+ </p>
57
+ </template>
58
+
59
+ <template v-else>
60
+ <UAlert
61
+ :color="state === 'rejected' ? 'warning' : 'error'"
62
+ variant="soft"
63
+ :icon="icon('warning')"
64
+ :title="t(`auth.magicLink.${state}.title`)"
65
+ :description="t(`auth.magicLink.${state}.description`)"
66
+ />
67
+ <slot name="retry" />
68
+ </template>
69
+ </div>
70
+ </template>
@@ -1,5 +1,6 @@
1
1
  <script setup lang="ts">
2
2
  import type { OrderList, OrderListKind, OrderListPosition } from "../../../interfaces/account/order-lists";
3
+ import { cartEcommerce } from "../../../shared/themeEvents";
3
4
 
4
5
  /**
5
6
  * Saves positions to a shopping or label list (account order lists BFF).
@@ -16,6 +17,7 @@ const { t } = useI18n();
16
17
  const toast = useToast();
17
18
  const cart = useCartStore();
18
19
  const authStore = useAuthStore();
20
+ const themeEvents = useThemeEvents();
19
21
 
20
22
  type Mode = "existing" | "new";
21
23
 
@@ -98,6 +100,9 @@ async function save(): Promise<void> {
98
100
  body: { name, kind: kind.value, public: false, positions },
99
101
  });
100
102
  }
103
+ if (positions.length) {
104
+ themeEvents.emit("add_to_orderlist", { ecommerce: cartEcommerce(positions) });
105
+ }
101
106
  toast.add({
102
107
  title: t("cart.saveToList.success", positions.length, { count: positions.length, list: name }),
103
108
  color: "success",
@@ -82,38 +82,24 @@ const detailUrl = computed(() => {
82
82
 
83
83
  return localePath(categoryProductPath([categorySlug, subcategorySlug], props.item));
84
84
  });
85
- const inputValue = ref(String(props.item.quantity));
86
85
  const confirmOpen = ref(false);
87
-
88
- const parsedInputQuantity = computed(() => {
89
- const sanitized = inputValue.value.replace(/[^0-9]/g, "");
90
- return parseInt(sanitized, 10) || 0;
91
- });
92
- const quantityInvalid = computed(() => parsedInputQuantity.value < 1);
93
- const quantityExceeded = computed(() => {
94
- if (typeof maxOrderQuantity.value !== "number") {
95
- return false;
96
- }
97
-
98
- return parsedInputQuantity.value > maxOrderQuantity.value;
99
- });
100
86
  const currentCartQuantity = computed(() => props.item.quantity);
101
87
 
102
- let quantityErrorTimer: ReturnType<typeof setTimeout> | null = null;
103
- const showQuantityError = ref(false);
104
- const maxExceededAttempted = ref(false);
105
-
106
- function triggerQuantityError() {
107
- showQuantityError.value = true;
108
- if (quantityErrorTimer !== null) {
109
- clearTimeout(quantityErrorTimer);
110
- }
111
- quantityErrorTimer = setTimeout(() => {
112
- showQuantityError.value = false;
113
- maxExceededAttempted.value = false;
114
- quantityErrorTimer = null;
115
- }, 2000);
116
- }
88
+ // Mini-cart: − at 1 removes the line (the store reads 0 as remove), so the
89
+ // stepper floor is 0 here.
90
+ const {
91
+ inputValue,
92
+ notice: quantityNotice,
93
+ decrease,
94
+ increase,
95
+ onInput: onQuantityInput,
96
+ commit: commitInput,
97
+ } = useQuantityStepper({
98
+ quantity: () => props.item.quantity,
99
+ max: () => maxOrderQuantity.value,
100
+ min: 0,
101
+ apply: next => cart.updateQuantity(props.item.id, next),
102
+ });
117
103
 
118
104
  const ariaQuantityOfLabel = computed(() =>
119
105
  t("cart.item.ariaQuantityOf", { name: props.item.name, quantity: props.item.quantity }),
@@ -128,50 +114,6 @@ const ariaIncreaseQuantityLabel = computed(() =>
128
114
  t("cart.item.ariaIncreaseQuantity", { name: props.item.name }),
129
115
  );
130
116
 
131
- watch(() => props.item.quantity, (val: number) => {
132
- inputValue.value = String(val);
133
- });
134
-
135
- function applyQuantity(nextQuantity: number) {
136
- if (typeof maxOrderQuantity.value === "number" && nextQuantity > maxOrderQuantity.value) {
137
- maxExceededAttempted.value = true;
138
- triggerQuantityError();
139
- return;
140
- }
141
- cart.updateQuantity(props.item.id, nextQuantity);
142
- }
143
-
144
- function decrease() {
145
- applyQuantity(props.item.quantity - 1);
146
- }
147
-
148
- function increase() {
149
- applyQuantity(props.item.quantity + 1);
150
- }
151
-
152
- function onQuantityInput(event: Event) {
153
- const input = event.target as HTMLInputElement;
154
- const sanitized = input.value.replace(/[^0-9]/g, "");
155
- inputValue.value = sanitized;
156
- }
157
-
158
- function commitInput() {
159
- if (quantityInvalid.value || quantityExceeded.value) {
160
- triggerQuantityError();
161
- inputValue.value = String(props.item.quantity);
162
- return;
163
- }
164
-
165
- applyQuantity(parsedInputQuantity.value);
166
- }
167
-
168
- onUnmounted(() => {
169
- if (quantityErrorTimer !== null) {
170
- clearTimeout(quantityErrorTimer);
171
- quantityErrorTimer = null;
172
- }
173
- });
174
-
175
117
  onMounted(() => {
176
118
  if (!props.item.categorySlug || !props.item.subcategorySlug) {
177
119
  void loadFallbackSlugs();
@@ -259,13 +201,13 @@ onMounted(() => {
259
201
  </template>
260
202
  </div>
261
203
  <UiFeedbackErrorBoundary
262
- v-if="showQuantityError && maxExceededAttempted && maxOrderQuantity"
204
+ v-if="quantityNotice === 'max' && maxOrderQuantity"
263
205
  :title="t('product.actions.maxQuantityReachedTitle', { count: currentCartQuantity })"
264
206
  :description="t('product.actions.maxQuantityReachedDescription', { max: maxOrderQuantity })"
265
207
  :show-retry="false"
266
208
  />
267
209
  <UiFeedbackErrorBoundary
268
- v-if="showQuantityError && quantityInvalid"
210
+ v-if="quantityNotice === 'invalid'"
269
211
  :title="t('product.actions.invalidQuantityTitle')"
270
212
  :description="t('product.actions.invalidQuantityDescription')"
271
213
  :show-retry="false"
@@ -7,7 +7,6 @@ const featureOrderLists = computed(() =>
7
7
  import { categoryProductPath } from "../../../composables/useProducts";
8
8
  import type { CalculatedCartLine } from "../../../interfaces/cart-calculation";
9
9
  import type { CartItem } from "../../../interfaces/cart-item";
10
- import { CART_MAX_QUANTITY } from "../../../interfaces/cart-item";
11
10
 
12
11
  /**
13
12
  * Full cart position (Cart 2.0): selector, drag handle, article identity,
@@ -64,31 +63,19 @@ const availabilityColor = computed(() => {
64
63
  });
65
64
 
66
65
  /* ---- quantity ---------------------------------------------------- */
67
- const inputValue = ref(String(props.item.quantity));
68
- watch(() => props.item.quantity, (val) => {
69
- inputValue.value = String(val);
66
+ const {
67
+ inputValue: quantityInput,
68
+ canDecrease,
69
+ decrease,
70
+ increase,
71
+ onInput: onQuantityInput,
72
+ commit: commitQuantity,
73
+ } = useQuantityStepper({
74
+ quantity: () => props.item.quantity,
75
+ max: () => props.item.maxOrderQuantity,
76
+ apply: next => cart.updateQuantityByKey(lineKey.value, next),
70
77
  });
71
78
 
72
- function applyQuantity(next: number): void {
73
- const clamped = Math.min(Math.max(next, 1), props.item.maxOrderQuantity ?? CART_MAX_QUANTITY);
74
- cart.updateQuantityByKey(lineKey.value, clamped);
75
- inputValue.value = String(clamped);
76
- }
77
-
78
- function onQuantityInput(event: Event): void {
79
- const input = event.target as HTMLInputElement;
80
- inputValue.value = input.value.replace(/[^0-9]/g, "").slice(0, 6);
81
- }
82
-
83
- function commitInput(): void {
84
- const parsed = parseInt(inputValue.value, 10);
85
- if (!parsed || parsed < 1) {
86
- inputValue.value = String(props.item.quantity);
87
- return;
88
- }
89
- applyQuantity(parsed);
90
- }
91
-
92
79
  // A position nobody can order reads as a warning, and one missing a cost centre
93
80
  // too: both are things the buyer has to act on before the cart will go through.
94
81
  // Everything else is a note.
@@ -293,20 +280,20 @@ const hintColor = (type: string) =>
293
280
  variant="soft"
294
281
  size="xs"
295
282
  tabindex="0"
296
- :disabled="item.quantity <= 1"
283
+ :disabled="!canDecrease"
297
284
  :aria-label="t('cart.item.ariaDecreaseQuantity', { name: item.name })"
298
- @click="applyQuantity(item.quantity - 1)"
285
+ @click="decrease"
299
286
  />
300
287
  <input
301
- v-model="inputValue"
288
+ v-model="quantityInput"
302
289
  type="text"
303
290
  inputmode="numeric"
304
291
  :aria-label="t('cart.item.ariaInputQuantity', { name: item.name })"
305
292
  class="w-14 text-center text-sm border border-(--ui-border) rounded px-1 py-0.5
306
293
  bg-transparent focus:outline-none focus:ring-1 focus:ring-(--ui-primary)"
307
294
  @input="onQuantityInput"
308
- @keydown.enter.prevent="commitInput"
309
- @blur="commitInput"
295
+ @keydown.enter.prevent="commitQuantity"
296
+ @blur="commitQuantity"
310
297
  >
311
298
  <UButton
312
299
  :icon="icon('plus')"
@@ -315,7 +302,7 @@ const hintColor = (type: string) =>
315
302
  size="xs"
316
303
  tabindex="0"
317
304
  :aria-label="t('cart.item.ariaIncreaseQuantity', { name: item.name })"
318
- @click="applyQuantity(item.quantity + 1)"
305
+ @click="increase"
319
306
  />
320
307
  </div>
321
308
  <span
@@ -1,4 +1,6 @@
1
1
  <script setup lang="ts">
2
+ import { cartEcommerce } from "../../../shared/themeEvents";
3
+
2
4
  /**
3
5
  * Send the cart in as a quotation request (RX-783).
4
6
  *
@@ -23,6 +25,7 @@ const validityDays = computed(() => quoteTermsForRequest.value?.defaultValidityD
23
25
  const localePath = useLocalePath();
24
26
  const toast = useToast();
25
27
  const cart = useCartStore();
28
+ const themeEvents = useThemeEvents();
26
29
  const { request, submitting } = useQuoteRequest();
27
30
  const { data: profile, status: profileStatus } = useCheckoutProfileSource();
28
31
 
@@ -45,8 +48,10 @@ const canSubmit = computed(() => Boolean(shippingAddressId.value && billingAddre
45
48
 
46
49
  async function submit(): Promise<void> {
47
50
  try {
51
+ // What goes into the quote, read before the cart is handed over below.
52
+ const quoted = cart.items.filter(i => !i.requisitionId);
48
53
  const result = await request({
49
- items: cart.items.filter(i => !i.requisitionId).map(i => ({
54
+ items: quoted.map(i => ({
50
55
  id: String(i.id),
51
56
  sku: i.sku,
52
57
  name: i.name,
@@ -59,6 +64,9 @@ async function submit(): Promise<void> {
59
64
  ...(note.value.trim() ? { note: note.value.trim() } : {}),
60
65
  ...(props.reason ? { reason: props.reason } : {}),
61
66
  });
67
+ if (quoted.length) {
68
+ themeEvents.emit("request_quote", { ecommerce: cartEcommerce(quoted) });
69
+ }
62
70
  // The server handed the cart over to the quote; the local copy follows.
63
71
  cart.clearCart();
64
72
  open.value = false;