@revenexx/cover 0.7.1 → 0.11.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/account.ts +4 -0
- package/app/api/forms.ts +1 -0
- package/app/app.config.ts +17 -12
- package/app/assets/css/cover.css +9 -0
- package/app/components/RevenexxForm.vue +84 -12
- package/app/components/account/AccountShell.vue +18 -0
- package/app/components/account/AccountSidebar.vue +2 -5
- package/app/components/account/approvals/AccountPendingApprovals.vue +178 -0
- package/app/components/account/dashboard/AccountDashboardKpis.vue +74 -34
- package/app/components/account/dashboard/AccountDashboardQuickActions.vue +24 -6
- package/app/components/account/orderlists/AccountOrderListDetail.vue +47 -4
- package/app/components/account/orders/AccountOrderDetail.vue +186 -1
- package/app/components/account/organization/AccountOrganization.vue +3 -1
- package/app/components/account/payments/AccountPayments.vue +129 -0
- package/app/components/account/quotes/AccountQuoteDetail.vue +48 -16
- package/app/components/account/team/AccountTeam.vue +32 -7
- package/app/components/auth/AuthForgotPasswordPanel.vue +9 -4
- package/app/components/auth/AuthLoginPanel.vue +136 -18
- package/app/components/auth/AuthMagicLinkPanel.vue +70 -0
- package/app/components/cart/actions/CartSaveToListModal.vue +5 -0
- package/app/components/cart/item/CartItem.vue +17 -75
- package/app/components/cart/position/CartPosition.vue +17 -30
- package/app/components/cart/quote/CartQuoteRequestModal.vue +9 -1
- package/app/components/cart/view/CartSummaryPanel.vue +54 -0
- package/app/components/category/view/GridView.vue +10 -1
- package/app/components/category/view/ListView.vue +10 -1
- package/app/components/checkout/confirmation/CheckoutConfirmationActions.vue +2 -0
- package/app/components/checkout/onepage/CheckoutAddressSection.vue +4 -4
- package/app/components/checkout/onepage/CheckoutDeliverySection.vue +31 -3
- package/app/components/checkout/onepage/CheckoutGate.vue +10 -7
- package/app/components/checkout/onepage/CheckoutOnePageView.vue +1 -1
- package/app/components/checkout/onepage/CheckoutPaymentSection.vue +10 -0
- package/app/components/checkout/onepage/CheckoutSummarySection.vue +7 -1
- package/app/components/form/FormPage.vue +40 -0
- package/app/components/layout/Region.vue +13 -0
- package/app/components/layout/footer/Footer.vue +8 -0
- package/app/components/layout/header/AppBar.vue +11 -4
- package/app/components/layout/header/MainNav.vue +26 -4
- package/app/components/layout/header/MobileMenu.vue +12 -0
- package/app/components/listing/ListingResults.vue +3 -1
- package/app/components/product/card/Compact.vue +10 -1
- package/app/components/product/detail/ProductDetailAddToCart.vue +51 -18
- package/app/components/product/detail/ProductDetailIdentity.vue +1 -1
- package/app/components/product/detail/ProductDetailPriceRequest.vue +39 -0
- package/app/components/product/detail/ProductDetailSaveToList.vue +10 -0
- package/app/components/product/detail/ProductDetailView.vue +57 -0
- package/app/composables/useAccountDashboard.ts +0 -10
- package/app/composables/useAccountHold.ts +45 -0
- package/app/composables/useAccountNavigation.ts +35 -0
- package/app/composables/useAccountPayments.ts +21 -0
- package/app/composables/useAccountQuotes.ts +15 -2
- package/app/composables/useAuthStore.ts +84 -2
- package/app/composables/useAuthoredForms.ts +26 -0
- package/app/composables/useAvailableOffers.ts +42 -0
- package/app/composables/useCategoryListing.ts +6 -0
- package/app/composables/useCheckoutOnePage.ts +21 -2
- package/app/composables/useGuestOrdering.ts +28 -0
- package/app/composables/useMasterDataEditable.ts +45 -7
- package/app/composables/useOrderListRules.ts +21 -1
- package/app/composables/usePendingApprovals.ts +37 -0
- package/app/composables/useProductCard.ts +29 -2
- package/app/composables/useProductListing.ts +79 -0
- package/app/composables/useQuantityStepper.ts +90 -0
- package/app/composables/useQuickActions.ts +35 -0
- package/app/composables/useRoleGrants.ts +32 -0
- package/app/composables/useSearchListing.ts +4 -0
- package/app/composables/useThemeEvents.ts +144 -0
- package/app/config/accountDashboard.ts +26 -0
- package/app/config/icons.ts +2 -0
- package/app/config/navigation.ts +2 -2
- package/app/config/quickActions.ts +40 -5
- package/app/formkit.config.ts +14 -0
- package/app/interfaces/account/approvals.ts +37 -0
- package/app/interfaces/account/dashboard.ts +2 -0
- package/app/interfaces/account/order-list.ts +29 -0
- package/app/interfaces/account/order-lists.ts +9 -0
- package/app/interfaces/account/payments.ts +48 -0
- package/app/interfaces/auth.ts +24 -2
- package/app/interfaces/b2b.ts +8 -8
- package/app/interfaces/offers.ts +35 -0
- package/app/interfaces/quantity-stepper.ts +17 -0
- package/app/interfaces/shopSettings.ts +77 -0
- package/app/layouts/default.vue +19 -10
- package/app/layouts/focus.vue +28 -7
- package/app/middleware/checkout-guard.ts +7 -1
- package/app/pages/punchout/transfer.vue +22 -0
- package/app/plugins/account-hold.client.ts +20 -0
- package/app/plugins/shop-settings.ts +27 -12
- package/app/plugins/theme-events.client.ts +132 -0
- package/app/shared/themeEvents.ts +445 -0
- package/i18n/locales/de/account.json +87 -0
- package/i18n/locales/de/auth.json +30 -0
- package/i18n/locales/de/cart.json +9 -1
- package/i18n/locales/de/checkout.json +4 -2
- package/i18n/locales/de/common.json +4 -0
- package/i18n/locales/de/cover.json +44 -0
- package/i18n/locales/de/editor.json +47 -1
- package/i18n/locales/de/forms.json +27 -0
- package/i18n/locales/en/account.json +87 -0
- package/i18n/locales/en/auth.json +30 -0
- package/i18n/locales/en/cart.json +9 -1
- package/i18n/locales/en/checkout.json +4 -2
- package/i18n/locales/en/common.json +4 -0
- package/i18n/locales/en/cover.json +44 -0
- package/i18n/locales/en/editor.json +47 -1
- package/i18n/locales/en/forms.json +27 -0
- package/nuxt.config.ts +15 -1
- package/package.json +6 -2
- package/server/api/account/address/[id].delete.ts +1 -1
- package/server/api/account/address/[id].put.ts +1 -1
- package/server/api/account/address/index.post.ts +1 -1
- package/server/api/account/order-lists/[id].get.ts +37 -3
- package/server/api/account/orders/[id]/cancel.post.ts +54 -0
- package/server/api/account/orders/[id]/messages.get.ts +63 -0
- package/server/api/account/orders/[id]/messages.post.ts +44 -0
- package/server/api/account/orders/[id]/return.post.ts +1 -0
- package/server/api/account/orders/[id].get.ts +1 -1
- package/server/api/account/organization.put.ts +1 -1
- package/server/api/account/payments.get.ts +54 -0
- package/server/api/account/pending-approvals/[id]/approve.post.ts +10 -0
- package/server/api/account/pending-approvals/[id]/decline.post.ts +10 -0
- package/server/api/account/pending-approvals/index.get.ts +26 -0
- package/server/api/account/profile.get.ts +3 -1
- package/server/api/account/profile.put.ts +1 -1
- package/server/api/account/quotes/[id]/decline.post.ts +35 -6
- package/server/api/account/team/[id].put.ts +1 -1
- package/server/api/account/team.post.ts +1 -1
- package/server/api/auth/login.post.ts +6 -0
- package/server/api/auth/magic-link.post.ts +32 -0
- package/server/api/auth/magic-link.put.ts +35 -0
- package/server/api/auth/otp.post.ts +33 -0
- package/server/api/auth/otp.put.ts +33 -0
- package/server/api/carts/[id]/activate.post.ts +1 -0
- package/server/api/carts/[id]/index.delete.ts +1 -0
- package/server/api/carts/[id]/index.put.ts +1 -0
- package/server/api/carts/[id]/items.post.ts +1 -0
- package/server/api/checkout/profile.get.ts +6 -3
- package/server/api/forms/[slug]/submit.post.ts +27 -16
- package/server/api/forms/[slug].get.ts +9 -1
- package/server/api/forms/index.get.ts +23 -0
- package/server/api/orders/index.post.ts +41 -0
- package/server/api/promotions/available.post.ts +37 -0
- package/server/api/quick-actions.get.ts +6 -38
- package/server/config/account/organization.json +0 -4
- package/server/config/shop/app-settings.json +4 -0
- package/server/data/forms/authored.json +337 -0
- package/server/interfaces/forms.ts +51 -0
- package/server/middleware/buyer-principal.ts +18 -0
- package/server/routes/punchout/start.get.ts +2 -2
- package/server/services/ApiAddressBookService.ts +43 -1
- package/server/services/ApiAuthService.ts +101 -10
- package/server/services/ApiCartService.ts +3 -10
- package/server/services/ApiFormsService.ts +56 -0
- package/server/services/ApiOrganizationService.ts +7 -2
- package/server/services/ApiTeamService.ts +93 -21
- package/server/services/MockB2BContextService.ts +1 -5
- package/server/services/MockFormsService.ts +63 -0
- package/server/utils/accountPayments.ts +45 -0
- package/server/utils/appSettings.ts +69 -4
- package/server/utils/buyerIdentity.ts +168 -0
- package/server/utils/cartOwnership.ts +27 -0
- package/server/utils/forms.ts +62 -14
- package/server/utils/formsService.ts +29 -0
- package/server/utils/liveOrderLists.ts +50 -23
- package/server/utils/liveOrders.ts +65 -24
- package/server/utils/livePrices.ts +7 -15
- package/server/utils/masterData.ts +60 -11
- package/server/utils/passwordlessSignIn.ts +82 -0
- package/server/utils/pendingApprovals.ts +175 -0
- package/server/utils/procurementCheckout.ts +2 -0
- package/server/utils/promotionsService.ts +90 -0
- package/server/utils/quickActionCatalogue.ts +53 -0
- package/server/utils/quotesService.ts +15 -0
- package/server/utils/revenexxSdk.ts +116 -2
- package/server/utils/shopSettings.ts +35 -4
|
@@ -35,6 +35,40 @@ const quantityInvalid = computed(() => quantity.value < 1);
|
|
|
35
35
|
const quantityExceeded = computed(() =>
|
|
36
36
|
currentCartQuantity.value + quantity.value > effectiveMaxQuantity.value,
|
|
37
37
|
);
|
|
38
|
+
/**
|
|
39
|
+
* What this buy box may still add: the line ceiling less what the cart already
|
|
40
|
+
* holds. Never below 1 — a line that is already full keeps the stepper at 1 and
|
|
41
|
+
* lets add-to-cart explain why it refuses.
|
|
42
|
+
*/
|
|
43
|
+
const remainingQuantity = computed(() =>
|
|
44
|
+
Math.max(1, effectiveMaxQuantity.value - currentCartQuantity.value),
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
// Same stepper rules as the cart page and the mini-cart; here the quantity is
|
|
48
|
+
// the amount to add, not a cart line.
|
|
49
|
+
const {
|
|
50
|
+
inputValue: quantityInput,
|
|
51
|
+
notice: quantityNotice,
|
|
52
|
+
canDecrease,
|
|
53
|
+
decrease,
|
|
54
|
+
increase,
|
|
55
|
+
onInput: onQuantityInput,
|
|
56
|
+
commit: commitQuantity,
|
|
57
|
+
} = useQuantityStepper({
|
|
58
|
+
quantity: () => quantity.value,
|
|
59
|
+
max: () => remainingQuantity.value,
|
|
60
|
+
apply: (next) => {
|
|
61
|
+
quantity.value = next;
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
// Adding to the cart shrinks what is left to add; an amount that no longer fits
|
|
66
|
+
// follows it down, so the next + never makes the number drop.
|
|
67
|
+
watch(remainingQuantity, (remaining) => {
|
|
68
|
+
if (quantity.value > remaining) {
|
|
69
|
+
quantity.value = remaining;
|
|
70
|
+
}
|
|
71
|
+
});
|
|
38
72
|
|
|
39
73
|
let exceededTimer: ReturnType<typeof setTimeout> | null = null;
|
|
40
74
|
const showQuantityExceeded = ref(false);
|
|
@@ -76,17 +110,6 @@ function buildPriceTiers(prices: { [key: string]: number }[]): CartItemPriceTier
|
|
|
76
110
|
.sort((a, b) => a.minQuantity - b.minQuantity);
|
|
77
111
|
}
|
|
78
112
|
|
|
79
|
-
function setQuantity(next: number) {
|
|
80
|
-
quantity.value = Math.max(1, Math.min(next, 999999));
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
function onQuantityInput(event: Event) {
|
|
84
|
-
const input = event.target as HTMLInputElement;
|
|
85
|
-
const sanitized = input.value.replace(/[^0-9]/g, "").slice(0, 6);
|
|
86
|
-
input.value = sanitized;
|
|
87
|
-
quantity.value = parseInt(sanitized) || 0;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
113
|
function addToCart() {
|
|
91
114
|
if (quantityInvalid.value) {
|
|
92
115
|
return;
|
|
@@ -146,33 +169,37 @@ onUnmounted(() => {
|
|
|
146
169
|
:icon="icon('minus')"
|
|
147
170
|
color="neutral"
|
|
148
171
|
variant="ghost"
|
|
172
|
+
class="min-h-11 min-w-11 justify-center lg:min-h-0 lg:min-w-0"
|
|
149
173
|
tabindex="0"
|
|
150
|
-
:disabled="
|
|
174
|
+
:disabled="!canDecrease"
|
|
151
175
|
:aria-label="t('cart.item.ariaDecreaseQuantity', { name: product.name })"
|
|
152
|
-
@click="
|
|
176
|
+
@click="decrease"
|
|
153
177
|
/>
|
|
154
178
|
<input
|
|
155
|
-
|
|
179
|
+
v-model="quantityInput"
|
|
156
180
|
type="text"
|
|
157
181
|
inputmode="numeric"
|
|
158
|
-
class="w-12 text-center text-sm font-medium bg-transparent
|
|
182
|
+
class="w-12 self-stretch text-center text-sm font-medium bg-transparent
|
|
159
183
|
focus:outline-none"
|
|
160
184
|
:aria-label="t('product.detail.quantity')"
|
|
161
185
|
@input="onQuantityInput"
|
|
186
|
+
@keydown.enter.prevent="commitQuantity"
|
|
187
|
+
@blur="commitQuantity"
|
|
162
188
|
>
|
|
163
189
|
<UButton
|
|
164
190
|
:icon="icon('plus')"
|
|
165
191
|
color="neutral"
|
|
166
192
|
variant="ghost"
|
|
193
|
+
class="min-h-11 min-w-11 justify-center lg:min-h-0 lg:min-w-0"
|
|
167
194
|
tabindex="0"
|
|
168
195
|
:aria-label="t('cart.item.ariaIncreaseQuantity', { name: product.name })"
|
|
169
|
-
@click="
|
|
196
|
+
@click="increase"
|
|
170
197
|
/>
|
|
171
198
|
</div>
|
|
172
199
|
<UButton
|
|
173
200
|
:icon="icon('cart')"
|
|
174
201
|
size="lg"
|
|
175
|
-
class="flex-1 justify-center"
|
|
202
|
+
class="flex-1 justify-center min-h-11 lg:min-h-0"
|
|
176
203
|
tabindex="0"
|
|
177
204
|
:label="t('product.actions.addToCart')"
|
|
178
205
|
:disabled="quantityInvalid"
|
|
@@ -182,11 +209,17 @@ onUnmounted(() => {
|
|
|
182
209
|
</div>
|
|
183
210
|
|
|
184
211
|
<UiFeedbackErrorBoundary
|
|
185
|
-
v-if="showQuantityExceeded"
|
|
212
|
+
v-if="showQuantityExceeded || quantityNotice === 'max'"
|
|
186
213
|
:title="t('product.actions.maxQuantityReachedTitle', { count: currentCartQuantity })"
|
|
187
214
|
:description="t('product.actions.maxQuantityReachedDescription', { max: effectiveMaxQuantity })"
|
|
188
215
|
:show-retry="false"
|
|
189
216
|
/>
|
|
217
|
+
<UiFeedbackErrorBoundary
|
|
218
|
+
v-if="quantityNotice === 'invalid'"
|
|
219
|
+
:title="t('product.actions.invalidQuantityTitle')"
|
|
220
|
+
:description="t('product.actions.invalidQuantityDescription')"
|
|
221
|
+
:show-retry="false"
|
|
222
|
+
/>
|
|
190
223
|
|
|
191
224
|
<!-- B2B incentives -->
|
|
192
225
|
<ul
|
|
@@ -74,7 +74,7 @@ async function copySku(): Promise<void> {
|
|
|
74
74
|
<button
|
|
75
75
|
type="button"
|
|
76
76
|
tabindex="0"
|
|
77
|
-
class="mt-2 inline-flex items-center gap-1.5 text-sm text-muted
|
|
77
|
+
class="mt-2 inline-flex items-center gap-1.5 min-h-11 lg:min-h-0 text-sm text-muted
|
|
78
78
|
hover:text-highlighted transition-colors cursor-pointer"
|
|
79
79
|
:title="t('product.detail.copySku')"
|
|
80
80
|
@click="copySku"
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* "Request a price" beside one article.
|
|
4
|
+
*
|
|
5
|
+
* Not the same offer as a quotation: the quotes app answers a whole cart that
|
|
6
|
+
* cannot be ordered as it stands, and this is one article and one question. The
|
|
7
|
+
* two live side by side on purpose — a buyer looking at a part they cannot price
|
|
8
|
+
* should not have to build a cart to ask about it.
|
|
9
|
+
*
|
|
10
|
+
* Shown only where the merchant published a form under that slug. An operator
|
|
11
|
+
* who never authored one has no link to a page that would explain nothing.
|
|
12
|
+
*/
|
|
13
|
+
const props = defineProps<{
|
|
14
|
+
sku: string;
|
|
15
|
+
}>();
|
|
16
|
+
|
|
17
|
+
const { hasForm } = useAuthoredForms();
|
|
18
|
+
const { icon } = useIcons();
|
|
19
|
+
const { t } = useI18n();
|
|
20
|
+
const localePath = useLocalePath();
|
|
21
|
+
|
|
22
|
+
const to = computed(() => ({
|
|
23
|
+
path: localePath("/price-request"),
|
|
24
|
+
query: { product: props.sku },
|
|
25
|
+
}));
|
|
26
|
+
</script>
|
|
27
|
+
|
|
28
|
+
<template>
|
|
29
|
+
<UButton
|
|
30
|
+
v-if="hasForm('price-request')"
|
|
31
|
+
:to="to"
|
|
32
|
+
variant="link"
|
|
33
|
+
color="neutral"
|
|
34
|
+
size="sm"
|
|
35
|
+
class="px-0 min-h-11 lg:min-h-0"
|
|
36
|
+
:icon="icon('mail')"
|
|
37
|
+
:label="t('forms.priceRequest.cta')"
|
|
38
|
+
/>
|
|
39
|
+
</template>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import type { OrderList, OrderListPosition } from "../../../interfaces/account/order-lists";
|
|
3
|
+
import { cartEcommerce } from "../../../shared/themeEvents";
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* "Add to order list" on the product detail page: shows on how many
|
|
@@ -27,6 +28,12 @@ const { icon } = useIcons();
|
|
|
27
28
|
const { t } = useI18n();
|
|
28
29
|
const toast = useToast();
|
|
29
30
|
const auth = useAuthStore();
|
|
31
|
+
const themeEvents = useThemeEvents();
|
|
32
|
+
|
|
33
|
+
/** `add_to_orderlist` — the article went onto a list (not off one). */
|
|
34
|
+
function reportAdded(): void {
|
|
35
|
+
themeEvents.emit("add_to_orderlist", { ecommerce: cartEcommerce([buildPosition()]) });
|
|
36
|
+
}
|
|
30
37
|
|
|
31
38
|
const open = ref(false);
|
|
32
39
|
const busyListId = ref<string | null>(null);
|
|
@@ -91,6 +98,7 @@ async function toggle(list: OrderList): Promise<void> {
|
|
|
91
98
|
});
|
|
92
99
|
await refresh();
|
|
93
100
|
if (!removing) {
|
|
101
|
+
reportAdded();
|
|
94
102
|
lastUsedId.value = list.id;
|
|
95
103
|
localStorage.setItem(LAST_USED_STORAGE, list.id);
|
|
96
104
|
}
|
|
@@ -122,6 +130,7 @@ async function createAndAdd(): Promise<void> {
|
|
|
122
130
|
body: { name, kind: "shopping", public: false, positions: [buildPosition()] },
|
|
123
131
|
});
|
|
124
132
|
await refresh();
|
|
133
|
+
reportAdded();
|
|
125
134
|
lastUsedId.value = created.id;
|
|
126
135
|
localStorage.setItem(LAST_USED_STORAGE, created.id);
|
|
127
136
|
newListName.value = "";
|
|
@@ -163,6 +172,7 @@ async function createAndAdd(): Promise<void> {
|
|
|
163
172
|
color="neutral"
|
|
164
173
|
variant="outline"
|
|
165
174
|
size="lg"
|
|
175
|
+
class="min-h-11 min-w-11 justify-center lg:min-h-0 lg:min-w-0"
|
|
166
176
|
tabindex="0"
|
|
167
177
|
:icon="icon('order-list')"
|
|
168
178
|
:aria-label="t('orderLists.saveTo.button')"
|
|
@@ -33,6 +33,26 @@ const currentCartQuantity = computed(() => {
|
|
|
33
33
|
return cartStore.items.find(item => item.id === id.value)?.quantity ?? 0;
|
|
34
34
|
});
|
|
35
35
|
|
|
36
|
+
/**
|
|
37
|
+
* The siblings of this article, and the parts sold alongside it.
|
|
38
|
+
*
|
|
39
|
+
* Both were built in the design system and reachable only where an editor had
|
|
40
|
+
* composed them onto a page — so the code-first storefront had no variant picker
|
|
41
|
+
* at all, and a buyer there could not choose a size. Variants are the buying
|
|
42
|
+
* decision, not a nicety: the wrong size is the wrong part, and a shop that
|
|
43
|
+
* cannot express it sends the buyer to the telephone.
|
|
44
|
+
*
|
|
45
|
+
* Both sections render nothing when the article has none, which is why they cost
|
|
46
|
+
* a storefront that does not need them nothing but the request.
|
|
47
|
+
*/
|
|
48
|
+
const { variants, axes, model } = useProductVariants(id);
|
|
49
|
+
const { groups: associationGroups } = useProductAssociations(id);
|
|
50
|
+
|
|
51
|
+
/** A sibling keeps the category path the buyer is already browsing. */
|
|
52
|
+
function variantLink(variant: { id: string; name: string }): string {
|
|
53
|
+
return localePath(categoryProductPath([categorySlug.value, subcategorySlug.value], variant as never));
|
|
54
|
+
}
|
|
55
|
+
|
|
36
56
|
const basePriceCents = computed(() => prices.value[0]?.["1"] ?? 0);
|
|
37
57
|
/** Price on request: no price for this buyer context — never render €0. */
|
|
38
58
|
const hasPrice = computed(() => Object.keys(prices.value[0] ?? {}).length > 0);
|
|
@@ -190,6 +210,12 @@ const breadcrumb = computed(() => [
|
|
|
190
210
|
:format-price="formatPrice"
|
|
191
211
|
:current-cart-quantity="currentCartQuantity"
|
|
192
212
|
/>
|
|
213
|
+
|
|
214
|
+
<!--
|
|
215
|
+
Deliberately outside the priced branch: an article the shop shows
|
|
216
|
+
no price for is exactly the one somebody asks about.
|
|
217
|
+
-->
|
|
218
|
+
<ProductDetailPriceRequest :sku="productInfo.sku" />
|
|
193
219
|
</div>
|
|
194
220
|
</div>
|
|
195
221
|
|
|
@@ -207,6 +233,37 @@ const breadcrumb = computed(() => [
|
|
|
207
233
|
:attributes="attributes"
|
|
208
234
|
/>
|
|
209
235
|
</div>
|
|
236
|
+
|
|
237
|
+
<!-- The siblings of this article: one row each, with a column per axis
|
|
238
|
+
that distinguishes them. Rendered only where the model has any. -->
|
|
239
|
+
<div
|
|
240
|
+
v-if="variants.length"
|
|
241
|
+
class="mt-14 pt-10 border-t border-(--ui-border)"
|
|
242
|
+
>
|
|
243
|
+
<ProductDetailVariants
|
|
244
|
+
:variants="variants"
|
|
245
|
+
:axes="axes"
|
|
246
|
+
:model="model"
|
|
247
|
+
:tax-rate="taxRate"
|
|
248
|
+
:link-for="variantLink"
|
|
249
|
+
:category-slug="categorySlug ?? ''"
|
|
250
|
+
:subcategory-slug="subcategorySlug"
|
|
251
|
+
show-filters
|
|
252
|
+
show-order-button
|
|
253
|
+
/>
|
|
254
|
+
</div>
|
|
255
|
+
|
|
256
|
+
<!-- What is sold alongside it. A way into the catalogue rather than a
|
|
257
|
+
second buy box, so the tiles carry no price and cost no offer call. -->
|
|
258
|
+
<div
|
|
259
|
+
v-if="associationGroups.length"
|
|
260
|
+
class="mt-14 pt-10 border-t border-(--ui-border)"
|
|
261
|
+
>
|
|
262
|
+
<ProductDetailAssociations
|
|
263
|
+
:groups="associationGroups"
|
|
264
|
+
:link-for="variantLink"
|
|
265
|
+
/>
|
|
266
|
+
</div>
|
|
210
267
|
</div>
|
|
211
268
|
</UContainer>
|
|
212
269
|
</template>
|
|
@@ -82,22 +82,12 @@ export const useAccountDashboard = () => {
|
|
|
82
82
|
return Number.isNaN(parsed.getTime()) ? value : d(parsed, { dateStyle: "medium" });
|
|
83
83
|
};
|
|
84
84
|
|
|
85
|
-
/* ---- quick actions ----------------------------------------------------- */
|
|
86
|
-
const quickActions = [
|
|
87
|
-
{ to: "/account/direct-order", labelKey: "directOrder.title", token: "direct-order" },
|
|
88
|
-
{ to: "/account/orders", labelKey: "account.nav.orders", token: "orders" },
|
|
89
|
-
{ to: "/account/order-lists", labelKey: "account.nav.orderLists", token: "order-list" },
|
|
90
|
-
{ to: "/account/requisitions", labelKey: "account.nav.requisitions", token: "check" },
|
|
91
|
-
{ to: "/account/cost-centers", labelKey: "account.nav.costCenters", token: "briefcase" },
|
|
92
|
-
];
|
|
93
|
-
|
|
94
85
|
return {
|
|
95
86
|
t,
|
|
96
87
|
auth,
|
|
97
88
|
formatCurrency,
|
|
98
89
|
formatDate,
|
|
99
90
|
statusColors,
|
|
100
|
-
quickActions,
|
|
101
91
|
ordersPending,
|
|
102
92
|
contextPending,
|
|
103
93
|
requisitionsPending,
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A buyer whose account is on hold, and what this merchant still lets them do.
|
|
3
|
+
*
|
|
4
|
+
* The platform decides both halves: it answers whether the account may act, and
|
|
5
|
+
* it shapes the permission set by the merchant's choice — keep what the role
|
|
6
|
+
* grants, cut back to the catalogue, or take everything away. It enforces that
|
|
7
|
+
* correctly, and the shop used to read none of it: a blocked buyer saw the whole
|
|
8
|
+
* shop, filled a cart, and was refused at the write by an error that explained
|
|
9
|
+
* nothing.
|
|
10
|
+
*
|
|
11
|
+
* So this says what the buyer may do and, more usefully, lets a surface say why.
|
|
12
|
+
* The wording is the point — "your account is on hold, please contact your
|
|
13
|
+
* account manager" is something a person can act on, and a 403 is not.
|
|
14
|
+
*/
|
|
15
|
+
export function useAccountHold() {
|
|
16
|
+
const authStore = useAuthStore();
|
|
17
|
+
const { account } = useShopSettings();
|
|
18
|
+
|
|
19
|
+
/** On hold: the platform said this account may not act. */
|
|
20
|
+
const onHold = computed(() => authStore.user?.active === false);
|
|
21
|
+
|
|
22
|
+
/** What the merchant left them, while it lasts. */
|
|
23
|
+
const stillAllowed = computed<"everything" | "catalogue" | "nothing">(() => {
|
|
24
|
+
if (!onHold.value) {
|
|
25
|
+
return "everything";
|
|
26
|
+
}
|
|
27
|
+
switch (account.value?.blockedBuyer) {
|
|
28
|
+
case "catalog_only":
|
|
29
|
+
return "catalogue";
|
|
30
|
+
case "deny_all":
|
|
31
|
+
return "nothing";
|
|
32
|
+
default:
|
|
33
|
+
// `keep` — the role's own grants stand and the platform gates on the
|
|
34
|
+
// account being inactive, which is what it did before this existed.
|
|
35
|
+
return "everything";
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
/** May they still browse and see prices. */
|
|
40
|
+
const mayBrowse = computed(() => stillAllowed.value !== "nothing");
|
|
41
|
+
/** May they still reach the account area and order. */
|
|
42
|
+
const mayAct = computed(() => stillAllowed.value === "everything");
|
|
43
|
+
|
|
44
|
+
return { onHold, stillAllowed, mayBrowse, mayAct };
|
|
45
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { ComputedRef } from "vue";
|
|
2
|
+
|
|
3
|
+
import type { AccountNavGroup } from "../config/navigation";
|
|
4
|
+
|
|
5
|
+
import { accountNavigation } from "../config/navigation";
|
|
6
|
+
|
|
7
|
+
export interface UseAccountNavigationReturn {
|
|
8
|
+
/** The sidebar groups in effect for this request. */
|
|
9
|
+
readonly navigation: ComputedRef<AccountNavGroup[]>;
|
|
10
|
+
/** True when a theme published the tenant's own account menu for this request. */
|
|
11
|
+
readonly isTenantAuthored: ComputedRef<boolean>;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The account navigation in effect, resolved in the same priority order the
|
|
16
|
+
* header uses (see MainNav):
|
|
17
|
+
* 1. per-request useState — a theme publishing the tenant's LIVE account
|
|
18
|
+
* menu (request-scoped, so multi-tenant safe)
|
|
19
|
+
* 2. app.config override — a theme's shipped defaults (custom-theme)
|
|
20
|
+
* 3. the layer's built-in full B2B tree
|
|
21
|
+
* The sidebar renders it; the quick-action catalogue is limited by it.
|
|
22
|
+
*/
|
|
23
|
+
export function useAccountNavigation(): UseAccountNavigationReturn {
|
|
24
|
+
const appConfig = useAppConfig();
|
|
25
|
+
const liveAccountNavigation = useState<AccountNavGroup[] | null>("cover:nav:accountNavigation", () => null);
|
|
26
|
+
|
|
27
|
+
const navigation = computed<AccountNavGroup[]>(() =>
|
|
28
|
+
liveAccountNavigation.value
|
|
29
|
+
?? (appConfig.accountNavigation as AccountNavGroup[] | undefined)
|
|
30
|
+
?? accountNavigation,
|
|
31
|
+
);
|
|
32
|
+
const isTenantAuthored = computed(() => liveAccountNavigation.value !== null);
|
|
33
|
+
|
|
34
|
+
return { navigation, isTenantAuthored };
|
|
35
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { AccountPaymentsResponse } from "../interfaces/account/payments";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The buyer's own payments — open, late and settled.
|
|
5
|
+
*
|
|
6
|
+
* Fetched once per page and shared, because the dashboard wants the outstanding
|
|
7
|
+
* figure and the payments page wants the rows, and they must not disagree.
|
|
8
|
+
*/
|
|
9
|
+
export function useAccountPayments() {
|
|
10
|
+
const { data, status, error, refresh } = useFetch<AccountPaymentsResponse>("/api/account/payments", {
|
|
11
|
+
key: "account-payments",
|
|
12
|
+
default: (): AccountPaymentsResponse => ({ payments: [], outstanding: [] }),
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
const payments = computed(() => data.value?.payments ?? []);
|
|
16
|
+
/** Still owed, per currency. Never one figure across two currencies. */
|
|
17
|
+
const outstanding = computed(() => data.value?.outstanding ?? []);
|
|
18
|
+
const overdue = computed(() => payments.value.filter(payment => payment.overdue));
|
|
19
|
+
|
|
20
|
+
return { payments, outstanding, overdue, status, error, refresh };
|
|
21
|
+
}
|
|
@@ -43,10 +43,23 @@ export const useAccountQuote = (id: string) => {
|
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
/**
|
|
47
|
+
* Say no — to the whole offer, or to the positions named.
|
|
48
|
+
*
|
|
49
|
+
* Naming positions leaves the rest open for a decision later, which is what a
|
|
50
|
+
* buyer wants when four of five parts are right. Naming none, or every open
|
|
51
|
+
* one, is a refusal of the offer as a whole.
|
|
52
|
+
*/
|
|
53
|
+
async function decline(reason?: string, lineIds?: string[]): Promise<void> {
|
|
47
54
|
declining.value = true;
|
|
48
55
|
try {
|
|
49
|
-
await $fetch(accountApi.quoteDecline(id), {
|
|
56
|
+
await $fetch(accountApi.quoteDecline(id), {
|
|
57
|
+
method: "POST",
|
|
58
|
+
body: {
|
|
59
|
+
...(reason ? { reason } : {}),
|
|
60
|
+
...(lineIds?.length ? { lineIds } : {}),
|
|
61
|
+
},
|
|
62
|
+
});
|
|
50
63
|
await refresh();
|
|
51
64
|
}
|
|
52
65
|
finally {
|
|
@@ -4,9 +4,32 @@ import type { AuthUser, LoginInput, RegisterInput, StoredSession } from "../inte
|
|
|
4
4
|
|
|
5
5
|
const WAS_AUTHENTICATED_KEY = "cover-was-authenticated";
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Turn what the platform answered into something a buyer can act on.
|
|
9
|
+
*
|
|
10
|
+
* The three contexts ask different questions of the same failures, so each names
|
|
11
|
+
* its own wording: "no account here" is the end of a sign-in and the whole point
|
|
12
|
+
* of a registration. A type this does not know falls back to the generic line,
|
|
13
|
+
* which is a last resort and not a destination — a failure that lands there
|
|
14
|
+
* repeatedly is a case missing from this switch, which is how a registration that
|
|
15
|
+
* could not happen came to say "something went wrong" and nothing else.
|
|
16
|
+
*/
|
|
17
|
+
function mapAuthError(err: unknown, context: "login" | "recovery" | "register" = "login"): string {
|
|
8
18
|
const type = (err as { data?: { data?: { type?: string } } })?.data?.data?.type;
|
|
9
19
|
if (typeof type === "string") {
|
|
20
|
+
if (context === "register") {
|
|
21
|
+
switch (type) {
|
|
22
|
+
case "user_email_already_exists":
|
|
23
|
+
return "auth.register.errors.emailExists";
|
|
24
|
+
case "registration_disabled":
|
|
25
|
+
return "auth.register.errors.registrationDisabled";
|
|
26
|
+
case "service_unavailable":
|
|
27
|
+
return "auth.errors.serviceUnavailable";
|
|
28
|
+
case "general_rate_limit_exceeded":
|
|
29
|
+
return "auth.login.errors.rateLimited";
|
|
30
|
+
}
|
|
31
|
+
return "auth.register.errors.unknown";
|
|
32
|
+
}
|
|
10
33
|
switch (type) {
|
|
11
34
|
case "service_unavailable":
|
|
12
35
|
return "auth.errors.serviceUnavailable";
|
|
@@ -17,6 +40,8 @@ function mapAuthError(err: unknown, context: "login" | "recovery" = "login"): st
|
|
|
17
40
|
: "auth.login.errors.invalidCredentials";
|
|
18
41
|
case "user_blocked":
|
|
19
42
|
return "auth.login.errors.accountBlocked";
|
|
43
|
+
case "organization_blocked":
|
|
44
|
+
return "auth.login.errors.organizationBlocked";
|
|
20
45
|
case "general_rate_limit_exceeded":
|
|
21
46
|
return context === "recovery"
|
|
22
47
|
? "auth.recovery.errors.rateLimited"
|
|
@@ -33,6 +58,9 @@ function mapAuthError(err: unknown, context: "login" | "recovery" = "login"): st
|
|
|
33
58
|
? "auth.recovery.errors.unknown"
|
|
34
59
|
: "auth.login.errors.unknown";
|
|
35
60
|
}
|
|
61
|
+
if (context === "register") {
|
|
62
|
+
return "auth.register.errors.network";
|
|
63
|
+
}
|
|
36
64
|
return context === "recovery"
|
|
37
65
|
? "auth.recovery.errors.network"
|
|
38
66
|
: "auth.login.errors.network";
|
|
@@ -78,7 +106,7 @@ export const useAuthStore = defineStore("auth", () => {
|
|
|
78
106
|
return created;
|
|
79
107
|
}
|
|
80
108
|
catch (err) {
|
|
81
|
-
error.value = mapAuthError(err);
|
|
109
|
+
error.value = mapAuthError(err, "register");
|
|
82
110
|
throw err;
|
|
83
111
|
}
|
|
84
112
|
finally {
|
|
@@ -111,6 +139,59 @@ export const useAuthStore = defineStore("auth", () => {
|
|
|
111
139
|
}
|
|
112
140
|
};
|
|
113
141
|
|
|
142
|
+
/**
|
|
143
|
+
* Ask for a way in that is not a password: a mailed link, or a mailed code.
|
|
144
|
+
*
|
|
145
|
+
* Answers the same for an address nobody holds, so the form cannot be used to
|
|
146
|
+
* ask who has an account. A code request hands back the id its confirmation
|
|
147
|
+
* needs; a link carries everything in the link.
|
|
148
|
+
*/
|
|
149
|
+
const requestSignInMail = async (kind: "magic-link" | "otp", email: string): Promise<string | null> => {
|
|
150
|
+
loading.value = true;
|
|
151
|
+
error.value = null;
|
|
152
|
+
try {
|
|
153
|
+
const result = await $fetch<{ sent: true; userId?: string }>(`/api/auth/${kind}`, {
|
|
154
|
+
method: "POST",
|
|
155
|
+
body: { email },
|
|
156
|
+
});
|
|
157
|
+
return result.userId ?? null;
|
|
158
|
+
}
|
|
159
|
+
catch (err) {
|
|
160
|
+
error.value = mapAuthError(err);
|
|
161
|
+
throw err;
|
|
162
|
+
}
|
|
163
|
+
finally {
|
|
164
|
+
loading.value = false;
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
/** Hand the secret back and become signed in, exactly as a password would. */
|
|
169
|
+
const confirmSignInMail = async (
|
|
170
|
+
kind: "magic-link" | "otp",
|
|
171
|
+
{ userId, secret }: { userId: string; secret: string },
|
|
172
|
+
) => {
|
|
173
|
+
loading.value = true;
|
|
174
|
+
error.value = null;
|
|
175
|
+
try {
|
|
176
|
+
const result = await $fetch<{ user: AuthUser; session: StoredSession }>(`/api/auth/${kind}`, {
|
|
177
|
+
method: "PUT",
|
|
178
|
+
body: { userId, secret },
|
|
179
|
+
});
|
|
180
|
+
user.value = result.user;
|
|
181
|
+
session.value = result.session;
|
|
182
|
+
markAuthenticated();
|
|
183
|
+
void useCartStore().onAuthLogin();
|
|
184
|
+
return result.session;
|
|
185
|
+
}
|
|
186
|
+
catch (err) {
|
|
187
|
+
error.value = mapAuthError(err);
|
|
188
|
+
throw err;
|
|
189
|
+
}
|
|
190
|
+
finally {
|
|
191
|
+
loading.value = false;
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
|
|
114
195
|
const logout = async () => {
|
|
115
196
|
loading.value = true;
|
|
116
197
|
error.value = null;
|
|
@@ -196,6 +277,7 @@ export const useAuthStore = defineStore("auth", () => {
|
|
|
196
277
|
return {
|
|
197
278
|
user, session, isLoggedIn, loading, error,
|
|
198
279
|
register, login, logout,
|
|
280
|
+
requestSignInMail, confirmSignInMail,
|
|
199
281
|
requestRecovery, confirmRecovery,
|
|
200
282
|
init,
|
|
201
283
|
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { FormSummary } from "../../server/interfaces/forms";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Which authored forms the merchant has published.
|
|
5
|
+
*
|
|
6
|
+
* For the surfaces that OFFER a form rather than being one: the price-request
|
|
7
|
+
* link beside an article, a service entry in the footer. Neither may appear when
|
|
8
|
+
* nothing answers under that slug, or the link leads to a page that explains
|
|
9
|
+
* nothing about why it is empty.
|
|
10
|
+
*
|
|
11
|
+
* Read from shared state the shop-settings plugin fills once per page load, for
|
|
12
|
+
* the same reason the settings are: a link that appeared a moment after the page
|
|
13
|
+
* did would move the buy box under the reader's cursor.
|
|
14
|
+
*/
|
|
15
|
+
export function useAuthoredForms() {
|
|
16
|
+
const state = useState<FormSummary[] | null>("cover:authored-forms", () => null);
|
|
17
|
+
|
|
18
|
+
const forms = computed(() => state.value ?? []);
|
|
19
|
+
|
|
20
|
+
/** Whether a form is published under this slug. False while unknown. */
|
|
21
|
+
function hasForm(slug: string): boolean {
|
|
22
|
+
return forms.value.some(form => form.slug === slug);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return { forms, hasForm };
|
|
26
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { AvailableOffer, AvailableOffersResponse } from "../interfaces/offers";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The offers this buyer could still reach, for the cart they are holding.
|
|
5
|
+
*
|
|
6
|
+
* Asked again whenever the cart's value changes, because the whole point is the
|
|
7
|
+
* distance: an offer twelve euros away is worth showing, and the same offer after
|
|
8
|
+
* the buyer has added the twelve euros is worth showing differently. The call
|
|
9
|
+
* writes nothing, so asking often costs nothing but the round trip.
|
|
10
|
+
*
|
|
11
|
+
* Nearest first. A buyer reads the top of a list and acts on it, and the top
|
|
12
|
+
* should be the one they can actually reach.
|
|
13
|
+
*/
|
|
14
|
+
export function useAvailableOffers(subtotal: Ref<number>, itemCount: Ref<number>) {
|
|
15
|
+
const { data, refresh, status } = useFetch<AvailableOffersResponse>("/api/promotions/available", {
|
|
16
|
+
method: "POST",
|
|
17
|
+
key: "available-offers",
|
|
18
|
+
body: computed(() => ({ subtotal: subtotal.value, itemCount: itemCount.value })),
|
|
19
|
+
default: (): AvailableOffersResponse => ({ offers: [], total: 0 }),
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const offers = computed<AvailableOffer[]>(() => {
|
|
23
|
+
const all = data.value?.offers ?? [];
|
|
24
|
+
return [...all].sort((a, b) => {
|
|
25
|
+
// Earned ones last: they are a fact, not something to work towards.
|
|
26
|
+
if (a.reached !== b.reached) {
|
|
27
|
+
return a.reached ? 1 : -1;
|
|
28
|
+
}
|
|
29
|
+
// Then nearest first; an offer with no distance after the ones with.
|
|
30
|
+
const da = a.missing?.amount ?? Number.POSITIVE_INFINITY;
|
|
31
|
+
const db = b.missing?.amount ?? Number.POSITIVE_INFINITY;
|
|
32
|
+
return da - db;
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
/** The one worth putting in front of the buyer: nearest, not yet earned. */
|
|
37
|
+
const nearest = computed<AvailableOffer | null>(() =>
|
|
38
|
+
offers.value.find(offer => !offer.reached && offer.missing) ?? null,
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
return { offers, nearest, total: computed(() => data.value?.total ?? 0), refresh, status };
|
|
42
|
+
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { useDebounceFn } from "@vueuse/core";
|
|
2
2
|
|
|
3
|
+
import { categoryListId } from "../shared/themeEvents";
|
|
4
|
+
|
|
3
5
|
export interface CategoryListingOptions {
|
|
4
6
|
/** Resolved category slug the listing is pinned to. */
|
|
5
7
|
readonly categorySlug: () => string;
|
|
@@ -58,6 +60,10 @@ export const useCategoryListing = (options: CategoryListingOptions) => {
|
|
|
58
60
|
facetFields: () => (subcategorySlug.value
|
|
59
61
|
? ["manufacturer", "available"]
|
|
60
62
|
: ["subcategory", "manufacturer", "available"]),
|
|
63
|
+
// Every shown page of the category is a product list view.
|
|
64
|
+
listEvent: () => (categorySlug.value
|
|
65
|
+
? { event: "view_item_list", listId: categoryListId(categorySlug.value, subcategorySlug.value) }
|
|
66
|
+
: null),
|
|
61
67
|
});
|
|
62
68
|
|
|
63
69
|
const title = computed(() =>
|