@revenexx/cover 0.19.0 → 0.21.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/marketing.ts +24 -0
- package/app/app.config.ts +22 -0
- package/app/components/account/approvals/AccountPendingApprovals.vue +54 -13
- package/app/components/account/approvals/AccountPendingOrderDetail.vue +156 -0
- package/app/components/account/loyalty/AccountLoyalty.vue +205 -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/cart/view/CartSummaryPanel.vue +4 -0
- package/app/components/checkout/onepage/CheckoutPaymentSection.vue +20 -8
- package/app/components/checkout/onepage/CheckoutSummarySection.vue +4 -0
- package/app/components/checkout/return/CheckoutPaymentReturn.vue +209 -0
- package/app/components/loyalty/hint/LoyaltyPerkHint.vue +28 -0
- package/app/components/newsletter/confirm/NewsletterConfirmation.vue +54 -0
- package/app/components/newsletter/preferences/NewsletterPreferenceCentre.vue +183 -0
- package/app/components/newsletter/state/NewsletterLinkRefusal.vue +45 -0
- package/app/components/review/form/ReviewForm.vue +211 -0
- package/app/composables/useAccountDashboard.ts +1 -0
- package/app/composables/useCampaignAttribution.ts +120 -0
- package/app/composables/useCheckoutOnePage.ts +80 -7
- package/app/composables/useLoyaltyAccount.ts +79 -0
- package/app/composables/useMarketingConsent.ts +49 -0
- package/app/composables/usePendingApprovals.ts +11 -3
- package/app/composables/usePspCheckout.ts +130 -29
- package/app/config/colorRamp.ts +55 -0
- package/app/config/navigation.ts +1 -1
- package/app/config/quickActions.ts +1 -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/account/points.vue +26 -0
- package/app/pages/checkout/payment-return.vue +17 -0
- package/app/pages/newsletter/confirm/[token].vue +23 -0
- package/app/pages/newsletter/preferences/[token].vue +24 -0
- package/app/pages/review/[token].vue +23 -0
- package/app/payments/psp/novalnet.ts +255 -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/plugins/campaign-attribution.client.ts +47 -0
- package/app/shared/campaignAttribution.ts +281 -0
- package/app/shared/personalisation.ts +107 -0
- package/app/shared/pspReturn.ts +62 -0
- package/i18n/locales/de/account.json +20 -5
- 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/de/marketing.json +71 -0
- package/i18n/locales/en/account.json +20 -5
- 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/i18n/locales/en/marketing.json +71 -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/campaigns/touches.post.ts +42 -0
- package/server/api/cart/attribution.put.ts +31 -0
- package/server/api/checkout/payment-return.post.ts +30 -0
- package/server/api/loyalty/account.get.ts +27 -0
- package/server/api/newsletter/confirm/[token].post.ts +21 -0
- package/server/api/newsletter/preferences/[token].get.ts +14 -0
- package/server/api/newsletter/preferences/[token].post.ts +36 -0
- package/server/api/orders/index.post.ts +47 -12
- package/server/api/payment/methods.post.ts +19 -9
- package/server/api/payment/psp-config.get.ts +5 -4
- package/server/api/reviews/requests/[token].get.ts +14 -0
- package/server/api/reviews/submit/[token].post.ts +31 -0
- package/server/interfaces/cart.ts +6 -0
- package/server/interfaces/marketing.ts +150 -0
- package/server/services/ApiCartService.ts +22 -0
- package/server/services/ApiMarketingService.ts +292 -0
- package/server/services/ApiProductService.ts +6 -2
- package/server/services/MockCartCalculationService.ts +29 -0
- package/server/services/MockMarketingService.ts +178 -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/marketingService.ts +63 -0
- package/server/utils/orderAttribution.ts +65 -0
- package/server/utils/orderPayment.ts +79 -0
- package/server/utils/pendingApprovals.ts +157 -2
- package/server/utils/personalisationViewer.ts +28 -0
- package/server/utils/pspConfig.ts +125 -13
- package/server/utils/pspReturn.ts +267 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** BFF paths of the marketing pages (RAD-293). Tokens are encoded here, once. */
|
|
2
|
+
export const marketingApi = {
|
|
3
|
+
confirm: (token: string) => `/api/newsletter/confirm/${encodeURIComponent(token)}`,
|
|
4
|
+
preferences: (token: string) => `/api/newsletter/preferences/${encodeURIComponent(token)}`,
|
|
5
|
+
reviewRequest: (token: string) => `/api/reviews/requests/${encodeURIComponent(token)}`,
|
|
6
|
+
reviewSubmit: (token: string) => `/api/reviews/submit/${encodeURIComponent(token)}`,
|
|
7
|
+
loyaltyAccount: () => "/api/loyalty/account",
|
|
8
|
+
touches: () => "/api/campaigns/touches",
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
/** Why a token page refused: the link is unknown, expired, or the shop failed. */
|
|
12
|
+
export type LinkRefusal = "unknown" | "expired" | "error";
|
|
13
|
+
|
|
14
|
+
export function linkRefusalOf(err: unknown): LinkRefusal {
|
|
15
|
+
const status = (err as { statusCode?: number; status?: number } | null)?.statusCode
|
|
16
|
+
?? (err as { status?: number } | null)?.status;
|
|
17
|
+
if (status === 410) {
|
|
18
|
+
return "expired";
|
|
19
|
+
}
|
|
20
|
+
if (status === 404) {
|
|
21
|
+
return "unknown";
|
|
22
|
+
}
|
|
23
|
+
return "error";
|
|
24
|
+
}
|
package/app/app.config.ts
CHANGED
|
@@ -50,6 +50,28 @@ export default defineAppConfig({
|
|
|
50
50
|
// through transpose and merged over the theme's locale files. Mock reads
|
|
51
51
|
// nothing, so the demo shows the theme's texts; a theme switches it to "api".
|
|
52
52
|
translationsService: "mock",
|
|
53
|
+
// The marketing apps (RAD-293): the newsletter confirmation and preference
|
|
54
|
+
// centre (marketing-consents), the review form (reviews), the loyalty page
|
|
55
|
+
// and perk hint (loyalty), audiences for personalised content and campaign
|
|
56
|
+
// touches. `mock` serves demo answers for every one of those pages.
|
|
57
|
+
marketingService: "mock",
|
|
58
|
+
// Which purposes of the merchant's cookie choice each marketing function
|
|
59
|
+
// rests on — codes of the Consent Manager's policy (its defaults are
|
|
60
|
+
// `statistics` and `marketing`). A function whose purpose was not allowed
|
|
61
|
+
// does nothing: no attribution is kept, no pop-up is counted, no audience
|
|
62
|
+
// is asked for.
|
|
63
|
+
marketing: {
|
|
64
|
+
purposes: {
|
|
65
|
+
// Where a visit came from (UTM parameters, first/last touch).
|
|
66
|
+
analytics: "statistics",
|
|
67
|
+
// The ad click id, and telling ad platforms about a conversion.
|
|
68
|
+
ads: "marketing",
|
|
69
|
+
// Showing a signed-in buyer content meant for their audiences.
|
|
70
|
+
personalisation: "marketing",
|
|
71
|
+
// Counting a campaign's pop-up impressions and clicks.
|
|
72
|
+
touches: "statistics",
|
|
73
|
+
},
|
|
74
|
+
},
|
|
53
75
|
// How an ordered quote is paid. A quote is a negotiated B2B price, so the
|
|
54
76
|
// order it becomes goes on account; a storefront that takes quotes on
|
|
55
77
|
// another method names its code here.
|
|
@@ -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,205 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* The buyer's loyalty programme in the account (RAD-293): their tier and its
|
|
4
|
+
* perks, a points balance where the programme counts points, and — for a
|
|
5
|
+
* yearly turnover bonus like eltric "Premium" — the stages, the turnover so
|
|
6
|
+
* far, the projection to year end and what is left to the next stage.
|
|
7
|
+
*
|
|
8
|
+
* The figures are the loyalty app's; this page computes nothing, so what the
|
|
9
|
+
* buyer reads is what the merchant settles.
|
|
10
|
+
*/
|
|
11
|
+
const { t, locale } = useI18n();
|
|
12
|
+
const { data, status, error, label } = useLoyaltyAccount();
|
|
13
|
+
|
|
14
|
+
const memberships = computed(() => data.value?.memberships ?? []);
|
|
15
|
+
const progress = computed(() => data.value?.progress ?? null);
|
|
16
|
+
|
|
17
|
+
function money(value: number | null | undefined): string {
|
|
18
|
+
if (value === null || value === undefined) {
|
|
19
|
+
return "–";
|
|
20
|
+
}
|
|
21
|
+
return new Intl.NumberFormat(locale.value, {
|
|
22
|
+
style: "currency",
|
|
23
|
+
currency: progress.value?.currency ?? "EUR",
|
|
24
|
+
maximumFractionDigits: 0,
|
|
25
|
+
}).format(value);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const share = computed(() => {
|
|
29
|
+
const tiers = progress.value?.tiers ?? [];
|
|
30
|
+
const top = tiers.reduce((max, tier) => Math.max(max, tier.threshold ?? 0), 0);
|
|
31
|
+
return top > 0 ? Math.min(100, Math.round(((progress.value?.turnoverYtd ?? 0) / top) * 100)) : 0;
|
|
32
|
+
});
|
|
33
|
+
</script>
|
|
34
|
+
|
|
35
|
+
<template>
|
|
36
|
+
<div
|
|
37
|
+
class="space-y-6"
|
|
38
|
+
data-account-loyalty
|
|
39
|
+
>
|
|
40
|
+
<USkeleton
|
|
41
|
+
v-if="status === 'pending' && !data"
|
|
42
|
+
class="h-40 w-full"
|
|
43
|
+
/>
|
|
44
|
+
<UAlert
|
|
45
|
+
v-else-if="error"
|
|
46
|
+
color="error"
|
|
47
|
+
variant="soft"
|
|
48
|
+
:description="t('marketing.loyalty.error')"
|
|
49
|
+
/>
|
|
50
|
+
<UiFeedbackEmptyState
|
|
51
|
+
v-else-if="!memberships.length"
|
|
52
|
+
icon="star"
|
|
53
|
+
:title="t('marketing.loyalty.none')"
|
|
54
|
+
/>
|
|
55
|
+
<template v-else>
|
|
56
|
+
<section
|
|
57
|
+
v-for="membership in memberships"
|
|
58
|
+
:key="membership.program.code"
|
|
59
|
+
class="border border-(--ui-border) rounded-xl p-5 space-y-3"
|
|
60
|
+
>
|
|
61
|
+
<h2 class="text-lg font-semibold text-highlighted">
|
|
62
|
+
{{ label(membership.program.labels, membership.program.code) }}
|
|
63
|
+
</h2>
|
|
64
|
+
<dl class="grid gap-3 sm:grid-cols-2 text-sm">
|
|
65
|
+
<div v-if="membership.tier">
|
|
66
|
+
<dt class="text-muted">
|
|
67
|
+
{{ t('marketing.loyalty.tier') }}
|
|
68
|
+
</dt>
|
|
69
|
+
<dd
|
|
70
|
+
class="font-medium text-highlighted"
|
|
71
|
+
data-loyalty-tier
|
|
72
|
+
>
|
|
73
|
+
{{ label(membership.tier.labels, membership.tier.code) }}
|
|
74
|
+
</dd>
|
|
75
|
+
</div>
|
|
76
|
+
<div v-if="membership.pointsBalance !== null">
|
|
77
|
+
<dt class="text-muted">
|
|
78
|
+
{{ t('marketing.loyalty.points') }}
|
|
79
|
+
</dt>
|
|
80
|
+
<dd class="font-medium text-highlighted">
|
|
81
|
+
{{ t('marketing.loyalty.pointsValue', { points: membership.pointsBalance }) }}
|
|
82
|
+
</dd>
|
|
83
|
+
</div>
|
|
84
|
+
</dl>
|
|
85
|
+
<div v-if="membership.tier?.perks.length">
|
|
86
|
+
<p class="text-sm text-muted mb-1">
|
|
87
|
+
{{ t('marketing.loyalty.perks') }}
|
|
88
|
+
</p>
|
|
89
|
+
<ul class="list-disc ps-5 text-sm space-y-0.5">
|
|
90
|
+
<li
|
|
91
|
+
v-for="(perk, index) in membership.tier.perks"
|
|
92
|
+
:key="index"
|
|
93
|
+
>
|
|
94
|
+
{{ label(perk) }}
|
|
95
|
+
</li>
|
|
96
|
+
</ul>
|
|
97
|
+
</div>
|
|
98
|
+
</section>
|
|
99
|
+
|
|
100
|
+
<section
|
|
101
|
+
v-if="progress"
|
|
102
|
+
class="border border-(--ui-border) rounded-xl p-5 space-y-4"
|
|
103
|
+
data-loyalty-progress
|
|
104
|
+
>
|
|
105
|
+
<h2 class="text-lg font-semibold text-highlighted">
|
|
106
|
+
{{ t('marketing.loyalty.progressTitle', { period: progress.period ?? '' }) }}
|
|
107
|
+
</h2>
|
|
108
|
+
<dl class="grid gap-3 sm:grid-cols-2 lg:grid-cols-4 text-sm">
|
|
109
|
+
<div>
|
|
110
|
+
<dt class="text-muted">
|
|
111
|
+
{{ t('marketing.loyalty.turnoverYtd') }}
|
|
112
|
+
</dt>
|
|
113
|
+
<dd class="font-semibold text-highlighted">
|
|
114
|
+
{{ money(progress.turnoverYtd) }}
|
|
115
|
+
</dd>
|
|
116
|
+
</div>
|
|
117
|
+
<div>
|
|
118
|
+
<dt class="text-muted">
|
|
119
|
+
{{ t('marketing.loyalty.projected') }}
|
|
120
|
+
</dt>
|
|
121
|
+
<dd class="font-semibold text-highlighted">
|
|
122
|
+
{{ money(progress.projectedTurnover) }}
|
|
123
|
+
</dd>
|
|
124
|
+
</div>
|
|
125
|
+
<div>
|
|
126
|
+
<dt class="text-muted">
|
|
127
|
+
{{ t('marketing.loyalty.bonusNow') }}
|
|
128
|
+
</dt>
|
|
129
|
+
<dd class="font-semibold text-highlighted">
|
|
130
|
+
{{ money(progress.bonusNow) }}
|
|
131
|
+
</dd>
|
|
132
|
+
</div>
|
|
133
|
+
<div>
|
|
134
|
+
<dt class="text-muted">
|
|
135
|
+
{{ t('marketing.loyalty.expectedBonus') }}
|
|
136
|
+
</dt>
|
|
137
|
+
<dd class="font-semibold text-highlighted">
|
|
138
|
+
{{ money(progress.expectedBonus) }}
|
|
139
|
+
</dd>
|
|
140
|
+
</div>
|
|
141
|
+
</dl>
|
|
142
|
+
|
|
143
|
+
<div
|
|
144
|
+
class="h-2 rounded-full bg-elevated overflow-hidden"
|
|
145
|
+
role="presentation"
|
|
146
|
+
>
|
|
147
|
+
<div
|
|
148
|
+
class="h-full rounded-full bg-primary w-(--loyalty-progress)"
|
|
149
|
+
:style="{ '--loyalty-progress': `${share}%` }"
|
|
150
|
+
/>
|
|
151
|
+
</div>
|
|
152
|
+
|
|
153
|
+
<p
|
|
154
|
+
class="text-sm font-medium text-highlighted"
|
|
155
|
+
data-loyalty-next
|
|
156
|
+
>
|
|
157
|
+
{{ progress.nextTier
|
|
158
|
+
? t('marketing.loyalty.nextTier', {
|
|
159
|
+
gap: money(progress.nextTier.gap),
|
|
160
|
+
tier: label(progress.nextTier.labels, progress.nextTier.code),
|
|
161
|
+
percent: progress.nextTier.bonusPercent,
|
|
162
|
+
})
|
|
163
|
+
: t('marketing.loyalty.topTier') }}
|
|
164
|
+
</p>
|
|
165
|
+
|
|
166
|
+
<ul class="space-y-1 text-sm">
|
|
167
|
+
<li
|
|
168
|
+
v-for="tier in progress.tiers"
|
|
169
|
+
:key="tier.code"
|
|
170
|
+
class="flex items-center gap-2"
|
|
171
|
+
:class="tier.reached ? 'text-highlighted' : 'text-muted'"
|
|
172
|
+
>
|
|
173
|
+
<span>{{ t('marketing.loyalty.stage', {
|
|
174
|
+
tier: label(tier.labels, tier.code),
|
|
175
|
+
threshold: money(tier.threshold),
|
|
176
|
+
percent: tier.bonusPercent,
|
|
177
|
+
}) }}</span>
|
|
178
|
+
<UBadge
|
|
179
|
+
v-if="tier.current"
|
|
180
|
+
size="sm"
|
|
181
|
+
variant="soft"
|
|
182
|
+
>
|
|
183
|
+
{{ t('marketing.loyalty.current') }}
|
|
184
|
+
</UBadge>
|
|
185
|
+
<UBadge
|
|
186
|
+
v-else-if="tier.reached"
|
|
187
|
+
size="sm"
|
|
188
|
+
variant="soft"
|
|
189
|
+
color="neutral"
|
|
190
|
+
>
|
|
191
|
+
{{ t('marketing.loyalty.reached') }}
|
|
192
|
+
</UBadge>
|
|
193
|
+
</li>
|
|
194
|
+
</ul>
|
|
195
|
+
|
|
196
|
+
<p class="text-xs text-muted">
|
|
197
|
+
{{ t('marketing.loyalty.rules') }}
|
|
198
|
+
<template v-if="progress.requiresNoOverdue">
|
|
199
|
+
{{ t('marketing.loyalty.rulesOverdue') }}
|
|
200
|
+
</template>
|
|
201
|
+
</p>
|
|
202
|
+
</section>
|
|
203
|
+
</template>
|
|
204
|
+
</div>
|
|
205
|
+
</template>
|