@revenexx/cover 0.2.32 → 0.2.33
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.
|
@@ -26,7 +26,7 @@ const appConfig = useAppConfig();
|
|
|
26
26
|
const earliestDeliveryDays = computed<number>(() =>
|
|
27
27
|
Number(appConfig.checkout?.earliestDeliveryDays ?? 0));
|
|
28
28
|
|
|
29
|
-
const { data: rates } = useFetch<{
|
|
29
|
+
const { data: rates, status: ratesStatus } = useFetch<{
|
|
30
30
|
managed: boolean;
|
|
31
31
|
methods: DeliveryOption[];
|
|
32
32
|
defaultMethod: string | null;
|
|
@@ -61,6 +61,20 @@ const deliveryOptions = computed<DeliveryOption[]>(() =>
|
|
|
61
61
|
?? (liveShipping.value ? [] : profile.value?.availableDeliveryMethods)
|
|
62
62
|
?? []);
|
|
63
63
|
|
|
64
|
+
/**
|
|
65
|
+
* Skeleton while the AUTHORITY for this section is still answering — which is
|
|
66
|
+
* this lookup in live mode and the profile in mock mode, not the profile in
|
|
67
|
+
* both. Gating on the profile alone was why a live checkout showed an empty
|
|
68
|
+
* "no delivery method" box for as long as the rates were in flight: the
|
|
69
|
+
* profile had long since resolved, carrying nothing this section may use.
|
|
70
|
+
*
|
|
71
|
+
* A failed request drops out of the skeleton on purpose. Waiting forever on a
|
|
72
|
+
* spinner tells the buyer less than the empty state does.
|
|
73
|
+
*/
|
|
74
|
+
const optionsPending = computed(() => (liveShipping.value
|
|
75
|
+
? ratesStatus.value !== "error" && rates.value === null
|
|
76
|
+
: profileLoading.value));
|
|
77
|
+
|
|
64
78
|
/**
|
|
65
79
|
* Keep the SELECTION inside the offered list — the order is rejected outright
|
|
66
80
|
* if it is not (`422 Delivery method 'standard' is not available for this
|
|
@@ -99,7 +113,7 @@ watch([deliveryOptions, () => form.value.deliveryMethod], ([options, selected])
|
|
|
99
113
|
|
|
100
114
|
<!-- Loading skeleton -->
|
|
101
115
|
<div
|
|
102
|
-
v-if="
|
|
116
|
+
v-if="optionsPending"
|
|
103
117
|
class="grid grid-cols-1 sm:grid-cols-2 gap-3"
|
|
104
118
|
>
|
|
105
119
|
<div
|
|
@@ -161,7 +175,7 @@ watch([deliveryOptions, () => form.value.deliveryMethod], ([options, selected])
|
|
|
161
175
|
a live storefront no longer falls back to the demo profile, so an empty
|
|
162
176
|
list means the list could not be loaded. -->
|
|
163
177
|
<p
|
|
164
|
-
v-if="!
|
|
178
|
+
v-if="!optionsPending && !deliveryOptions.length"
|
|
165
179
|
class="text-sm text-muted"
|
|
166
180
|
>
|
|
167
181
|
{{ t('onepage.delivery.noneAvailable') }}
|
|
@@ -16,7 +16,7 @@ const billingCountry = computed(() => {
|
|
|
16
16
|
return profile.value?.addresses.find(a => a.id === addressId)?.country ?? "DE";
|
|
17
17
|
});
|
|
18
18
|
|
|
19
|
-
const { data: eligible } = useFetch<{
|
|
19
|
+
const { data: eligible, status: eligibleStatus } = useFetch<{
|
|
20
20
|
managed: boolean;
|
|
21
21
|
methods: PaymentOption[];
|
|
22
22
|
defaultMethod: string | null;
|
|
@@ -52,6 +52,11 @@ const paymentOptions = computed<PaymentOption[]>(() =>
|
|
|
52
52
|
?? (livePayments.value ? [] : profile.value?.availablePaymentMethods)
|
|
53
53
|
?? []);
|
|
54
54
|
|
|
55
|
+
/** The delivery section's twin: wait on this list, not on the profile. */
|
|
56
|
+
const optionsPending = computed(() => (livePayments.value
|
|
57
|
+
? eligibleStatus.value !== "error" && eligible.value === null
|
|
58
|
+
: profileLoading.value));
|
|
59
|
+
|
|
55
60
|
/**
|
|
56
61
|
* The same reconciliation the delivery section does, for the same reason: a
|
|
57
62
|
* selection outside the offered list is rejected by the orders app, and the
|
|
@@ -143,7 +148,7 @@ if (import.meta.client) {
|
|
|
143
148
|
|
|
144
149
|
<!-- Loading skeleton -->
|
|
145
150
|
<div
|
|
146
|
-
v-if="
|
|
151
|
+
v-if="optionsPending"
|
|
147
152
|
class="grid grid-cols-1 sm:grid-cols-3 gap-3"
|
|
148
153
|
>
|
|
149
154
|
<div
|
|
@@ -209,7 +214,7 @@ if (import.meta.client) {
|
|
|
209
214
|
a live storefront no longer falls back to the demo profile, so an empty
|
|
210
215
|
list means the list could not be loaded. -->
|
|
211
216
|
<p
|
|
212
|
-
v-if="!
|
|
217
|
+
v-if="!optionsPending && !paymentOptions.length"
|
|
213
218
|
class="text-sm text-muted"
|
|
214
219
|
>
|
|
215
220
|
{{ t('onepage.payment.noneAvailable') }}
|
|
@@ -132,6 +132,15 @@ export function useCheckoutOnePage() {
|
|
|
132
132
|
if (!f.paymentMethod) {
|
|
133
133
|
return false;
|
|
134
134
|
}
|
|
135
|
+
// A delivery method is required for the same reason a payment method
|
|
136
|
+
// is, and it became reachable when the profile stopped inventing one:
|
|
137
|
+
// in live mode the value stays empty until the shipping lookup answers,
|
|
138
|
+
// and an order placed in that window would carry no shipping line at
|
|
139
|
+
// all — the order route only validates a method that is actually set.
|
|
140
|
+
// The buyer sees the skeleton meanwhile, not a disabled-looking form.
|
|
141
|
+
if (!f.deliveryMethod) {
|
|
142
|
+
return false;
|
|
143
|
+
}
|
|
135
144
|
if (orderNumberRequired.value && !f.orderNumber.trim()) {
|
|
136
145
|
return false;
|
|
137
146
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@revenexx/cover",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.33",
|
|
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",
|
|
@@ -43,14 +43,54 @@ const GUEST_PROFILE: CheckoutProfile = {
|
|
|
43
43
|
* Checkout profile backed by the address book service: the checkout and
|
|
44
44
|
* /account/addresses read and write the same store — the mutable demo
|
|
45
45
|
* JSON in mock mode, the customers app's contact addresses in live mode
|
|
46
|
-
* (`addressService` registry key).
|
|
47
|
-
*
|
|
48
|
-
*
|
|
46
|
+
* (`addressService` registry key).
|
|
47
|
+
*
|
|
48
|
+
* THE DEMO METHODS ABOVE ARE MOCK-MODE ONLY. They used to ship in every mode
|
|
49
|
+
* as "fallbacks", on the reasoning that a live checkout resolves its methods
|
|
50
|
+
* via /api/shipping/rates and /api/payment/methods anyway — but a fallback
|
|
51
|
+
* nobody asked for is still data, and the form seeded itself from
|
|
52
|
+
* `defaultDeliveryMethod`. That put "standard" into an order on a tenant whose
|
|
53
|
+
* only method is `zone-deutschland`, and the orders app rejected it:
|
|
54
|
+
*
|
|
55
|
+
* 422 Delivery method 'standard' is not available for this order
|
|
56
|
+
*
|
|
57
|
+
* So each block now follows the registry key of the domain that owns it. In
|
|
58
|
+
* live mode the profile answers with EMPTY lists and EMPTY defaults, which is
|
|
59
|
+
* what makes the sections wait for their own authority instead of rendering
|
|
60
|
+
* something plausible and wrong.
|
|
49
61
|
*/
|
|
62
|
+
type MethodBlocks = Pick<
|
|
63
|
+
CheckoutProfile,
|
|
64
|
+
"availableDeliveryMethods" | "defaultDeliveryMethod" | "availablePaymentMethods" | "defaultPaymentMethod"
|
|
65
|
+
>;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Keep each demo block only while the domain that owns it still runs on mock
|
|
69
|
+
* data. The caller passes ITS OWN blocks rather than having them picked here:
|
|
70
|
+
* the guest profile deliberately offers a narrower payment list than an
|
|
71
|
+
* account does, and a helper that reached for BASE_PROFILE would hand guests
|
|
72
|
+
* "Bestellschein" and "Kostenstelle" — which is how the first version of this
|
|
73
|
+
* broke the guest checkout.
|
|
74
|
+
*/
|
|
75
|
+
function methodsFor(event: H3Event, mock: MethodBlocks): MethodBlocks {
|
|
76
|
+
const liveShipping = resolveShippingServiceKey(event) === "api";
|
|
77
|
+
const livePayments = resolvePaymentServiceKey(event) === "api";
|
|
78
|
+
|
|
79
|
+
return {
|
|
80
|
+
availableDeliveryMethods: liveShipping ? [] : mock.availableDeliveryMethods,
|
|
81
|
+
// "" and not a guess: the section adopts the first method its own
|
|
82
|
+
// lookup offers, and an empty value is what keeps the buyer from
|
|
83
|
+
// submitting before that answer has arrived.
|
|
84
|
+
defaultDeliveryMethod: liveShipping ? "" : mock.defaultDeliveryMethod,
|
|
85
|
+
availablePaymentMethods: livePayments ? [] : mock.availablePaymentMethods,
|
|
86
|
+
defaultPaymentMethod: livePayments ? "" : mock.defaultPaymentMethod,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
50
90
|
export class LocalFileCheckoutProfileService implements ICheckoutProfileService {
|
|
51
91
|
async getProfile(event: H3Event, userId: string | null): Promise<CheckoutProfile> {
|
|
52
92
|
if (!userId) {
|
|
53
|
-
return GUEST_PROFILE;
|
|
93
|
+
return { ...GUEST_PROFILE, ...methodsFor(event, GUEST_PROFILE) };
|
|
54
94
|
}
|
|
55
95
|
try {
|
|
56
96
|
const entries = await getAddressBookService(event).list(event);
|
|
@@ -70,6 +110,7 @@ export class LocalFileCheckoutProfileService implements ICheckoutProfileService
|
|
|
70
110
|
?? "";
|
|
71
111
|
return {
|
|
72
112
|
...BASE_PROFILE,
|
|
113
|
+
...methodsFor(event, BASE_PROFILE),
|
|
73
114
|
addresses,
|
|
74
115
|
defaultShippingAddressId: defaultOf("shipping"),
|
|
75
116
|
defaultBillingAddressId: defaultOf("billing"),
|
|
@@ -79,6 +120,7 @@ export class LocalFileCheckoutProfileService implements ICheckoutProfileService
|
|
|
79
120
|
// Address book unavailable — checkout still works via add-new.
|
|
80
121
|
return {
|
|
81
122
|
...BASE_PROFILE,
|
|
123
|
+
...methodsFor(event, BASE_PROFILE),
|
|
82
124
|
addresses: [],
|
|
83
125
|
defaultShippingAddressId: "",
|
|
84
126
|
defaultBillingAddressId: "",
|