@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
|
@@ -61,7 +61,13 @@ const sorting = ref([{ id: "updatedAt", desc: true }]);
|
|
|
61
61
|
|
|
62
62
|
const columns = computed<TableColumn<OrderList>[]>(() => [
|
|
63
63
|
{ accessorKey: "name", header: t("orderLists.columns.name") },
|
|
64
|
-
|
|
64
|
+
// Below lg the kind folds into the name cell as a badge under the name.
|
|
65
|
+
{
|
|
66
|
+
id: "kind",
|
|
67
|
+
header: t("orderLists.columns.kind"),
|
|
68
|
+
enableSorting: false,
|
|
69
|
+
meta: { class: { th: "max-lg:hidden", td: "max-lg:hidden" } },
|
|
70
|
+
},
|
|
65
71
|
{
|
|
66
72
|
id: "positions",
|
|
67
73
|
accessorFn: row => row.positions.length,
|
|
@@ -81,6 +87,14 @@ const columns = computed<TableColumn<OrderList>[]>(() => [
|
|
|
81
87
|
|
|
82
88
|
const formatDate = (value: string) => d(new Date(value), { dateStyle: "medium" });
|
|
83
89
|
|
|
90
|
+
/* ---- mobile card list (below md) ---------------------------------------- */
|
|
91
|
+
const { items: sortItems, model: mobileSort, sorted: sortedLists } = useMobileTableSort(filtered, sorting, () => [
|
|
92
|
+
{ id: "updatedAt", label: t("orderLists.columns.updatedAt"), kind: "date", value: list => list.updatedAt },
|
|
93
|
+
{ id: "name", label: t("orderLists.columns.name"), kind: "text", value: list => list.name },
|
|
94
|
+
{ id: "value", label: t("orderLists.columns.value"), kind: "number", value: listValue },
|
|
95
|
+
{ id: "positions", label: t("orderLists.columns.positions"), kind: "number", value: list => list.positions.length },
|
|
96
|
+
]);
|
|
97
|
+
|
|
84
98
|
/* ---- create / edit modal ------------------------------------------ */
|
|
85
99
|
// How many lists a buyer may keep, and what a new one starts as, are the
|
|
86
100
|
// orderlists app's answers. The app refuses a list past its ceiling with an
|
|
@@ -170,6 +184,7 @@ async function addToCart(list: OrderList): Promise<void> {
|
|
|
170
184
|
<UButton
|
|
171
185
|
color="primary"
|
|
172
186
|
tabindex="0"
|
|
187
|
+
class="max-lg:min-h-11"
|
|
173
188
|
:icon="icon('plus')"
|
|
174
189
|
:disabled="listsFull"
|
|
175
190
|
:title="listsFull ? t('orderLists.limitReached', { max: maxLists }) : undefined"
|
|
@@ -179,12 +194,90 @@ async function addToCart(list: OrderList): Promise<void> {
|
|
|
179
194
|
</template>
|
|
180
195
|
</UiTableToolbar>
|
|
181
196
|
|
|
197
|
+
<UiTableCardList
|
|
198
|
+
v-model:sort="mobileSort"
|
|
199
|
+
:rows="sortedLists"
|
|
200
|
+
:row-key="list => list.id"
|
|
201
|
+
:sort-items="sortItems"
|
|
202
|
+
:loading="status === 'pending'"
|
|
203
|
+
>
|
|
204
|
+
<template #item="{ row }">
|
|
205
|
+
<div class="flex items-start justify-between gap-2">
|
|
206
|
+
<div class="min-w-0 -mt-1">
|
|
207
|
+
<ULink
|
|
208
|
+
class="inline-flex min-h-11 items-center font-semibold text-highlighted hover:text-primary transition-colors break-words"
|
|
209
|
+
:to="localePath(`/account/order-lists/${row.id}`)"
|
|
210
|
+
>
|
|
211
|
+
{{ row.name }}
|
|
212
|
+
</ULink>
|
|
213
|
+
<div class="-mt-2">
|
|
214
|
+
<UBadge
|
|
215
|
+
:color="row.kind === 'shopping' ? 'primary' : 'info'"
|
|
216
|
+
variant="subtle"
|
|
217
|
+
size="sm"
|
|
218
|
+
:label="t(`orderLists.kinds.${row.kind}`)"
|
|
219
|
+
/>
|
|
220
|
+
</div>
|
|
221
|
+
</div>
|
|
222
|
+
<div class="flex items-center shrink-0 -my-2 -me-2.5">
|
|
223
|
+
<UButton
|
|
224
|
+
color="neutral"
|
|
225
|
+
variant="ghost"
|
|
226
|
+
class="size-11 justify-center"
|
|
227
|
+
:icon="icon('eye')"
|
|
228
|
+
:aria-label="t('orderLists.details')"
|
|
229
|
+
:to="localePath(`/account/order-lists/${row.id}`)"
|
|
230
|
+
/>
|
|
231
|
+
<UButton
|
|
232
|
+
v-if="row.kind === 'shopping' && row.positions.length"
|
|
233
|
+
color="primary"
|
|
234
|
+
variant="soft"
|
|
235
|
+
class="size-11 justify-center"
|
|
236
|
+
:icon="icon('cart')"
|
|
237
|
+
:aria-label="t('cart.requisition.load')"
|
|
238
|
+
@click="addToCart(row)"
|
|
239
|
+
/>
|
|
240
|
+
</div>
|
|
241
|
+
</div>
|
|
242
|
+
<p class="mt-2 text-sm tabular-nums">
|
|
243
|
+
<span class="text-muted">{{ t('orderLists.columns.positions') }}: {{ row.positions.length }}</span>
|
|
244
|
+
<span class="text-dimmed"> · </span>
|
|
245
|
+
<span class="text-highlighted">{{ formatCurrency(listValue(row)) }}</span>
|
|
246
|
+
</p>
|
|
247
|
+
<p class="mt-1 inline-flex items-center gap-1.5 text-sm text-muted">
|
|
248
|
+
<UIcon
|
|
249
|
+
:name="icon(row.public ? 'users' : 'user')"
|
|
250
|
+
class="size-4 shrink-0"
|
|
251
|
+
/>
|
|
252
|
+
{{ row.public ? t('orderLists.public') : row.owner.name }}
|
|
253
|
+
</p>
|
|
254
|
+
<p class="mt-1 text-xs text-muted">
|
|
255
|
+
{{ t('orderLists.columns.updatedAt') }}: {{ formatDate(row.updatedAt) }}
|
|
256
|
+
</p>
|
|
257
|
+
</template>
|
|
258
|
+
<template #empty>
|
|
259
|
+
<UiFeedbackEmptyState
|
|
260
|
+
v-if="search || kindFilter !== 'all'"
|
|
261
|
+
:icon="icon('no-results')"
|
|
262
|
+
:title="t('table.noResults.title')"
|
|
263
|
+
:description="t('table.noResults.description')"
|
|
264
|
+
/>
|
|
265
|
+
<UiFeedbackEmptyState
|
|
266
|
+
v-else
|
|
267
|
+
:icon="icon('empty')"
|
|
268
|
+
:title="t('orderLists.empty.title')"
|
|
269
|
+
:description="t('orderLists.empty.description')"
|
|
270
|
+
/>
|
|
271
|
+
</template>
|
|
272
|
+
</UiTableCardList>
|
|
273
|
+
|
|
182
274
|
<UTable
|
|
183
275
|
v-model:sorting="sorting"
|
|
276
|
+
class="hidden md:block"
|
|
184
277
|
:data="filtered"
|
|
185
278
|
:columns="columns"
|
|
186
279
|
:loading="status === 'pending'"
|
|
187
|
-
:ui="tableUi"
|
|
280
|
+
:ui="{ ...tableUi, th: `${tableUi.th} max-lg:px-2`, td: `${tableUi.td} max-lg:px-2` }"
|
|
188
281
|
>
|
|
189
282
|
<template #name-header="{ column }">
|
|
190
283
|
<UiTableSortButton
|
|
@@ -213,11 +306,19 @@ async function addToCart(list: OrderList): Promise<void> {
|
|
|
213
306
|
|
|
214
307
|
<template #name-cell="{ row }">
|
|
215
308
|
<ULink
|
|
216
|
-
class="font-semibold text-highlighted hover:text-primary transition-colors"
|
|
309
|
+
class="font-semibold text-highlighted hover:text-primary transition-colors inline-block whitespace-normal min-w-28 max-lg:py-3 max-lg:-my-3"
|
|
217
310
|
:to="localePath(`/account/order-lists/${row.original.id}`)"
|
|
218
311
|
>
|
|
219
312
|
{{ row.original.name }}
|
|
220
313
|
</ULink>
|
|
314
|
+
<div class="mt-1 lg:hidden">
|
|
315
|
+
<UBadge
|
|
316
|
+
:color="row.original.kind === 'shopping' ? 'primary' : 'info'"
|
|
317
|
+
variant="subtle"
|
|
318
|
+
size="sm"
|
|
319
|
+
:label="t(`orderLists.kinds.${row.original.kind}`)"
|
|
320
|
+
/>
|
|
321
|
+
</div>
|
|
221
322
|
</template>
|
|
222
323
|
<template #kind-cell="{ row }">
|
|
223
324
|
<UBadge
|
|
@@ -234,10 +335,10 @@ async function addToCart(list: OrderList): Promise<void> {
|
|
|
234
335
|
<span class="tabular-nums text-highlighted">{{ formatCurrency(listValue(row.original)) }}</span>
|
|
235
336
|
</template>
|
|
236
337
|
<template #visibility-cell="{ row }">
|
|
237
|
-
<span class="inline-flex items-center gap-1.5 text-sm text-muted">
|
|
338
|
+
<span class="inline-flex items-center gap-1.5 text-sm text-muted whitespace-normal">
|
|
238
339
|
<UIcon
|
|
239
340
|
:name="icon(row.original.public ? 'users' : 'user')"
|
|
240
|
-
class="size-4"
|
|
341
|
+
class="size-4 shrink-0"
|
|
241
342
|
/>
|
|
242
343
|
{{ row.original.public
|
|
243
344
|
? t('orderLists.public')
|
|
@@ -245,16 +346,17 @@ async function addToCart(list: OrderList): Promise<void> {
|
|
|
245
346
|
</span>
|
|
246
347
|
</template>
|
|
247
348
|
<template #updatedAt-cell="{ row }">
|
|
248
|
-
{{ formatDate(row.original.updatedAt) }}
|
|
349
|
+
<span class="whitespace-normal">{{ formatDate(row.original.updatedAt) }}</span>
|
|
249
350
|
</template>
|
|
250
351
|
<template #actions-cell="{ row }">
|
|
251
|
-
<div class="flex items-center justify-end gap-1">
|
|
352
|
+
<div class="flex items-center justify-end gap-1 max-lg:gap-0">
|
|
252
353
|
<UTooltip :text="t('orderLists.details')">
|
|
253
354
|
<UButton
|
|
254
355
|
color="neutral"
|
|
255
356
|
variant="ghost"
|
|
256
357
|
size="sm"
|
|
257
358
|
tabindex="0"
|
|
359
|
+
class="max-lg:size-11 max-lg:justify-center"
|
|
258
360
|
:icon="icon('eye')"
|
|
259
361
|
:aria-label="t('orderLists.details')"
|
|
260
362
|
:to="localePath(`/account/order-lists/${row.original.id}`)"
|
|
@@ -269,6 +371,7 @@ async function addToCart(list: OrderList): Promise<void> {
|
|
|
269
371
|
variant="soft"
|
|
270
372
|
size="sm"
|
|
271
373
|
tabindex="0"
|
|
374
|
+
class="max-lg:size-11 max-lg:justify-center"
|
|
272
375
|
:icon="icon('cart')"
|
|
273
376
|
:aria-label="t('cart.requisition.load')"
|
|
274
377
|
@click="addToCart(row.original)"
|
|
@@ -306,6 +409,7 @@ async function addToCart(list: OrderList): Promise<void> {
|
|
|
306
409
|
<UModal
|
|
307
410
|
v-model:open="modalOpen"
|
|
308
411
|
:title="t('orderLists.addTitle')"
|
|
412
|
+
:close="{ class: 'max-lg:size-11 max-lg:justify-center' }"
|
|
309
413
|
>
|
|
310
414
|
<template #body>
|
|
311
415
|
<div class="space-y-4">
|
|
@@ -316,6 +420,7 @@ async function addToCart(list: OrderList): Promise<void> {
|
|
|
316
420
|
<UInput
|
|
317
421
|
v-model="formName"
|
|
318
422
|
class="w-full"
|
|
423
|
+
:ui="{ base: 'max-lg:min-h-11' }"
|
|
319
424
|
:placeholder="t('orderLists.namePlaceholder')"
|
|
320
425
|
/>
|
|
321
426
|
</UFormField>
|
|
@@ -325,6 +430,7 @@ async function addToCart(list: OrderList): Promise<void> {
|
|
|
325
430
|
<URadioGroup
|
|
326
431
|
v-model="formKind"
|
|
327
432
|
orientation="horizontal"
|
|
433
|
+
:ui="{ item: 'max-lg:min-h-11 max-lg:items-center', fieldset: 'max-lg:gap-x-4' }"
|
|
328
434
|
:items="[
|
|
329
435
|
{ value: 'shopping', label: t('orderLists.kinds.shopping') },
|
|
330
436
|
{ value: 'label', label: t('orderLists.kinds.label') },
|
|
@@ -343,12 +449,14 @@ async function addToCart(list: OrderList): Promise<void> {
|
|
|
343
449
|
color="neutral"
|
|
344
450
|
variant="ghost"
|
|
345
451
|
tabindex="0"
|
|
452
|
+
class="max-lg:min-h-11"
|
|
346
453
|
:label="t('cart.item.cancel')"
|
|
347
454
|
@click="modalOpen = false"
|
|
348
455
|
/>
|
|
349
456
|
<UButton
|
|
350
457
|
color="primary"
|
|
351
458
|
tabindex="0"
|
|
459
|
+
class="max-lg:min-h-11"
|
|
352
460
|
:disabled="!formName.trim()"
|
|
353
461
|
:loading="saving"
|
|
354
462
|
:label="t('governance.save')"
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { accountApi } from "../../../api/account";
|
|
3
|
+
import { withdrawalPath } from "../../../config/navigation";
|
|
3
4
|
import type { AccountOrder, AccountOrderMessage, AccountOrderStatus, AccountOrderPaymentStatus } from "../../../interfaces/account/order-list";
|
|
4
5
|
|
|
6
|
+
import AccountOrderPay from "./AccountOrderPay.vue";
|
|
7
|
+
|
|
5
8
|
/**
|
|
6
9
|
* Detail page content of one order (account pattern: detail = own page):
|
|
7
10
|
* head facts, fulfillment progress with carrier tracking, positions and
|
|
@@ -70,6 +73,16 @@ async function sendMessage(): Promise<void> {
|
|
|
70
73
|
}
|
|
71
74
|
}
|
|
72
75
|
|
|
76
|
+
/* ---- paying it --------------------------------------------------------- */
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* An order with no payment behind it — one approved after it was requested took
|
|
80
|
+
* none at the checkout — waits for the buyer here (RAD-173). Whether it does is
|
|
81
|
+
* the shop's answer, asked of the order and its payments — not a guess from the
|
|
82
|
+
* badge.
|
|
83
|
+
*/
|
|
84
|
+
const payOpen = ref(false);
|
|
85
|
+
|
|
73
86
|
/* ---- calling it off ---------------------------------------------------- */
|
|
74
87
|
|
|
75
88
|
const cancelOpen = ref(false);
|
|
@@ -343,6 +356,23 @@ async function submitReturn(): Promise<void> {
|
|
|
343
356
|
:title="t('orders.awaitingApproval', { names: order.approvers.join(', ') })"
|
|
344
357
|
/>
|
|
345
358
|
|
|
359
|
+
<UAlert
|
|
360
|
+
v-if="order.payable"
|
|
361
|
+
color="info"
|
|
362
|
+
variant="soft"
|
|
363
|
+
:icon="icon('payment')"
|
|
364
|
+
:title="t('orders.pay.due')"
|
|
365
|
+
>
|
|
366
|
+
<template #actions>
|
|
367
|
+
<UButton
|
|
368
|
+
color="primary"
|
|
369
|
+
size="sm"
|
|
370
|
+
:label="t('orders.pay.action')"
|
|
371
|
+
@click="payOpen = true"
|
|
372
|
+
/>
|
|
373
|
+
</template>
|
|
374
|
+
</UAlert>
|
|
375
|
+
|
|
346
376
|
<!-- Fulfillment progress + tracking -->
|
|
347
377
|
<section
|
|
348
378
|
v-if="showProgress"
|
|
@@ -400,6 +430,7 @@ async function submitReturn(): Promise<void> {
|
|
|
400
430
|
variant="ghost"
|
|
401
431
|
size="xs"
|
|
402
432
|
tabindex="0"
|
|
433
|
+
class="max-lg:size-11 max-lg:justify-center"
|
|
403
434
|
:icon="icon('copy')"
|
|
404
435
|
:aria-label="t('orders.detail.copyTracking')"
|
|
405
436
|
@click="copyTracking"
|
|
@@ -436,7 +467,7 @@ async function submitReturn(): Promise<void> {
|
|
|
436
467
|
/>
|
|
437
468
|
</span>
|
|
438
469
|
<div class="min-w-0 flex-1">
|
|
439
|
-
<p class="text-sm font-medium text-highlighted truncate">
|
|
470
|
+
<p class="text-sm font-medium text-highlighted md:truncate">
|
|
440
471
|
{{ position.name }}
|
|
441
472
|
</p>
|
|
442
473
|
<p class="text-xs text-muted">
|
|
@@ -586,6 +617,7 @@ async function submitReturn(): Promise<void> {
|
|
|
586
617
|
color="neutral"
|
|
587
618
|
variant="outline"
|
|
588
619
|
tabindex="0"
|
|
620
|
+
class="max-lg:min-h-11"
|
|
589
621
|
:icon="icon('package')"
|
|
590
622
|
:label="t('orders.returns.requestReturn')"
|
|
591
623
|
@click="openReturn"
|
|
@@ -598,15 +630,28 @@ async function submitReturn(): Promise<void> {
|
|
|
598
630
|
color="error"
|
|
599
631
|
variant="outline"
|
|
600
632
|
tabindex="0"
|
|
633
|
+
class="max-lg:min-h-11"
|
|
601
634
|
:icon="icon('close')"
|
|
602
635
|
:label="t('orders.cancel.action')"
|
|
603
636
|
@click="cancelOpen = true"
|
|
604
637
|
/>
|
|
638
|
+
<!-- The withdrawal function (§ 356a BGB), with this order filled in. -->
|
|
639
|
+
<UButton
|
|
640
|
+
v-if="order.status !== 'cancelled'"
|
|
641
|
+
color="neutral"
|
|
642
|
+
variant="outline"
|
|
643
|
+
tabindex="0"
|
|
644
|
+
class="max-lg:min-h-11"
|
|
645
|
+
:icon="icon('file')"
|
|
646
|
+
:to="to(withdrawalPath, { order: order.id })"
|
|
647
|
+
:label="t('withdrawal.cta')"
|
|
648
|
+
/>
|
|
605
649
|
<UButton
|
|
606
650
|
v-if="order.status !== 'cancelled'"
|
|
607
651
|
color="primary"
|
|
608
652
|
variant="soft"
|
|
609
653
|
tabindex="0"
|
|
654
|
+
class="max-lg:min-h-11"
|
|
610
655
|
:icon="icon('reset')"
|
|
611
656
|
:label="t('orders.orderAgain')"
|
|
612
657
|
@click="orderAgain"
|
|
@@ -660,6 +705,7 @@ async function submitReturn(): Promise<void> {
|
|
|
660
705
|
<UButton
|
|
661
706
|
size="sm"
|
|
662
707
|
color="primary"
|
|
708
|
+
class="max-lg:min-h-11"
|
|
663
709
|
:disabled="!draft.trim() || sending"
|
|
664
710
|
:loading="sending"
|
|
665
711
|
:label="t('orders.messages.send')"
|
|
@@ -668,12 +714,20 @@ async function submitReturn(): Promise<void> {
|
|
|
668
714
|
</div>
|
|
669
715
|
</section>
|
|
670
716
|
|
|
717
|
+
<AccountOrderPay
|
|
718
|
+
v-if="order.payable"
|
|
719
|
+
v-model:open="payOpen"
|
|
720
|
+
:order="order"
|
|
721
|
+
@paid="refresh"
|
|
722
|
+
/>
|
|
723
|
+
|
|
671
724
|
<!-- Cancel modal. The reason is asked for up front because the merchant
|
|
672
725
|
may require it, and a form that could have said so beats an error
|
|
673
726
|
that has to. -->
|
|
674
727
|
<UModal
|
|
675
728
|
v-model:open="cancelOpen"
|
|
676
729
|
:title="t('orders.cancel.title', { number: order.id })"
|
|
730
|
+
:close="{ class: 'max-lg:size-11 max-lg:justify-center' }"
|
|
677
731
|
>
|
|
678
732
|
<template #body>
|
|
679
733
|
<div class="space-y-4">
|
|
@@ -695,11 +749,13 @@ async function submitReturn(): Promise<void> {
|
|
|
695
749
|
<UButton
|
|
696
750
|
color="neutral"
|
|
697
751
|
variant="ghost"
|
|
752
|
+
class="max-lg:min-h-11"
|
|
698
753
|
:label="t('cart.item.cancel')"
|
|
699
754
|
@click="cancelOpen = false"
|
|
700
755
|
/>
|
|
701
756
|
<UButton
|
|
702
757
|
color="error"
|
|
758
|
+
class="max-lg:min-h-11"
|
|
703
759
|
:loading="cancelling"
|
|
704
760
|
:label="t('orders.cancel.confirm')"
|
|
705
761
|
@click="submitCancel"
|
|
@@ -712,6 +768,7 @@ async function submitReturn(): Promise<void> {
|
|
|
712
768
|
<UModal
|
|
713
769
|
v-model:open="returnOpen"
|
|
714
770
|
:title="t('orders.returns.modalTitle')"
|
|
771
|
+
:close="{ class: 'max-lg:size-11 max-lg:justify-center' }"
|
|
715
772
|
>
|
|
716
773
|
<template #body>
|
|
717
774
|
<div class="space-y-4">
|
|
@@ -728,7 +785,7 @@ async function submitReturn(): Promise<void> {
|
|
|
728
785
|
class="flex items-center gap-3"
|
|
729
786
|
>
|
|
730
787
|
<div class="min-w-0 flex-1">
|
|
731
|
-
<p class="text-sm font-medium text-highlighted truncate">
|
|
788
|
+
<p class="text-sm font-medium text-highlighted max-md:break-words md:truncate">
|
|
732
789
|
{{ position.name }}
|
|
733
790
|
</p>
|
|
734
791
|
<p class="text-xs text-muted">
|
|
@@ -739,7 +796,12 @@ async function submitReturn(): Promise<void> {
|
|
|
739
796
|
v-model="returnQuantities[position.orderItemId as string]"
|
|
740
797
|
:min="0"
|
|
741
798
|
:max="position.returnableQuantity ?? 0"
|
|
742
|
-
class="w-28 shrink-0"
|
|
799
|
+
class="w-28 shrink-0 max-lg:w-36"
|
|
800
|
+
:ui="{
|
|
801
|
+
base: 'max-lg:min-h-11',
|
|
802
|
+
increment: 'max-lg:[&>button]:size-11',
|
|
803
|
+
decrement: 'max-lg:[&>button]:size-11',
|
|
804
|
+
}"
|
|
743
805
|
:aria-label="t('orders.returns.quantity')"
|
|
744
806
|
/>
|
|
745
807
|
</div>
|
|
@@ -759,11 +821,13 @@ async function submitReturn(): Promise<void> {
|
|
|
759
821
|
<UButton
|
|
760
822
|
color="neutral"
|
|
761
823
|
variant="ghost"
|
|
824
|
+
class="max-lg:min-h-11"
|
|
762
825
|
:label="t('orders.returns.cancel')"
|
|
763
826
|
@click="returnOpen = false"
|
|
764
827
|
/>
|
|
765
828
|
<UButton
|
|
766
829
|
color="primary"
|
|
830
|
+
class="max-lg:min-h-11"
|
|
767
831
|
:loading="submittingReturn"
|
|
768
832
|
:disabled="selectedReturnPositions.length === 0"
|
|
769
833
|
:label="t('orders.returns.submit')"
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { accountApi } from "../../../api/account";
|
|
3
|
+
import type { AccountOrder } from "../../../interfaces/account/order-list";
|
|
4
|
+
import type { PaymentOption } from "../../../interfaces/payment";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Paying an order that took no payment at the checkout (RAD-173).
|
|
8
|
+
*
|
|
9
|
+
* An order that waited for somebody's approval was not paid when it was
|
|
10
|
+
* requested, because there was nothing to pay for yet. Once approved it waits for
|
|
11
|
+
* the buyer, and this is where they pay it: the order's own method over the
|
|
12
|
+
* order's own total. A card method mounts the provider's secure field, the same
|
|
13
|
+
* one the checkout uses; a redirect method hands the buyer to the provider.
|
|
14
|
+
*/
|
|
15
|
+
const props = defineProps<{
|
|
16
|
+
order: AccountOrder;
|
|
17
|
+
}>();
|
|
18
|
+
|
|
19
|
+
const emit = defineEmits<{ paid: [] }>();
|
|
20
|
+
|
|
21
|
+
const open = defineModel<boolean>("open", { default: false });
|
|
22
|
+
|
|
23
|
+
const { t } = useI18n();
|
|
24
|
+
const { icon } = useIcons();
|
|
25
|
+
const toast = useToast();
|
|
26
|
+
const { formatCurrency } = useCartSummaryFormatting();
|
|
27
|
+
const psp = usePspCheckout();
|
|
28
|
+
|
|
29
|
+
const option = ref<PaymentOption | null>(null);
|
|
30
|
+
// Whether the order's method came back at all. Without it the dialog cannot
|
|
31
|
+
// know whether a card is needed, and the payments app would refuse the method
|
|
32
|
+
// anyway — so it says so rather than offering a button that only fails.
|
|
33
|
+
const loading = ref(false);
|
|
34
|
+
const unavailable = ref(false);
|
|
35
|
+
const paying = ref(false);
|
|
36
|
+
const cardEl = ref<HTMLElement | null>(null);
|
|
37
|
+
const cardError = ref<string | null>(null);
|
|
38
|
+
// One per attempt, so a double click pays once; renewed after a refusal.
|
|
39
|
+
const attempt = ref("");
|
|
40
|
+
|
|
41
|
+
const needsCardField = computed(() => psp.requiresInstrument(option.value));
|
|
42
|
+
const amount = computed(() => formatCurrency(props.order.total));
|
|
43
|
+
|
|
44
|
+
/** The order's method as the payments app describes it — label, and whether it takes a card. */
|
|
45
|
+
async function loadOption(): Promise<void> {
|
|
46
|
+
option.value = null;
|
|
47
|
+
unavailable.value = false;
|
|
48
|
+
loading.value = true;
|
|
49
|
+
try {
|
|
50
|
+
const { methods } = await $fetch<{ methods: PaymentOption[] }>("/api/payment/methods", {
|
|
51
|
+
method: "POST",
|
|
52
|
+
body: { amount: props.order.total, country: props.order.paymentCountry ?? "", currency: props.order.currency },
|
|
53
|
+
});
|
|
54
|
+
option.value = methods.find(m => m.method === props.order.paymentMethod) ?? null;
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
option.value = null;
|
|
58
|
+
}
|
|
59
|
+
finally {
|
|
60
|
+
loading.value = false;
|
|
61
|
+
unavailable.value = option.value === null;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async function syncCardField(): Promise<void> {
|
|
66
|
+
cardError.value = null;
|
|
67
|
+
await nextTick();
|
|
68
|
+
if (needsCardField.value && cardEl.value && option.value) {
|
|
69
|
+
try {
|
|
70
|
+
await psp.mount(cardEl.value, option.value);
|
|
71
|
+
}
|
|
72
|
+
catch (err) {
|
|
73
|
+
cardError.value = err instanceof Error ? err.message : String(err);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
psp.destroy();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
watch(open, async (isOpen) => {
|
|
82
|
+
if (!isOpen) {
|
|
83
|
+
psp.destroy();
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
attempt.value = crypto.randomUUID();
|
|
87
|
+
await loadOption();
|
|
88
|
+
await syncCardField();
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
onBeforeUnmount(() => psp.destroy());
|
|
92
|
+
|
|
93
|
+
async function pay(): Promise<void> {
|
|
94
|
+
paying.value = true;
|
|
95
|
+
try {
|
|
96
|
+
const body: Record<string, unknown> = {
|
|
97
|
+
idempotencyKey: attempt.value,
|
|
98
|
+
returnUrl: window.location.href,
|
|
99
|
+
};
|
|
100
|
+
if (psp.hasActive()) {
|
|
101
|
+
const instrument = await psp.tokenize();
|
|
102
|
+
if (instrument) {
|
|
103
|
+
body.paymentInstrument = instrument;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
const answer = await $fetch<{ requiresAction?: boolean; redirectUrl?: string }>(accountApi.orderPay(props.order.id), {
|
|
107
|
+
method: "POST",
|
|
108
|
+
body,
|
|
109
|
+
});
|
|
110
|
+
if (answer.requiresAction && answer.redirectUrl) {
|
|
111
|
+
window.location.href = answer.redirectUrl;
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
open.value = false;
|
|
115
|
+
toast.add({ title: t("orders.pay.done"), color: "success", icon: icon("success") });
|
|
116
|
+
emit("paid");
|
|
117
|
+
}
|
|
118
|
+
catch (err) {
|
|
119
|
+
const statusCode = (err as { statusCode?: number })?.statusCode;
|
|
120
|
+
// The order no longer owes anything — paid meanwhile, from another tab or
|
|
121
|
+
// by the merchant. Not a failure: say so and show the order as it is.
|
|
122
|
+
if (statusCode === 409) {
|
|
123
|
+
open.value = false;
|
|
124
|
+
toast.add({ title: t("orders.pay.settled"), color: "info", icon: icon("info") });
|
|
125
|
+
emit("paid");
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
// A declined or refused payment is final under its key: payments answers a
|
|
129
|
+
// replay with the stored failure. The next try (another card) is a new
|
|
130
|
+
// payment and gets a new key. An outage keeps the key, and the route lets
|
|
131
|
+
// the payment made under it through, so a retry gets back what did go
|
|
132
|
+
// through (a 3-D Secure redirect included) instead of charging twice.
|
|
133
|
+
if (statusCode === 402 || statusCode === 422) {
|
|
134
|
+
attempt.value = crypto.randomUUID();
|
|
135
|
+
}
|
|
136
|
+
toast.add({
|
|
137
|
+
title: t("orders.pay.failed"),
|
|
138
|
+
description: (err as { data?: { message?: string } })?.data?.message ?? (err instanceof Error ? err.message : undefined),
|
|
139
|
+
color: "error",
|
|
140
|
+
icon: icon("error"),
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
finally {
|
|
144
|
+
paying.value = false;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
</script>
|
|
148
|
+
|
|
149
|
+
<template>
|
|
150
|
+
<UModal
|
|
151
|
+
v-model:open="open"
|
|
152
|
+
:title="t('orders.pay.title', { number: order.id })"
|
|
153
|
+
>
|
|
154
|
+
<template #body>
|
|
155
|
+
<div class="space-y-4">
|
|
156
|
+
<p class="text-sm text-default">
|
|
157
|
+
{{ t('orders.pay.intro', { amount }) }}
|
|
158
|
+
</p>
|
|
159
|
+
<div v-if="order.paymentMethod">
|
|
160
|
+
<p class="text-xs text-muted">
|
|
161
|
+
{{ t('orders.pay.method') }}
|
|
162
|
+
</p>
|
|
163
|
+
<p class="text-sm font-medium text-highlighted">
|
|
164
|
+
{{ option?.label ?? t(`paymentMethods.${order.paymentMethod}`) }}
|
|
165
|
+
</p>
|
|
166
|
+
</div>
|
|
167
|
+
<UAlert
|
|
168
|
+
v-if="unavailable"
|
|
169
|
+
color="warning"
|
|
170
|
+
variant="soft"
|
|
171
|
+
:icon="icon('warning')"
|
|
172
|
+
:title="t('orders.pay.unavailable')"
|
|
173
|
+
/>
|
|
174
|
+
<!-- PSP secure card field (mounted client-side by the provider) -->
|
|
175
|
+
<div
|
|
176
|
+
v-if="needsCardField"
|
|
177
|
+
class="space-y-1.5"
|
|
178
|
+
>
|
|
179
|
+
<label class="block text-sm font-medium text-muted">{{ t('onepage.payment.cardDetails') }}</label>
|
|
180
|
+
<div
|
|
181
|
+
ref="cardEl"
|
|
182
|
+
class="w-full p-3 rounded-lg border border-(--ui-border) bg-(--ui-bg)"
|
|
183
|
+
/>
|
|
184
|
+
<p
|
|
185
|
+
v-if="cardError"
|
|
186
|
+
class="text-sm text-error-500"
|
|
187
|
+
>
|
|
188
|
+
{{ cardError }}
|
|
189
|
+
</p>
|
|
190
|
+
</div>
|
|
191
|
+
</div>
|
|
192
|
+
</template>
|
|
193
|
+
<template #footer>
|
|
194
|
+
<div class="flex items-center justify-end gap-2 w-full">
|
|
195
|
+
<UButton
|
|
196
|
+
color="neutral"
|
|
197
|
+
variant="ghost"
|
|
198
|
+
:label="t('cart.item.cancel')"
|
|
199
|
+
@click="open = false"
|
|
200
|
+
/>
|
|
201
|
+
<UButton
|
|
202
|
+
color="primary"
|
|
203
|
+
:loading="paying || loading"
|
|
204
|
+
:disabled="unavailable"
|
|
205
|
+
:label="t('orders.pay.confirm', { amount })"
|
|
206
|
+
@click="pay"
|
|
207
|
+
/>
|
|
208
|
+
</div>
|
|
209
|
+
</template>
|
|
210
|
+
</UModal>
|
|
211
|
+
</template>
|