@revenexx/cover 0.2.24 → 0.2.26
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/app.config.ts +7 -0
- package/app/components/checkout/onepage/CheckoutDeliverySection.vue +48 -6
- package/app/components/checkout/onepage/CheckoutPaymentSection.vue +30 -1
- package/app/interfaces/delivery.ts +8 -1
- package/i18n/locales/de/checkout.json +3 -0
- package/i18n/locales/en/checkout.json +3 -0
- package/package.json +1 -1
- package/server/api/shipping/rates.post.ts +7 -2
package/app/app.config.ts
CHANGED
|
@@ -80,6 +80,13 @@ export default defineAppConfig({
|
|
|
80
80
|
support: true,
|
|
81
81
|
},
|
|
82
82
|
},
|
|
83
|
+
// The delivery step's calendar. A storefront whose goods need a lead time
|
|
84
|
+
// sets it here, so the date picker cannot offer a day the merchant could
|
|
85
|
+
// never hit — a catalogue with three weeks of lead time must not let a buyer
|
|
86
|
+
// request tomorrow.
|
|
87
|
+
checkout: {
|
|
88
|
+
earliestDeliveryDays: 0,
|
|
89
|
+
},
|
|
83
90
|
ui: {
|
|
84
91
|
icons: nuxtUiIcons(DEFAULT_ICON_WEIGHT),
|
|
85
92
|
},
|
|
@@ -17,11 +17,27 @@ const shippingCountry = computed(() => {
|
|
|
17
17
|
return address?.country ?? "DE";
|
|
18
18
|
});
|
|
19
19
|
|
|
20
|
+
/**
|
|
21
|
+
* The first day the merchant could realistically deliver, in days from today.
|
|
22
|
+
* Offering an earlier one is a request nobody can honour — see
|
|
23
|
+
* `checkout.earliestDeliveryDays`.
|
|
24
|
+
*/
|
|
25
|
+
const appConfig = useAppConfig();
|
|
26
|
+
const earliestDeliveryDays = computed<number>(() =>
|
|
27
|
+
Number(appConfig.checkout?.earliestDeliveryDays ?? 0));
|
|
28
|
+
|
|
20
29
|
const { data: rates } = useFetch<{
|
|
21
30
|
managed: boolean;
|
|
22
31
|
methods: DeliveryOption[];
|
|
23
32
|
defaultMethod: string | null;
|
|
24
33
|
}>("/api/shipping/rates", {
|
|
34
|
+
// STABLE KEY, deliberately. Without one Nuxt derives it from the request —
|
|
35
|
+
// body included — and the body carries the cart total, which is 0 while the
|
|
36
|
+
// server renders and the real sum once the store has hydrated. Two different
|
|
37
|
+
// keys, so the client looked up a payload entry that did not exist, found
|
|
38
|
+
// nothing, and never refetched either: on a hard page load the section fell
|
|
39
|
+
// back to the demo profile and offered methods this merchant does not have.
|
|
40
|
+
key: "checkout-shipping-rates",
|
|
25
41
|
method: "POST",
|
|
26
42
|
body: computed(() => ({
|
|
27
43
|
amount: cartStore.subtotal,
|
|
@@ -31,8 +47,19 @@ const { data: rates } = useFetch<{
|
|
|
31
47
|
default: () => null,
|
|
32
48
|
});
|
|
33
49
|
|
|
50
|
+
/**
|
|
51
|
+
* The demo profile is a MOCK-MODE fallback and must never surface on a live
|
|
52
|
+
* storefront. When the live list is missing — the request failed, or it raced
|
|
53
|
+
* a cart that was still syncing on a hard page load — falling through to it
|
|
54
|
+
* offered methods this merchant does not have: "Express 9,90 €" on a shop that
|
|
55
|
+
* ships by quote, "Bestellschein" and "Kostenstelle" on a tenant that only
|
|
56
|
+
* knows invoice and its PSP. An empty list is honest; sample data is not.
|
|
57
|
+
*/
|
|
58
|
+
const liveShipping = computed(() => appConfig.shippingService === "api");
|
|
34
59
|
const deliveryOptions = computed<DeliveryOption[]>(() =>
|
|
35
|
-
rates.value?.methods
|
|
60
|
+
rates.value?.methods
|
|
61
|
+
?? (liveShipping.value ? [] : profile.value?.availableDeliveryMethods)
|
|
62
|
+
?? []);
|
|
36
63
|
|
|
37
64
|
// A method that became unavailable (country switch, free-above flip)
|
|
38
65
|
// resets the selection to the first available one.
|
|
@@ -93,7 +120,10 @@ watch(deliveryOptions, (options) => {
|
|
|
93
120
|
<p class="text-sm font-semibold text-highlighted">
|
|
94
121
|
{{ option.label }}
|
|
95
122
|
</p>
|
|
96
|
-
<p
|
|
123
|
+
<p
|
|
124
|
+
v-if="option.eta"
|
|
125
|
+
class="text-xs text-muted mt-0.5"
|
|
126
|
+
>
|
|
97
127
|
{{ option.eta }} {{ t('onepage.delivery.businessDays') }}
|
|
98
128
|
</p>
|
|
99
129
|
</div>
|
|
@@ -104,12 +134,24 @@ watch(deliveryOptions, (options) => {
|
|
|
104
134
|
/>
|
|
105
135
|
</div>
|
|
106
136
|
<p class="text-sm font-medium text-highlighted tabular-nums mt-2">
|
|
107
|
-
{{ option.
|
|
108
|
-
? t('onepage.delivery.
|
|
109
|
-
:
|
|
137
|
+
{{ option.quoteRequired
|
|
138
|
+
? t('onepage.delivery.onRequest')
|
|
139
|
+
: option.price === 0
|
|
140
|
+
? t('onepage.delivery.free')
|
|
141
|
+
: formatCurrency(option.price) }}
|
|
110
142
|
</p>
|
|
111
143
|
</button>
|
|
112
144
|
</div>
|
|
145
|
+
|
|
146
|
+
<!-- Nothing to choose from. Says so rather than leaving a blank box:
|
|
147
|
+
a live storefront no longer falls back to the demo profile, so an empty
|
|
148
|
+
list means the list could not be loaded. -->
|
|
149
|
+
<p
|
|
150
|
+
v-if="!profileLoading && !deliveryOptions.length"
|
|
151
|
+
class="text-sm text-muted"
|
|
152
|
+
>
|
|
153
|
+
{{ t('onepage.delivery.noneAvailable') }}
|
|
154
|
+
</p>
|
|
113
155
|
</fieldset>
|
|
114
156
|
|
|
115
157
|
<!-- Requested date + delivery note side by side -->
|
|
@@ -122,7 +164,7 @@ watch(deliveryOptions, (options) => {
|
|
|
122
164
|
<FormKit
|
|
123
165
|
type="datepicker"
|
|
124
166
|
:value="form.requestedDate"
|
|
125
|
-
:min-days="
|
|
167
|
+
:min-days="earliestDeliveryDays"
|
|
126
168
|
:max-days="100"
|
|
127
169
|
disable-weekends
|
|
128
170
|
@input="(value: unknown) => { form.requestedDate = String(value ?? ''); validateField('requestedDate'); }"
|
|
@@ -21,6 +21,13 @@ const { data: eligible } = useFetch<{
|
|
|
21
21
|
methods: PaymentOption[];
|
|
22
22
|
defaultMethod: string | null;
|
|
23
23
|
}>("/api/payment/methods", {
|
|
24
|
+
// STABLE KEY, deliberately. Without one Nuxt derives it from the request —
|
|
25
|
+
// body included — and the body carries the cart total, which is 0 while the
|
|
26
|
+
// server renders and the real sum once the store has hydrated. Two different
|
|
27
|
+
// keys, so the client looked up a payload entry that did not exist, found
|
|
28
|
+
// nothing, and never refetched either: on a hard page load the section fell
|
|
29
|
+
// back to the demo profile and offered methods this merchant does not have.
|
|
30
|
+
key: "checkout-payment-methods",
|
|
24
31
|
method: "POST",
|
|
25
32
|
body: computed(() => ({
|
|
26
33
|
amount: cartStore.total,
|
|
@@ -30,8 +37,20 @@ const { data: eligible } = useFetch<{
|
|
|
30
37
|
default: () => null,
|
|
31
38
|
});
|
|
32
39
|
|
|
40
|
+
/**
|
|
41
|
+
* The demo profile is a MOCK-MODE fallback and must never surface on a live
|
|
42
|
+
* storefront. When the live list is missing — the request failed, or it raced
|
|
43
|
+
* a cart that was still syncing on a hard page load — falling through to it
|
|
44
|
+
* offered methods this merchant does not have: "Express 9,90 €" on a shop that
|
|
45
|
+
* ships by quote, "Bestellschein" and "Kostenstelle" on a tenant that only
|
|
46
|
+
* knows invoice and its PSP. An empty list is honest; sample data is not.
|
|
47
|
+
*/
|
|
48
|
+
const appConfig = useAppConfig();
|
|
49
|
+
const livePayments = computed(() => appConfig.paymentService === "api");
|
|
33
50
|
const paymentOptions = computed<PaymentOption[]>(() =>
|
|
34
|
-
eligible.value?.methods
|
|
51
|
+
eligible.value?.methods
|
|
52
|
+
?? (livePayments.value ? [] : profile.value?.availablePaymentMethods)
|
|
53
|
+
?? []);
|
|
35
54
|
|
|
36
55
|
// A method that became ineligible (country switch, order value) resets
|
|
37
56
|
// the selection to the first available one.
|
|
@@ -179,6 +198,16 @@ if (import.meta.client) {
|
|
|
179
198
|
>
|
|
180
199
|
{{ fieldErrors.paymentMethod }}
|
|
181
200
|
</p>
|
|
201
|
+
|
|
202
|
+
<!-- Nothing to choose from. Says so rather than leaving a blank box:
|
|
203
|
+
a live storefront no longer falls back to the demo profile, so an empty
|
|
204
|
+
list means the list could not be loaded. -->
|
|
205
|
+
<p
|
|
206
|
+
v-if="!profileLoading && !paymentOptions.length"
|
|
207
|
+
class="text-sm text-muted"
|
|
208
|
+
>
|
|
209
|
+
{{ t('onepage.payment.noneAvailable') }}
|
|
210
|
+
</p>
|
|
182
211
|
</fieldset>
|
|
183
212
|
|
|
184
213
|
<!-- Method-specific fields -->
|
|
@@ -8,6 +8,13 @@ export interface DeliveryOption {
|
|
|
8
8
|
method: DeliveryMethod;
|
|
9
9
|
label: string;
|
|
10
10
|
price: number;
|
|
11
|
-
/** Delivery estimate in business days, e.g. "1–2". */
|
|
11
|
+
/** Delivery estimate in business days, e.g. "1–2". Empty when unknown. */
|
|
12
12
|
eta: string;
|
|
13
|
+
/**
|
|
14
|
+
* The method applies but carries no automatic price — the merchant quotes
|
|
15
|
+
* it. Set when a matrix declines above its `quote_above` measure, e.g. a
|
|
16
|
+
* consignment past the parcel weight limit. `price` is meaningless then and
|
|
17
|
+
* must not be shown as a number.
|
|
18
|
+
*/
|
|
19
|
+
quoteRequired?: boolean;
|
|
13
20
|
}
|
|
@@ -113,6 +113,8 @@
|
|
|
113
113
|
"method": "Liefermethode",
|
|
114
114
|
"businessDays": "Werktage",
|
|
115
115
|
"free": "Kostenlos",
|
|
116
|
+
"onRequest": "Auf Anfrage",
|
|
117
|
+
"noneAvailable": "Für diesen Warenkorb konnte keine Versandart ermittelt werden. Bitte kontaktieren Sie uns.",
|
|
116
118
|
"requestedDate": "Gewünschtes Lieferdatum",
|
|
117
119
|
"deliveryNote": "Lieferhinweis",
|
|
118
120
|
"deliveryNotePlaceholder": "Besondere Lieferanweisungen...",
|
|
@@ -123,6 +125,7 @@
|
|
|
123
125
|
},
|
|
124
126
|
"payment": {
|
|
125
127
|
"method": "Zahlungsmethode",
|
|
128
|
+
"noneAvailable": "Keine Zahlungsart verfügbar. Bitte kontaktieren Sie uns.",
|
|
126
129
|
"poNumber": "Bestellnummer",
|
|
127
130
|
"poNumberPlaceholder": "Bestellnummer eingeben...",
|
|
128
131
|
"costCenter": "Kostenstelle",
|
|
@@ -113,6 +113,8 @@
|
|
|
113
113
|
"method": "Delivery Method",
|
|
114
114
|
"businessDays": "business days",
|
|
115
115
|
"free": "Free",
|
|
116
|
+
"onRequest": "On request",
|
|
117
|
+
"noneAvailable": "No shipping method could be determined for this basket. Please contact us.",
|
|
116
118
|
"requestedDate": "Requested Delivery Date",
|
|
117
119
|
"deliveryNote": "Delivery Note",
|
|
118
120
|
"deliveryNotePlaceholder": "Special delivery instructions...",
|
|
@@ -123,6 +125,7 @@
|
|
|
123
125
|
},
|
|
124
126
|
"payment": {
|
|
125
127
|
"method": "Payment Method",
|
|
128
|
+
"noneAvailable": "No payment method available. Please contact us.",
|
|
126
129
|
"poNumber": "PO Number",
|
|
127
130
|
"poNumberPlaceholder": "Enter PO number...",
|
|
128
131
|
"costCenter": "Cost Center",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@revenexx/cover",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.26",
|
|
4
4
|
"description": "Cover \u2014 revenexx design system for Nuxt. Distributed as a Nuxt layer: generic UI components, theming tokens and stores shared by the demo shop, custom storefronts and the Blokkli theme.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./nuxt.config.ts",
|
|
@@ -6,9 +6,11 @@ interface ApiShippingRate {
|
|
|
6
6
|
code: string;
|
|
7
7
|
name: string;
|
|
8
8
|
labels: Record<string, string> | null;
|
|
9
|
-
|
|
9
|
+
/** Null when the rate is quote-only — see `quote_required`. */
|
|
10
|
+
price: number | null;
|
|
10
11
|
eta_days_min: number | null;
|
|
11
12
|
eta_days_max: number | null;
|
|
13
|
+
quote_required?: boolean;
|
|
12
14
|
}
|
|
13
15
|
|
|
14
16
|
function formatEta(rate: ApiShippingRate): string {
|
|
@@ -55,8 +57,11 @@ export default defineEventHandler(async (event) => {
|
|
|
55
57
|
const methods: DeliveryOption[] = rates.map(rate => ({
|
|
56
58
|
method: rate.code,
|
|
57
59
|
label: rate.labels?.[locale] ?? rate.name,
|
|
58
|
-
|
|
60
|
+
// A quote-only rate has no price. Zero would be read as free, so the
|
|
61
|
+
// number is kept out of the way and the flag carries the meaning.
|
|
62
|
+
price: rate.price ?? 0,
|
|
59
63
|
eta: formatEta(rate),
|
|
64
|
+
...(rate.quote_required ? { quoteRequired: true } : {}),
|
|
60
65
|
}));
|
|
61
66
|
|
|
62
67
|
return {
|