@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,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
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether somebody may order without an account, and as which kind of buyer.
|
|
3
|
+
*
|
|
4
|
+
* The orders app decides. Until it did, every storefront answered this in its
|
|
5
|
+
* own configuration file — so two shops on one tenant could disagree, neither
|
|
6
|
+
* answer was the merchant's, and switching it off meant a developer and a
|
|
7
|
+
* redeploy.
|
|
8
|
+
*
|
|
9
|
+
* The kind matters on both sides. The app cannot tell a company shopper from a
|
|
10
|
+
* private one — a guest has no contact and no organisation to read — so the shop
|
|
11
|
+
* states which it is when it places the order, and the app enforces that answer.
|
|
12
|
+
* Which means the shop must never offer a path it will then be refused on.
|
|
13
|
+
*/
|
|
14
|
+
export function useGuestOrdering() {
|
|
15
|
+
const { orders } = useShopSettings();
|
|
16
|
+
|
|
17
|
+
/** What the merchant allows; `both` while unknown, as the app's own default. */
|
|
18
|
+
const allowed = computed(() => orders.value?.guestOrdering ?? "both");
|
|
19
|
+
|
|
20
|
+
/** May a business buyer order without an account. */
|
|
21
|
+
const b2b = computed(() => allowed.value === "both" || allowed.value === "b2b");
|
|
22
|
+
/** May a private buyer. */
|
|
23
|
+
const b2c = computed(() => allowed.value === "both" || allowed.value === "b2c");
|
|
24
|
+
/** Is there any guest path at all. */
|
|
25
|
+
const any = computed(() => b2b.value || b2c.value);
|
|
26
|
+
|
|
27
|
+
return { allowed, b2b, b2c, any };
|
|
28
|
+
}
|
|
@@ -1,14 +1,29 @@
|
|
|
1
1
|
import type { ComputedRef } from "vue";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Whether
|
|
4
|
+
* Whether this buyer may change this part of their own master data.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
6
|
+
* The customers app decides, and it refuses the write itself — so this is the
|
|
7
|
+
* matching UX and not the rule. Offering a form the platform will refuse costs
|
|
8
|
+
* the buyer the work of filling it; hiding one it would have accepted costs them
|
|
9
|
+
* the change.
|
|
10
|
+
*
|
|
11
|
+
* `team` follows the company rather than the addresses: a merchant who keeps the
|
|
12
|
+
* company record keeps its people too.
|
|
10
13
|
*/
|
|
11
14
|
export function useMasterDataEditable(area: "addresses" | "profile" | "organization" | "team"): ComputedRef<boolean> {
|
|
12
|
-
const
|
|
13
|
-
return computed(() =>
|
|
15
|
+
const { account } = useShopSettings();
|
|
16
|
+
return computed(() => {
|
|
17
|
+
switch (account.value?.selfService) {
|
|
18
|
+
case "none":
|
|
19
|
+
return false;
|
|
20
|
+
case "addresses_only":
|
|
21
|
+
return area === "addresses";
|
|
22
|
+
default:
|
|
23
|
+
// Editable while unknown, which is the app's own default — a shop
|
|
24
|
+
// that cannot reach the setting must not lock a buyer out of data
|
|
25
|
+
// the merchant never took away from them.
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
});
|
|
14
29
|
}
|
|
@@ -68,5 +68,25 @@ export function useOrderListRules() {
|
|
|
68
68
|
/** The kind a new list starts as, where the app names one. */
|
|
69
69
|
const defaultKind = computed(() => orderLists.value?.defaultKind ?? null);
|
|
70
70
|
|
|
71
|
-
|
|
71
|
+
/**
|
|
72
|
+
* What becomes of a position whose part the shop no longer carries.
|
|
73
|
+
*
|
|
74
|
+
* `include` takes it anyway and lets the cart object, `skip` leaves it out and
|
|
75
|
+
* says so, `fail` refuses the whole list. A list outlives the catalogue it was
|
|
76
|
+
* written from, so this is not an edge case — it is what happens to every list
|
|
77
|
+
* eventually.
|
|
78
|
+
*/
|
|
79
|
+
const onMissingArticle = computed<"include" | "skip" | "fail">(() =>
|
|
80
|
+
orderLists.value?.onMissingArticle ?? "include",
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
return {
|
|
84
|
+
canEditPositions,
|
|
85
|
+
canManage,
|
|
86
|
+
maxPositions,
|
|
87
|
+
maxLists,
|
|
88
|
+
cartMergeMode,
|
|
89
|
+
defaultKind,
|
|
90
|
+
onMissingArticle,
|
|
91
|
+
};
|
|
72
92
|
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { PendingApproval, PendingApprovalsResponse } from "../interfaces/account/approvals";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* What is waiting on this approver, and the two things they can do about it.
|
|
5
|
+
*
|
|
6
|
+
* Oldest first: a request that has been waiting three days is more urgent than
|
|
7
|
+
* one that landed this morning, and a queue sorted the other way hides exactly
|
|
8
|
+
* the row somebody is chasing.
|
|
9
|
+
*/
|
|
10
|
+
export function usePendingApprovals() {
|
|
11
|
+
const { data, status, error, refresh } = useFetch<PendingApprovalsResponse>("/api/account/pending-approvals", {
|
|
12
|
+
key: "pending-approvals",
|
|
13
|
+
default: (): PendingApprovalsResponse => ({ approvals: [] }),
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
const approvals = computed<PendingApproval[]>(() =>
|
|
17
|
+
[...(data.value?.approvals ?? [])].sort((a, b) => a.at.localeCompare(b.at)),
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
const deciding = ref<string | null>(null);
|
|
21
|
+
|
|
22
|
+
async function decide(id: string, decision: "approve" | "decline", reason?: string): Promise<void> {
|
|
23
|
+
deciding.value = id;
|
|
24
|
+
try {
|
|
25
|
+
await $fetch(`/api/account/pending-approvals/${id}/${decision}`, {
|
|
26
|
+
method: "POST",
|
|
27
|
+
body: reason?.trim() ? { reason: reason.trim() } : {},
|
|
28
|
+
});
|
|
29
|
+
await refresh();
|
|
30
|
+
}
|
|
31
|
+
finally {
|
|
32
|
+
deciding.value = null;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return { approvals, count: computed(() => approvals.value.length), deciding, decide, status, error, refresh };
|
|
37
|
+
}
|
package/app/config/icons.ts
CHANGED
|
@@ -123,6 +123,8 @@ export const coverIconGroups: CoverIconGroup[] = [
|
|
|
123
123
|
"package": "box",
|
|
124
124
|
"delivery": "delivery",
|
|
125
125
|
"payment": "card",
|
|
126
|
+
// An offer a buyer has not earned yet — the cart's "you could still get".
|
|
127
|
+
"offer": "ticket-sale",
|
|
126
128
|
"store": "shop",
|
|
127
129
|
"direct-order": "keyboard",
|
|
128
130
|
"order-list": "clipboard-list",
|
package/app/config/navigation.ts
CHANGED
|
@@ -33,7 +33,7 @@ export const footerLinks = {
|
|
|
33
33
|
support: {
|
|
34
34
|
heading: "Support",
|
|
35
35
|
links: [
|
|
36
|
-
{ label: "Contact", to: "/
|
|
36
|
+
{ label: "Contact", to: "/contact" },
|
|
37
37
|
{ label: "Documentation", to: "/support/docs" },
|
|
38
38
|
{ label: "System Status", to: "/support/status" },
|
|
39
39
|
{ label: "Request Quote", to: "/quote" },
|
|
@@ -117,7 +117,7 @@ export const topbarUsps: TopbarUsp[] = [
|
|
|
117
117
|
|
|
118
118
|
/** Right side of the topbar — quick links. */
|
|
119
119
|
export const topbarQuickLinks: NavItem[] = [
|
|
120
|
-
{ labelKey: "topbar.contact", to: "/
|
|
120
|
+
{ labelKey: "topbar.contact", to: "/contact" },
|
|
121
121
|
{ labelKey: "topbar.aboutUs", to: "/about" },
|
|
122
122
|
{ labelKey: "topbar.locations", to: "/locations" },
|
|
123
123
|
];
|
package/app/formkit.config.ts
CHANGED
|
@@ -66,6 +66,20 @@ export default defineFormKitConfig({
|
|
|
66
66
|
input: "w-4 h-4 rounded border-(--ui-border) accent-(--ui-primary)",
|
|
67
67
|
label: "text-sm text-highlighted !font-normal",
|
|
68
68
|
},
|
|
69
|
+
// A radio inherits `global.input` without this, so every option
|
|
70
|
+
// rendered as a full-width bordered box. The Cockpit's palette offers
|
|
71
|
+
// radio groups, so an operator could author a form the shop could not
|
|
72
|
+
// render presentably — and "choose one" is the second thing anybody
|
|
73
|
+
// puts on a contact form.
|
|
74
|
+
radio: {
|
|
75
|
+
options: "flex flex-col gap-2",
|
|
76
|
+
option: "flex items-center",
|
|
77
|
+
wrapper: "flex items-center gap-2 cursor-pointer",
|
|
78
|
+
inner: "flex items-center !w-auto",
|
|
79
|
+
input: "w-4 h-4 border-(--ui-border) accent-(--ui-primary)",
|
|
80
|
+
label: "text-sm text-highlighted !font-normal",
|
|
81
|
+
legend: "text-sm font-medium text-highlighted",
|
|
82
|
+
},
|
|
69
83
|
}),
|
|
70
84
|
},
|
|
71
85
|
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What is waiting on this approver.
|
|
3
|
+
*
|
|
4
|
+
* A different question from "what did my company ask for", and the one an approver
|
|
5
|
+
* signs in to answer. The shop showed only the second, so the person whose whole
|
|
6
|
+
* reason for being there is to say yes or no found a list of other people's
|
|
7
|
+
* requests with no buttons on it — and the deciding happened in the Cockpit, which
|
|
8
|
+
* is not where a buying organisation works.
|
|
9
|
+
*/
|
|
10
|
+
export interface PendingApproval {
|
|
11
|
+
id: string;
|
|
12
|
+
/** The request this layer belongs to. */
|
|
13
|
+
requestId: string;
|
|
14
|
+
/** Its number, as the requester knows it. */
|
|
15
|
+
requestNumber: string | null;
|
|
16
|
+
/** Who asked. */
|
|
17
|
+
requestedBy: string | null;
|
|
18
|
+
/** What it comes to, where the request states a figure. */
|
|
19
|
+
total: number | null;
|
|
20
|
+
currency: string | null;
|
|
21
|
+
/** The cost centre it books to. */
|
|
22
|
+
costCentreCode: string | null;
|
|
23
|
+
/**
|
|
24
|
+
* Which layer of the chain this is.
|
|
25
|
+
*
|
|
26
|
+
* Approvals are stacked: approving one unlocks the next, and the request is
|
|
27
|
+
* approved when the last of them is. A queue that hid the position would make
|
|
28
|
+
* an approver think theirs was the only signature needed.
|
|
29
|
+
*/
|
|
30
|
+
layer: number;
|
|
31
|
+
/** When it landed on this desk. */
|
|
32
|
+
at: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface PendingApprovalsResponse {
|
|
36
|
+
approvals: PendingApproval[];
|
|
37
|
+
}
|
|
@@ -59,6 +59,35 @@ export interface AccountOrder {
|
|
|
59
59
|
readonly approvers?: string[];
|
|
60
60
|
/** Returns already requested against this order. */
|
|
61
61
|
readonly returns?: AccountOrderReturn[];
|
|
62
|
+
/**
|
|
63
|
+
* Whether the buyer may still call this order off.
|
|
64
|
+
*
|
|
65
|
+
* The orders app refuses a cancellation once anything has shipped, and holds
|
|
66
|
+
* one that is on hold where the merchant said a hold blocks it too. So the
|
|
67
|
+
* shop asks rather than deciding: a button that produces an error is worse
|
|
68
|
+
* than no button.
|
|
69
|
+
*/
|
|
70
|
+
readonly cancellable?: boolean;
|
|
71
|
+
/** Where cancelling requires the buyer to say why, as the merchant set it. */
|
|
72
|
+
readonly cancelNeedsReason?: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* What has been said about this order, buyer-visible only.
|
|
75
|
+
*
|
|
76
|
+
* The merchant's desk keeps its own notes beside these and the buyer never
|
|
77
|
+
* sees them — a trail is a record of a conversation WITH the buyer, and the
|
|
78
|
+
* desk's remarks about a customer are not part of it.
|
|
79
|
+
*/
|
|
80
|
+
readonly messages?: AccountOrderMessage[];
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** One thing said about an order, by either side. */
|
|
84
|
+
export interface AccountOrderMessage {
|
|
85
|
+
readonly id: string;
|
|
86
|
+
readonly body: string;
|
|
87
|
+
readonly author: string | null;
|
|
88
|
+
readonly at: string;
|
|
89
|
+
/** True where the buyer wrote it, so the two sides read apart. */
|
|
90
|
+
readonly fromBuyer: boolean;
|
|
62
91
|
}
|
|
63
92
|
|
|
64
93
|
export interface AccountOrderListResponse {
|
|
@@ -20,6 +20,15 @@ export interface OrderListPosition {
|
|
|
20
20
|
customSku?: string;
|
|
21
21
|
categorySlug?: string;
|
|
22
22
|
subcategorySlug?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Whether the shop still carries this part.
|
|
25
|
+
*
|
|
26
|
+
* A list is a decision somebody made once and everybody orders from since, so
|
|
27
|
+
* it outlives the catalogue: a seal is discontinued and the list still names it.
|
|
28
|
+
* Undefined where the question could not be asked — a failed catalogue read
|
|
29
|
+
* must not make a part look discontinued.
|
|
30
|
+
*/
|
|
31
|
+
available?: boolean;
|
|
23
32
|
}
|
|
24
33
|
|
|
25
34
|
export interface OrderList {
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the buyer still owes, and what they have already paid.
|
|
3
|
+
*
|
|
4
|
+
* A B2B buyer on account does not ask "did my card go through" — they ask which
|
|
5
|
+
* invoices are open and which are late, because somebody in their accounts
|
|
6
|
+
* department is asking them. The platform has kept this all along and no shop
|
|
7
|
+
* showed it, so the answer was a telephone call to the merchant.
|
|
8
|
+
*
|
|
9
|
+
* Amounts are in the currency the payment was taken in; a buyer trading in two
|
|
10
|
+
* currencies has two sets of figures and they are never added together.
|
|
11
|
+
*/
|
|
12
|
+
export type AccountPaymentState =
|
|
13
|
+
| "open"
|
|
14
|
+
| "pending"
|
|
15
|
+
| "authorized"
|
|
16
|
+
| "paid"
|
|
17
|
+
| "partially_paid"
|
|
18
|
+
| "refunded"
|
|
19
|
+
| "failed";
|
|
20
|
+
|
|
21
|
+
export interface AccountPayment {
|
|
22
|
+
id: string;
|
|
23
|
+
/** The order this is for, as the buyer knows it. */
|
|
24
|
+
orderNumber: string | null;
|
|
25
|
+
amount: number;
|
|
26
|
+
currency: string;
|
|
27
|
+
state: AccountPaymentState;
|
|
28
|
+
/** How it was to be paid, in the merchant's own words for it. */
|
|
29
|
+
method: string | null;
|
|
30
|
+
/** When the money arrived, where it has. */
|
|
31
|
+
paidAt: string | null;
|
|
32
|
+
/** When it is due. Absent where the merchant set no term. */
|
|
33
|
+
dueAt: string | null;
|
|
34
|
+
/**
|
|
35
|
+
* Past its due date and still unpaid.
|
|
36
|
+
*
|
|
37
|
+
* Computed from the date rather than read from the dunning stage: a merchant
|
|
38
|
+
* who has not started chasing still has an overdue invoice, and the buyer who
|
|
39
|
+
* wants to settle it before the chasing starts is the one this is for.
|
|
40
|
+
*/
|
|
41
|
+
overdue: boolean;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface AccountPaymentsResponse {
|
|
45
|
+
payments: AccountPayment[];
|
|
46
|
+
/** Still owed, per currency — never summed across them. */
|
|
47
|
+
outstanding: Array<{ currency: string; amount: number }>;
|
|
48
|
+
}
|
package/app/interfaces/auth.ts
CHANGED
|
@@ -16,6 +16,17 @@ export interface AuthUser {
|
|
|
16
16
|
contactId?: string;
|
|
17
17
|
/** The contact's B2B organization, when one applies. */
|
|
18
18
|
organizationId?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Whether this account may act.
|
|
21
|
+
*
|
|
22
|
+
* The platform answers it — a blocked, pending or rejected contact is not
|
|
23
|
+
* active — and the shop used to throw the answer away, so every such buyer saw
|
|
24
|
+
* the whole shop, filled a cart, and was refused at the write by an error that
|
|
25
|
+
* explained nothing. Undefined where the source does not say, which is the demo
|
|
26
|
+
* and every older session cookie: absent means active, because that is what it
|
|
27
|
+
* meant before anybody asked.
|
|
28
|
+
*/
|
|
29
|
+
active?: boolean;
|
|
19
30
|
}
|
|
20
31
|
|
|
21
32
|
/**
|
package/app/interfaces/b2b.ts
CHANGED
|
@@ -37,14 +37,14 @@ export interface OrganizationSettings {
|
|
|
37
37
|
minOrderValue: number;
|
|
38
38
|
};
|
|
39
39
|
checkout: {
|
|
40
|
-
/**
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
40
|
+
/**
|
|
41
|
+
* The order/PO number is a mandatory field.
|
|
42
|
+
*
|
|
43
|
+
* Whether somebody may order WITHOUT an account used to sit here too. It
|
|
44
|
+
* is the orders app's, because that app refuses such a placement itself —
|
|
45
|
+
* a shop holding a second answer could offer a buyer a whole checkout to
|
|
46
|
+
* be turned away at the end of it.
|
|
47
|
+
*/
|
|
48
48
|
orderNumberRequired: boolean;
|
|
49
49
|
};
|
|
50
50
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What this buyer could still get.
|
|
3
|
+
*
|
|
4
|
+
* A different question from what their cart is owed, and the promotions app makes
|
|
5
|
+
* the point itself: a shop that can only answer the second can only tell a buyer
|
|
6
|
+
* about a discount after they have already earned it. This one answers the first —
|
|
7
|
+
* each offer says how far away it is, and "12 € more" is the sentence that raises
|
|
8
|
+
* an order value.
|
|
9
|
+
*
|
|
10
|
+
* Deliberately not called a promotion. A buyer does not read "promotion"; they read
|
|
11
|
+
* an offer they are twelve euros short of.
|
|
12
|
+
*/
|
|
13
|
+
export interface AvailableOffer {
|
|
14
|
+
id: string;
|
|
15
|
+
/** What the merchant named it — shown as it stands. */
|
|
16
|
+
name: string;
|
|
17
|
+
/** True where the cart already qualifies: earned, not merely available. */
|
|
18
|
+
reached: boolean;
|
|
19
|
+
/** A code has to be entered for this one; the code itself is never sent. */
|
|
20
|
+
needsCode: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* How far away it is, where the distance is a number the buyer can act on.
|
|
23
|
+
*
|
|
24
|
+
* `value` is an amount in the cart's currency, `quantity` a count of units.
|
|
25
|
+
* Absent where the condition is not a number — "only for first orders" has no
|
|
26
|
+
* distance, and a shop that invented one would be lying about what to do next.
|
|
27
|
+
*/
|
|
28
|
+
missing?: { kind: "value" | "quantity"; amount: number; required: number };
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface AvailableOffersResponse {
|
|
32
|
+
offers: AvailableOffer[];
|
|
33
|
+
/** How many the merchant has in total, when more exist than are listed. */
|
|
34
|
+
total: number;
|
|
35
|
+
}
|
|
@@ -31,6 +31,12 @@ export interface CartAppSettings {
|
|
|
31
31
|
maxLines: number;
|
|
32
32
|
/** carts.max_quantity_per_line — ceiling per line; 0 = no limit. */
|
|
33
33
|
maxQuantityPerLine: number;
|
|
34
|
+
/**
|
|
35
|
+
* carts.default_currency — what a cart is denominated in when nothing else
|
|
36
|
+
* says. Asked wherever a figure has to be stated before a cart exists, so the
|
|
37
|
+
* shop does not fall back to a currency of its own choosing.
|
|
38
|
+
*/
|
|
39
|
+
currency: string;
|
|
34
40
|
}
|
|
35
41
|
|
|
36
42
|
/* ------------------------------------------------------------------ */
|
|
@@ -56,6 +62,21 @@ export interface OrderAppSettings {
|
|
|
56
62
|
* entirely on what will happen to it.
|
|
57
63
|
*/
|
|
58
64
|
onUnorderablePosition: "place" | "drop" | "refuse";
|
|
65
|
+
/**
|
|
66
|
+
* orders.guest_ordering — which kind of shopper may order with no account.
|
|
67
|
+
*
|
|
68
|
+
* The shop used to carry this in its own configuration, which meant two
|
|
69
|
+
* storefronts on one tenant could disagree and a merchant who wanted it off
|
|
70
|
+
* had to ask a developer.
|
|
71
|
+
*/
|
|
72
|
+
guestOrdering: "both" | "b2c" | "b2b" | "none";
|
|
73
|
+
/**
|
|
74
|
+
* orders.partial_shipment — whether a delivery may leave the rest open.
|
|
75
|
+
*
|
|
76
|
+
* `never` is the merchant whose goods are worthless half-delivered. The shop
|
|
77
|
+
* then does not ask a buyer to choose, because the answer is already given.
|
|
78
|
+
*/
|
|
79
|
+
partialShipment: "allowed" | "never";
|
|
59
80
|
}
|
|
60
81
|
|
|
61
82
|
/* ------------------------------------------------------------------ */
|
|
@@ -137,6 +158,15 @@ export interface OrderListAppSettings {
|
|
|
137
158
|
maxLists: number;
|
|
138
159
|
/** orderlists.shared_lists_editable — may the whole company edit a shared list. */
|
|
139
160
|
sharedEditable: boolean;
|
|
161
|
+
/**
|
|
162
|
+
* orderlists.on_missing_article — what becomes of a position whose part the
|
|
163
|
+
* shop no longer carries: take it anyway, leave it out, or refuse the lot.
|
|
164
|
+
*
|
|
165
|
+
* Not an edge case. A list is a decision made once and ordered from for years,
|
|
166
|
+
* so it outlives the catalogue it was written from; this is what happens to
|
|
167
|
+
* every list eventually.
|
|
168
|
+
*/
|
|
169
|
+
onMissingArticle: "include" | "skip" | "fail";
|
|
140
170
|
/** orderlists.cart_merge_mode — adding a list to a cart appends or replaces. */
|
|
141
171
|
cartMergeMode: "append" | "replace";
|
|
142
172
|
/** orderlists.default_kind — the kind a new list starts as; null = unset. */
|
|
@@ -181,6 +211,25 @@ export interface SignInAppSettings {
|
|
|
181
211
|
export interface AccountAppSettings {
|
|
182
212
|
/** customers.single_default_address_per_type — one default per address type. */
|
|
183
213
|
singleDefaultAddressPerType: boolean;
|
|
214
|
+
/**
|
|
215
|
+
* customers.self_service_master_data — how much of their own data a buyer may
|
|
216
|
+
* change here.
|
|
217
|
+
*
|
|
218
|
+
* Where an ERP is the record, an edit in the shop is a second truth the next
|
|
219
|
+
* import overwrites. The shop used to answer this with four flags of its own,
|
|
220
|
+
* which hid the forms while the platform went on accepting the write.
|
|
221
|
+
*/
|
|
222
|
+
selfService: "all" | "addresses_only" | "none";
|
|
223
|
+
/**
|
|
224
|
+
* customers.blocked_contact_behavior — what a buyer whose account is on hold
|
|
225
|
+
* may still do: keep what their role grants, browse the catalogue only, or
|
|
226
|
+
* nothing at all.
|
|
227
|
+
*
|
|
228
|
+
* The platform enforces it on the permission set. The shop reads it to say
|
|
229
|
+
* WHY, because a buyer who fills a cart and is refused at the write learns
|
|
230
|
+
* only that something is broken.
|
|
231
|
+
*/
|
|
232
|
+
blockedBuyer: "keep" | "catalog_only" | "deny_all";
|
|
184
233
|
}
|
|
185
234
|
|
|
186
235
|
/* ------------------------------------------------------------------ */
|
|
@@ -205,6 +254,33 @@ export interface ProcurementAppSettings {
|
|
|
205
254
|
gate: "none" | "booking_account";
|
|
206
255
|
}
|
|
207
256
|
|
|
257
|
+
/* ------------------------------------------------------------------ */
|
|
258
|
+
/* Authored forms */
|
|
259
|
+
/* ------------------------------------------------------------------ */
|
|
260
|
+
|
|
261
|
+
export interface FormAppSettings {
|
|
262
|
+
/**
|
|
263
|
+
* forms.honeypot_field — the name of a decoy field the storefront renders
|
|
264
|
+
* hidden. A human never fills it; a bot fills everything, and a submission
|
|
265
|
+
* that arrives with it filled in is spam.
|
|
266
|
+
*
|
|
267
|
+
* The app expects the SHOP to render it — it can only judge what it is sent.
|
|
268
|
+
* So a tenant who configured a trap and a storefront that never rendered the
|
|
269
|
+
* field add up to no trap at all, which is what shipped: null here means the
|
|
270
|
+
* merchant named none, and the empty string the app declares means the same.
|
|
271
|
+
*/
|
|
272
|
+
honeypotField: string | null;
|
|
273
|
+
/**
|
|
274
|
+
* forms.spam_handling — what becomes of a caught submission. `flag` stores it
|
|
275
|
+
* marked as spam so a false positive is recoverable; `reject` refuses it and
|
|
276
|
+
* nothing is stored, no automation ever hears about it.
|
|
277
|
+
*
|
|
278
|
+
* The storefront reads it to know what to SAY: under `reject` a caught
|
|
279
|
+
* visitor is told their message did not arrive, because it did not.
|
|
280
|
+
*/
|
|
281
|
+
spamHandling: "flag" | "reject";
|
|
282
|
+
}
|
|
283
|
+
|
|
208
284
|
/* ------------------------------------------------------------------ */
|
|
209
285
|
/* The whole answer */
|
|
210
286
|
/* ------------------------------------------------------------------ */
|
|
@@ -222,6 +298,7 @@ export interface ShopSettings {
|
|
|
222
298
|
account: AccountAppSettings;
|
|
223
299
|
inventory: InventoryAppSettings;
|
|
224
300
|
procurement: ProcurementAppSettings;
|
|
301
|
+
forms: FormAppSettings;
|
|
225
302
|
/**
|
|
226
303
|
* Whether these came from the platform apps or from the bundled demo
|
|
227
304
|
* tenant. Both are configured values read the same way, so no surface has
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A buyer whose account is on hold stops being offered the cart.
|
|
3
|
+
*
|
|
4
|
+
* The platform refuses their orders — it shapes the permission set by the
|
|
5
|
+
* merchant's choice, and at `catalog_only` there is no ordering permission left.
|
|
6
|
+
* The shop's part is not to enforce that a second time but to stop asking: a
|
|
7
|
+
* quantity stepper that works and a checkout button that does not is worse than
|
|
8
|
+
* a cart that plainly says it is read-only.
|
|
9
|
+
*
|
|
10
|
+
* Where the merchant left the buyer their permissions (`keep`) nothing changes:
|
|
11
|
+
* the hold is a notice, not a lock, and the account area says so.
|
|
12
|
+
*/
|
|
13
|
+
export default defineNuxtPlugin(() => {
|
|
14
|
+
const cart = useCartStore();
|
|
15
|
+
const { mayAct } = useAccountHold();
|
|
16
|
+
|
|
17
|
+
watch(mayAct, (allowed) => {
|
|
18
|
+
cart.setReadOnly(!allowed);
|
|
19
|
+
}, { immediate: true });
|
|
20
|
+
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { FormSummary } from "../../server/interfaces/forms";
|
|
1
2
|
import type { ShopSettings } from "../interfaces/shopSettings";
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -32,21 +33,35 @@ const forwardedHeaders = () =>
|
|
|
32
33
|
useRequestHeaders(["cookie", "x-revenexx-tenant", "x-revenexx-context"]);
|
|
33
34
|
|
|
34
35
|
export default defineNuxtPlugin(async () => {
|
|
35
|
-
const
|
|
36
|
+
const settings = useState<ShopSettings | null>("cover:shop-settings", () => null);
|
|
37
|
+
// The forms the merchant published, fetched in the same breath rather than by
|
|
38
|
+
// a plugin of its own: it is the same kind of fact (what this shop HAS, before
|
|
39
|
+
// anything renders), and beside an awaited call it costs no round trip. A link
|
|
40
|
+
// that appeared after the page did would move the buy box under the cursor.
|
|
41
|
+
const forms = useState<FormSummary[] | null>("cover:authored-forms", () => null);
|
|
36
42
|
|
|
37
|
-
// Hydration: the server already put the
|
|
38
|
-
if (
|
|
43
|
+
// Hydration: the server already put the answers in the payload.
|
|
44
|
+
if (settings.value && forms.value) {
|
|
39
45
|
return;
|
|
40
46
|
}
|
|
41
47
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
// allSettled rather than a .catch() on each call: this must survive a $fetch
|
|
49
|
+
// that does not hand back a thenable at all, which is what a test harness does
|
|
50
|
+
// for an endpoint nobody registered. A TypeError here takes the whole app
|
|
51
|
+
// initialisation down with it, and the router with that.
|
|
52
|
+
const headers = forwardedHeaders();
|
|
53
|
+
const [answered, offered] = await Promise.allSettled([
|
|
54
|
+
$fetch<ShopSettings>("/api/shop/settings", { headers }),
|
|
55
|
+
$fetch<{ forms: FormSummary[] }>("/api/forms", { headers }),
|
|
56
|
+
]);
|
|
57
|
+
const settled = answered.status === "fulfilled" ? answered.value : null;
|
|
58
|
+
const published = offered.status === "fulfilled" ? offered.value : null;
|
|
59
|
+
|
|
60
|
+
// Left null on failure. Every reader falls back to what the layer has always
|
|
61
|
+
// done, and a page that cannot learn the merchant's terms states none — which
|
|
62
|
+
// is the same thing it does for a merchant who set none.
|
|
63
|
+
if (settled) {
|
|
64
|
+
settings.value = settled;
|
|
51
65
|
}
|
|
66
|
+
forms.value = published?.forms ?? [];
|
|
52
67
|
});
|