@revenexx/cover 0.7.1 → 0.10.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/api/forms.ts +1 -0
- package/app/app.config.ts +17 -12
- package/app/components/RevenexxForm.vue +80 -12
- package/app/components/account/AccountShell.vue +18 -0
- package/app/components/account/approvals/AccountPendingApprovals.vue +178 -0
- package/app/components/account/orderlists/AccountOrderListDetail.vue +47 -4
- package/app/components/account/orders/AccountOrderDetail.vue +186 -1
- package/app/components/account/payments/AccountPayments.vue +129 -0
- package/app/components/account/quotes/AccountQuoteDetail.vue +48 -16
- package/app/components/auth/AuthLoginPanel.vue +131 -15
- package/app/components/auth/AuthMagicLinkPanel.vue +70 -0
- package/app/components/cart/view/CartSummaryPanel.vue +54 -0
- package/app/components/checkout/onepage/CheckoutDeliverySection.vue +13 -1
- package/app/components/checkout/onepage/CheckoutGate.vue +8 -7
- package/app/components/form/FormPage.vue +40 -0
- package/app/components/layout/header/AppBar.vue +7 -1
- package/app/components/layout/header/MainNav.vue +23 -1
- package/app/components/layout/header/MobileMenu.vue +12 -0
- package/app/components/product/detail/ProductDetailPriceRequest.vue +39 -0
- package/app/components/product/detail/ProductDetailView.vue +57 -0
- package/app/composables/useAccountHold.ts +45 -0
- package/app/composables/useAccountPayments.ts +21 -0
- package/app/composables/useAccountQuotes.ts +15 -2
- package/app/composables/useAuthStore.ts +82 -2
- package/app/composables/useAuthoredForms.ts +26 -0
- package/app/composables/useAvailableOffers.ts +42 -0
- package/app/composables/useGuestOrdering.ts +28 -0
- package/app/composables/useMasterDataEditable.ts +22 -7
- package/app/composables/useOrderListRules.ts +21 -1
- package/app/composables/usePendingApprovals.ts +37 -0
- package/app/config/icons.ts +2 -0
- package/app/config/navigation.ts +2 -2
- package/app/formkit.config.ts +14 -0
- package/app/interfaces/account/approvals.ts +37 -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 +11 -0
- package/app/interfaces/b2b.ts +8 -8
- package/app/interfaces/offers.ts +35 -0
- package/app/interfaces/shopSettings.ts +77 -0
- package/app/plugins/account-hold.client.ts +20 -0
- package/app/plugins/shop-settings.ts +27 -12
- package/i18n/locales/de/account.json +80 -0
- package/i18n/locales/de/auth.json +29 -0
- package/i18n/locales/de/cart.json +7 -0
- package/i18n/locales/de/checkout.json +2 -1
- package/i18n/locales/de/common.json +2 -0
- package/i18n/locales/de/forms.json +27 -0
- package/i18n/locales/en/account.json +80 -0
- package/i18n/locales/en/auth.json +29 -0
- package/i18n/locales/en/cart.json +7 -0
- package/i18n/locales/en/checkout.json +2 -1
- package/i18n/locales/en/common.json +2 -0
- package/i18n/locales/en/forms.json +27 -0
- package/package.json +2 -1
- 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/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 +25 -0
- 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/magic-link.post.ts +32 -0
- package/server/api/auth/magic-link.put.ts +30 -0
- package/server/api/auth/otp.post.ts +33 -0
- package/server/api/auth/otp.put.ts +28 -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 +8 -0
- package/server/api/promotions/available.post.ts +37 -0
- 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/services/ApiAuthService.ts +10 -0
- package/server/services/ApiFormsService.ts +56 -0
- 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/forms.ts +62 -14
- package/server/utils/formsService.ts +29 -0
- package/server/utils/liveOrders.ts +26 -0
- package/server/utils/masterData.ts +31 -11
- package/server/utils/passwordlessSignIn.ts +73 -0
- package/server/utils/pendingApprovals.ts +153 -0
- package/server/utils/promotionsService.ts +90 -0
- package/server/utils/quotesService.ts +15 -0
- package/server/utils/shopSettings.ts +35 -4
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* The landing of a mailed sign-in link.
|
|
4
|
+
*
|
|
5
|
+
* The link carries the two things the platform needs, so there is nothing to ask
|
|
6
|
+
* the buyer: the panel confirms on arrival and says which of the three things
|
|
7
|
+
* happened — signed in, the link is spent, or the service could not be reached.
|
|
8
|
+
*
|
|
9
|
+
* A spent link is the ordinary case and not an error to apologise for: links
|
|
10
|
+
* expire, and people open them twice. So it offers the way back rather than a
|
|
11
|
+
* message about what went wrong.
|
|
12
|
+
*/
|
|
13
|
+
const props = defineProps<{
|
|
14
|
+
userId: string;
|
|
15
|
+
secret: string;
|
|
16
|
+
}>();
|
|
17
|
+
|
|
18
|
+
const emit = defineEmits<{
|
|
19
|
+
(e: "success"): void;
|
|
20
|
+
}>();
|
|
21
|
+
|
|
22
|
+
const { t } = useI18n();
|
|
23
|
+
const { icon } = useIcons();
|
|
24
|
+
const auth = useAuthStore();
|
|
25
|
+
|
|
26
|
+
type State = "confirming" | "rejected" | "unavailable";
|
|
27
|
+
const state = ref<State>("confirming");
|
|
28
|
+
|
|
29
|
+
onMounted(async () => {
|
|
30
|
+
if (!props.userId || !props.secret) {
|
|
31
|
+
// A link that lost its query, or somebody typing the address by hand.
|
|
32
|
+
state.value = "rejected";
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
try {
|
|
36
|
+
await auth.confirmSignInMail("magic-link", { userId: props.userId, secret: props.secret });
|
|
37
|
+
emit("success");
|
|
38
|
+
}
|
|
39
|
+
catch (err) {
|
|
40
|
+
const status = (err as { status?: number; statusCode?: number })?.status
|
|
41
|
+
?? (err as { statusCode?: number })?.statusCode;
|
|
42
|
+
state.value = status === 401 ? "rejected" : "unavailable";
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
</script>
|
|
46
|
+
|
|
47
|
+
<template>
|
|
48
|
+
<div class="bg-elevated py-6 px-8 rounded-lg space-y-4">
|
|
49
|
+
<template v-if="state === 'confirming'">
|
|
50
|
+
<p class="flex items-center gap-2 text-sm text-muted">
|
|
51
|
+
<UIcon
|
|
52
|
+
:name="icon('loading')"
|
|
53
|
+
class="size-4 animate-spin"
|
|
54
|
+
/>
|
|
55
|
+
{{ t('auth.magicLink.confirming') }}
|
|
56
|
+
</p>
|
|
57
|
+
</template>
|
|
58
|
+
|
|
59
|
+
<template v-else>
|
|
60
|
+
<UAlert
|
|
61
|
+
:color="state === 'rejected' ? 'warning' : 'error'"
|
|
62
|
+
variant="soft"
|
|
63
|
+
:icon="icon('warning')"
|
|
64
|
+
:title="t(`auth.magicLink.${state}.title`)"
|
|
65
|
+
:description="t(`auth.magicLink.${state}.description`)"
|
|
66
|
+
/>
|
|
67
|
+
<slot name="retry" />
|
|
68
|
+
</template>
|
|
69
|
+
</div>
|
|
70
|
+
</template>
|
|
@@ -121,6 +121,23 @@ const incentiveProgress = computed(() => {
|
|
|
121
121
|
return Math.min(100, Math.round((subtotalAmount.value / openIncentive.value.threshold) * 100));
|
|
122
122
|
});
|
|
123
123
|
|
|
124
|
+
/* ---- offers this buyer could still reach ------------------------------- */
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* What the merchant is offering that this cart has not earned yet.
|
|
128
|
+
*
|
|
129
|
+
* The incentives above are the shop's own two thresholds. These are the
|
|
130
|
+
* merchant's promotions, and the difference is the one the promotions app makes
|
|
131
|
+
* itself: a shop that can only say what a cart IS owed can only mention a
|
|
132
|
+
* discount once it has already been earned. Here each offer says how far away it
|
|
133
|
+
* is, and "12 € more" is the sentence that raises an order value.
|
|
134
|
+
*
|
|
135
|
+
* Nothing is shown where the merchant has none, and nothing is invented: a code
|
|
136
|
+
* offer says a code is needed without ever naming one.
|
|
137
|
+
*/
|
|
138
|
+
const itemCount = computed(() => cart.items.reduce((n, item) => n + item.quantity, 0));
|
|
139
|
+
const { offers: availableOffers, nearest: nearestOffer } = useAvailableOffers(subtotalAmount, itemCount);
|
|
140
|
+
|
|
124
141
|
/**
|
|
125
142
|
* The promises that close B2B orders — and promises are merchant-specific. A
|
|
126
143
|
* storefront switches off what its own terms do not cover; a shop with three
|
|
@@ -189,6 +206,43 @@ const trustItems = computed(() => {
|
|
|
189
206
|
</template>
|
|
190
207
|
</div>
|
|
191
208
|
|
|
209
|
+
<!-- What this cart has not earned yet. Nearest first, because the top of
|
|
210
|
+
a list is what a buyer acts on. -->
|
|
211
|
+
<div
|
|
212
|
+
v-if="availableOffers.length"
|
|
213
|
+
class="pt-3 border-t border-(--ui-border) space-y-1.5"
|
|
214
|
+
>
|
|
215
|
+
<p class="text-xs font-semibold text-highlighted">
|
|
216
|
+
{{ t('cart.offers.title') }}
|
|
217
|
+
</p>
|
|
218
|
+
<div
|
|
219
|
+
v-for="offer in availableOffers.slice(0, 3)"
|
|
220
|
+
:key="offer.id"
|
|
221
|
+
class="flex items-start gap-1.5 text-xs"
|
|
222
|
+
:class="offer.reached ? 'text-success' : 'text-muted'"
|
|
223
|
+
>
|
|
224
|
+
<UIcon
|
|
225
|
+
:name="icon(offer.reached ? 'success' : 'offer')"
|
|
226
|
+
class="size-4 shrink-0 mt-px"
|
|
227
|
+
/>
|
|
228
|
+
<span>
|
|
229
|
+
{{ offer.name }}
|
|
230
|
+
<template v-if="offer.missing">
|
|
231
|
+
—
|
|
232
|
+
{{ offer.missing.kind === 'value'
|
|
233
|
+
? t('cart.offers.missingValue', { amount: formatCurrency(offer.missing.amount) })
|
|
234
|
+
: t('cart.offers.missingQuantity', { count: offer.missing.amount }) }}
|
|
235
|
+
</template>
|
|
236
|
+
<template v-else-if="offer.reached">
|
|
237
|
+
— {{ t('cart.offers.reached') }}
|
|
238
|
+
</template>
|
|
239
|
+
<template v-if="offer.needsCode">
|
|
240
|
+
· {{ t('cart.offers.needsCode') }}
|
|
241
|
+
</template>
|
|
242
|
+
</span>
|
|
243
|
+
</div>
|
|
244
|
+
</div>
|
|
245
|
+
|
|
192
246
|
<!--
|
|
193
247
|
Promotion codes. Entering one recalculates the cart, because what
|
|
194
248
|
a code is worth is the promotions app's answer and depends on the
|
|
@@ -5,6 +5,9 @@ import type { DeliveryOption } from "../../../interfaces/delivery";
|
|
|
5
5
|
|
|
6
6
|
const { icon } = useIcons();
|
|
7
7
|
const { t, locale } = useI18n();
|
|
8
|
+
// Whether this merchant ships in parts at all — the orders app's answer.
|
|
9
|
+
const { orders } = useShopSettings();
|
|
10
|
+
const partialShipmentAllowed = computed(() => (orders.value?.partialShipment ?? "allowed") === "allowed");
|
|
8
11
|
const { form, profile, profileLoading, fieldErrors, validateField } = useCheckoutOnePage();
|
|
9
12
|
const { formatCurrency } = useCartSummaryFormatting();
|
|
10
13
|
const cartStore = useCartStore();
|
|
@@ -218,11 +221,20 @@ watch([deliveryOptions, () => form.value.deliveryMethod], ([options, selected])
|
|
|
218
221
|
</div>
|
|
219
222
|
</div>
|
|
220
223
|
|
|
221
|
-
<!-- Partial delivery
|
|
224
|
+
<!-- Partial delivery. Only where the merchant ships in parts at all: where
|
|
225
|
+
they do not, the orders app refuses such a shipment and the question has
|
|
226
|
+
an answer already, so asking it would be a choice with one outcome. -->
|
|
222
227
|
<UCheckbox
|
|
228
|
+
v-if="partialShipmentAllowed"
|
|
223
229
|
v-model="form.partialDelivery"
|
|
224
230
|
:label="t('onepage.delivery.partialDelivery')"
|
|
225
231
|
:description="t('onepage.delivery.partialDeliveryHint')"
|
|
226
232
|
/>
|
|
233
|
+
<p
|
|
234
|
+
v-else
|
|
235
|
+
class="text-xs text-muted"
|
|
236
|
+
>
|
|
237
|
+
{{ t('onepage.delivery.completeDeliveryOnly') }}
|
|
238
|
+
</p>
|
|
227
239
|
</div>
|
|
228
240
|
</template>
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
/**
|
|
3
|
-
* Checkout entry for signed-out visitors: sign in to use the account
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* Checkout entry for signed-out visitors: sign in to use the account checkout,
|
|
4
|
+
* or continue as a business or private guest.
|
|
5
|
+
*
|
|
6
|
+
* Which of the two guest paths is open is the orders app's answer, not this
|
|
7
|
+
* shop's — and it has to be, because the app refuses a placement it does not
|
|
8
|
+
* allow. A gate offering a path that ends in a refusal wastes the buyer's whole
|
|
9
|
+
* checkout.
|
|
6
10
|
*/
|
|
7
11
|
const emit = defineEmits<{
|
|
8
12
|
(e: "signedIn"): void;
|
|
@@ -10,11 +14,8 @@ const emit = defineEmits<{
|
|
|
10
14
|
|
|
11
15
|
const { icon } = useIcons();
|
|
12
16
|
const { t } = useI18n();
|
|
13
|
-
const { settings } = useB2BContext();
|
|
14
17
|
const { customerType } = useCheckoutOnePage();
|
|
15
|
-
|
|
16
|
-
const guestB2b = computed(() => settings.value?.checkout.guestOrdering.b2b ?? false);
|
|
17
|
-
const guestB2c = computed(() => settings.value?.checkout.guestOrdering.b2c ?? false);
|
|
18
|
+
const { b2b: guestB2b, b2c: guestB2c } = useGuestOrdering();
|
|
18
19
|
</script>
|
|
19
20
|
|
|
20
21
|
<template>
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* A page whose content is one authored form — contact, price request, return
|
|
4
|
+
* request. The shell is here so a storefront's page stays what a page should be:
|
|
5
|
+
* the slug it renders, the words above it, and nothing else.
|
|
6
|
+
*
|
|
7
|
+
* <FormPage slug="contact" :title="t('forms.contact.title')" />
|
|
8
|
+
*
|
|
9
|
+
* `context` pre-fills fields by name, which is how an article or an order number
|
|
10
|
+
* arrives from the page that linked here.
|
|
11
|
+
*/
|
|
12
|
+
const props = defineProps<{
|
|
13
|
+
/** The form's slug, as published in the Cockpit. */
|
|
14
|
+
slug: string;
|
|
15
|
+
title: string;
|
|
16
|
+
intro?: string;
|
|
17
|
+
context?: Record<string, unknown>;
|
|
18
|
+
}>();
|
|
19
|
+
|
|
20
|
+
useHead({ title: props.title });
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<template>
|
|
24
|
+
<UContainer class="max-w-xl py-10 lg:py-14">
|
|
25
|
+
<h1 class="text-2xl font-semibold text-highlighted mb-2">
|
|
26
|
+
{{ title }}
|
|
27
|
+
</h1>
|
|
28
|
+
<p
|
|
29
|
+
v-if="intro"
|
|
30
|
+
class="text-muted mb-8"
|
|
31
|
+
>
|
|
32
|
+
{{ intro }}
|
|
33
|
+
</p>
|
|
34
|
+
|
|
35
|
+
<RevenexxForm
|
|
36
|
+
:slug="slug"
|
|
37
|
+
:context="context"
|
|
38
|
+
/>
|
|
39
|
+
</UContainer>
|
|
40
|
+
</template>
|
|
@@ -45,7 +45,13 @@ const { navigateToSearch } = useSearch();
|
|
|
45
45
|
<template>
|
|
46
46
|
<UHeader
|
|
47
47
|
v-model:open="isMenuOpen"
|
|
48
|
-
:toggle="{
|
|
48
|
+
:toggle="{
|
|
49
|
+
color: 'primary',
|
|
50
|
+
class: 'md:hidden',
|
|
51
|
+
// Nuxt UI labels this 'Open menu' in English whatever the shop speaks,
|
|
52
|
+
// which is what a screen reader on a German storefront was reading out.
|
|
53
|
+
'aria-label': t('nav.openMenu'),
|
|
54
|
+
}"
|
|
49
55
|
:ui="headerUi"
|
|
50
56
|
>
|
|
51
57
|
<template #left>
|
|
@@ -16,7 +16,29 @@ const PANEL_CLOSE_DELAY_MS = 180;
|
|
|
16
16
|
const appConfig = useAppConfig();
|
|
17
17
|
const liveMain = useState<typeof defaultMainNav | null>("cover:nav:mainNavigation", () => null);
|
|
18
18
|
const liveSecondary = useState<typeof defaultSecondaryNav | null>("cover:nav:mainNavigationSecondary", () => null);
|
|
19
|
-
const
|
|
19
|
+
const configuredMain = computed(() => liveMain.value ?? (appConfig.mainNavigation as typeof defaultMainNav | undefined) ?? defaultMainNav);
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The way into the catalogue, which every shop needs and one kept forgetting.
|
|
23
|
+
*
|
|
24
|
+
* The panel itself is built from the tenant's own category tree and works in any
|
|
25
|
+
* storefront — but it only opens from a navigation entry that asks for it, and a
|
|
26
|
+
* storefront writing its own navigation has no reason to know that. The result was
|
|
27
|
+
* a shop whose catalogue was reachable from the home page and the search field
|
|
28
|
+
* alone, for months, without anything going red.
|
|
29
|
+
*
|
|
30
|
+
* So the layer adds the entry where the navigation carries none. A storefront that
|
|
31
|
+
* genuinely does not want it sets `catalogueMenu: false` — which is a decision,
|
|
32
|
+
* where the old silence was an oversight.
|
|
33
|
+
*/
|
|
34
|
+
const mainNavigation = computed(() => {
|
|
35
|
+
const items = configuredMain.value;
|
|
36
|
+
const wanted = (appConfig.catalogueMenu as boolean | undefined) !== false;
|
|
37
|
+
if (!wanted || items.some(item => item.panel === "categories")) {
|
|
38
|
+
return items;
|
|
39
|
+
}
|
|
40
|
+
return [{ labelKey: "nav.catalogue", to: "/search", panel: "categories" as const }, ...items];
|
|
41
|
+
});
|
|
20
42
|
const mainNavigationSecondary = computed(() => liveSecondary.value ?? (appConfig.mainNavigationSecondary as typeof defaultSecondaryNav | undefined) ?? defaultSecondaryNav);
|
|
21
43
|
|
|
22
44
|
const { icon } = useIcons();
|
|
@@ -4,6 +4,10 @@ import { mainNavigation as defaultMainNav } from "../../../config/navigation";
|
|
|
4
4
|
const { icon } = useIcons();
|
|
5
5
|
|
|
6
6
|
const { categoryNavItems } = useCategories();
|
|
7
|
+
// Searching is the way into a B2B catalogue, and on a phone this drawer was
|
|
8
|
+
// the only place it could live — the header's own field is desktop-only, so a
|
|
9
|
+
// buyer on a phone had no way to search at all.
|
|
10
|
+
const { navigateToSearch } = useSearch();
|
|
7
11
|
const auth = useAuthStore();
|
|
8
12
|
const toast = useToast();
|
|
9
13
|
const { t } = useI18n();
|
|
@@ -37,6 +41,14 @@ const onLogout = async () => {
|
|
|
37
41
|
|
|
38
42
|
<template>
|
|
39
43
|
<div class="flex flex-col gap-4 pb-4">
|
|
44
|
+
<!-- The search, first: on a phone the header has no room for the field, and
|
|
45
|
+
without it here a buyer cannot reach the catalogue by article number at
|
|
46
|
+
all — which is how most of them reach it. -->
|
|
47
|
+
<UiFormsSearchInput
|
|
48
|
+
class="w-full"
|
|
49
|
+
@search="navigateToSearch"
|
|
50
|
+
/>
|
|
51
|
+
|
|
40
52
|
<UNavigationMenu
|
|
41
53
|
:items="mainNavItems"
|
|
42
54
|
orientation="vertical"
|
|
@@ -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"
|
|
36
|
+
:icon="icon('mail')"
|
|
37
|
+
:label="t('forms.priceRequest.cta')"
|
|
38
|
+
/>
|
|
39
|
+
</template>
|
|
@@ -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>
|
|
@@ -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,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";
|
|
@@ -33,6 +56,9 @@ function mapAuthError(err: unknown, context: "login" | "recovery" = "login"): st
|
|
|
33
56
|
? "auth.recovery.errors.unknown"
|
|
34
57
|
: "auth.login.errors.unknown";
|
|
35
58
|
}
|
|
59
|
+
if (context === "register") {
|
|
60
|
+
return "auth.register.errors.network";
|
|
61
|
+
}
|
|
36
62
|
return context === "recovery"
|
|
37
63
|
? "auth.recovery.errors.network"
|
|
38
64
|
: "auth.login.errors.network";
|
|
@@ -78,7 +104,7 @@ export const useAuthStore = defineStore("auth", () => {
|
|
|
78
104
|
return created;
|
|
79
105
|
}
|
|
80
106
|
catch (err) {
|
|
81
|
-
error.value = mapAuthError(err);
|
|
107
|
+
error.value = mapAuthError(err, "register");
|
|
82
108
|
throw err;
|
|
83
109
|
}
|
|
84
110
|
finally {
|
|
@@ -111,6 +137,59 @@ export const useAuthStore = defineStore("auth", () => {
|
|
|
111
137
|
}
|
|
112
138
|
};
|
|
113
139
|
|
|
140
|
+
/**
|
|
141
|
+
* Ask for a way in that is not a password: a mailed link, or a mailed code.
|
|
142
|
+
*
|
|
143
|
+
* Answers the same for an address nobody holds, so the form cannot be used to
|
|
144
|
+
* ask who has an account. A code request hands back the id its confirmation
|
|
145
|
+
* needs; a link carries everything in the link.
|
|
146
|
+
*/
|
|
147
|
+
const requestSignInMail = async (kind: "magic-link" | "otp", email: string): Promise<string | null> => {
|
|
148
|
+
loading.value = true;
|
|
149
|
+
error.value = null;
|
|
150
|
+
try {
|
|
151
|
+
const result = await $fetch<{ sent: true; userId?: string }>(`/api/auth/${kind}`, {
|
|
152
|
+
method: "POST",
|
|
153
|
+
body: { email },
|
|
154
|
+
});
|
|
155
|
+
return result.userId ?? null;
|
|
156
|
+
}
|
|
157
|
+
catch (err) {
|
|
158
|
+
error.value = mapAuthError(err);
|
|
159
|
+
throw err;
|
|
160
|
+
}
|
|
161
|
+
finally {
|
|
162
|
+
loading.value = false;
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
/** Hand the secret back and become signed in, exactly as a password would. */
|
|
167
|
+
const confirmSignInMail = async (
|
|
168
|
+
kind: "magic-link" | "otp",
|
|
169
|
+
{ userId, secret }: { userId: string; secret: string },
|
|
170
|
+
) => {
|
|
171
|
+
loading.value = true;
|
|
172
|
+
error.value = null;
|
|
173
|
+
try {
|
|
174
|
+
const result = await $fetch<{ user: AuthUser; session: StoredSession }>(`/api/auth/${kind}`, {
|
|
175
|
+
method: "PUT",
|
|
176
|
+
body: { userId, secret },
|
|
177
|
+
});
|
|
178
|
+
user.value = result.user;
|
|
179
|
+
session.value = result.session;
|
|
180
|
+
markAuthenticated();
|
|
181
|
+
void useCartStore().onAuthLogin();
|
|
182
|
+
return result.session;
|
|
183
|
+
}
|
|
184
|
+
catch (err) {
|
|
185
|
+
error.value = mapAuthError(err);
|
|
186
|
+
throw err;
|
|
187
|
+
}
|
|
188
|
+
finally {
|
|
189
|
+
loading.value = false;
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
|
|
114
193
|
const logout = async () => {
|
|
115
194
|
loading.value = true;
|
|
116
195
|
error.value = null;
|
|
@@ -196,6 +275,7 @@ export const useAuthStore = defineStore("auth", () => {
|
|
|
196
275
|
return {
|
|
197
276
|
user, session, isLoggedIn, loading, error,
|
|
198
277
|
register, login, logout,
|
|
278
|
+
requestSignInMail, confirmSignInMail,
|
|
199
279
|
requestRecovery, confirmRecovery,
|
|
200
280
|
init,
|
|
201
281
|
};
|
|
@@ -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
|
+
}
|