@revenexx/cover 0.19.0 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/app/api/marketing.ts +24 -0
  2. package/app/app.config.ts +22 -0
  3. package/app/components/account/loyalty/AccountLoyalty.vue +205 -0
  4. package/app/components/cart/view/CartSummaryPanel.vue +4 -0
  5. package/app/components/checkout/onepage/CheckoutSummarySection.vue +4 -0
  6. package/app/components/loyalty/hint/LoyaltyPerkHint.vue +28 -0
  7. package/app/components/newsletter/confirm/NewsletterConfirmation.vue +54 -0
  8. package/app/components/newsletter/preferences/NewsletterPreferenceCentre.vue +183 -0
  9. package/app/components/newsletter/state/NewsletterLinkRefusal.vue +45 -0
  10. package/app/components/review/form/ReviewForm.vue +211 -0
  11. package/app/composables/useCampaignAttribution.ts +120 -0
  12. package/app/composables/useCheckoutOnePage.ts +9 -0
  13. package/app/composables/useLoyaltyAccount.ts +79 -0
  14. package/app/composables/useMarketingConsent.ts +49 -0
  15. package/app/config/navigation.ts +1 -1
  16. package/app/config/quickActions.ts +1 -0
  17. package/app/pages/account/points.vue +26 -0
  18. package/app/pages/newsletter/confirm/[token].vue +23 -0
  19. package/app/pages/newsletter/preferences/[token].vue +24 -0
  20. package/app/pages/review/[token].vue +23 -0
  21. package/app/plugins/campaign-attribution.client.ts +47 -0
  22. package/app/shared/campaignAttribution.ts +281 -0
  23. package/app/shared/personalisation.ts +107 -0
  24. package/i18n/locales/de/account.json +3 -2
  25. package/i18n/locales/de/marketing.json +71 -0
  26. package/i18n/locales/en/account.json +3 -2
  27. package/i18n/locales/en/marketing.json +71 -0
  28. package/package.json +1 -1
  29. package/server/api/campaigns/touches.post.ts +42 -0
  30. package/server/api/cart/attribution.put.ts +31 -0
  31. package/server/api/loyalty/account.get.ts +27 -0
  32. package/server/api/newsletter/confirm/[token].post.ts +21 -0
  33. package/server/api/newsletter/preferences/[token].get.ts +14 -0
  34. package/server/api/newsletter/preferences/[token].post.ts +36 -0
  35. package/server/api/orders/index.post.ts +10 -1
  36. package/server/api/reviews/requests/[token].get.ts +14 -0
  37. package/server/api/reviews/submit/[token].post.ts +31 -0
  38. package/server/interfaces/cart.ts +6 -0
  39. package/server/interfaces/marketing.ts +150 -0
  40. package/server/services/ApiCartService.ts +16 -0
  41. package/server/services/ApiMarketingService.ts +292 -0
  42. package/server/services/MockMarketingService.ts +178 -0
  43. package/server/utils/marketingService.ts +63 -0
  44. package/server/utils/orderAttribution.ts +65 -0
  45. package/server/utils/personalisationViewer.ts +28 -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.
@@ -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>
@@ -3,6 +3,7 @@ import CartApprovalsPanel from "./CartApprovalsPanel.vue";
3
3
  import CartWorkflowPickerModal from "../actions/CartWorkflowPickerModal.vue";
4
4
  import PunchoutTransferAction from "../../punchout/action/PunchoutTransferAction.vue";
5
5
  import CartQuoteRequestModal from "../quote/CartQuoteRequestModal.vue";
6
+ import LoyaltyPerkHint from "../../loyalty/hint/LoyaltyPerkHint.vue";
6
7
 
7
8
  /**
8
9
  * Cart summary 2.0: the calculated totals block in document order, the
@@ -206,6 +207,9 @@ const trustItems = computed(() => {
206
207
  </template>
207
208
  </div>
208
209
 
210
+ <!-- The perks of the buyer's loyalty tier (RAD-293) -->
211
+ <LoyaltyPerkHint class="print:hidden" />
212
+
209
213
  <!-- What this cart has not earned yet. Nearest first, because the top of
210
214
  a list is what a buyer acts on. -->
211
215
  <div
@@ -1,5 +1,6 @@
1
1
  <script setup lang="ts">
2
2
  import CartApprovalsPanel from "../../cart/view/CartApprovalsPanel.vue";
3
+ import LoyaltyPerkHint from "../../loyalty/hint/LoyaltyPerkHint.vue";
3
4
 
4
5
  const { icon } = useIcons();
5
6
  const { getImage } = useProductImage();
@@ -66,6 +67,9 @@ async function handlePlaceOrder() {
66
67
  </h2>
67
68
  <USeparator />
68
69
 
70
+ <!-- The perks of the buyer's loyalty tier (RAD-293) -->
71
+ <LoyaltyPerkHint />
72
+
69
73
  <!-- Submit error -->
70
74
  <UAlert
71
75
  v-if="submitError"
@@ -0,0 +1,28 @@
1
+ <script setup lang="ts">
2
+ /**
3
+ * The perks of the buyer's loyalty tier where they matter — in the cart and
4
+ * the checkout (RAD-293, eltric "Premium": "frachtfrei ab 75 € statt 145 €").
5
+ * Only the words: the discount itself is a promotion with a tier condition
6
+ * and arrives through the cart calculation like every other one.
7
+ */
8
+ const { t } = useI18n();
9
+ const { icon } = useIcons();
10
+ const { perks } = useLoyaltyAccount();
11
+ </script>
12
+
13
+ <template>
14
+ <div
15
+ v-if="perks && perks.items.length"
16
+ class="flex items-start gap-1.5 text-xs text-highlighted"
17
+ data-loyalty-perk-hint
18
+ >
19
+ <UIcon
20
+ :name="icon('star')"
21
+ class="size-4 shrink-0 mt-px text-primary"
22
+ />
23
+ <p>
24
+ <span class="font-semibold">{{ t('marketing.loyalty.perkHint', { tier: perks.tier }) }}</span>
25
+ {{ perks.items.join(' · ') }}
26
+ </p>
27
+ </div>
28
+ </template>
@@ -0,0 +1,54 @@
1
+ <script setup lang="ts">
2
+ import { linkRefusalOf, marketingApi, type LinkRefusal } from "../../../api/marketing";
3
+ import NewsletterLinkRefusal from "../state/NewsletterLinkRefusal.vue";
4
+
5
+ /**
6
+ * The double opt-in confirmation (RAD-293). The link in the confirmation
7
+ * mail lands here; the page confirms in the browser, after it is shown —
8
+ * never while the server renders it — so a mail scanner that fetches the link
9
+ * without running it confirms nobody.
10
+ */
11
+ const props = defineProps<{ token: string }>();
12
+
13
+ const { t } = useI18n();
14
+
15
+ type State = "working" | "done" | "already" | LinkRefusal;
16
+ const state = ref<State>("working");
17
+
18
+ onMounted(async () => {
19
+ try {
20
+ const answer = await $fetch<{ alreadyConfirmed?: boolean }>(marketingApi.confirm(props.token), {
21
+ method: "POST",
22
+ body: { page_url: window.location.origin + window.location.pathname },
23
+ });
24
+ state.value = answer?.alreadyConfirmed ? "already" : "done";
25
+ }
26
+ catch (err) {
27
+ state.value = linkRefusalOf(err);
28
+ }
29
+ });
30
+ </script>
31
+
32
+ <template>
33
+ <div data-newsletter-confirmation>
34
+ <p
35
+ v-if="state === 'working'"
36
+ class="text-muted"
37
+ role="status"
38
+ >
39
+ {{ t('marketing.confirm.working') }}
40
+ </p>
41
+ <UiFeedbackEmptyState
42
+ v-else-if="state === 'done' || state === 'already'"
43
+ icon="success"
44
+ :title="t('marketing.confirm.doneTitle')"
45
+ :description="state === 'already' ? t('marketing.confirm.alreadyText') : t('marketing.confirm.doneText')"
46
+ role="status"
47
+ />
48
+ <NewsletterLinkRefusal
49
+ v-else
50
+ :refusal="state"
51
+ :expired-text="t('marketing.confirm.expiredText')"
52
+ />
53
+ </div>
54
+ </template>
@@ -0,0 +1,183 @@
1
+ <script setup lang="ts">
2
+ import { linkRefusalOf, marketingApi } from "../../../api/marketing";
3
+ import NewsletterLinkRefusal from "../state/NewsletterLinkRefusal.vue";
4
+
5
+ /**
6
+ * The preference centre (RAD-293), behind the personal link in every mail's
7
+ * footer: which of the shop's mails go to this address, with the wording each
8
+ * one was agreed under, and leaving all of them at once.
9
+ *
10
+ * Choosing a type that needs a double opt-in does not subscribe it: the
11
+ * recipient gets a confirmation mail and is told so, because a box that
12
+ * looks ticked but sends nothing is worse than an honest "check your inbox".
13
+ */
14
+ const props = defineProps<{ token: string }>();
15
+
16
+ interface PreferenceType {
17
+ code: string;
18
+ label: string;
19
+ description: string | null;
20
+ subscribed: boolean;
21
+ consentTextId: string | null;
22
+ consentText: string | null;
23
+ }
24
+
25
+ interface PreferenceView {
26
+ addressHint: string;
27
+ types: PreferenceType[];
28
+ }
29
+
30
+ interface SaveAnswer {
31
+ view: PreferenceView;
32
+ changes: { subscription_type: string | null; action: string }[];
33
+ }
34
+
35
+ const { t } = useI18n();
36
+
37
+ const { data, error, status } = await useFetch<PreferenceView>(() => marketingApi.preferences(props.token), {
38
+ key: `newsletter-preferences:${props.token}`,
39
+ });
40
+
41
+ const choices = reactive<Record<string, boolean>>({});
42
+ watch(data, (view) => {
43
+ for (const type of view?.types ?? []) {
44
+ choices[type.code] = type.subscribed;
45
+ }
46
+ }, { immediate: true });
47
+
48
+ const saving = ref(false);
49
+ const saveError = ref(false);
50
+ const outcome = ref<null | { kind: "saved"; requested: string[] } | { kind: "unsubscribed" }>(null);
51
+
52
+ const refusal = computed(() => (error.value ? linkRefusalOf(error.value) : null));
53
+
54
+ async function send(body: Record<string, unknown>): Promise<SaveAnswer | null> {
55
+ saving.value = true;
56
+ saveError.value = false;
57
+ try {
58
+ const answer = await $fetch<SaveAnswer>(marketingApi.preferences(props.token), { method: "POST", body });
59
+ data.value = answer.view;
60
+ return answer;
61
+ }
62
+ catch {
63
+ saveError.value = true;
64
+ return null;
65
+ }
66
+ finally {
67
+ saving.value = false;
68
+ }
69
+ }
70
+
71
+ async function save(): Promise<void> {
72
+ const types = data.value?.types ?? [];
73
+ const answer = await send({
74
+ choices: types.map(type => ({
75
+ subscription_type: type.code,
76
+ subscribed: choices[type.code] === true,
77
+ ...(type.consentTextId ? { consent_text_id: type.consentTextId } : {}),
78
+ })),
79
+ });
80
+ if (answer) {
81
+ const labelOf = (code: string | null) => types.find(type => type.code === code)?.label ?? code ?? "";
82
+ outcome.value = {
83
+ kind: "saved",
84
+ requested: answer.changes.filter(change => change.action === "requested").map(change => labelOf(change.subscription_type)),
85
+ };
86
+ }
87
+ }
88
+
89
+ async function unsubscribeAll(): Promise<void> {
90
+ if (await send({ unsubscribe_all: true })) {
91
+ outcome.value = { kind: "unsubscribed" };
92
+ }
93
+ }
94
+ </script>
95
+
96
+ <template>
97
+ <div data-newsletter-preferences>
98
+ <NewsletterLinkRefusal
99
+ v-if="refusal"
100
+ :refusal="refusal"
101
+ :expired-text="t('marketing.preferences.expiredText')"
102
+ />
103
+ <USkeleton
104
+ v-else-if="status === 'pending' && !data"
105
+ class="h-40 w-full"
106
+ />
107
+ <template v-else-if="data">
108
+ <p class="text-muted mb-6">
109
+ {{ t('marketing.preferences.intro', { address: data.addressHint }) }}
110
+ </p>
111
+
112
+ <UAlert
113
+ v-if="outcome"
114
+ class="mb-6"
115
+ color="success"
116
+ variant="soft"
117
+ role="status"
118
+ :title="outcome.kind === 'unsubscribed' ? t('marketing.preferences.unsubscribedAll') : t('marketing.preferences.saved')"
119
+ :description="outcome.kind === 'saved' && outcome.requested.length
120
+ ? t('marketing.preferences.requested', { types: outcome.requested.join(', ') })
121
+ : undefined"
122
+ />
123
+ <UAlert
124
+ v-if="saveError"
125
+ class="mb-6"
126
+ color="error"
127
+ variant="soft"
128
+ :title="t('marketing.link.errorTitle')"
129
+ :description="t('marketing.link.errorText')"
130
+ />
131
+
132
+ <p
133
+ v-if="!data.types.length"
134
+ class="text-muted"
135
+ >
136
+ {{ t('marketing.preferences.empty') }}
137
+ </p>
138
+ <form
139
+ v-else
140
+ class="space-y-5"
141
+ @submit.prevent="save"
142
+ >
143
+ <div
144
+ v-for="type in data.types"
145
+ :key="type.code"
146
+ class="border border-(--ui-border) rounded-lg p-4"
147
+ >
148
+ <UCheckbox
149
+ v-model="choices[type.code]"
150
+ :name="type.code"
151
+ :label="type.label"
152
+ :description="type.description ?? undefined"
153
+ />
154
+ <p
155
+ v-if="type.consentText"
156
+ class="text-xs text-muted mt-2 ms-6"
157
+ >
158
+ {{ type.consentText }}
159
+ </p>
160
+ </div>
161
+
162
+ <div class="flex flex-wrap items-center gap-3 pt-2">
163
+ <UButton
164
+ type="submit"
165
+ :loading="saving"
166
+ >
167
+ {{ t('marketing.preferences.save') }}
168
+ </UButton>
169
+ <UButton
170
+ type="button"
171
+ variant="link"
172
+ color="neutral"
173
+ :disabled="saving"
174
+ data-unsubscribe-all
175
+ @click="unsubscribeAll"
176
+ >
177
+ {{ t('marketing.preferences.unsubscribeAll') }}
178
+ </UButton>
179
+ </div>
180
+ </form>
181
+ </template>
182
+ </div>
183
+ </template>
@@ -0,0 +1,45 @@
1
+ <script setup lang="ts">
2
+ import type { LinkRefusal } from "../../../api/marketing";
3
+
4
+ /**
5
+ * What a personal link from a mail says when it cannot be used: unknown,
6
+ * expired, or the shop failed to ask. Shared by the newsletter and the review
7
+ * pages, which reach the visitor the same way.
8
+ */
9
+ const props = defineProps<{
10
+ refusal: LinkRefusal;
11
+ /** What to do about an expired link differs per page. */
12
+ expiredText: string;
13
+ }>();
14
+
15
+ const { t } = useI18n();
16
+ const { to } = useAppUrl();
17
+
18
+ const title = computed(() => {
19
+ if (props.refusal === "expired") return t("marketing.link.expiredTitle");
20
+ if (props.refusal === "unknown") return t("marketing.link.unknownTitle");
21
+ return t("marketing.link.errorTitle");
22
+ });
23
+ const description = computed(() => {
24
+ if (props.refusal === "expired") return props.expiredText;
25
+ if (props.refusal === "unknown") return t("marketing.link.unknownText");
26
+ return t("marketing.link.errorText");
27
+ });
28
+ </script>
29
+
30
+ <template>
31
+ <UiFeedbackEmptyState
32
+ :icon="refusal === 'error' ? 'error' : 'warning'"
33
+ :title="title"
34
+ :description="description"
35
+ :data-link-refusal="refusal"
36
+ >
37
+ <UButton
38
+ class="mt-6"
39
+ :to="to('/')"
40
+ variant="outline"
41
+ >
42
+ {{ t('marketing.link.toShop') }}
43
+ </UButton>
44
+ </UiFeedbackEmptyState>
45
+ </template>