@revenexx/cover 0.14.0 → 0.16.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.
- package/app/api/account.ts +1 -0
- package/app/components/RevenexxForm.vue +183 -19
- package/app/components/account/address/AccountAddressCard.vue +8 -2
- package/app/components/account/address/AccountAddressView.vue +5 -1
- package/app/components/account/carts/AccountCartsTable.vue +85 -3
- package/app/components/account/dashboard/AccountDashboardBudgets.vue +2 -1
- package/app/components/account/dashboard/AccountDashboardRecentOrders.vue +2 -1
- package/app/components/account/dashboard/AccountDashboardRequisitions.vue +2 -1
- package/app/components/account/directorder/AccountDirectOrder.vue +100 -12
- package/app/components/account/governance/AccountApprovalLimitsTable.vue +124 -8
- package/app/components/account/governance/AccountCostCenterDetail.vue +3 -2
- package/app/components/account/governance/AccountCostCentersTable.vue +133 -6
- package/app/components/account/governance/AccountRequisitionDetail.vue +2 -1
- package/app/components/account/governance/AccountRequisitionsTable.vue +102 -6
- package/app/components/account/governance/AccountWorkflowDetail.vue +3 -2
- package/app/components/account/governance/AccountWorkflowsTable.vue +76 -1
- package/app/components/account/governance/GovernanceApprovalLimitModal.vue +8 -0
- package/app/components/account/governance/GovernanceCostCenterModal.vue +7 -0
- package/app/components/account/governance/GovernanceWorkflowModal.vue +7 -0
- package/app/components/account/orderlists/AccountOrderListDetail.vue +14 -4
- package/app/components/account/orderlists/AccountOrderListsTable.vue +115 -7
- package/app/components/account/orders/AccountOrderDetail.vue +67 -3
- package/app/components/account/orders/AccountOrderPay.vue +211 -0
- package/app/components/account/orders/AccountOrdersTable.vue +119 -10
- package/app/components/account/organization/AccountOrganization.vue +6 -0
- package/app/components/account/profile/AccountPasswordForm.vue +2 -0
- package/app/components/account/profile/AccountProfileForm.vue +4 -0
- package/app/components/account/quotes/AccountQuoteDetail.vue +7 -10
- package/app/components/account/team/AccountTeam.vue +91 -0
- package/app/components/auth/AuthLoginTeaser.vue +1 -1
- package/app/components/auth/AuthRegisterPanel.vue +22 -3
- package/app/components/cart/manage/CartNameModal.vue +4 -0
- package/app/components/checkout/onepage/CheckoutAddressSection.vue +5 -1
- package/app/components/checkout/onepage/CheckoutGuestDetailsSection.vue +9 -1
- package/app/components/checkout/onepage/CheckoutSummarySection.vue +6 -1
- package/app/components/form/FormPage.vue +7 -4
- package/app/components/layout/footer/Footer.vue +15 -2
- package/app/components/layout/header/LocaleSwitcher.vue +79 -12
- package/app/components/ui/forms/PasswordInput.vue +2 -0
- package/app/components/ui/forms/SearchInput.vue +205 -8
- package/app/components/ui/table/TableCardList.vue +69 -0
- package/app/components/ui/table/TableSortButton.vue +1 -1
- package/app/components/ui/table/TableToolbar.vue +2 -0
- package/app/components/withdrawal/WithdrawalDeclaration.vue +286 -0
- package/app/composables/useCheckoutOnePage.ts +22 -0
- package/app/composables/useMobileTableSort.ts +82 -0
- package/app/composables/useProductCard.ts +14 -0
- package/app/composables/useProductListing.ts +27 -1
- package/app/composables/useSearchEvents.ts +67 -0
- package/app/config/forms.ts +8 -0
- package/app/config/navigation.ts +8 -0
- package/app/formkit.config.ts +21 -0
- package/app/interfaces/account/order-list.ts +11 -0
- package/app/interfaces/account/quotes.ts +7 -3
- package/app/interfaces/market.ts +7 -0
- package/app/pages/punchout/transfer.vue +36 -1
- package/app/pages/widerruf.vue +33 -0
- package/app/plugins/search-events.client.ts +41 -0
- package/app/shared/addressLines.ts +66 -0
- package/app/shared/checkoutAddressRefusal.ts +63 -0
- package/app/shared/locale.ts +133 -0
- package/app/shared/searchAttribution.ts +91 -0
- package/app/shared/themeEvents.ts +1 -1
- package/i18n/locales/de/account.json +13 -1
- package/i18n/locales/de/cart.json +1 -0
- package/i18n/locales/de/checkout.json +1 -1
- package/i18n/locales/de/common.json +7 -0
- package/i18n/locales/de/search.json +7 -0
- package/i18n/locales/de/withdrawal.json +34 -0
- package/i18n/locales/en/account.json +13 -1
- package/i18n/locales/en/cart.json +1 -0
- package/i18n/locales/en/checkout.json +1 -1
- package/i18n/locales/en/common.json +7 -0
- package/i18n/locales/en/search.json +7 -0
- package/i18n/locales/en/withdrawal.json +34 -0
- package/nuxt.config.ts +3 -0
- package/package.json +1 -1
- package/server/api/account/orders/[id]/pay.post.ts +100 -0
- package/server/api/account/orders/[id].get.ts +5 -1
- package/server/api/account/quotes/[id]/order.post.ts +22 -22
- package/server/api/brands.get.ts +3 -2
- package/server/api/categories/[slug]/subcategories.get.ts +9 -6
- package/server/api/forms/[slug].get.ts +1 -3
- package/server/api/orders/index.post.ts +33 -50
- package/server/api/products/index.get.ts +6 -1
- package/server/api/punchout/return.post.ts +3 -1
- package/server/api/search/events.post.ts +65 -0
- package/server/api/typesense/search.post.ts +12 -1
- package/server/api/typesense/suggest.post.ts +43 -22
- package/server/data/forms/authored.json +69 -8
- package/server/dev/errorHandler.ts +47 -0
- package/server/interfaces/brand.ts +3 -2
- package/server/interfaces/product.ts +5 -0
- package/server/interfaces/punchout.ts +5 -0
- package/server/middleware/missing-media.ts +35 -0
- package/server/middleware/punchout-hand-back-csp.ts +17 -0
- package/server/plugins/vue-devtools-sink.ts +28 -0
- package/server/services/ApiBrandService.ts +8 -8
- package/server/services/ApiMarketService.ts +9 -2
- package/server/services/ApiProductService.ts +1 -1
- package/server/services/MockFormsService.ts +3 -1
- package/server/utils/addressRefusal.ts +63 -0
- package/server/utils/country.ts +23 -0
- package/server/utils/forms.ts +23 -1
- package/server/utils/liveOrders.ts +44 -2
- package/server/utils/locale.ts +58 -4
- package/server/utils/orderPayment.ts +155 -0
- package/server/utils/punchoutFormAction.ts +44 -0
- package/server/utils/searchClient.ts +27 -4
- package/server/utils/searchEvents.ts +46 -0
- package/server/utils/searchMultiSearchFallback.ts +2 -0
- package/server/utils/searchSuggest.ts +207 -0
- package/server/utils/suggestTiles.ts +141 -0
|
@@ -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,
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { MaybeRefOrGetter, Ref } from "vue";
|
|
2
|
+
|
|
3
|
+
export interface TableSortState {
|
|
4
|
+
id: string;
|
|
5
|
+
desc: boolean;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* One sortable column as the mobile card list offers it. `kind` picks the
|
|
10
|
+
* wording: text sorts A–Z / Z–A, numbers highest / lowest first, dates
|
|
11
|
+
* newest / oldest first.
|
|
12
|
+
*/
|
|
13
|
+
export interface MobileSortColumn<T> {
|
|
14
|
+
id: string;
|
|
15
|
+
label: string;
|
|
16
|
+
kind: "text" | "number" | "date";
|
|
17
|
+
value: (row: T) => string | number;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface MobileSortItem {
|
|
21
|
+
value: string;
|
|
22
|
+
label: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Below md the data tables turn into card lists (datatable-ux); the cards
|
|
27
|
+
* cannot carry clickable column headers, so a select stands in for them.
|
|
28
|
+
* This drives that select from the table's own TanStack `sorting` ref, so
|
|
29
|
+
* table and cards always agree, and returns the rows in that order.
|
|
30
|
+
*/
|
|
31
|
+
export function useMobileTableSort<T>(
|
|
32
|
+
rows: MaybeRefOrGetter<T[]>,
|
|
33
|
+
sorting: Ref<TableSortState[]>,
|
|
34
|
+
columns: MaybeRefOrGetter<MobileSortColumn<T>[]>,
|
|
35
|
+
) {
|
|
36
|
+
const { t } = useI18n();
|
|
37
|
+
|
|
38
|
+
const labelKeys = {
|
|
39
|
+
text: { asc: "table.sortAsc", desc: "table.sortDesc" },
|
|
40
|
+
number: { asc: "table.sortLow", desc: "table.sortHigh" },
|
|
41
|
+
date: { asc: "table.sortOldest", desc: "table.sortNewest" },
|
|
42
|
+
} as const;
|
|
43
|
+
|
|
44
|
+
const items = computed<MobileSortItem[]>(() =>
|
|
45
|
+
toValue(columns).flatMap(({ id, label, kind }) => {
|
|
46
|
+
const asc = { value: `${id}:asc`, label: t(labelKeys[kind].asc, { column: label }) };
|
|
47
|
+
const desc = { value: `${id}:desc`, label: t(labelKeys[kind].desc, { column: label }) };
|
|
48
|
+
// Numbers and dates read best biggest / newest first.
|
|
49
|
+
return kind === "text" ? [asc, desc] : [desc, asc];
|
|
50
|
+
}),
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
const model = computed({
|
|
54
|
+
get: () => {
|
|
55
|
+
const active = sorting.value[0];
|
|
56
|
+
return active ? `${active.id}:${active.desc ? "desc" : "asc"}` : "";
|
|
57
|
+
},
|
|
58
|
+
set: (value: string) => {
|
|
59
|
+
const [id = "", direction] = value.split(":");
|
|
60
|
+
sorting.value = [{ id, desc: direction === "desc" }];
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
const sorted = computed<T[]>(() => {
|
|
65
|
+
const list = [...toValue(rows)];
|
|
66
|
+
const active = sorting.value[0];
|
|
67
|
+
const column = active && toValue(columns).find(entry => entry.id === active.id);
|
|
68
|
+
if (!active || !column) {
|
|
69
|
+
return list;
|
|
70
|
+
}
|
|
71
|
+
list.sort((a, b) => {
|
|
72
|
+
const left = column.value(a);
|
|
73
|
+
const right = column.value(b);
|
|
74
|
+
return typeof left === "number" && typeof right === "number"
|
|
75
|
+
? left - right
|
|
76
|
+
: String(left).localeCompare(String(right));
|
|
77
|
+
});
|
|
78
|
+
return active.desc ? list.reverse() : list;
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
return { items, model, sorted };
|
|
82
|
+
}
|
|
@@ -17,6 +17,7 @@ export function useProductCard(
|
|
|
17
17
|
const { useOffer } = useOffers();
|
|
18
18
|
const { offer } = useOffer(() => getProduct().id);
|
|
19
19
|
const events = useThemeEvents();
|
|
20
|
+
const search = useSearchEvents();
|
|
20
21
|
|
|
21
22
|
/** Report that the buyer opened this product from the list it was shown in. */
|
|
22
23
|
function select(): void {
|
|
@@ -29,6 +30,19 @@ export function useProductCard(
|
|
|
29
30
|
events.emit("select_item", {
|
|
30
31
|
ecommerce: { items: [item], ...(list?.listId ? { list_id: list.listId } : {}) },
|
|
31
32
|
});
|
|
33
|
+
// A result of the search page: a click on that search (PE-867).
|
|
34
|
+
const shown = search.shown.value;
|
|
35
|
+
if (list?.listId === "search" && shown) {
|
|
36
|
+
const product = getProduct();
|
|
37
|
+
search.click({
|
|
38
|
+
queryId: shown.queryId,
|
|
39
|
+
q: shown.q,
|
|
40
|
+
collection: "products",
|
|
41
|
+
docId: String(product.id),
|
|
42
|
+
...(list.position ? { position: list.position } : {}),
|
|
43
|
+
sku: product.sku,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
32
46
|
}
|
|
33
47
|
|
|
34
48
|
return { url, getImage, select };
|
|
@@ -59,6 +59,12 @@ export interface ListingResponse {
|
|
|
59
59
|
priceFilter?: boolean;
|
|
60
60
|
/** Where curation sends this search instead of showing results. */
|
|
61
61
|
redirect?: string;
|
|
62
|
+
/** The search's id, for the click events its results send (PE-867). */
|
|
63
|
+
queryId?: string;
|
|
64
|
+
/** The locale whose index answered (live search only). */
|
|
65
|
+
locale?: string;
|
|
66
|
+
/** True when another language's index answered than the page asked for. */
|
|
67
|
+
localeFallback?: boolean;
|
|
62
68
|
}
|
|
63
69
|
|
|
64
70
|
/**
|
|
@@ -222,6 +228,19 @@ export function useProductListing(options: ProductListingOptions) {
|
|
|
222
228
|
}
|
|
223
229
|
}, { immediate: true });
|
|
224
230
|
|
|
231
|
+
/* ---- search events (PE-867) ------------------------------------ */
|
|
232
|
+
// The search page's results report their clicks against the search they
|
|
233
|
+
// came from: its id is kept where the product cards can read it.
|
|
234
|
+
if (import.meta.client && options.listEvent) {
|
|
235
|
+
const { shown } = useSearchEvents();
|
|
236
|
+
watch(data, (loaded) => {
|
|
237
|
+
const spec = options.listEvent?.();
|
|
238
|
+
if (spec?.event === "search" && loaded?.queryId) {
|
|
239
|
+
shown.value = { queryId: loaded.queryId, q: spec.term };
|
|
240
|
+
}
|
|
241
|
+
}, { immediate: true });
|
|
242
|
+
}
|
|
243
|
+
|
|
225
244
|
/* ---- theme events --------------------------------------------- */
|
|
226
245
|
// Reported once per shown page of results, after the offers for it have
|
|
227
246
|
// settled — a list view without prices tells a tag little. Client-only:
|
|
@@ -305,6 +324,13 @@ export function useProductListing(options: ProductListingOptions) {
|
|
|
305
324
|
/** A curated redirect for this query (search view only), or undefined. */
|
|
306
325
|
const redirect = computed(() => data.value?.redirect || undefined);
|
|
307
326
|
|
|
327
|
+
/**
|
|
328
|
+
* The locale the results came from when it is another language than the
|
|
329
|
+
* page's — the search service had no index for the page's language and
|
|
330
|
+
* answered from the tenant's default one (PE-865). Undefined otherwise.
|
|
331
|
+
*/
|
|
332
|
+
const servedLocale = computed(() => data.value?.localeFallback ? data.value.locale : undefined);
|
|
333
|
+
|
|
308
334
|
const activeFilterCount = computed(() =>
|
|
309
335
|
Object.values(activeFilters.value).reduce((sum, values) => sum + values.length, 0)
|
|
310
336
|
+ (priceFilter.value && (priceRange.value.min !== undefined || priceRange.value.max !== undefined) ? 1 : 0),
|
|
@@ -342,7 +368,7 @@ export function useProductListing(options: ProductListingOptions) {
|
|
|
342
368
|
})));
|
|
343
369
|
|
|
344
370
|
return {
|
|
345
|
-
query, sort, sortOptions, page, activeFilters, priceRange, priceFilter, redirect,
|
|
371
|
+
query, sort, sortOptions, page, activeFilters, priceRange, priceFilter, redirect, servedLocale,
|
|
346
372
|
data, pending, error, execute,
|
|
347
373
|
products, facets, found, totalPages, isEmpty,
|
|
348
374
|
chips, activeFilterCount, removeChip, clearFilters,
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { rememberSearchClick } from "../shared/searchAttribution";
|
|
2
|
+
import { browserSession } from "../shared/themeEvents";
|
|
3
|
+
|
|
4
|
+
export type SearchEventType = "click" | "add_to_cart" | "purchase";
|
|
5
|
+
|
|
6
|
+
export interface SearchEventPayload {
|
|
7
|
+
type: SearchEventType;
|
|
8
|
+
/** The search's `queryId`; required for a click. */
|
|
9
|
+
queryId?: string;
|
|
10
|
+
/** The collection of the document: products, categories, manufacturers, pages. */
|
|
11
|
+
collection: string;
|
|
12
|
+
docId?: string;
|
|
13
|
+
/** 1-based position in what was shown. */
|
|
14
|
+
position?: number;
|
|
15
|
+
q?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** The search the current results page shows, for its result clicks. */
|
|
19
|
+
export interface ShownSearch {
|
|
20
|
+
queryId: string;
|
|
21
|
+
q: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Tells the search service what a shopper did with a search (PE-867): a click
|
|
26
|
+
* on a result or a quick search tile, and — through the plugin that watches
|
|
27
|
+
* the theme events — the add-to-cart and purchase that follow it.
|
|
28
|
+
*
|
|
29
|
+
* Fire and forget: an event never delays the navigation it comes with, is
|
|
30
|
+
* sent with `keepalive` so a page change does not cancel it, and a failure is
|
|
31
|
+
* swallowed. Nothing is sent on the server.
|
|
32
|
+
*/
|
|
33
|
+
export function useSearchEvents() {
|
|
34
|
+
// Not useI18n(): the search-events plugin calls this outside a component
|
|
35
|
+
// setup, where useI18n() throws.
|
|
36
|
+
const i18n = useNuxtApp().$i18n as unknown as { locale: { value: string } } | undefined;
|
|
37
|
+
const shown = useState<ShownSearch | null>("search:shown", () => null);
|
|
38
|
+
|
|
39
|
+
function send(payload: SearchEventPayload): void {
|
|
40
|
+
if (import.meta.server) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
void $fetch("/api/search/events", {
|
|
44
|
+
method: "POST",
|
|
45
|
+
body: payload,
|
|
46
|
+
headers: i18n?.locale.value ? { "x-locale": i18n.locale.value } : {},
|
|
47
|
+
keepalive: true,
|
|
48
|
+
}).catch(() => {});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* A click on a search hit or tile. A product click is also remembered by
|
|
53
|
+
* its article number, so the cart can be attributed to the search.
|
|
54
|
+
*/
|
|
55
|
+
function click(payload: Omit<SearchEventPayload, "type"> & { sku?: string }): void {
|
|
56
|
+
if (!payload.queryId) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const { sku, ...event } = payload;
|
|
60
|
+
send({ type: "click", ...event });
|
|
61
|
+
if (sku && payload.docId && payload.collection === "products") {
|
|
62
|
+
rememberSearchClick(browserSession(), sku, { queryId: payload.queryId, docId: payload.docId, q: payload.q ?? "" });
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return { send, click, shown };
|
|
67
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The red asterisk after the label of a field the visitor cannot leave out —
|
|
3
|
+
* before it on a checkbox, whose label is a whole sentence. Pseudo-content via
|
|
4
|
+
* a FormKit `label-class` (or `legend-class` on a radio group), so the label
|
|
5
|
+
* text stays as written.
|
|
6
|
+
*/
|
|
7
|
+
export const REQUIRED_MARK = "after:content-['*'] after:ml-0.5 after:text-error";
|
|
8
|
+
export const REQUIRED_MARK_LEADING = "before:content-['*'] before:mr-0.5 before:text-error";
|
package/app/config/navigation.ts
CHANGED
|
@@ -41,6 +41,14 @@ export const footerLinks = {
|
|
|
41
41
|
},
|
|
42
42
|
};
|
|
43
43
|
|
|
44
|
+
/**
|
|
45
|
+
* Where a consumer withdraws from a contract (§ 356a BGB). Not one of the
|
|
46
|
+
* `legalLinks`: those are the tenant's to replace, and this entry has to stay
|
|
47
|
+
* reachable on every page whatever a tenant's menu says, so the footer renders
|
|
48
|
+
* it on its own. The order detail page links here with `?order=` pre-filled.
|
|
49
|
+
*/
|
|
50
|
+
export const withdrawalPath = "/widerruf";
|
|
51
|
+
|
|
44
52
|
export const legalLinks = [
|
|
45
53
|
{ label: "Privacy Policy", to: "/legal/privacy" },
|
|
46
54
|
{ label: "Terms of Service", to: "/legal/terms" },
|