@revenexx/cover 0.6.0 → 0.7.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/app.config.ts +12 -0
- package/app/components/account/address/AccountAddressView.vue +12 -1
- package/app/components/account/orderlists/AccountOrderListDetail.vue +16 -2
- package/app/components/account/orderlists/AccountOrderListsTable.vue +9 -1
- package/app/components/account/quotes/AccountQuoteDetail.vue +77 -3
- package/app/components/auth/AuthLoginPanel.vue +31 -0
- package/app/components/auth/AuthRegisterPanel.vue +71 -3
- package/app/components/cart/drawer/CartDrawer.vue +2 -1
- package/app/components/cart/item/CartItem.vue +4 -1
- package/app/components/cart/position/CartPosition.vue +7 -2
- package/app/components/cart/quote/CartQuoteRequestModal.vue +9 -0
- package/app/components/cart/view/CartSummaryPanel.vue +42 -5
- package/app/components/category/info/CategoryPrice.vue +4 -2
- package/app/components/layout/header/TopBar.vue +13 -4
- package/app/components/product/card/Compact.vue +4 -2
- package/app/components/product/detail/ProductDetailAddToCart.vue +8 -3
- package/app/composables/useCartLimits.ts +54 -0
- package/app/composables/useCartStore.ts +39 -6
- package/app/composables/useCartSummaryFormatting.ts +21 -3
- package/app/composables/useDeliveryPromise.ts +112 -0
- package/app/composables/useOrderListRules.ts +72 -0
- package/app/composables/useProduct.ts +5 -2
- package/app/composables/useRegistrationConfig.ts +27 -6
- package/app/composables/useShopSettings.ts +66 -0
- package/app/config/navigation.ts +16 -2
- package/app/interfaces/account/quotes.ts +20 -0
- package/app/interfaces/cart-calculation.ts +9 -1
- package/app/interfaces/shopSettings.ts +246 -0
- package/app/plugins/shop-settings.ts +52 -0
- package/i18n/locales/de/account.json +6 -0
- package/i18n/locales/de/auth.json +12 -0
- package/i18n/locales/de/cart.json +12 -3
- package/i18n/locales/de/common.json +3 -2
- package/i18n/locales/en/account.json +6 -0
- package/i18n/locales/en/auth.json +12 -0
- package/i18n/locales/en/cart.json +12 -3
- package/i18n/locales/en/common.json +3 -2
- package/nuxt.config.ts +0 -1
- package/package.json +1 -1
- package/server/api/account/quotes/[id]/decline.post.ts +1 -1
- package/server/api/account/quotes/[id]/order.post.ts +25 -5
- package/server/api/account/quotes/[id].get.ts +1 -1
- package/server/api/account/quotes.get.ts +10 -3
- package/server/api/auth/registration-config.get.ts +19 -33
- package/server/api/cart/calculate.post.ts +35 -18
- package/server/api/orders/index.post.ts +30 -0
- package/server/api/shop/settings.get.ts +14 -0
- package/server/config/shop/app-settings.json +54 -0
- package/server/interfaces/cartCalculation.ts +22 -0
- package/server/services/MockB2BContextService.ts +43 -1
- package/server/services/MockCartCalculationService.ts +117 -11
- package/server/utils/appSettings.ts +242 -0
- package/server/utils/livePrices.ts +24 -2
- package/server/utils/quotesService.ts +109 -16
- package/server/utils/shopSettings.ts +130 -0
package/app/app.config.ts
CHANGED
|
@@ -36,6 +36,11 @@ export default defineAppConfig({
|
|
|
36
36
|
// quotation request, priced in the Cockpit and ordered from the account.
|
|
37
37
|
quotesService: "mock",
|
|
38
38
|
themeService: "mock",
|
|
39
|
+
// What the shop was CONFIGURED to do — the platform apps' own tenant
|
|
40
|
+
// settings, read through the gateway's settings resolver. Mock answers
|
|
41
|
+
// nothing, and every surface then falls back to the default the owning app
|
|
42
|
+
// itself declares, so the demo and an untouched live tenant behave alike.
|
|
43
|
+
settingsService: "mock",
|
|
39
44
|
// How an ordered quote is paid. A quote is a negotiated B2B price, so the
|
|
40
45
|
// order it becomes goes on account; a storefront that takes quotes on
|
|
41
46
|
// another method names its code here.
|
|
@@ -102,6 +107,13 @@ export default defineAppConfig({
|
|
|
102
107
|
support: true,
|
|
103
108
|
},
|
|
104
109
|
},
|
|
110
|
+
// The shipping app states its order cut-off in UTC — it has to, it serves
|
|
111
|
+
// every market. Which zone a storefront quotes it back in is the shop's own
|
|
112
|
+
// decision, so it is named here. UTC by default: a shop that has not said
|
|
113
|
+
// shows the figure as the app holds it rather than one shifted by a guess.
|
|
114
|
+
shipping: {
|
|
115
|
+
cutoffTimezone: "UTC",
|
|
116
|
+
},
|
|
105
117
|
// The delivery step's calendar. A storefront whose goods need a lead time
|
|
106
118
|
// sets it here, so the date picker cannot offer a day the merchant could
|
|
107
119
|
// never hit — a catalogue with three weeks of lead time must not let a buyer
|
|
@@ -60,13 +60,24 @@ function toggleEdit(address: AccountAddress) {
|
|
|
60
60
|
editingIds[address.id] = !editingIds[address.id];
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
+
/**
|
|
64
|
+
* Whether one default per type is the rule, as the customers app holds it.
|
|
65
|
+
*
|
|
66
|
+
* On — the app's own default — marking an address as the default takes that
|
|
67
|
+
* mark off the others of its type, because the app would have done so anyway and
|
|
68
|
+
* a form showing two defaults is a form that lies about what it saved. Off, a
|
|
69
|
+
* merchant keeps several and the shop stops taking marks away.
|
|
70
|
+
*/
|
|
71
|
+
const { account: accountTerms } = useShopSettings();
|
|
72
|
+
const singleDefaultPerType = computed(() => accountTerms.value?.singleDefaultAddressPerType ?? true);
|
|
73
|
+
|
|
63
74
|
function onIsDefaultChange(address: AccountAddress, value: boolean) {
|
|
64
75
|
const state = formStates[address.id];
|
|
65
76
|
if (!state) {
|
|
66
77
|
return;
|
|
67
78
|
}
|
|
68
79
|
state.isDefault = value;
|
|
69
|
-
if (value) {
|
|
80
|
+
if (value && singleDefaultPerType.value) {
|
|
70
81
|
for (const other of addresses.value) {
|
|
71
82
|
if (other.id !== address.id && other.type === address.type) {
|
|
72
83
|
const otherState = formStates[other.id];
|
|
@@ -23,7 +23,15 @@ const { data: list, status, error, refresh } = useFetch<OrderList>(
|
|
|
23
23
|
{ key: `account-order-list:${props.listId}` },
|
|
24
24
|
);
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
// Two different permissions, because the orderlists app grants two. What is ON
|
|
27
|
+
// a shared list is the company's to change where the merchant allows it; the
|
|
28
|
+
// list itself — its name, its sharing, its existence — stays with its owner.
|
|
29
|
+
const { canEditPositions, canManage, maxPositions, cartMergeMode } = useOrderListRules();
|
|
30
|
+
const isOwner = computed(() => !!list.value && canManage(list.value));
|
|
31
|
+
const mayEditPositions = computed(() => !!list.value && canEditPositions(list.value));
|
|
32
|
+
const positionsFull = computed(() =>
|
|
33
|
+
maxPositions.value !== null && (list.value?.positions.length ?? 0) >= maxPositions.value,
|
|
34
|
+
);
|
|
27
35
|
const listValue = computed(() =>
|
|
28
36
|
Math.round((list.value?.positions ?? []).reduce((sum, p) => sum + p.price * p.quantity, 0) * 100) / 100,
|
|
29
37
|
);
|
|
@@ -102,6 +110,12 @@ async function addToCart(): Promise<void> {
|
|
|
102
110
|
if (!list.value) {
|
|
103
111
|
return;
|
|
104
112
|
}
|
|
113
|
+
// Replace or append, as the orderlists app says. A buyer whose list IS the
|
|
114
|
+
// order wants the cart to be the list; one whose list is a set of extras
|
|
115
|
+
// wants it added. Guessing loses a cart or double-orders half of it.
|
|
116
|
+
if (cartMergeMode.value === "replace") {
|
|
117
|
+
cart.clearCart();
|
|
118
|
+
}
|
|
105
119
|
let added = 0;
|
|
106
120
|
for (const position of list.value.positions) {
|
|
107
121
|
const ok = cart.addItem({
|
|
@@ -250,7 +264,7 @@ async function addToCart(): Promise<void> {
|
|
|
250
264
|
</p>
|
|
251
265
|
</div>
|
|
252
266
|
<div
|
|
253
|
-
v-if="
|
|
267
|
+
v-if="mayEditPositions"
|
|
254
268
|
class="flex items-center gap-1 shrink-0"
|
|
255
269
|
>
|
|
256
270
|
<UButton
|
|
@@ -82,6 +82,12 @@ const columns = computed<TableColumn<OrderList>[]>(() => [
|
|
|
82
82
|
const formatDate = (value: string) => d(new Date(value), { dateStyle: "medium" });
|
|
83
83
|
|
|
84
84
|
/* ---- create / edit modal ------------------------------------------ */
|
|
85
|
+
// How many lists a buyer may keep, and what a new one starts as, are the
|
|
86
|
+
// orderlists app's answers. The app refuses a list past its ceiling with an
|
|
87
|
+
// error; a shop that does not know the ceiling offers a button that fails.
|
|
88
|
+
const { maxLists, defaultKind } = useOrderListRules();
|
|
89
|
+
const listsFull = computed(() => maxLists.value !== null && (lists.value?.length ?? 0) >= maxLists.value);
|
|
90
|
+
|
|
85
91
|
const modalOpen = ref(false);
|
|
86
92
|
const formName = ref("");
|
|
87
93
|
const formKind = ref<OrderListKind>("shopping");
|
|
@@ -90,7 +96,7 @@ const saving = ref(false);
|
|
|
90
96
|
|
|
91
97
|
function openCreate(): void {
|
|
92
98
|
formName.value = "";
|
|
93
|
-
formKind.value = "shopping";
|
|
99
|
+
formKind.value = defaultKind.value ?? "shopping";
|
|
94
100
|
formPublic.value = false;
|
|
95
101
|
modalOpen.value = true;
|
|
96
102
|
}
|
|
@@ -165,6 +171,8 @@ async function addToCart(list: OrderList): Promise<void> {
|
|
|
165
171
|
color="primary"
|
|
166
172
|
tabindex="0"
|
|
167
173
|
:icon="icon('plus')"
|
|
174
|
+
:disabled="listsFull"
|
|
175
|
+
:title="listsFull ? t('orderLists.limitReached', { max: maxLists }) : undefined"
|
|
168
176
|
:label="t('orderLists.add')"
|
|
169
177
|
@click="openCreate"
|
|
170
178
|
/>
|
|
@@ -51,7 +51,11 @@ const stateHint = computed(() => {
|
|
|
51
51
|
const q = quote.value;
|
|
52
52
|
if (!q) return null;
|
|
53
53
|
if (q.canOrder) {
|
|
54
|
-
|
|
54
|
+
// About to lapse, as the quotes app decides "about to". A buyer who is not
|
|
55
|
+
// warned has to ask for the same price a second time.
|
|
56
|
+
return q.expiresSoon
|
|
57
|
+
? { color: "warning" as const, text: t("quotes.detail.hint.expiresSoon", { date: formatDate(q.validUntil) }) }
|
|
58
|
+
: { color: "success" as const, text: t("quotes.detail.hint.ready", { date: formatDate(q.validUntil) }) };
|
|
55
59
|
}
|
|
56
60
|
switch (q.status) {
|
|
57
61
|
case "requested":
|
|
@@ -70,6 +74,53 @@ const stateHint = computed(() => {
|
|
|
70
74
|
|
|
71
75
|
const seller = computed(() => quote.value?.trail.filter(e => e.actor === "seller" && e.body) ?? []);
|
|
72
76
|
|
|
77
|
+
/* ---- what may be taken ------------------------------------------------- */
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* The positions nobody has decided yet — the only ones a buyer can act on.
|
|
81
|
+
*/
|
|
82
|
+
const openLines = computed(() => quote.value?.lines.filter(line => line.decision === "open") ?? []);
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Which of them the buyer picked.
|
|
86
|
+
*
|
|
87
|
+
* Offered only where the quotes app allows a basket to be taken apart, and only
|
|
88
|
+
* where there is more than one thing to choose between: a checkbox beside a
|
|
89
|
+
* single position asks a question with one answer.
|
|
90
|
+
*/
|
|
91
|
+
const selectable = computed(() =>
|
|
92
|
+
Boolean(quote.value?.partialAcceptance) && quote.value?.canOrder === true && openLines.value.length > 1,
|
|
93
|
+
);
|
|
94
|
+
const selected = ref<string[]>([]);
|
|
95
|
+
|
|
96
|
+
// Everything open, until the buyer says otherwise. Starting empty would show a
|
|
97
|
+
// total of nothing and an order button that does nothing.
|
|
98
|
+
watch(openLines, (lines) => {
|
|
99
|
+
selected.value = lines.map(line => line.id);
|
|
100
|
+
}, { immediate: true });
|
|
101
|
+
|
|
102
|
+
const isSelected = (id: string) => selected.value.includes(id);
|
|
103
|
+
function toggleLine(id: string): void {
|
|
104
|
+
selected.value = isSelected(id)
|
|
105
|
+
? selected.value.filter(lineId => lineId !== id)
|
|
106
|
+
: [...selected.value, id];
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** A partial pick: some of what is open, not all of it. */
|
|
110
|
+
const partialPick = computed(() =>
|
|
111
|
+
selectable.value && selected.value.length > 0 && selected.value.length < openLines.value.length,
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
/** What the buyer is about to order — their pick, or the whole quote. */
|
|
115
|
+
const selectedTotal = computed(() => {
|
|
116
|
+
if (!partialPick.value) {
|
|
117
|
+
return quote.value?.grandTotal ?? 0;
|
|
118
|
+
}
|
|
119
|
+
return openLines.value
|
|
120
|
+
.filter(line => isSelected(line.id))
|
|
121
|
+
.reduce((sum, line) => sum + line.lineTotal, 0);
|
|
122
|
+
});
|
|
123
|
+
|
|
73
124
|
/* ---- order ------------------------------------------------------------- */
|
|
74
125
|
const orderOpen = ref(false);
|
|
75
126
|
const customerOrderNumber = ref("");
|
|
@@ -80,6 +131,9 @@ async function submitOrder(): Promise<void> {
|
|
|
80
131
|
const result = await order({
|
|
81
132
|
...(customerOrderNumber.value.trim() ? { customerOrderNumber: customerOrderNumber.value.trim() } : {}),
|
|
82
133
|
...(orderNote.value.trim() ? { orderNote: orderNote.value.trim() } : {}),
|
|
134
|
+
// Only a real subset travels: everything open says the same thing as
|
|
135
|
+
// nothing, and the app has a simpler path for it.
|
|
136
|
+
...(partialPick.value ? { lineIds: selected.value } : {}),
|
|
83
137
|
});
|
|
84
138
|
orderOpen.value = false;
|
|
85
139
|
toast.add({
|
|
@@ -198,7 +252,14 @@ async function submitDecline(): Promise<void> {
|
|
|
198
252
|
v-for="line in quote.lines"
|
|
199
253
|
:key="line.id"
|
|
200
254
|
class="px-4 sm:px-5 py-3 flex flex-wrap items-center gap-x-4 gap-y-1"
|
|
255
|
+
:class="selectable && line.decision === 'open' && !isSelected(line.id) ? 'opacity-55' : ''"
|
|
201
256
|
>
|
|
257
|
+
<UCheckbox
|
|
258
|
+
v-if="selectable && line.decision === 'open'"
|
|
259
|
+
:model-value="isSelected(line.id)"
|
|
260
|
+
:aria-label="t('quotes.detail.selectPosition', { name: line.name })"
|
|
261
|
+
@update:model-value="toggleLine(line.id)"
|
|
262
|
+
/>
|
|
202
263
|
<div class="min-w-0 flex-1">
|
|
203
264
|
<p class="text-sm font-medium text-highlighted">
|
|
204
265
|
{{ line.name }}
|
|
@@ -339,10 +400,21 @@ async function submitDecline(): Promise<void> {
|
|
|
339
400
|
v-if="quote.canOrder"
|
|
340
401
|
color="primary"
|
|
341
402
|
:icon="icon('cart')"
|
|
342
|
-
:
|
|
403
|
+
:disabled="selectable && selected.length === 0"
|
|
404
|
+
:label="partialPick
|
|
405
|
+
? t('quotes.actions.orderSelected', { count: selected.length, total: formatCurrency(selectedTotal) })
|
|
406
|
+
: t('quotes.actions.order', { total: formatCurrency(quote.grandTotal) })"
|
|
343
407
|
@click="orderOpen = true"
|
|
344
408
|
/>
|
|
345
409
|
</div>
|
|
410
|
+
<!-- What taking part of a quote leaves behind. The rest stays open and
|
|
411
|
+
can be ordered later, which is a second order and worth saying. -->
|
|
412
|
+
<p
|
|
413
|
+
v-if="partialPick"
|
|
414
|
+
class="text-xs text-muted text-right"
|
|
415
|
+
>
|
|
416
|
+
{{ t('quotes.detail.partialHint', { remaining: openLines.length - selected.length }) }}
|
|
417
|
+
</p>
|
|
346
418
|
|
|
347
419
|
<!-- Order modal -->
|
|
348
420
|
<UModal
|
|
@@ -352,7 +424,9 @@ async function submitDecline(): Promise<void> {
|
|
|
352
424
|
<template #body>
|
|
353
425
|
<div class="space-y-4">
|
|
354
426
|
<p class="text-sm text-default">
|
|
355
|
-
{{
|
|
427
|
+
{{ partialPick
|
|
428
|
+
? t('quotes.order.introSelected', { count: selected.length, total: formatCurrency(selectedTotal) })
|
|
429
|
+
: t('quotes.order.intro', { total: formatCurrency(quote.grandTotal) }) }}
|
|
356
430
|
</p>
|
|
357
431
|
<UFormField :label="t('quotes.order.customerOrderNumber')">
|
|
358
432
|
<UInput
|
|
@@ -15,6 +15,23 @@ const localePath = useLocalePath();
|
|
|
15
15
|
const auth = useAuthStore();
|
|
16
16
|
const { loading, error } = storeToRefs(auth);
|
|
17
17
|
|
|
18
|
+
/**
|
|
19
|
+
* How this merchant lets a buyer sign in, as the customers app decides.
|
|
20
|
+
*
|
|
21
|
+
* Only the password is built here. Where the merchant has switched it off and
|
|
22
|
+
* put a mailed link or a mailed code in its place, this form cannot sign anybody
|
|
23
|
+
* in — so it says how to get in instead of offering a field whose submission
|
|
24
|
+
* the app refuses. Building those two ways in is its own work (RX-798).
|
|
25
|
+
*/
|
|
26
|
+
const { signIn } = useShopSettings();
|
|
27
|
+
const passwordOffered = computed(() => signIn.value?.password ?? true);
|
|
28
|
+
const mailedWayIn = computed(() => {
|
|
29
|
+
if (signIn.value?.magicLink) {
|
|
30
|
+
return "magicLink" as const;
|
|
31
|
+
}
|
|
32
|
+
return signIn.value?.emailOtp ? "emailOtp" as const : null;
|
|
33
|
+
});
|
|
34
|
+
|
|
18
35
|
const state = reactive<LoginFormState>({
|
|
19
36
|
email: "",
|
|
20
37
|
password: "",
|
|
@@ -40,7 +57,21 @@ async function onSubmit(): Promise<void> {
|
|
|
40
57
|
{{ t('auth.login.existingCustomer') }}
|
|
41
58
|
</h2>
|
|
42
59
|
|
|
60
|
+
<!-- The merchant signs buyers in some other way. Saying so beats a
|
|
61
|
+
password field that cannot work. -->
|
|
62
|
+
<UAlert
|
|
63
|
+
v-if="!passwordOffered"
|
|
64
|
+
class="mt-6"
|
|
65
|
+
color="info"
|
|
66
|
+
variant="soft"
|
|
67
|
+
:title="t('auth.login.passwordDisabled.title')"
|
|
68
|
+
:description="mailedWayIn
|
|
69
|
+
? t(`auth.login.passwordDisabled.${mailedWayIn}`)
|
|
70
|
+
: t('auth.login.passwordDisabled.contact')"
|
|
71
|
+
/>
|
|
72
|
+
|
|
43
73
|
<FormKit
|
|
74
|
+
v-if="passwordOffered"
|
|
44
75
|
type="form"
|
|
45
76
|
:actions="false"
|
|
46
77
|
class="space-y-4 pt-6"
|
|
@@ -21,8 +21,35 @@ const { loading, error } = storeToRefs(auth);
|
|
|
21
21
|
// When B2B self-registration is off we show a notice instead of the form, and
|
|
22
22
|
// when a VAT id is mandatory we make that field required. Defaults open.
|
|
23
23
|
const { data: registration } = useRegistrationConfig();
|
|
24
|
+
const { signIn } = useShopSettings();
|
|
24
25
|
const registrationEnabled = computed(() => registration.value?.b2b !== false);
|
|
25
26
|
const vatRequired = computed(() => registration.value?.vatRequired === true);
|
|
27
|
+
/**
|
|
28
|
+
* Whether a new account is signed in at once, or waits for the merchant.
|
|
29
|
+
*
|
|
30
|
+
* Where it waits, signing in straight after registering is a request the
|
|
31
|
+
* customers app refuses — there is no account yet, only an application. So the
|
|
32
|
+
* shop does not try, and says so instead: an applicant left staring at a login
|
|
33
|
+
* error has no way of knowing they did everything right.
|
|
34
|
+
*/
|
|
35
|
+
const needsApproval = computed(() => registration.value?.mode === "approval_required");
|
|
36
|
+
const applied = ref(false);
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* How far the customers app checks a VAT id.
|
|
40
|
+
*
|
|
41
|
+
* `format` checks the shape, which the form can check too — so it does, and the
|
|
42
|
+
* buyer is told at the field rather than by a rejected submission. `vies` checks
|
|
43
|
+
* it against the European register, which this form cannot do and must not
|
|
44
|
+
* pretend to: it says the id will be verified instead of implying it passed.
|
|
45
|
+
*/
|
|
46
|
+
const vatValidation = computed(() => registration.value?.vatValidation ?? "off");
|
|
47
|
+
/**
|
|
48
|
+
* What confirming the address means here, as the customers app decides it.
|
|
49
|
+
* `required_for_login` is the one worth saying out loud: the account exists but
|
|
50
|
+
* cannot be used until the buyer opens the mail.
|
|
51
|
+
*/
|
|
52
|
+
const emailConfirmation = computed(() => signIn.value?.emailVerification ?? "off");
|
|
26
53
|
|
|
27
54
|
const state = reactive<RegisterFormState>({
|
|
28
55
|
mode: "new",
|
|
@@ -58,6 +85,22 @@ const salutationItems = computed(() => [
|
|
|
58
85
|
})),
|
|
59
86
|
]);
|
|
60
87
|
|
|
88
|
+
// The VAT field's rules: mandatory where the app demands one, and shaped where
|
|
89
|
+
// the app checks the shape. Two letters and at least two more characters is the
|
|
90
|
+
// shape every European id shares — deliberately loose, because the app holds the
|
|
91
|
+
// real rule and a stricter pattern here would refuse ids the app accepts.
|
|
92
|
+
const VAT_SHAPE = "/^[A-Za-z]{2}[A-Za-z0-9 .-]{2,}$/";
|
|
93
|
+
const vatRules = computed(() => {
|
|
94
|
+
const rules: string[] = [];
|
|
95
|
+
if (state.mode === "new" && vatRequired.value) {
|
|
96
|
+
rules.push("required");
|
|
97
|
+
}
|
|
98
|
+
if (vatValidation.value !== "off") {
|
|
99
|
+
rules.push(`matches:${VAT_SHAPE}`);
|
|
100
|
+
}
|
|
101
|
+
return rules.length ? rules.join("|") : undefined;
|
|
102
|
+
});
|
|
103
|
+
|
|
61
104
|
function buildProfile(): RegistrationProfile {
|
|
62
105
|
return {
|
|
63
106
|
mode: state.mode,
|
|
@@ -91,6 +134,11 @@ async function onSubmit(): Promise<void> {
|
|
|
91
134
|
name: `${state.firstName} ${state.lastName}`.trim(),
|
|
92
135
|
profile: buildProfile(),
|
|
93
136
|
});
|
|
137
|
+
if (needsApproval.value) {
|
|
138
|
+
// Nothing to sign in to yet. The form gives way to the answer.
|
|
139
|
+
applied.value = true;
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
94
142
|
await auth.login({
|
|
95
143
|
email: state.email,
|
|
96
144
|
password: state.password,
|
|
@@ -157,8 +205,20 @@ async function onSubmit(): Promise<void> {
|
|
|
157
205
|
</fieldset>
|
|
158
206
|
</div>
|
|
159
207
|
|
|
208
|
+
<!-- Sent, and waiting on the merchant. -->
|
|
209
|
+
<UAlert
|
|
210
|
+
v-if="applied"
|
|
211
|
+
color="success"
|
|
212
|
+
variant="soft"
|
|
213
|
+
:icon="icon('success')"
|
|
214
|
+
:title="t('auth.register.applied.title')"
|
|
215
|
+
:description="emailConfirmation !== 'off'
|
|
216
|
+
? t('auth.register.applied.confirmEmail', { email: state.email })
|
|
217
|
+
: t('auth.register.applied.description', { email: state.email })"
|
|
218
|
+
/>
|
|
219
|
+
|
|
160
220
|
<FormKit
|
|
161
|
-
v-if="registrationEnabled"
|
|
221
|
+
v-if="registrationEnabled && !applied"
|
|
162
222
|
type="form"
|
|
163
223
|
:actions="false"
|
|
164
224
|
@submit="onSubmit"
|
|
@@ -186,8 +246,10 @@ async function onSubmit(): Promise<void> {
|
|
|
186
246
|
type="text"
|
|
187
247
|
:label="t('auth.register.fields2.vatId')"
|
|
188
248
|
name="vatId"
|
|
189
|
-
:validation="
|
|
190
|
-
:help="
|
|
249
|
+
:validation="vatRules"
|
|
250
|
+
:help="vatValidation === 'vies'
|
|
251
|
+
? t('auth.register.fields2.vatIdVerified')
|
|
252
|
+
: t('auth.register.fields2.vatIdHint')"
|
|
191
253
|
placeholder="DE123456789"
|
|
192
254
|
/>
|
|
193
255
|
<FormKit
|
|
@@ -356,7 +418,13 @@ async function onSubmit(): Promise<void> {
|
|
|
356
418
|
outer-class="rounded-lg bg-default shadow-sm p-6"
|
|
357
419
|
/>
|
|
358
420
|
|
|
421
|
+
<!-- Only where the merchant actually reviews applications. Telling
|
|
422
|
+
every applicant they will be vetted, when the customers app signs
|
|
423
|
+
them in the moment they submit, is a promise of a wait that never
|
|
424
|
+
happens — and it costs the merchant the buyer who decides to come
|
|
425
|
+
back once they have been "approved". -->
|
|
359
426
|
<UAlert
|
|
427
|
+
v-if="needsApproval"
|
|
360
428
|
color="info"
|
|
361
429
|
variant="soft"
|
|
362
430
|
:icon="icon('info')"
|
|
@@ -4,7 +4,8 @@ const { icon } = useIcons();
|
|
|
4
4
|
const { t } = useI18n();
|
|
5
5
|
const { to } = useAppUrl();
|
|
6
6
|
const { isOpen, items, isEmpty } = storeToRefs(useCartStore());
|
|
7
|
-
|
|
7
|
+
// Net or gross: the prices app's basis, the market's override. Not the shop's.
|
|
8
|
+
const { taxIncludedPrices } = useShopSettings();
|
|
8
9
|
</script>
|
|
9
10
|
|
|
10
11
|
<template>
|
|
@@ -35,7 +35,10 @@ const displayPrice = computed(() =>
|
|
|
35
35
|
const formattedPrice = computed(() =>
|
|
36
36
|
displayPrice.value.toLocaleString(locale as string, { style: "currency", currency: currency.value }),
|
|
37
37
|
);
|
|
38
|
-
|
|
38
|
+
// The article's own stock ceiling and the carts app's line ceiling, whichever
|
|
39
|
+
// binds first — the same pair the buy box and the store apply.
|
|
40
|
+
const { lineCeiling } = useCartLimits();
|
|
41
|
+
const maxOrderQuantity = computed(() => lineCeiling(props.item.maxOrderQuantity));
|
|
39
42
|
const localePath = useLocalePath();
|
|
40
43
|
const fallbackCategorySlug = ref<string | null>(null);
|
|
41
44
|
const fallbackSubcategorySlug = ref<string | null>(null);
|
|
@@ -89,8 +89,13 @@ function commitInput(): void {
|
|
|
89
89
|
applyQuantity(parsed);
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
+
// A position nobody can order reads as a warning, and one missing a cost centre
|
|
93
|
+
// too: both are things the buyer has to act on before the cart will go through.
|
|
94
|
+
// Everything else is a note.
|
|
92
95
|
const hintColor = (type: string) =>
|
|
93
|
-
type === "missing-cost-center"
|
|
96
|
+
type === "missing-cost-center" || type === "not-orderable"
|
|
97
|
+
? "warning" as const
|
|
98
|
+
: "info" as const;
|
|
94
99
|
</script>
|
|
95
100
|
|
|
96
101
|
<template>
|
|
@@ -108,7 +113,7 @@ const hintColor = (type: string) =>
|
|
|
108
113
|
:key="hint.type"
|
|
109
114
|
:color="hintColor(hint.type)"
|
|
110
115
|
variant="soft"
|
|
111
|
-
:icon="icon(hint.type === '
|
|
116
|
+
:icon="icon(hintColor(hint.type) === 'warning' ? 'warning' : 'info')"
|
|
112
117
|
:title="t(hint.messageKey, hint.params ?? {})"
|
|
113
118
|
:ui="{ root: 'py-2', title: 'text-xs' }"
|
|
114
119
|
/>
|
|
@@ -17,6 +17,9 @@ const props = defineProps<{
|
|
|
17
17
|
|
|
18
18
|
const { icon } = useIcons();
|
|
19
19
|
const { t } = useI18n();
|
|
20
|
+
// How long a quote will be valid — the quotes app's `default_validity_days`.
|
|
21
|
+
const { quotes: quoteTermsForRequest } = useShopSettings();
|
|
22
|
+
const validityDays = computed(() => quoteTermsForRequest.value?.defaultValidityDays ?? 0);
|
|
20
23
|
const localePath = useLocalePath();
|
|
21
24
|
const toast = useToast();
|
|
22
25
|
const cart = useCartStore();
|
|
@@ -122,6 +125,12 @@ async function submit(): Promise<void> {
|
|
|
122
125
|
<li>{{ t('cart.quote.steps.price') }}</li>
|
|
123
126
|
<li>{{ t('cart.quote.steps.notify') }}</li>
|
|
124
127
|
<li>{{ t('cart.quote.steps.order') }}</li>
|
|
128
|
+
<!-- How long the answer will stand, as the quotes app decides it.
|
|
129
|
+
A buyer who does not know reads "we will get back to you" as
|
|
130
|
+
an open-ended promise. -->
|
|
131
|
+
<li v-if="validityDays > 0">
|
|
132
|
+
{{ t('cart.quote.steps.validity', { days: validityDays }) }}
|
|
133
|
+
</li>
|
|
125
134
|
</ul>
|
|
126
135
|
</div>
|
|
127
136
|
</template>
|
|
@@ -11,6 +11,7 @@ import CartQuoteRequestModal from "../quote/CartQuoteRequestModal.vue";
|
|
|
11
11
|
*/
|
|
12
12
|
const { icon } = useIcons();
|
|
13
13
|
const { t } = useI18n();
|
|
14
|
+
const toast = useToast();
|
|
14
15
|
const { to } = useAppUrl();
|
|
15
16
|
const cart = useCartStore();
|
|
16
17
|
const actions = useCartActions();
|
|
@@ -25,12 +26,35 @@ const { formatCurrency } = useCartSummaryFormatting();
|
|
|
25
26
|
|
|
26
27
|
const codeInput = ref("");
|
|
27
28
|
|
|
29
|
+
// What the promotions app allows: how many codes a cart may carry, and whether a
|
|
30
|
+
// buyer with no account gets discounts at all. Offering a field the engine will
|
|
31
|
+
// refuse is worse than not offering it.
|
|
32
|
+
const { promotions } = useShopSettings();
|
|
33
|
+
const authStore = useAuthStore();
|
|
34
|
+
const maxCodes = computed(() => promotions.value?.maxCodesPerCart ?? 0);
|
|
35
|
+
const codesFull = computed(() => maxCodes.value > 0 && cart.voucherCodes.length >= maxCodes.value);
|
|
36
|
+
const codesOffered = computed(() =>
|
|
37
|
+
Boolean(authStore.user) || (promotions.value?.anonymousAllowed ?? true),
|
|
38
|
+
);
|
|
39
|
+
|
|
28
40
|
function applyCode(): void {
|
|
29
41
|
const code = codeInput.value.trim();
|
|
30
42
|
if (!code) {
|
|
31
43
|
return;
|
|
32
44
|
}
|
|
33
|
-
cart.addVoucherCode(code)
|
|
45
|
+
if (!cart.addVoucherCode(code)) {
|
|
46
|
+
// Refused, and the buyer is told why rather than watching the field empty
|
|
47
|
+
// itself: a code that vanishes reads as a code that was accepted.
|
|
48
|
+
toast.add({
|
|
49
|
+
title: codesFull.value
|
|
50
|
+
? t("cart.summary.voucherLimit", { max: maxCodes.value })
|
|
51
|
+
: t("cart.summary.voucherDuplicate"),
|
|
52
|
+
color: "warning",
|
|
53
|
+
icon: icon("warning"),
|
|
54
|
+
duration: 3000,
|
|
55
|
+
});
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
34
58
|
codeInput.value = "";
|
|
35
59
|
}
|
|
36
60
|
|
|
@@ -111,9 +135,18 @@ const TRUST_ITEMS = [
|
|
|
111
135
|
] as const;
|
|
112
136
|
|
|
113
137
|
const appConfig = useAppConfig();
|
|
138
|
+
// The delivery line states the merchant's own cut-off and lead time — the same
|
|
139
|
+
// sentence the header carries, and for the same reason: the shop used to say
|
|
140
|
+
// four o'clock out of a figure of its own while the merchant shipped by another.
|
|
141
|
+
// A merchant who has named no cut-off gets no such line.
|
|
142
|
+
const { deliveryCutoffLabel } = useDeliveryPromise();
|
|
143
|
+
const trustLabel = (id: string, key: string): string | null =>
|
|
144
|
+
id === "delivery" ? deliveryCutoffLabel.value : t(key);
|
|
114
145
|
const trustItems = computed(() => {
|
|
115
146
|
const configured = appConfig.cart?.trust as Record<string, boolean> | undefined;
|
|
116
|
-
return TRUST_ITEMS
|
|
147
|
+
return TRUST_ITEMS
|
|
148
|
+
.filter(item => configured?.[item.id] !== false)
|
|
149
|
+
.filter(item => trustLabel(item.id, item.key) !== null);
|
|
117
150
|
});
|
|
118
151
|
</script>
|
|
119
152
|
|
|
@@ -163,19 +196,23 @@ const trustItems = computed(() => {
|
|
|
163
196
|
that is worth nothing still shows: removing it silently would
|
|
164
197
|
leave the buyer wondering where their discount went.
|
|
165
198
|
-->
|
|
166
|
-
<div
|
|
199
|
+
<div
|
|
200
|
+
v-if="codesOffered"
|
|
201
|
+
class="flex flex-col gap-2"
|
|
202
|
+
>
|
|
167
203
|
<div class="flex gap-2">
|
|
168
204
|
<UInput
|
|
169
205
|
v-model="codeInput"
|
|
170
206
|
:placeholder="t('cart.summary.voucherPlaceholder')"
|
|
171
207
|
size="sm"
|
|
172
208
|
class="flex-1"
|
|
209
|
+
:disabled="codesFull"
|
|
173
210
|
@keyup.enter="applyCode"
|
|
174
211
|
/>
|
|
175
212
|
<UButton
|
|
176
213
|
size="sm"
|
|
177
214
|
variant="subtle"
|
|
178
|
-
:disabled="!codeInput.trim()"
|
|
215
|
+
:disabled="!codeInput.trim() || codesFull"
|
|
179
216
|
@click="applyCode"
|
|
180
217
|
>
|
|
181
218
|
{{ t('cart.summary.voucherApply') }}
|
|
@@ -290,7 +327,7 @@ const trustItems = computed(() => {
|
|
|
290
327
|
:name="icon(item.token)"
|
|
291
328
|
class="size-4 shrink-0 text-primary"
|
|
292
329
|
/>
|
|
293
|
-
{{
|
|
330
|
+
{{ trustLabel(item.id, item.key) }}
|
|
294
331
|
</li>
|
|
295
332
|
</ul>
|
|
296
333
|
</div>
|
|
@@ -3,7 +3,9 @@ import { getDisplayUnitPrice, getPriceTiers, getPriceWithOptionalTax } from "../
|
|
|
3
3
|
import type { ProductList } from "../../../interfaces/product-list";
|
|
4
4
|
|
|
5
5
|
const { t } = useI18n();
|
|
6
|
-
const { public: { locale
|
|
6
|
+
const { public: { locale } } = useRuntimeConfig();
|
|
7
|
+
// Net or gross: the prices app's basis, the market's override. Not the shop's.
|
|
8
|
+
const { taxIncludedPrices } = useShopSettings();
|
|
7
9
|
const currency = useDisplayCurrency();
|
|
8
10
|
|
|
9
11
|
function formatPrice(price: number) {
|
|
@@ -26,7 +28,7 @@ const displayPrice = computed<number | null>(() => {
|
|
|
26
28
|
return null;
|
|
27
29
|
}
|
|
28
30
|
|
|
29
|
-
return getPriceWithOptionalTax(basePrice, props.product.tax.rate, taxIncludedPrices);
|
|
31
|
+
return getPriceWithOptionalTax(basePrice, props.product.tax.rate, taxIncludedPrices.value);
|
|
30
32
|
});
|
|
31
33
|
</script>
|
|
32
34
|
|
|
@@ -9,6 +9,15 @@ const topbarQuickLinks = computed(() => liveQuickLinks.value ?? (appConfig.topba
|
|
|
9
9
|
const { icon } = useIcons();
|
|
10
10
|
const { t } = useI18n();
|
|
11
11
|
const localePath = useLocalePath();
|
|
12
|
+
|
|
13
|
+
// The delivery lines state figures the shipping app owns. One whose figure this
|
|
14
|
+
// merchant never set carries no promise and is not rendered.
|
|
15
|
+
const { uspLabel } = useDeliveryPromise();
|
|
16
|
+
const usps = computed(() =>
|
|
17
|
+
topbarUsps
|
|
18
|
+
.map(usp => ({ usp, label: uspLabel(usp) }))
|
|
19
|
+
.filter((entry): entry is { usp: typeof entry.usp; label: string } => entry.label !== null),
|
|
20
|
+
);
|
|
12
21
|
</script>
|
|
13
22
|
|
|
14
23
|
<template>
|
|
@@ -22,15 +31,15 @@ const localePath = useLocalePath();
|
|
|
22
31
|
class="flex-1 hidden lg:flex items-center gap-6"
|
|
23
32
|
>
|
|
24
33
|
<li
|
|
25
|
-
v-for="
|
|
26
|
-
:key="usp.labelKey"
|
|
34
|
+
v-for="entry in usps"
|
|
35
|
+
:key="entry.usp.labelKey"
|
|
27
36
|
class="flex items-center gap-2"
|
|
28
37
|
>
|
|
29
38
|
<UIcon
|
|
30
|
-
:name="icon(usp.icon)"
|
|
39
|
+
:name="icon(entry.usp.icon)"
|
|
31
40
|
class="size-4 shrink-0 text-primary"
|
|
32
41
|
/>
|
|
33
|
-
{{
|
|
42
|
+
{{ entry.label }}
|
|
34
43
|
</li>
|
|
35
44
|
</ul>
|
|
36
45
|
<ul
|
|
@@ -29,7 +29,9 @@ const props = withDefaults(defineProps<{
|
|
|
29
29
|
|
|
30
30
|
const { t } = useI18n();
|
|
31
31
|
const { icon } = useIcons();
|
|
32
|
-
const { public: { locale
|
|
32
|
+
const { public: { locale } } = useRuntimeConfig();
|
|
33
|
+
// Net or gross: the prices app's basis, the market's override. Not the shop's.
|
|
34
|
+
const { taxIncludedPrices } = useShopSettings();
|
|
33
35
|
const currency = useDisplayCurrency();
|
|
34
36
|
|
|
35
37
|
const { url } = useProductCard(() => props.product);
|
|
@@ -49,7 +51,7 @@ const displayPrice = computed<number | null>(() => {
|
|
|
49
51
|
if (basePrice === null) {
|
|
50
52
|
return null;
|
|
51
53
|
}
|
|
52
|
-
return getPriceWithOptionalTax(basePrice, props.product.tax.rate, taxIncludedPrices);
|
|
54
|
+
return getPriceWithOptionalTax(basePrice, props.product.tax.rate, taxIncludedPrices.value);
|
|
53
55
|
});
|
|
54
56
|
|
|
55
57
|
function formatPrice(price: number): string {
|