@revenexx/cover 0.20.0 → 0.21.1
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/components/account/approvals/AccountPendingApprovals.vue +54 -13
- package/app/components/account/approvals/AccountPendingOrderDetail.vue +156 -0
- package/app/components/account/orders/AccountOrderContents.vue +142 -0
- package/app/components/account/orders/AccountOrderDetail.vue +16 -178
- package/app/components/account/orders/AccountOrderHead.vue +79 -0
- package/app/components/account/orders/AccountOrderPay.vue +13 -3
- package/app/components/account/orders/AccountOrdersTable.vue +2 -0
- package/app/components/cart/position/CartPosition.vue +6 -6
- package/app/components/checkout/onepage/CheckoutPaymentSection.vue +20 -8
- package/app/components/checkout/return/CheckoutPaymentReturn.vue +209 -0
- package/app/composables/useAccountDashboard.ts +1 -0
- package/app/composables/useCheckoutOnePage.ts +71 -7
- package/app/composables/usePendingApprovals.ts +11 -3
- package/app/composables/usePspCheckout.ts +130 -29
- package/app/config/colorRamp.ts +55 -0
- package/app/interfaces/account/approvals.ts +34 -1
- package/app/interfaces/account/order-list.ts +8 -1
- package/app/interfaces/cart-calculation.ts +7 -1
- package/app/interfaces/cart-item.ts +12 -0
- package/app/interfaces/payment.ts +22 -0
- package/app/pages/checkout/payment-return.vue +17 -0
- package/app/payments/psp/novalnet.ts +254 -0
- package/app/payments/psp/registry.ts +7 -3
- package/app/payments/psp/rules.ts +99 -0
- package/app/payments/psp/stripe.ts +6 -2
- package/app/payments/psp/types.ts +72 -6
- package/app/shared/pspReturn.ts +62 -0
- package/i18n/locales/de/account.json +17 -3
- package/i18n/locales/de/cart.json +4 -2
- package/i18n/locales/de/checkout.json +32 -0
- package/i18n/locales/de/editor.json +10 -0
- package/i18n/locales/en/account.json +17 -3
- package/i18n/locales/en/cart.json +4 -2
- package/i18n/locales/en/checkout.json +32 -0
- package/i18n/locales/en/editor.json +10 -0
- package/package.json +3 -2
- package/server/api/account/orders/[id]/pay.post.ts +47 -7
- package/server/api/account/pending-approvals/index.get.ts +16 -12
- package/server/api/account/pending-approvals/orders/[number]/approve.post.ts +6 -0
- package/server/api/account/pending-approvals/orders/[number]/reject.post.ts +6 -0
- package/server/api/account/pending-approvals/orders/[number].get.ts +15 -0
- package/server/api/checkout/payment-return.post.ts +30 -0
- package/server/api/orders/index.post.ts +37 -11
- package/server/api/payment/methods.post.ts +19 -9
- package/server/api/payment/psp-config.get.ts +5 -4
- package/server/services/ApiCartService.ts +6 -0
- package/server/services/ApiProductService.ts +6 -2
- package/server/services/MockCartCalculationService.ts +29 -0
- package/server/utils/cartItemHints.ts +29 -0
- package/server/utils/checkoutSession.ts +16 -0
- package/server/utils/liveCatalog.ts +244 -31
- package/server/utils/liveOrders.ts +33 -0
- package/server/utils/orderPayment.ts +79 -0
- package/server/utils/pendingApprovals.ts +157 -2
- package/server/utils/procurementCheckout.ts +5 -0
- package/server/utils/pspConfig.ts +125 -13
- package/server/utils/pspReturn.ts +267 -0
|
@@ -9,20 +9,28 @@
|
|
|
9
9
|
*
|
|
10
10
|
* A decline asks for a reason. An approval does not: "yes" needs no explaining, and
|
|
11
11
|
* a required field in front of it would be a toll on the common case. A refusal the
|
|
12
|
-
* requester cannot read is one they will simply ask for again
|
|
12
|
+
* requester cannot read is one they will simply ask for again — which is why an
|
|
13
|
+
* order's rejection cannot go without one.
|
|
14
|
+
*
|
|
15
|
+
* Two kinds wait here (RAD-229): procurement layers, and colleagues' orders the
|
|
16
|
+
* orders app holds pending. An order opens on its own page before anybody signs it.
|
|
13
17
|
*/
|
|
18
|
+
import type { PendingApproval } from "../../../interfaces/account/approvals";
|
|
19
|
+
|
|
14
20
|
const { t, d } = useI18n();
|
|
15
21
|
const { icon } = useIcons();
|
|
16
22
|
const toast = useToast();
|
|
17
23
|
const { approvals, deciding, decide, status } = usePendingApprovals();
|
|
18
24
|
const { formatCurrency } = useCartSummaryFormatting();
|
|
25
|
+
const localePath = useLocalePath();
|
|
19
26
|
|
|
20
|
-
const declineFor = ref<
|
|
27
|
+
const declineFor = ref<PendingApproval | null>(null);
|
|
21
28
|
const declineReason = ref("");
|
|
29
|
+
const reasonMissing = computed(() => declineFor.value?.kind === "order" && !declineReason.value.trim());
|
|
22
30
|
|
|
23
|
-
async function approve(
|
|
31
|
+
async function approve(approval: PendingApproval): Promise<void> {
|
|
24
32
|
try {
|
|
25
|
-
await decide(
|
|
33
|
+
await decide(approval, "approve");
|
|
26
34
|
toast.add({ title: t("approvals.queue.approved"), color: "success", icon: icon("success") });
|
|
27
35
|
}
|
|
28
36
|
catch (err) {
|
|
@@ -36,12 +44,12 @@ async function approve(id: string): Promise<void> {
|
|
|
36
44
|
}
|
|
37
45
|
|
|
38
46
|
async function submitDecline(): Promise<void> {
|
|
39
|
-
const
|
|
40
|
-
if (!
|
|
47
|
+
const approval = declineFor.value;
|
|
48
|
+
if (!approval || reasonMissing.value) {
|
|
41
49
|
return;
|
|
42
50
|
}
|
|
43
51
|
try {
|
|
44
|
-
await decide(
|
|
52
|
+
await decide(approval, "decline", declineReason.value);
|
|
45
53
|
declineFor.value = null;
|
|
46
54
|
declineReason.value = "";
|
|
47
55
|
toast.add({ title: t("approvals.queue.declined"), color: "success", icon: icon("success") });
|
|
@@ -94,7 +102,27 @@ async function submitDecline(): Promise<void> {
|
|
|
94
102
|
:key="approval.id"
|
|
95
103
|
class="px-4 sm:px-5 py-4 flex flex-wrap items-center gap-x-4 gap-y-2"
|
|
96
104
|
>
|
|
97
|
-
<div
|
|
105
|
+
<div
|
|
106
|
+
v-if="approval.kind === 'order'"
|
|
107
|
+
class="min-w-0 flex-1"
|
|
108
|
+
>
|
|
109
|
+
<p class="text-sm font-medium text-highlighted">
|
|
110
|
+
<NuxtLink
|
|
111
|
+
:to="localePath(`/account/approvals/orders/${approval.id}`)"
|
|
112
|
+
class="hover:underline"
|
|
113
|
+
>
|
|
114
|
+
{{ t('approvals.queue.order', { number: approval.id }) }}
|
|
115
|
+
</NuxtLink>
|
|
116
|
+
</p>
|
|
117
|
+
<p class="text-xs text-muted">
|
|
118
|
+
<template v-if="approval.requestedBy">{{ approval.requestedBy }} · </template>
|
|
119
|
+
{{ approval.at ? d(new Date(approval.at), { dateStyle: 'medium' }) : '' }}
|
|
120
|
+
</p>
|
|
121
|
+
</div>
|
|
122
|
+
<div
|
|
123
|
+
v-else
|
|
124
|
+
class="min-w-0 flex-1"
|
|
125
|
+
>
|
|
98
126
|
<p class="text-sm font-medium text-highlighted">
|
|
99
127
|
{{ approval.requestNumber ?? t('approvals.queue.unnamedRequest') }}
|
|
100
128
|
<!-- Which signature this is. Hiding it would let an approver
|
|
@@ -117,20 +145,28 @@ async function submitDecline(): Promise<void> {
|
|
|
117
145
|
</p>
|
|
118
146
|
|
|
119
147
|
<div class="flex items-center gap-2">
|
|
148
|
+
<UButton
|
|
149
|
+
v-if="approval.kind === 'order'"
|
|
150
|
+
size="sm"
|
|
151
|
+
color="neutral"
|
|
152
|
+
variant="ghost"
|
|
153
|
+
:to="localePath(`/account/approvals/orders/${approval.id}`)"
|
|
154
|
+
:label="t('approvals.queue.review')"
|
|
155
|
+
/>
|
|
120
156
|
<UButton
|
|
121
157
|
size="sm"
|
|
122
158
|
color="neutral"
|
|
123
159
|
variant="outline"
|
|
124
160
|
:disabled="deciding === approval.id"
|
|
125
161
|
:label="t('approvals.queue.decline')"
|
|
126
|
-
@click="declineFor = approval
|
|
162
|
+
@click="declineFor = approval"
|
|
127
163
|
/>
|
|
128
164
|
<UButton
|
|
129
165
|
size="sm"
|
|
130
166
|
color="primary"
|
|
131
167
|
:loading="deciding === approval.id"
|
|
132
168
|
:label="t('approvals.queue.approve')"
|
|
133
|
-
@click="approve(approval
|
|
169
|
+
@click="approve(approval)"
|
|
134
170
|
/>
|
|
135
171
|
</div>
|
|
136
172
|
</li>
|
|
@@ -140,15 +176,19 @@ async function submitDecline(): Promise<void> {
|
|
|
140
176
|
requester has to know whether to ask again differently. -->
|
|
141
177
|
<UModal
|
|
142
178
|
:open="declineFor !== null"
|
|
143
|
-
:title="t('approvals.queue.declineTitle')"
|
|
179
|
+
:title="declineFor?.kind === 'order' ? t('approvals.queue.declineOrderTitle') : t('approvals.queue.declineTitle')"
|
|
144
180
|
@update:open="(open: boolean) => { if (!open) declineFor = null; }"
|
|
145
181
|
>
|
|
146
182
|
<template #body>
|
|
147
183
|
<div class="space-y-4">
|
|
148
184
|
<p class="text-sm text-default">
|
|
149
|
-
{{ t('approvals.queue.declineIntro') }}
|
|
185
|
+
{{ declineFor?.kind === 'order' ? t('approvals.queue.declineOrderIntro') : t('approvals.queue.declineIntro') }}
|
|
150
186
|
</p>
|
|
151
|
-
<UFormField
|
|
187
|
+
<UFormField
|
|
188
|
+
:label="t('approvals.queue.declineReason')"
|
|
189
|
+
:required="declineFor?.kind === 'order'"
|
|
190
|
+
:hint="reasonMissing ? t('approvals.queue.reasonRequired') : undefined"
|
|
191
|
+
>
|
|
152
192
|
<UTextarea
|
|
153
193
|
v-model="declineReason"
|
|
154
194
|
class="w-full"
|
|
@@ -168,6 +208,7 @@ async function submitDecline(): Promise<void> {
|
|
|
168
208
|
/>
|
|
169
209
|
<UButton
|
|
170
210
|
color="error"
|
|
211
|
+
:disabled="reasonMissing"
|
|
171
212
|
:label="t('approvals.queue.decline')"
|
|
172
213
|
@click="submitDecline"
|
|
173
214
|
/>
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { PendingOrderDetail } from "../../../interfaces/account/approvals";
|
|
3
|
+
import AccountOrderContents from "../orders/AccountOrderContents.vue";
|
|
4
|
+
import AccountOrderHead from "../orders/AccountOrderHead.vue";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A colleague's order, as the person who may approve it reads it before deciding
|
|
8
|
+
* (RAD-229) — the account pattern's detail page, never a slideover.
|
|
9
|
+
*
|
|
10
|
+
* What the order holds and where it goes, read-only, and the two decisions. No
|
|
11
|
+
* cancel, return, payment or messages: those are the requester's, and the orders
|
|
12
|
+
* app keeps them so. A no always carries its reason, because it is the one thing
|
|
13
|
+
* the requester learns.
|
|
14
|
+
*/
|
|
15
|
+
const props = defineProps<{
|
|
16
|
+
orderNumber: string;
|
|
17
|
+
}>();
|
|
18
|
+
|
|
19
|
+
const { t } = useI18n();
|
|
20
|
+
const { icon } = useIcons();
|
|
21
|
+
const toast = useToast();
|
|
22
|
+
const localePath = useLocalePath();
|
|
23
|
+
const { decide, deciding } = usePendingApprovals();
|
|
24
|
+
|
|
25
|
+
const { data, status, error, refresh } = useFetch<PendingOrderDetail>(
|
|
26
|
+
`/api/account/pending-approvals/orders/${encodeURIComponent(props.orderNumber)}`,
|
|
27
|
+
{ key: `pending-order:${props.orderNumber}` },
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
const rejectOpen = ref(false);
|
|
31
|
+
const rejectReason = ref("");
|
|
32
|
+
|
|
33
|
+
async function settle(decision: "approve" | "decline"): Promise<void> {
|
|
34
|
+
try {
|
|
35
|
+
await decide({ kind: "order", id: props.orderNumber }, decision, decision === "decline" ? rejectReason.value : undefined);
|
|
36
|
+
rejectOpen.value = false;
|
|
37
|
+
toast.add({
|
|
38
|
+
title: decision === "approve" ? t("approvals.queue.approved") : t("approvals.queue.declined"),
|
|
39
|
+
color: "success",
|
|
40
|
+
icon: icon("success"),
|
|
41
|
+
});
|
|
42
|
+
await navigateTo(localePath("/account/approvals"));
|
|
43
|
+
}
|
|
44
|
+
catch (err) {
|
|
45
|
+
// Most often a colleague deciding it first; the page then says so.
|
|
46
|
+
await refresh();
|
|
47
|
+
toast.add({
|
|
48
|
+
title: t("approvals.queue.failed"),
|
|
49
|
+
description: (err as { data?: { message?: string } })?.data?.message,
|
|
50
|
+
color: "error",
|
|
51
|
+
icon: icon("error"),
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
</script>
|
|
56
|
+
|
|
57
|
+
<template>
|
|
58
|
+
<div>
|
|
59
|
+
<USkeleton
|
|
60
|
+
v-if="status === 'pending'"
|
|
61
|
+
class="h-64 w-full rounded-xl"
|
|
62
|
+
/>
|
|
63
|
+
|
|
64
|
+
<UiFeedbackErrorBoundary
|
|
65
|
+
v-else-if="error || !data"
|
|
66
|
+
:title="t('orders.notFound')"
|
|
67
|
+
:show-retry="false"
|
|
68
|
+
/>
|
|
69
|
+
|
|
70
|
+
<div
|
|
71
|
+
v-else
|
|
72
|
+
class="space-y-6"
|
|
73
|
+
>
|
|
74
|
+
<p
|
|
75
|
+
v-if="data.requestedBy"
|
|
76
|
+
class="text-sm text-muted"
|
|
77
|
+
>
|
|
78
|
+
{{ t('approvals.order.requestedBy', { name: data.requestedBy }) }}
|
|
79
|
+
</p>
|
|
80
|
+
|
|
81
|
+
<AccountOrderHead :order="data.order" />
|
|
82
|
+
|
|
83
|
+
<UAlert
|
|
84
|
+
v-if="!data.pending"
|
|
85
|
+
color="neutral"
|
|
86
|
+
variant="soft"
|
|
87
|
+
:icon="icon('info')"
|
|
88
|
+
:title="t('approvals.order.notPending')"
|
|
89
|
+
/>
|
|
90
|
+
|
|
91
|
+
<AccountOrderContents :order="data.order" />
|
|
92
|
+
|
|
93
|
+
<div
|
|
94
|
+
v-if="data.pending"
|
|
95
|
+
class="flex flex-wrap justify-end gap-2"
|
|
96
|
+
>
|
|
97
|
+
<UButton
|
|
98
|
+
color="neutral"
|
|
99
|
+
variant="outline"
|
|
100
|
+
class="max-lg:min-h-11"
|
|
101
|
+
:disabled="deciding !== null"
|
|
102
|
+
:label="t('approvals.queue.decline')"
|
|
103
|
+
@click="rejectOpen = true"
|
|
104
|
+
/>
|
|
105
|
+
<UButton
|
|
106
|
+
color="primary"
|
|
107
|
+
class="max-lg:min-h-11"
|
|
108
|
+
:loading="deciding === orderNumber"
|
|
109
|
+
:label="t('approvals.queue.approve')"
|
|
110
|
+
@click="settle('approve')"
|
|
111
|
+
/>
|
|
112
|
+
</div>
|
|
113
|
+
</div>
|
|
114
|
+
|
|
115
|
+
<UModal
|
|
116
|
+
v-model:open="rejectOpen"
|
|
117
|
+
:title="t('approvals.queue.declineOrderTitle')"
|
|
118
|
+
>
|
|
119
|
+
<template #body>
|
|
120
|
+
<div class="space-y-4">
|
|
121
|
+
<p class="text-sm text-default">
|
|
122
|
+
{{ t('approvals.queue.declineOrderIntro') }}
|
|
123
|
+
</p>
|
|
124
|
+
<UFormField
|
|
125
|
+
:label="t('approvals.queue.declineReason')"
|
|
126
|
+
required
|
|
127
|
+
>
|
|
128
|
+
<UTextarea
|
|
129
|
+
v-model="rejectReason"
|
|
130
|
+
class="w-full"
|
|
131
|
+
:rows="2"
|
|
132
|
+
:placeholder="t('approvals.queue.declineReasonPlaceholder')"
|
|
133
|
+
/>
|
|
134
|
+
</UFormField>
|
|
135
|
+
</div>
|
|
136
|
+
</template>
|
|
137
|
+
<template #footer>
|
|
138
|
+
<div class="flex items-center justify-end gap-2 w-full">
|
|
139
|
+
<UButton
|
|
140
|
+
color="neutral"
|
|
141
|
+
variant="ghost"
|
|
142
|
+
:label="t('cart.item.cancel')"
|
|
143
|
+
@click="rejectOpen = false"
|
|
144
|
+
/>
|
|
145
|
+
<UButton
|
|
146
|
+
color="error"
|
|
147
|
+
:disabled="!rejectReason.trim()"
|
|
148
|
+
:loading="deciding === orderNumber"
|
|
149
|
+
:label="t('approvals.queue.decline')"
|
|
150
|
+
@click="settle('decline')"
|
|
151
|
+
/>
|
|
152
|
+
</div>
|
|
153
|
+
</template>
|
|
154
|
+
</UModal>
|
|
155
|
+
</div>
|
|
156
|
+
</template>
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { AccountOrder } from "../../../interfaces/account/order-list";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* What an order holds and where it goes: the positions with their totals, the
|
|
6
|
+
* addresses, the payment method and the tracking. Read-only, shared by the
|
|
7
|
+
* buyer's own order page and the approver's view (RAD-229).
|
|
8
|
+
*/
|
|
9
|
+
defineProps<{
|
|
10
|
+
order: AccountOrder;
|
|
11
|
+
}>();
|
|
12
|
+
|
|
13
|
+
const { icon } = useIcons();
|
|
14
|
+
const { t } = useI18n();
|
|
15
|
+
const { formatCurrency } = useCartSummaryFormatting();
|
|
16
|
+
|
|
17
|
+
/* Addresses arrive as " · "-joined lines. */
|
|
18
|
+
const addressLines = (value: string): string[] => value.split(" · ");
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<template>
|
|
22
|
+
<div class="space-y-6">
|
|
23
|
+
<!-- Positions -->
|
|
24
|
+
<section class="border border-(--ui-border) rounded-xl overflow-hidden">
|
|
25
|
+
<h2 class="px-4 sm:px-5 py-3 text-sm font-semibold text-highlighted bg-elevated/60 border-b border-(--ui-border)">
|
|
26
|
+
{{ t('orders.positionsTitle') }}
|
|
27
|
+
</h2>
|
|
28
|
+
<ul class="divide-y divide-(--ui-border) px-4 sm:px-5">
|
|
29
|
+
<li
|
|
30
|
+
v-for="position in order.positions"
|
|
31
|
+
:key="position.id"
|
|
32
|
+
class="flex items-center gap-3 py-3"
|
|
33
|
+
>
|
|
34
|
+
<span
|
|
35
|
+
class="w-14 h-14 shrink-0 flex items-center justify-center rounded-lg
|
|
36
|
+
bg-elevated/60 ring-1 ring-(--ui-border) p-1.5"
|
|
37
|
+
>
|
|
38
|
+
<ProductMediaImage
|
|
39
|
+
:src="position.image ?? ''"
|
|
40
|
+
:alt="position.name"
|
|
41
|
+
/>
|
|
42
|
+
</span>
|
|
43
|
+
<div class="min-w-0 flex-1">
|
|
44
|
+
<p class="text-sm font-medium text-highlighted md:truncate">
|
|
45
|
+
{{ position.name }}
|
|
46
|
+
</p>
|
|
47
|
+
<p class="text-xs text-muted">
|
|
48
|
+
{{ position.sku }} · {{ position.quantity }}× {{ formatCurrency(position.unitPrice) }}
|
|
49
|
+
</p>
|
|
50
|
+
</div>
|
|
51
|
+
<span class="text-sm tabular-nums text-highlighted shrink-0">
|
|
52
|
+
{{ formatCurrency(position.lineTotal) }}
|
|
53
|
+
</span>
|
|
54
|
+
</li>
|
|
55
|
+
</ul>
|
|
56
|
+
<div class="px-4 sm:px-5 py-3 border-t border-(--ui-border) text-sm">
|
|
57
|
+
<div
|
|
58
|
+
v-if="order.subtotal !== undefined"
|
|
59
|
+
class="flex justify-between py-0.5 text-highlighted"
|
|
60
|
+
>
|
|
61
|
+
<span>{{ t('orders.card.subtotal') }}</span>
|
|
62
|
+
<span class="tabular-nums">{{ formatCurrency(order.subtotal) }}</span>
|
|
63
|
+
</div>
|
|
64
|
+
<div
|
|
65
|
+
v-if="order.shipping !== undefined"
|
|
66
|
+
class="flex justify-between py-0.5 text-highlighted"
|
|
67
|
+
>
|
|
68
|
+
<span>{{ t('orders.card.shipping') }}</span>
|
|
69
|
+
<span class="tabular-nums">{{ formatCurrency(order.shipping) }}</span>
|
|
70
|
+
</div>
|
|
71
|
+
<div
|
|
72
|
+
v-if="order.tax !== undefined"
|
|
73
|
+
class="flex justify-between py-0.5 text-muted"
|
|
74
|
+
>
|
|
75
|
+
<span>{{ t('orders.card.tax') }}</span>
|
|
76
|
+
<span class="tabular-nums">{{ formatCurrency(order.tax) }}</span>
|
|
77
|
+
</div>
|
|
78
|
+
<div
|
|
79
|
+
class="flex justify-between pt-2 mt-1 border-t border-(--ui-border)
|
|
80
|
+
font-semibold text-highlighted"
|
|
81
|
+
>
|
|
82
|
+
<span>{{ t('orders.card.total') }}</span>
|
|
83
|
+
<span class="tabular-nums">{{ formatCurrency(order.total) }}</span>
|
|
84
|
+
</div>
|
|
85
|
+
</div>
|
|
86
|
+
</section>
|
|
87
|
+
|
|
88
|
+
<!-- Delivery & payment -->
|
|
89
|
+
<section class="border border-(--ui-border) rounded-xl overflow-hidden">
|
|
90
|
+
<h2 class="px-4 sm:px-5 py-3 text-sm font-semibold text-highlighted bg-elevated/60 border-b border-(--ui-border)">
|
|
91
|
+
{{ t('orders.detail.infoTitle') }}
|
|
92
|
+
</h2>
|
|
93
|
+
<dl class="grid grid-cols-1 sm:grid-cols-2 gap-x-8 gap-y-6 p-4 sm:p-5 text-sm">
|
|
94
|
+
<div v-if="order.deliveryAddress">
|
|
95
|
+
<dt class="font-medium text-highlighted">
|
|
96
|
+
{{ t('orders.deliveryAddress') }}
|
|
97
|
+
</dt>
|
|
98
|
+
<dd class="mt-2 text-muted">
|
|
99
|
+
<span
|
|
100
|
+
v-for="line in addressLines(order.deliveryAddress)"
|
|
101
|
+
:key="line"
|
|
102
|
+
class="block"
|
|
103
|
+
>{{ line }}</span>
|
|
104
|
+
</dd>
|
|
105
|
+
</div>
|
|
106
|
+
<div v-if="order.billingAddress">
|
|
107
|
+
<dt class="font-medium text-highlighted">
|
|
108
|
+
{{ t('orders.detail.billingAddress') }}
|
|
109
|
+
</dt>
|
|
110
|
+
<dd class="mt-2 text-muted">
|
|
111
|
+
<span
|
|
112
|
+
v-for="line in addressLines(order.billingAddress)"
|
|
113
|
+
:key="line"
|
|
114
|
+
class="block"
|
|
115
|
+
>{{ line }}</span>
|
|
116
|
+
</dd>
|
|
117
|
+
</div>
|
|
118
|
+
<div v-if="order.paymentMethod">
|
|
119
|
+
<dt class="font-medium text-highlighted">
|
|
120
|
+
{{ t('orders.detail.paymentMethodLabel') }}
|
|
121
|
+
</dt>
|
|
122
|
+
<dd class="mt-2 text-muted flex items-center gap-2">
|
|
123
|
+
<UIcon
|
|
124
|
+
:name="icon('payment')"
|
|
125
|
+
class="size-4 text-dimmed"
|
|
126
|
+
/>
|
|
127
|
+
{{ t(`paymentMethods.${order.paymentMethod}`) }}
|
|
128
|
+
</dd>
|
|
129
|
+
</div>
|
|
130
|
+
<div v-if="order.tracking">
|
|
131
|
+
<dt class="font-medium text-highlighted">
|
|
132
|
+
{{ t('orders.detail.trackingTitle') }}
|
|
133
|
+
</dt>
|
|
134
|
+
<dd class="mt-2 text-muted">
|
|
135
|
+
<span class="block">{{ order.tracking.carrier }}</span>
|
|
136
|
+
<span class="block tabular-nums">{{ order.tracking.trackingNumber }}</span>
|
|
137
|
+
</dd>
|
|
138
|
+
</div>
|
|
139
|
+
</dl>
|
|
140
|
+
</section>
|
|
141
|
+
</div>
|
|
142
|
+
</template>
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { accountApi } from "../../../api/account";
|
|
3
3
|
import { withdrawalPath } from "../../../config/navigation";
|
|
4
|
-
import type { AccountOrder, AccountOrderMessage
|
|
4
|
+
import type { AccountOrder, AccountOrderMessage } from "../../../interfaces/account/order-list";
|
|
5
5
|
|
|
6
|
+
import AccountOrderContents from "./AccountOrderContents.vue";
|
|
7
|
+
import AccountOrderHead from "./AccountOrderHead.vue";
|
|
6
8
|
import AccountOrderPay from "./AccountOrderPay.vue";
|
|
7
9
|
|
|
8
10
|
/**
|
|
@@ -25,7 +27,6 @@ const { t, d } = useI18n();
|
|
|
25
27
|
const { to } = useAppUrl();
|
|
26
28
|
const toast = useToast();
|
|
27
29
|
const cart = useCartStore();
|
|
28
|
-
const { formatCurrency } = useCartSummaryFormatting();
|
|
29
30
|
|
|
30
31
|
const { data: order, status, error, refresh } = useFetch<AccountOrder>(
|
|
31
32
|
`/api/account/orders/${props.orderId}`,
|
|
@@ -115,20 +116,6 @@ async function submitCancel(): Promise<void> {
|
|
|
115
116
|
}
|
|
116
117
|
}
|
|
117
118
|
|
|
118
|
-
const statusColors: Record<AccountOrderStatus, "info" | "warning" | "primary" | "success" | "error"> = {
|
|
119
|
-
"processing": "info",
|
|
120
|
-
"approval-pending": "warning",
|
|
121
|
-
"shipped": "primary",
|
|
122
|
-
"delivered": "success",
|
|
123
|
-
"cancelled": "error",
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
const paymentColors: Record<AccountOrderPaymentStatus, "warning" | "success" | "neutral"> = {
|
|
127
|
-
open: "warning",
|
|
128
|
-
paid: "success",
|
|
129
|
-
refunded: "neutral",
|
|
130
|
-
};
|
|
131
|
-
|
|
132
119
|
const formatDate = (value: string) => {
|
|
133
120
|
const parsed = new Date(value);
|
|
134
121
|
return Number.isNaN(parsed.getTime()) ? value : d(parsed, { dateStyle: "medium" });
|
|
@@ -161,8 +148,6 @@ const milestoneDate = (step: string): string | undefined => {
|
|
|
161
148
|
return milestone?.date ? formatDate(milestone.date) : undefined;
|
|
162
149
|
};
|
|
163
150
|
|
|
164
|
-
/* ---- addresses (seeded as " · "-joined lines) ------------------------- */
|
|
165
|
-
const addressLines = (value: string): string[] => value.split(" · ");
|
|
166
151
|
|
|
167
152
|
async function copyTracking(): Promise<void> {
|
|
168
153
|
if (!order.value?.tracking) {
|
|
@@ -305,48 +290,18 @@ async function submitReturn(): Promise<void> {
|
|
|
305
290
|
v-else
|
|
306
291
|
class="space-y-6"
|
|
307
292
|
>
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
</div>
|
|
321
|
-
<div v-if="order.orderNumber">
|
|
322
|
-
<p class="text-xs text-muted">
|
|
323
|
-
{{ t('orders.card.yourOrderNumber') }}
|
|
324
|
-
</p>
|
|
325
|
-
<p class="text-sm font-medium text-highlighted">
|
|
326
|
-
{{ order.orderNumber }}
|
|
327
|
-
</p>
|
|
328
|
-
</div>
|
|
329
|
-
<div>
|
|
330
|
-
<p class="text-xs text-muted">
|
|
331
|
-
{{ t('orders.card.total') }}
|
|
332
|
-
</p>
|
|
333
|
-
<p class="text-sm font-semibold text-highlighted tabular-nums">
|
|
334
|
-
{{ formatCurrency(order.total) }}
|
|
335
|
-
</p>
|
|
336
|
-
</div>
|
|
337
|
-
<div class="flex items-center gap-2 ms-auto">
|
|
338
|
-
<UBadge
|
|
339
|
-
:color="statusColors[order.status]"
|
|
340
|
-
variant="subtle"
|
|
341
|
-
:label="t(`orders.status.${order.status}`)"
|
|
342
|
-
/>
|
|
343
|
-
<UBadge
|
|
344
|
-
:color="paymentColors[order.paymentStatus]"
|
|
345
|
-
variant="outline"
|
|
346
|
-
:label="t(`orders.payment.${order.paymentStatus}`)"
|
|
347
|
-
/>
|
|
348
|
-
</div>
|
|
349
|
-
</div>
|
|
293
|
+
<AccountOrderHead :order="order" />
|
|
294
|
+
|
|
295
|
+
<!-- Somebody who may approve said no (RAD-229): the reason is the one
|
|
296
|
+
thing the requester learns, so it stands where they look first. -->
|
|
297
|
+
<UAlert
|
|
298
|
+
v-if="order.status === 'rejected'"
|
|
299
|
+
color="error"
|
|
300
|
+
variant="soft"
|
|
301
|
+
:icon="icon('close')"
|
|
302
|
+
:title="t('orders.rejected.title')"
|
|
303
|
+
:description="order.rejection?.reason"
|
|
304
|
+
/>
|
|
350
305
|
|
|
351
306
|
<UAlert
|
|
352
307
|
v-if="order.status === 'approval-pending' && order.approvers?.length"
|
|
@@ -446,124 +401,7 @@ async function submitReturn(): Promise<void> {
|
|
|
446
401
|
</div>
|
|
447
402
|
</section>
|
|
448
403
|
|
|
449
|
-
|
|
450
|
-
<section class="border border-(--ui-border) rounded-xl overflow-hidden">
|
|
451
|
-
<h2 class="px-4 sm:px-5 py-3 text-sm font-semibold text-highlighted bg-elevated/60 border-b border-(--ui-border)">
|
|
452
|
-
{{ t('orders.positionsTitle') }}
|
|
453
|
-
</h2>
|
|
454
|
-
<ul class="divide-y divide-(--ui-border) px-4 sm:px-5">
|
|
455
|
-
<li
|
|
456
|
-
v-for="position in order.positions"
|
|
457
|
-
:key="position.id"
|
|
458
|
-
class="flex items-center gap-3 py-3"
|
|
459
|
-
>
|
|
460
|
-
<span
|
|
461
|
-
class="w-14 h-14 shrink-0 flex items-center justify-center rounded-lg
|
|
462
|
-
bg-elevated/60 ring-1 ring-(--ui-border) p-1.5"
|
|
463
|
-
>
|
|
464
|
-
<ProductMediaImage
|
|
465
|
-
:src="position.image ?? ''"
|
|
466
|
-
:alt="position.name"
|
|
467
|
-
/>
|
|
468
|
-
</span>
|
|
469
|
-
<div class="min-w-0 flex-1">
|
|
470
|
-
<p class="text-sm font-medium text-highlighted md:truncate">
|
|
471
|
-
{{ position.name }}
|
|
472
|
-
</p>
|
|
473
|
-
<p class="text-xs text-muted">
|
|
474
|
-
{{ position.sku }} · {{ position.quantity }}× {{ formatCurrency(position.unitPrice) }}
|
|
475
|
-
</p>
|
|
476
|
-
</div>
|
|
477
|
-
<span class="text-sm tabular-nums text-highlighted shrink-0">
|
|
478
|
-
{{ formatCurrency(position.lineTotal) }}
|
|
479
|
-
</span>
|
|
480
|
-
</li>
|
|
481
|
-
</ul>
|
|
482
|
-
<div class="px-4 sm:px-5 py-3 border-t border-(--ui-border) text-sm">
|
|
483
|
-
<div
|
|
484
|
-
v-if="order.subtotal !== undefined"
|
|
485
|
-
class="flex justify-between py-0.5 text-highlighted"
|
|
486
|
-
>
|
|
487
|
-
<span>{{ t('orders.card.subtotal') }}</span>
|
|
488
|
-
<span class="tabular-nums">{{ formatCurrency(order.subtotal) }}</span>
|
|
489
|
-
</div>
|
|
490
|
-
<div
|
|
491
|
-
v-if="order.shipping !== undefined"
|
|
492
|
-
class="flex justify-between py-0.5 text-highlighted"
|
|
493
|
-
>
|
|
494
|
-
<span>{{ t('orders.card.shipping') }}</span>
|
|
495
|
-
<span class="tabular-nums">{{ formatCurrency(order.shipping) }}</span>
|
|
496
|
-
</div>
|
|
497
|
-
<div
|
|
498
|
-
v-if="order.tax !== undefined"
|
|
499
|
-
class="flex justify-between py-0.5 text-muted"
|
|
500
|
-
>
|
|
501
|
-
<span>{{ t('orders.card.tax') }}</span>
|
|
502
|
-
<span class="tabular-nums">{{ formatCurrency(order.tax) }}</span>
|
|
503
|
-
</div>
|
|
504
|
-
<div
|
|
505
|
-
class="flex justify-between pt-2 mt-1 border-t border-(--ui-border)
|
|
506
|
-
font-semibold text-highlighted"
|
|
507
|
-
>
|
|
508
|
-
<span>{{ t('orders.card.total') }}</span>
|
|
509
|
-
<span class="tabular-nums">{{ formatCurrency(order.total) }}</span>
|
|
510
|
-
</div>
|
|
511
|
-
</div>
|
|
512
|
-
</section>
|
|
513
|
-
|
|
514
|
-
<!-- Delivery & payment -->
|
|
515
|
-
<section class="border border-(--ui-border) rounded-xl overflow-hidden">
|
|
516
|
-
<h2 class="px-4 sm:px-5 py-3 text-sm font-semibold text-highlighted bg-elevated/60 border-b border-(--ui-border)">
|
|
517
|
-
{{ t('orders.detail.infoTitle') }}
|
|
518
|
-
</h2>
|
|
519
|
-
<dl class="grid grid-cols-1 sm:grid-cols-2 gap-x-8 gap-y-6 p-4 sm:p-5 text-sm">
|
|
520
|
-
<div v-if="order.deliveryAddress">
|
|
521
|
-
<dt class="font-medium text-highlighted">
|
|
522
|
-
{{ t('orders.deliveryAddress') }}
|
|
523
|
-
</dt>
|
|
524
|
-
<dd class="mt-2 text-muted">
|
|
525
|
-
<span
|
|
526
|
-
v-for="line in addressLines(order.deliveryAddress)"
|
|
527
|
-
:key="line"
|
|
528
|
-
class="block"
|
|
529
|
-
>{{ line }}</span>
|
|
530
|
-
</dd>
|
|
531
|
-
</div>
|
|
532
|
-
<div v-if="order.billingAddress">
|
|
533
|
-
<dt class="font-medium text-highlighted">
|
|
534
|
-
{{ t('orders.detail.billingAddress') }}
|
|
535
|
-
</dt>
|
|
536
|
-
<dd class="mt-2 text-muted">
|
|
537
|
-
<span
|
|
538
|
-
v-for="line in addressLines(order.billingAddress)"
|
|
539
|
-
:key="line"
|
|
540
|
-
class="block"
|
|
541
|
-
>{{ line }}</span>
|
|
542
|
-
</dd>
|
|
543
|
-
</div>
|
|
544
|
-
<div v-if="order.paymentMethod">
|
|
545
|
-
<dt class="font-medium text-highlighted">
|
|
546
|
-
{{ t('orders.detail.paymentMethodLabel') }}
|
|
547
|
-
</dt>
|
|
548
|
-
<dd class="mt-2 text-muted flex items-center gap-2">
|
|
549
|
-
<UIcon
|
|
550
|
-
:name="icon('payment')"
|
|
551
|
-
class="size-4 text-dimmed"
|
|
552
|
-
/>
|
|
553
|
-
{{ t(`paymentMethods.${order.paymentMethod}`) }}
|
|
554
|
-
</dd>
|
|
555
|
-
</div>
|
|
556
|
-
<div v-if="order.tracking">
|
|
557
|
-
<dt class="font-medium text-highlighted">
|
|
558
|
-
{{ t('orders.detail.trackingTitle') }}
|
|
559
|
-
</dt>
|
|
560
|
-
<dd class="mt-2 text-muted">
|
|
561
|
-
<span class="block">{{ order.tracking.carrier }}</span>
|
|
562
|
-
<span class="block tabular-nums">{{ order.tracking.trackingNumber }}</span>
|
|
563
|
-
</dd>
|
|
564
|
-
</div>
|
|
565
|
-
</dl>
|
|
566
|
-
</section>
|
|
404
|
+
<AccountOrderContents :order="order" />
|
|
567
405
|
|
|
568
406
|
<!-- Existing returns -->
|
|
569
407
|
<section
|