@revenexx/cover 0.15.0 → 0.17.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 (85) hide show
  1. package/app/api/account.ts +1 -0
  2. package/app/components/RevenexxForm.vue +183 -19
  3. package/app/components/account/address/AccountAddressCard.vue +8 -2
  4. package/app/components/account/address/AccountAddressView.vue +5 -1
  5. package/app/components/account/carts/AccountCartsTable.vue +85 -3
  6. package/app/components/account/dashboard/AccountDashboardBudgets.vue +2 -1
  7. package/app/components/account/dashboard/AccountDashboardRecentOrders.vue +2 -1
  8. package/app/components/account/dashboard/AccountDashboardRequisitions.vue +2 -1
  9. package/app/components/account/directorder/AccountDirectOrder.vue +100 -12
  10. package/app/components/account/governance/AccountApprovalLimitsTable.vue +124 -8
  11. package/app/components/account/governance/AccountCostCenterDetail.vue +3 -2
  12. package/app/components/account/governance/AccountCostCentersTable.vue +133 -6
  13. package/app/components/account/governance/AccountRequisitionDetail.vue +2 -1
  14. package/app/components/account/governance/AccountRequisitionsTable.vue +102 -6
  15. package/app/components/account/governance/AccountWorkflowDetail.vue +3 -2
  16. package/app/components/account/governance/AccountWorkflowsTable.vue +76 -1
  17. package/app/components/account/governance/GovernanceApprovalLimitModal.vue +8 -0
  18. package/app/components/account/governance/GovernanceCostCenterModal.vue +7 -0
  19. package/app/components/account/governance/GovernanceWorkflowModal.vue +7 -0
  20. package/app/components/account/orderlists/AccountOrderListDetail.vue +14 -4
  21. package/app/components/account/orderlists/AccountOrderListsTable.vue +115 -7
  22. package/app/components/account/orders/AccountOrderDetail.vue +67 -3
  23. package/app/components/account/orders/AccountOrderPay.vue +211 -0
  24. package/app/components/account/orders/AccountOrdersTable.vue +119 -10
  25. package/app/components/account/organization/AccountOrganization.vue +6 -0
  26. package/app/components/account/profile/AccountPasswordForm.vue +2 -0
  27. package/app/components/account/profile/AccountProfileForm.vue +4 -0
  28. package/app/components/account/quotes/AccountQuoteDetail.vue +7 -10
  29. package/app/components/account/team/AccountTeam.vue +91 -0
  30. package/app/components/auth/AuthLoginTeaser.vue +1 -1
  31. package/app/components/auth/AuthRegisterPanel.vue +22 -3
  32. package/app/components/cart/manage/CartNameModal.vue +4 -0
  33. package/app/components/checkout/onepage/CheckoutAddressSection.vue +5 -1
  34. package/app/components/checkout/onepage/CheckoutGuestDetailsSection.vue +9 -1
  35. package/app/components/checkout/onepage/CheckoutSummarySection.vue +6 -1
  36. package/app/components/form/FormPage.vue +7 -4
  37. package/app/components/layout/footer/Footer.vue +15 -2
  38. package/app/components/ui/forms/PasswordInput.vue +2 -0
  39. package/app/components/ui/table/TableCardList.vue +69 -0
  40. package/app/components/ui/table/TableSortButton.vue +1 -1
  41. package/app/components/ui/table/TableToolbar.vue +2 -0
  42. package/app/components/withdrawal/WithdrawalDeclaration.vue +286 -0
  43. package/app/composables/useCheckoutOnePage.ts +22 -0
  44. package/app/composables/useMobileTableSort.ts +82 -0
  45. package/app/config/forms.ts +8 -0
  46. package/app/config/navigation.ts +8 -0
  47. package/app/formkit.config.ts +21 -0
  48. package/app/interfaces/account/order-list.ts +11 -0
  49. package/app/interfaces/account/quotes.ts +7 -3
  50. package/app/pages/punchout/transfer.vue +36 -1
  51. package/app/pages/widerruf.vue +33 -0
  52. package/app/shared/addressLines.ts +66 -0
  53. package/app/shared/checkoutAddressRefusal.ts +63 -0
  54. package/i18n/locales/de/account.json +13 -1
  55. package/i18n/locales/de/cart.json +1 -0
  56. package/i18n/locales/de/checkout.json +1 -1
  57. package/i18n/locales/de/common.json +7 -0
  58. package/i18n/locales/de/withdrawal.json +34 -0
  59. package/i18n/locales/en/account.json +13 -1
  60. package/i18n/locales/en/cart.json +1 -0
  61. package/i18n/locales/en/checkout.json +1 -1
  62. package/i18n/locales/en/common.json +7 -0
  63. package/i18n/locales/en/withdrawal.json +34 -0
  64. package/nuxt.config.ts +3 -0
  65. package/package.json +1 -1
  66. package/server/api/account/orders/[id]/pay.post.ts +100 -0
  67. package/server/api/account/orders/[id].get.ts +5 -1
  68. package/server/api/account/quotes/[id]/order.post.ts +22 -22
  69. package/server/api/forms/[slug].get.ts +1 -3
  70. package/server/api/orders/index.post.ts +33 -50
  71. package/server/api/punchout/return.post.ts +3 -1
  72. package/server/data/forms/authored.json +69 -8
  73. package/server/dev/errorHandler.ts +47 -0
  74. package/server/interfaces/punchout.ts +5 -0
  75. package/server/middleware/missing-media.ts +35 -0
  76. package/server/middleware/punchout-hand-back-csp.ts +17 -0
  77. package/server/plugins/vue-devtools-sink.ts +28 -0
  78. package/server/services/ApiCartService.ts +75 -6
  79. package/server/services/MockFormsService.ts +3 -1
  80. package/server/utils/addressRefusal.ts +63 -0
  81. package/server/utils/country.ts +23 -0
  82. package/server/utils/forms.ts +23 -1
  83. package/server/utils/liveOrders.ts +44 -2
  84. package/server/utils/orderPayment.ts +155 -0
  85. package/server/utils/punchoutFormAction.ts +44 -0
@@ -34,6 +34,7 @@ function save(): void {
34
34
  <UModal
35
35
  v-model:open="open"
36
36
  :title="mode === 'create' ? t('cart.multi.newCartTitle') : t('cart.multi.renameTitle')"
37
+ :close="{ class: 'max-lg:size-11 max-lg:justify-center' }"
37
38
  >
38
39
  <template #body>
39
40
  <UFormField
@@ -43,6 +44,7 @@ function save(): void {
43
44
  <UInput
44
45
  v-model="name"
45
46
  class="w-full"
47
+ :ui="{ base: 'max-lg:min-h-11' }"
46
48
  :placeholder="t('cart.multi.namePlaceholder')"
47
49
  @keydown.enter="save"
48
50
  />
@@ -53,12 +55,14 @@ function save(): void {
53
55
  color="neutral"
54
56
  variant="ghost"
55
57
  tabindex="0"
58
+ class="max-lg:min-h-11"
56
59
  :label="t('cart.item.cancel')"
57
60
  @click="open = false"
58
61
  />
59
62
  <UButton
60
63
  color="primary"
61
64
  tabindex="0"
65
+ class="max-lg:min-h-11"
62
66
  :disabled="!name.trim()"
63
67
  :label="mode === 'create' ? t('cart.multi.create') : t('cart.multi.rename')"
64
68
  @click="save"
@@ -3,7 +3,7 @@ import CheckoutSectionTitle from "./CheckoutSectionTitle.vue";
3
3
  import CheckoutAddressPickerModal from "../../../components/checkout/onepage/CheckoutAddressPickerModal.vue";
4
4
 
5
5
  const { t } = useI18n();
6
- const { form, profile, profileLoading, fieldErrors } = useCheckoutOnePage();
6
+ const { form, profile, profileLoading, fieldErrors, clearFieldError } = useCheckoutOnePage();
7
7
 
8
8
  const showShippingPicker = ref(false);
9
9
  const showBillingPicker = ref(false);
@@ -16,6 +16,10 @@ const selectedBilling = computed(() =>
16
16
  profile.value?.addresses.find(a => a.id === form.value.billingAddressId),
17
17
  );
18
18
 
19
+ // A refused address (RAD-236) stops being the subject once another is picked.
20
+ watch(() => form.value.shippingAddressId, () => clearFieldError("shippingAddressId"));
21
+ watch(() => form.value.billingAddressId, () => clearFieldError("billingAddressId"));
22
+
19
23
  function changeBilling() {
20
24
  if (form.value.billingSameAsShipping) {
21
25
  form.value.billingSameAsShipping = false;
@@ -9,7 +9,7 @@ import type { CheckoutGuestAddress } from "../../../composables/useCheckoutOnePa
9
9
  */
10
10
  const { t } = useI18n();
11
11
  const {
12
- form, customerType, guestContact, guestShipping, guestBilling, fieldErrors, validateField,
12
+ form, customerType, guestContact, guestShipping, guestBilling, fieldErrors, validateField, clearFieldError,
13
13
  } = useCheckoutOnePage();
14
14
 
15
15
  const isBusiness = computed(() => customerType.value === "guest-business");
@@ -92,21 +92,25 @@ const addressFields: AddressFieldRow[] = [
92
92
  :label="t(field.labelKey)"
93
93
  required
94
94
  :class="field.half ? '' : 'sm:col-span-2'"
95
+ :error="fieldErrors[`guestShipping.${field.key}`]"
95
96
  >
96
97
  <UInput
97
98
  v-model="guestShipping[field.key]"
98
99
  class="w-full"
100
+ @update:model-value="clearFieldError(`guestShipping.${field.key}`)"
99
101
  />
100
102
  </UFormField>
101
103
  </template>
102
104
  <UFormField
103
105
  :label="t('onepage.guest.country')"
104
106
  required
107
+ :error="fieldErrors['guestShipping.country']"
105
108
  >
106
109
  <USelect
107
110
  v-model="guestShipping.country"
108
111
  :items="countryItems"
109
112
  class="w-full"
113
+ @update:model-value="clearFieldError('guestShipping.country')"
110
114
  />
111
115
  </UFormField>
112
116
  </div>
@@ -131,21 +135,25 @@ const addressFields: AddressFieldRow[] = [
131
135
  :label="t(field.labelKey)"
132
136
  required
133
137
  :class="field.half ? '' : 'sm:col-span-2'"
138
+ :error="fieldErrors[`guestBilling.${field.key}`]"
134
139
  >
135
140
  <UInput
136
141
  v-model="guestBilling[field.key]"
137
142
  class="w-full"
143
+ @update:model-value="clearFieldError(`guestBilling.${field.key}`)"
138
144
  />
139
145
  </UFormField>
140
146
  </template>
141
147
  <UFormField
142
148
  :label="t('onepage.guest.country')"
143
149
  required
150
+ :error="fieldErrors['guestBilling.country']"
144
151
  >
145
152
  <USelect
146
153
  v-model="guestBilling.country"
147
154
  :items="countryItems"
148
155
  class="w-full"
156
+ @update:model-value="clearFieldError('guestBilling.country')"
149
157
  />
150
158
  </UFormField>
151
159
  </div>
@@ -2,6 +2,7 @@
2
2
  import CartApprovalsPanel from "../../cart/view/CartApprovalsPanel.vue";
3
3
 
4
4
  const { icon } = useIcons();
5
+ const { getImage } = useProductImage();
5
6
 
6
7
  const { t } = useI18n();
7
8
  const checkout = useCheckoutOnePage();
@@ -83,7 +84,7 @@ async function handlePlaceOrder() {
83
84
  >
84
85
  <img
85
86
  v-if="item.image"
86
- :src="item.image"
87
+ :src="getImage(item.image)"
87
88
  :alt="item.name"
88
89
  class="w-12 h-12 object-cover rounded-md shrink-0 border border-(--ui-border)"
89
90
  >
@@ -172,6 +173,10 @@ async function handlePlaceOrder() {
172
173
  validateField('acceptedTerms')"
173
174
  >
174
175
  <template #label>
176
+ <span
177
+ class="mr-0.5 text-error"
178
+ aria-hidden="true"
179
+ >*</span>
175
180
  <i18n-t keypath="onepage.summary.termsText">
176
181
  <template #link>
177
182
  <a
@@ -32,9 +32,12 @@ useHead({ title: props.title });
32
32
  {{ intro }}
33
33
  </p>
34
34
 
35
- <RevenexxForm
36
- :slug="slug"
37
- :context="context"
38
- />
35
+ <div class="bg-elevated py-6 px-6 sm:px-8 rounded-lg">
36
+ <RevenexxForm
37
+ :slug="slug"
38
+ :context="context"
39
+ cards
40
+ />
41
+ </div>
39
42
  </UContainer>
40
43
  </template>
@@ -1,6 +1,6 @@
1
1
  <script setup lang="ts">
2
2
  import type { ShopContact } from "../../../config/navigation";
3
- import { footerLinks as defaultFooterLinks, legalLinks as defaultLegalLinks, shopContact as noContact } from "../../../config/navigation";
3
+ import { footerLinks as defaultFooterLinks, legalLinks as defaultLegalLinks, shopContact as noContact, withdrawalPath } from "../../../config/navigation";
4
4
 
5
5
  // Consumers replace the footer columns / legal links, in priority order:
6
6
  // per-request live menus (useState, e.g. the Blokkli theme from the pages app)
@@ -15,7 +15,10 @@ const appConfig = useAppConfig();
15
15
  const liveFooterLinks = useState<{ heading: string; links: { label: string; to: string }[] }[] | null>("cover:nav:footerLinks", () => null);
16
16
  const liveLegalLinks = useState<{ label: string; to: string }[] | null>("cover:nav:legalLinks", () => null);
17
17
  const footerLinks = computed(() => liveFooterLinks.value ?? (appConfig.footerLinks as typeof defaultFooterLinks | undefined) ?? defaultFooterLinks);
18
- const legalLinks = computed(() => liveLegalLinks.value ?? (appConfig.legalLinks as typeof defaultLegalLinks | undefined) ?? defaultLegalLinks);
18
+ // The withdrawal entry is rendered on its own below, so a tenant menu that
19
+ // already lists it does not print it twice.
20
+ const legalLinks = computed(() => (liveLegalLinks.value ?? (appConfig.legalLinks as typeof defaultLegalLinks | undefined) ?? defaultLegalLinks)
21
+ .filter(link => link.to !== withdrawalPath));
19
22
  // The shop's own contact details. The design system holds none, so a storefront
20
23
  // that states nothing prints nothing rather than somebody else's address.
21
24
  const shopContact = computed<ShopContact>(() => (appConfig.shopContact as ShopContact | undefined) ?? noContact);
@@ -143,6 +146,16 @@ const year = new Date().getFullYear();
143
146
  >
144
147
  {{ t(link.label) }}
145
148
  </NuxtLink>
149
+ <!-- The withdrawal function (§ 356a BGB) has to be reachable from
150
+ every page, signed in or not, so no tenant menu can drop it. -->
151
+ <NuxtLink
152
+ :to="localePath(withdrawalPath)"
153
+ tabindex="0"
154
+ class="text-xs text-dimmed dark:text-white/70
155
+ hover:text-default dark:hover:text-white transition-colors"
156
+ >
157
+ {{ t('withdrawal.cta') }}
158
+ </NuxtLink>
146
159
  <!-- Reopens the cookie choice (Consent Manager). Renders nothing in
147
160
  the editor, where no banner is shown either. -->
148
161
  <ConsentPreferencesLink
@@ -74,6 +74,7 @@ const strengthText = computed(() => {
74
74
  :color="showStrength ? color : undefined"
75
75
  :placeholder="placeholder"
76
76
  class="w-full"
77
+ :ui="{ base: 'max-lg:min-h-11 max-lg:pe-12', trailing: 'max-lg:pe-0' }"
77
78
  >
78
79
  <template #trailing>
79
80
  <UTooltip :text="showPassword ? t('auth.password.hide') : t('auth.password.show')">
@@ -81,6 +82,7 @@ const strengthText = computed(() => {
81
82
  color="neutral"
82
83
  variant="link"
83
84
  size="sm"
85
+ class="max-lg:size-11 max-lg:justify-center"
84
86
  :icon="showPassword ? icon('eye-off') : icon('eye')"
85
87
  :aria-label="showPassword ? t('auth.password.hide') : t('auth.password.show')"
86
88
  :aria-pressed="showPassword"
@@ -0,0 +1,69 @@
1
+ <script setup lang="ts" generic="T">
2
+ /**
3
+ * Mobile face of a data table (datatable-ux): below md the table gives way
4
+ * to this stacked card list. A sort select stands in for the clickable
5
+ * column headers (feed it from useMobileTableSort), skeleton cards cover
6
+ * loading, and the `empty` slot takes the table's empty state. Each record
7
+ * renders through the `item` slot.
8
+ */
9
+ import type { MobileSortItem } from "../../../composables/useMobileTableSort";
10
+
11
+ defineProps<{
12
+ rows: T[];
13
+ rowKey: (row: T) => string;
14
+ sortItems?: MobileSortItem[];
15
+ loading?: boolean;
16
+ }>();
17
+
18
+ defineSlots<{
19
+ item: (props: { row: T }) => unknown;
20
+ empty: () => unknown;
21
+ }>();
22
+
23
+ const sort = defineModel<string>("sort", { default: "" });
24
+
25
+ const { t } = useI18n();
26
+ const { icon } = useIcons();
27
+ </script>
28
+
29
+ <template>
30
+ <div class="md:hidden">
31
+ <div
32
+ v-if="loading"
33
+ class="space-y-3"
34
+ >
35
+ <USkeleton
36
+ v-for="index in 3"
37
+ :key="index"
38
+ class="h-24 w-full"
39
+ />
40
+ </div>
41
+ <template v-else-if="rows.length">
42
+ <USelect
43
+ v-if="sortItems?.length"
44
+ v-model="sort"
45
+ :items="sortItems"
46
+ :aria-label="t('table.sortBy')"
47
+ :icon="icon('sort')"
48
+ class="w-full mb-3"
49
+ :ui="{ base: 'min-h-11' }"
50
+ />
51
+ <ul class="border border-(--ui-border) rounded-xl divide-y divide-(--ui-border)">
52
+ <li
53
+ v-for="row in rows"
54
+ :key="rowKey(row)"
55
+ class="p-4"
56
+ >
57
+ <slot
58
+ name="item"
59
+ :row="row"
60
+ />
61
+ </li>
62
+ </ul>
63
+ </template>
64
+ <slot
65
+ v-else
66
+ name="empty"
67
+ />
68
+ </div>
69
+ </template>
@@ -37,7 +37,7 @@ const sortIcon = computed(() => {
37
37
  type="button"
38
38
  tabindex="0"
39
39
  class="group inline-flex items-center gap-1.5 text-xs font-semibold uppercase tracking-wide
40
- text-muted hover:text-highlighted transition-colors cursor-pointer"
40
+ text-muted hover:text-highlighted transition-colors cursor-pointer max-lg:-my-3.5 max-lg:min-h-11"
41
41
  :aria-label="label"
42
42
  @click="column.toggleSorting(sorted === 'asc')"
43
43
  >
@@ -30,6 +30,7 @@ const { icon } = useIcons();
30
30
  :icon="icon('search')"
31
31
  :placeholder="searchPlaceholder"
32
32
  class="w-full sm:w-auto sm:flex-1 sm:max-w-md"
33
+ :ui="{ base: 'max-lg:min-h-11' }"
33
34
  />
34
35
  <div
35
36
  v-if="$slots.actions"
@@ -50,6 +51,7 @@ const { icon } = useIcons();
50
51
  :variant="filter === item.value ? 'soft' : 'ghost'"
51
52
  size="sm"
52
53
  tabindex="0"
54
+ class="max-lg:min-h-11"
53
55
  @click="filter = item.value"
54
56
  >
55
57
  {{ item.label }}
@@ -0,0 +1,286 @@
1
+ <script setup lang="ts">
2
+ import type { FormError, FormErrorEvent } from "@nuxt/ui";
3
+
4
+ import { formsApi } from "../../api/forms";
5
+
6
+ /**
7
+ * The withdrawal function (§ 356a BGB).
8
+ *
9
+ * A consumer who reached this page through a "Vertrag widerrufen" link fills in
10
+ * the declaration and sends it with "Widerruf bestätigen" — the two labels the
11
+ * law prescribes, so neither is configurable. It works without an account:
12
+ * a guest has the same right as a signed-in buyer.
13
+ *
14
+ * Sent as a submission of the authored form `widerruf`, through the same BFF
15
+ * route every other form uses. The platform records it and sends the customer
16
+ * the confirmation by email; what this page owes is the confirmation on screen,
17
+ * with the moment it was received.
18
+ *
19
+ * The data keys are fixed (`order_id`, `name`, `email`, `statement`): the
20
+ * platform reads them by name, and the form has to declare exactly these, or
21
+ * the BFF drops what it never asked for.
22
+ */
23
+ const props = defineProps<{
24
+ /** Pre-filled order number, e.g. from the order detail page. */
25
+ orderId?: string;
26
+ }>();
27
+
28
+ interface WithdrawalState {
29
+ order_id: string;
30
+ name: string;
31
+ email: string;
32
+ statement: string;
33
+ }
34
+
35
+ const FORM_SLUG = "widerruf";
36
+ const EMAIL_PATTERN = /^[^@\s]+@[^@\s]+\.[^@\s]+$/;
37
+
38
+ const { t, d } = useI18n();
39
+ const { icon } = useIcons();
40
+ const auth = useAuthStore();
41
+
42
+ const state = reactive<WithdrawalState>({
43
+ order_id: props.orderId ?? "",
44
+ name: "",
45
+ email: "",
46
+ statement: "",
47
+ });
48
+
49
+ /** The pre-filled sentence follows the order number until the customer writes their own. */
50
+ const statementEdited = ref(false);
51
+
52
+ function defaultStatement(orderId: string): string {
53
+ const order = orderId.trim();
54
+ return order ? t("withdrawal.defaultStatement", { order }) : t("withdrawal.defaultStatementNoOrder");
55
+ }
56
+
57
+ watch(() => state.order_id, (orderId) => {
58
+ if (!statementEdited.value) {
59
+ state.statement = defaultStatement(orderId);
60
+ }
61
+ }, { immediate: true });
62
+
63
+ function onStatementInput(): void {
64
+ statementEdited.value = true;
65
+ }
66
+
67
+ // A signed-in buyer should not have to type who they are.
68
+ watch(() => auth.user, (user) => {
69
+ if (!user) {
70
+ return;
71
+ }
72
+ state.name ||= user.name ?? "";
73
+ state.email ||= user.email ?? "";
74
+ }, { immediate: true });
75
+
76
+ function validate(values: Partial<WithdrawalState>): FormError[] {
77
+ const errors: FormError[] = [];
78
+ if (!values.name?.trim()) {
79
+ errors.push({ name: "name", message: t("withdrawal.errors.nameRequired") });
80
+ }
81
+ if (!values.email?.trim()) {
82
+ errors.push({ name: "email", message: t("withdrawal.errors.emailRequired") });
83
+ }
84
+ else if (!EMAIL_PATTERN.test(values.email.trim())) {
85
+ errors.push({ name: "email", message: t("withdrawal.errors.emailInvalid") });
86
+ }
87
+ if (!values.order_id?.trim()) {
88
+ errors.push({ name: "order_id", message: t("withdrawal.errors.orderIdRequired") });
89
+ }
90
+ if (!values.statement?.trim()) {
91
+ errors.push({ name: "statement", message: t("withdrawal.errors.statementRequired") });
92
+ }
93
+ return errors;
94
+ }
95
+
96
+ /** Puts the keyboard on the first field that needs attention. */
97
+ function onError(event: FormErrorEvent): void {
98
+ const id = event.errors[0]?.id;
99
+ if (id && import.meta.client) {
100
+ document.getElementById(id)?.focus();
101
+ }
102
+ }
103
+
104
+ const submitting = ref(false);
105
+ const submitError = ref<string | null>(null);
106
+ const received = ref<{ at: Date; data: WithdrawalState } | null>(null);
107
+ const confirmationHeading = ref<HTMLElement | null>(null);
108
+
109
+ async function onSubmit(): Promise<void> {
110
+ submitError.value = null;
111
+ submitting.value = true;
112
+ const data: WithdrawalState = {
113
+ order_id: state.order_id.trim(),
114
+ name: state.name.trim(),
115
+ email: state.email.trim(),
116
+ statement: state.statement.trim(),
117
+ };
118
+ try {
119
+ const res = await $fetch<{ ok: boolean }>(formsApi.submit(FORM_SLUG), {
120
+ method: "POST",
121
+ body: {
122
+ data,
123
+ source: import.meta.client ? window.location.pathname : undefined,
124
+ },
125
+ });
126
+ if (!res.ok) {
127
+ submitError.value = t("withdrawal.errors.rejected");
128
+ return;
129
+ }
130
+ received.value = { at: new Date(), data };
131
+ await nextTick();
132
+ confirmationHeading.value?.focus();
133
+ }
134
+ catch {
135
+ submitError.value = t("withdrawal.errors.failed");
136
+ }
137
+ finally {
138
+ submitting.value = false;
139
+ }
140
+ }
141
+
142
+ const receivedAt = computed(() =>
143
+ received.value ? d(received.value.at, { dateStyle: "long", timeStyle: "short" }) : "");
144
+
145
+ const summary = computed(() => received.value
146
+ ? [
147
+ { key: "order_id", label: t("withdrawal.fields.orderId"), value: received.value.data.order_id },
148
+ { key: "name", label: t("withdrawal.fields.name"), value: received.value.data.name },
149
+ { key: "email", label: t("withdrawal.fields.email"), value: received.value.data.email },
150
+ { key: "statement", label: t("withdrawal.fields.statement"), value: received.value.data.statement },
151
+ ]
152
+ : []);
153
+ </script>
154
+
155
+ <template>
156
+ <!-- Confirmation: what was received, and when. -->
157
+ <section
158
+ v-if="received"
159
+ class="space-y-6"
160
+ aria-live="polite"
161
+ >
162
+ <div class="flex items-start gap-3">
163
+ <UIcon
164
+ :name="icon('success')"
165
+ class="size-7 shrink-0 text-success"
166
+ />
167
+ <div>
168
+ <h2
169
+ ref="confirmationHeading"
170
+ tabindex="-1"
171
+ class="text-xl font-semibold text-highlighted focus:outline-none"
172
+ >
173
+ {{ t('withdrawal.done.title') }}
174
+ </h2>
175
+ <p class="text-sm text-muted mt-1">
176
+ <time :datetime="received.at.toISOString()">{{ t('withdrawal.done.receivedAt', { date: receivedAt }) }}</time>
177
+ </p>
178
+ </div>
179
+ </div>
180
+
181
+ <p class="text-default">
182
+ {{ t('withdrawal.done.intro') }}
183
+ </p>
184
+
185
+ <dl class="border border-(--ui-border) rounded-xl divide-y divide-(--ui-border)">
186
+ <div
187
+ v-for="row in summary"
188
+ :key="row.key"
189
+ class="px-4 py-3 sm:grid sm:grid-cols-3 sm:gap-4"
190
+ >
191
+ <dt class="text-sm font-medium text-highlighted">
192
+ {{ row.label }}
193
+ </dt>
194
+ <dd class="mt-1 sm:mt-0 sm:col-span-2 text-sm text-default whitespace-pre-line break-words">
195
+ {{ row.value }}
196
+ </dd>
197
+ </div>
198
+ </dl>
199
+ </section>
200
+
201
+ <!-- Declaration -->
202
+ <UForm
203
+ v-else
204
+ :state="state"
205
+ :validate="validate"
206
+ :validate-on="['blur']"
207
+ class="space-y-5"
208
+ novalidate
209
+ @submit="onSubmit"
210
+ @error="onError"
211
+ >
212
+ <p class="text-sm text-muted">
213
+ {{ t('withdrawal.requiredHint') }}
214
+ </p>
215
+
216
+ <UFormField
217
+ name="name"
218
+ :label="t('withdrawal.fields.name')"
219
+ required
220
+ >
221
+ <UInput
222
+ v-model="state.name"
223
+ autocomplete="name"
224
+ class="w-full"
225
+ />
226
+ </UFormField>
227
+
228
+ <UFormField
229
+ name="email"
230
+ :label="t('withdrawal.fields.email')"
231
+ :help="t('withdrawal.fields.emailHelp')"
232
+ required
233
+ >
234
+ <UInput
235
+ v-model="state.email"
236
+ type="email"
237
+ autocomplete="email"
238
+ class="w-full"
239
+ />
240
+ </UFormField>
241
+
242
+ <UFormField
243
+ name="order_id"
244
+ :label="t('withdrawal.fields.orderId')"
245
+ :help="t('withdrawal.fields.orderIdHelp')"
246
+ required
247
+ >
248
+ <UInput
249
+ v-model="state.order_id"
250
+ class="w-full"
251
+ />
252
+ </UFormField>
253
+
254
+ <UFormField
255
+ name="statement"
256
+ :label="t('withdrawal.fields.statement')"
257
+ :help="t('withdrawal.fields.statementHelp')"
258
+ required
259
+ >
260
+ <UTextarea
261
+ v-model="state.statement"
262
+ :rows="5"
263
+ class="w-full"
264
+ @input="onStatementInput"
265
+ />
266
+ </UFormField>
267
+
268
+ <UAlert
269
+ v-if="submitError"
270
+ role="alert"
271
+ color="error"
272
+ variant="soft"
273
+ :icon="icon('error')"
274
+ :title="submitError"
275
+ />
276
+
277
+ <UButton
278
+ type="submit"
279
+ size="lg"
280
+ class="min-h-11"
281
+ :loading="submitting"
282
+ :disabled="submitting"
283
+ :label="t('withdrawal.confirm')"
284
+ />
285
+ </UForm>
286
+ </template>
@@ -1,6 +1,7 @@
1
1
  import { checkoutApi } from "../api/checkout";
2
2
  import type { CartCalculation } from "../interfaces/cart-calculation";
3
3
  import type { CheckoutOnePageForm, CheckoutProfile } from "../interfaces/checkout";
4
+ import { checkoutAddressFieldOf, checkoutAddressRefusalOf } from "../shared/checkoutAddressRefusal";
4
5
  import { browserSession, purchaseFromCart, stashPurchase } from "../shared/themeEvents";
5
6
 
6
7
  /**
@@ -377,6 +378,19 @@ export function useCheckoutOnePage() {
377
378
  };
378
379
  }
379
380
  catch (err) {
381
+ // An address the orders app refused for its country (RAD-236): the
382
+ // sentence goes on the field it names, and above the order button,
383
+ // where the buyer is looking when it comes back.
384
+ const refusal = checkoutAddressRefusalOf(err);
385
+ if (refusal) {
386
+ const field = checkoutAddressFieldOf(refusal, {
387
+ guest: isGuest.value,
388
+ billingSameAsShipping: form.value.billingSameAsShipping,
389
+ });
390
+ fieldErrors.value = { ...fieldErrors.value, [field]: refusal.message };
391
+ submitError.value = refusal.message;
392
+ return null;
393
+ }
380
394
  submitError.value = err instanceof Error
381
395
  ? err.message
382
396
  : t("onepage.errors.submitError");
@@ -387,6 +401,13 @@ export function useCheckoutOnePage() {
387
401
  }
388
402
  }
389
403
 
404
+ /** Drop one field's error once the buyer changes what it was about. */
405
+ function clearFieldError(name: string) {
406
+ if (fieldErrors.value[name]) {
407
+ fieldErrors.value = { ...fieldErrors.value, [name]: undefined };
408
+ }
409
+ }
410
+
390
411
  /**
391
412
  * Requester checkout outcome: a requisition entering its workflow
392
413
  * instead of an order.
@@ -479,6 +500,7 @@ export function useCheckoutOnePage() {
479
500
  fetchSessionToken,
480
501
  validateField,
481
502
  validateAll,
503
+ clearFieldError,
482
504
  buildOrderPayload,
483
505
  submitOrder,
484
506
  submitRequisition,