@revenexx/cover 0.10.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/assets/css/cover.css +9 -0
- package/app/components/RevenexxForm.vue +4 -0
- package/app/components/account/AccountSidebar.vue +2 -5
- package/app/components/account/dashboard/AccountDashboardKpis.vue +74 -34
- package/app/components/account/dashboard/AccountDashboardQuickActions.vue +24 -6
- package/app/components/account/organization/AccountOrganization.vue +3 -1
- package/app/components/account/team/AccountTeam.vue +32 -7
- package/app/components/auth/AuthForgotPasswordPanel.vue +9 -4
- package/app/components/auth/AuthLoginPanel.vue +5 -3
- 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/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 +18 -2
- package/app/components/checkout/onepage/CheckoutGate.vue +2 -0
- 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/layout/Region.vue +13 -0
- package/app/components/layout/footer/Footer.vue +8 -0
- package/app/components/layout/header/AppBar.vue +4 -3
- package/app/components/layout/header/MainNav.vue +3 -3
- 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 +1 -1
- package/app/components/product/detail/ProductDetailSaveToList.vue +10 -0
- package/app/composables/useAccountDashboard.ts +0 -10
- package/app/composables/useAccountNavigation.ts +35 -0
- package/app/composables/useAuthStore.ts +2 -0
- package/app/composables/useCategoryListing.ts +6 -0
- package/app/composables/useCheckoutOnePage.ts +21 -2
- package/app/composables/useMasterDataEditable.ts +23 -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/quickActions.ts +40 -5
- package/app/interfaces/account/dashboard.ts +2 -0
- package/app/interfaces/auth.ts +13 -2
- package/app/interfaces/quantity-stepper.ts +17 -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/theme-events.client.ts +132 -0
- package/app/shared/themeEvents.ts +445 -0
- package/i18n/locales/de/account.json +7 -0
- package/i18n/locales/de/auth.json +1 -0
- package/i18n/locales/de/cart.json +2 -1
- package/i18n/locales/de/checkout.json +2 -1
- package/i18n/locales/de/common.json +2 -0
- package/i18n/locales/de/cover.json +44 -0
- package/i18n/locales/de/editor.json +47 -1
- package/i18n/locales/en/account.json +7 -0
- package/i18n/locales/en/auth.json +1 -0
- package/i18n/locales/en/cart.json +2 -1
- package/i18n/locales/en/checkout.json +2 -1
- package/i18n/locales/en/common.json +2 -0
- package/i18n/locales/en/cover.json +44 -0
- package/i18n/locales/en/editor.json +47 -1
- package/nuxt.config.ts +15 -1
- package/package.json +5 -2
- package/server/api/account/orders/[id]/cancel.post.ts +1 -1
- package/server/api/account/orders/[id]/messages.get.ts +1 -1
- package/server/api/account/orders/[id]/messages.post.ts +1 -1
- 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/pending-approvals/index.get.ts +1 -0
- package/server/api/account/profile.get.ts +3 -1
- package/server/api/auth/login.post.ts +6 -0
- package/server/api/auth/magic-link.put.ts +6 -1
- package/server/api/auth/otp.put.ts +6 -1
- 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/orders/index.post.ts +33 -0
- package/server/api/quick-actions.get.ts +6 -38
- 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 +98 -17
- package/server/services/ApiCartService.ts +3 -10
- package/server/services/ApiOrganizationService.ts +7 -2
- package/server/services/ApiTeamService.ts +93 -21
- package/server/utils/buyerIdentity.ts +168 -0
- package/server/utils/cartOwnership.ts +27 -0
- package/server/utils/liveOrderLists.ts +50 -23
- package/server/utils/liveOrders.ts +39 -24
- package/server/utils/livePrices.ts +7 -15
- package/server/utils/masterData.ts +29 -0
- package/server/utils/passwordlessSignIn.ts +13 -4
- package/server/utils/pendingApprovals.ts +29 -7
- package/server/utils/procurementCheckout.ts +2 -0
- package/server/utils/quickActionCatalogue.ts +53 -0
- package/server/utils/revenexxSdk.ts +116 -2
|
@@ -0,0 +1,445 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The theme event contract (`theme-events/1`) as cover speaks it.
|
|
3
|
+
*
|
|
4
|
+
* Everything here is pure: no Nuxt, no Vue, no store. It turns what the shop
|
|
5
|
+
* holds — cart lines, listing hits, a route — into what the contract allows, so
|
|
6
|
+
* the rules (net and gross, "on request" is null and never 0, which page is
|
|
7
|
+
* which, where nothing may be emitted) are decided once and unit-tested
|
|
8
|
+
* without an application around them. `useThemeEvents()` stamps the
|
|
9
|
+
* context and sends; the plugin and the components only say what happened.
|
|
10
|
+
*
|
|
11
|
+
* Never put anything about the visitor in here beyond the two booleans the
|
|
12
|
+
* envelope carries. The contract closes every object, so a forbidden field is
|
|
13
|
+
* dropped by validation in dev — but the place to not send it is here.
|
|
14
|
+
*/
|
|
15
|
+
import type {
|
|
16
|
+
PageType,
|
|
17
|
+
ThemeEventEcommerce,
|
|
18
|
+
ThemeEventItem,
|
|
19
|
+
} from "@revenexx/tag-manager-nuxt/events";
|
|
20
|
+
|
|
21
|
+
import type { CartItem } from "../interfaces/cart-item";
|
|
22
|
+
import type { ProductList } from "../interfaces/product-list";
|
|
23
|
+
|
|
24
|
+
/** The cart store's own fallback rate (`TAX_RATE`), as a percentage. */
|
|
25
|
+
const DEFAULT_TAX_PERCENT = 19;
|
|
26
|
+
|
|
27
|
+
/** Path prefixes of the editor and the preview — nothing is ever emitted there. */
|
|
28
|
+
const EDITOR_PATH_PREFIXES = ["/admin", "/preview"];
|
|
29
|
+
|
|
30
|
+
/** Hosts the theme editor renders on. */
|
|
31
|
+
const EDITOR_HOST_SUFFIX = ".theme.rvnxx.site";
|
|
32
|
+
|
|
33
|
+
const round2 = (n: number): number => Math.round(n * 100) / 100;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* A unit price the contract can carry: a positive finite amount, rounded to
|
|
37
|
+
* cents — or `null`. Zero is "on request" in this shop (the prices app answers
|
|
38
|
+
* on_request rather than 0), and a tag must never report a free article.
|
|
39
|
+
*/
|
|
40
|
+
export function eventPrice(value: unknown): number | null {
|
|
41
|
+
return typeof value === "number" && Number.isFinite(value) && value > 0 ? round2(value) : null;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** A tax rate as a fraction, accepting both 19 and 0.19. */
|
|
45
|
+
function taxFraction(rate: unknown): number {
|
|
46
|
+
const raw = typeof rate === "number" && Number.isFinite(rate) && rate >= 0 ? rate : DEFAULT_TAX_PERCENT;
|
|
47
|
+
return raw > 1 ? raw / 100 : raw;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Net and gross from the one price the shop holds. Cart lines and listing
|
|
52
|
+
* offers carry the NET unit price — the cart store taxes it on top, and
|
|
53
|
+
* displays it with tax only where the market quotes gross — so gross is
|
|
54
|
+
* derived, never read.
|
|
55
|
+
*/
|
|
56
|
+
export function netAndGross(net: number | null, taxRate: unknown): { price_net: number | null; price_gross: number | null } {
|
|
57
|
+
if (net === null) {
|
|
58
|
+
return { price_net: null, price_gross: null };
|
|
59
|
+
}
|
|
60
|
+
return { price_net: net, price_gross: round2(net * (1 + taxFraction(taxRate))) };
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Anything shaped like a cart line: a cart item, an order-list position, a
|
|
65
|
+
* quote request position. Only what an event may carry is read.
|
|
66
|
+
*/
|
|
67
|
+
export type LineLike = Pick<CartItem, "id" | "sku" | "name" | "price" | "quantity">
|
|
68
|
+
& Partial<Pick<CartItem, "name2" | "taxRate" | "priceTiers">>;
|
|
69
|
+
|
|
70
|
+
/** The unit price a line pays at its quantity — the cart store's tier rule. */
|
|
71
|
+
export function lineUnitPrice(item: Pick<LineLike, "price" | "priceTiers" | "quantity">): number {
|
|
72
|
+
let price = item.price;
|
|
73
|
+
for (const tier of item.priceTiers ?? []) {
|
|
74
|
+
if (item.quantity >= tier.minQuantity) {
|
|
75
|
+
price = tier.unitPrice;
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return price;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** A cart line as a contract item. `quantity` overrides the line's own (a delta). */
|
|
85
|
+
export function cartLineToItem(item: LineLike, quantity: number = item.quantity): ThemeEventItem {
|
|
86
|
+
const { price_net, price_gross } = netAndGross(eventPrice(lineUnitPrice(item)), item.taxRate);
|
|
87
|
+
return {
|
|
88
|
+
sku: item.sku || String(item.id),
|
|
89
|
+
name: item.name || item.sku || String(item.id),
|
|
90
|
+
...(item.name2 ? { variant: item.name2.slice(0, 128) } : {}),
|
|
91
|
+
price_net,
|
|
92
|
+
price_gross,
|
|
93
|
+
quantity,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** The unit price of the first tier of a listing offer (`{ "1": cents }`), in currency units. */
|
|
98
|
+
export function offerUnitPrice(prices: { [key: string]: number }[] | undefined): number | null {
|
|
99
|
+
const map = prices?.[0];
|
|
100
|
+
if (!map) {
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
const tiers = Object.entries(map)
|
|
104
|
+
.map(([q, cents]) => ({ q: Number.parseInt(q, 10), cents: Number(cents) }))
|
|
105
|
+
.filter(t => Number.isFinite(t.q) && t.q > 0 && Number.isFinite(t.cents))
|
|
106
|
+
.sort((a, b) => a.q - b.q);
|
|
107
|
+
const first = tiers[0];
|
|
108
|
+
return first ? eventPrice(first.cents / first.q / 100) : null;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** A listing hit as a contract item, priced from its offer when one has arrived. */
|
|
112
|
+
export function listingProductToItem(
|
|
113
|
+
product: ProductList,
|
|
114
|
+
options: { position?: number; listId?: string; prices?: { [key: string]: number }[] } = {},
|
|
115
|
+
): ThemeEventItem {
|
|
116
|
+
const net = offerUnitPrice(options.prices ?? product.prices);
|
|
117
|
+
const categoryPath = [product.category, product.subcategory]
|
|
118
|
+
.filter((c): c is string => typeof c === "string" && c.trim().length > 0)
|
|
119
|
+
.map(c => c.slice(0, 128));
|
|
120
|
+
return {
|
|
121
|
+
sku: product.sku || String(product.id),
|
|
122
|
+
name: product.name || product.sku || String(product.id),
|
|
123
|
+
...(categoryPath.length ? { category_path: categoryPath } : {}),
|
|
124
|
+
...netAndGross(net, product.tax?.rate),
|
|
125
|
+
quantity: 1,
|
|
126
|
+
...(options.position && options.position >= 1 ? { list_position: Math.floor(options.position) } : {}),
|
|
127
|
+
...(options.listId ? { list_id: options.listId.slice(0, 128) } : {}),
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/** Sum of the items' net and gross, or null as soon as one line is on request. */
|
|
132
|
+
export function itemsValue(items: ThemeEventItem[]): Pick<ThemeEventEcommerce, "value_net" | "value_gross"> {
|
|
133
|
+
let net = 0;
|
|
134
|
+
let gross = 0;
|
|
135
|
+
for (const item of items) {
|
|
136
|
+
if (item.price_net == null || item.price_gross == null) {
|
|
137
|
+
return { value_net: null, value_gross: null };
|
|
138
|
+
}
|
|
139
|
+
net += item.price_net * item.quantity;
|
|
140
|
+
gross += item.price_gross * item.quantity;
|
|
141
|
+
}
|
|
142
|
+
return { value_net: round2(net), value_gross: round2(gross) };
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** The `ecommerce` block for a set of cart lines: items plus their value. */
|
|
146
|
+
export function cartEcommerce(lines: readonly LineLike[], extra: Partial<ThemeEventEcommerce> = {}): ThemeEventEcommerce {
|
|
147
|
+
const items = lines.map(line => cartLineToItem(line));
|
|
148
|
+
return { items, ...itemsValue(items), ...extra };
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/** The list id of a category listing, as the contract names it. */
|
|
152
|
+
export function categoryListId(categorySlug: string, subcategorySlug?: string): string {
|
|
153
|
+
return `category:${categorySlug}${subcategorySlug ? `/${subcategorySlug}` : ""}`.slice(0, 128);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/* ---- where we are --------------------------------------------------------- */
|
|
157
|
+
|
|
158
|
+
/** The path without a leading locale segment (`/en/cart` → `/cart`). */
|
|
159
|
+
export function stripLocalePrefix(path: string, localeCodes: readonly string[]): string {
|
|
160
|
+
const clean = (path.split(/[?#]/)[0] || "/").replace(/\/+$/, "") || "/";
|
|
161
|
+
const first = clean.split("/")[1] ?? "";
|
|
162
|
+
if (first && localeCodes.includes(first)) {
|
|
163
|
+
return clean.slice(first.length + 1) || "/";
|
|
164
|
+
}
|
|
165
|
+
return clean;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const startsWithSegment = (path: string, prefix: string): boolean =>
|
|
169
|
+
path === prefix || path.startsWith(`${prefix}/`);
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* True where the shop is being authored or previewed: the editor and preview
|
|
173
|
+
* routes, a `?blokkliEdit=1` render, and the theme editor's own hosts. The
|
|
174
|
+
* editor seeds sample carts and renders sample products — none of that is a
|
|
175
|
+
* shopper, and none of it may reach a tag.
|
|
176
|
+
*/
|
|
177
|
+
export function isEditorContext(where: {
|
|
178
|
+
path: string;
|
|
179
|
+
host?: string;
|
|
180
|
+
query?: Record<string, unknown>;
|
|
181
|
+
localeCodes?: readonly string[];
|
|
182
|
+
}): boolean {
|
|
183
|
+
if (where.host && where.host.toLowerCase().split(":")[0]!.endsWith(EDITOR_HOST_SUFFIX)) {
|
|
184
|
+
return true;
|
|
185
|
+
}
|
|
186
|
+
const edit = where.query?.blokkliEdit;
|
|
187
|
+
if (edit === "1" || (Array.isArray(edit) && edit.includes("1"))) {
|
|
188
|
+
return true;
|
|
189
|
+
}
|
|
190
|
+
const path = stripLocalePrefix(where.path, where.localeCodes ?? []);
|
|
191
|
+
return EDITOR_PATH_PREFIXES.some(prefix => startsWithSegment(path, prefix));
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/** What kind of page a path is, in the contract's vocabulary. */
|
|
195
|
+
export function pageTypeOf(fullPath: string, localeCodes: readonly string[] = []): PageType {
|
|
196
|
+
const path = stripLocalePrefix(fullPath, localeCodes);
|
|
197
|
+
if (path === "/") {
|
|
198
|
+
return "home";
|
|
199
|
+
}
|
|
200
|
+
if (startsWithSegment(path, "/category")) {
|
|
201
|
+
return path.split("/").includes("product") ? "product" : "category";
|
|
202
|
+
}
|
|
203
|
+
const rules: [string, PageType][] = [
|
|
204
|
+
["/search", "search"],
|
|
205
|
+
["/cart", "cart"],
|
|
206
|
+
["/checkout/confirmation", "confirmation"],
|
|
207
|
+
["/checkout", "checkout"],
|
|
208
|
+
["/account/quotes", "quote"],
|
|
209
|
+
["/account/order-lists", "orderlist"],
|
|
210
|
+
["/account", "account"],
|
|
211
|
+
["/punchout", "punchout"],
|
|
212
|
+
["/login", "login"],
|
|
213
|
+
["/register", "register"],
|
|
214
|
+
];
|
|
215
|
+
return rules.find(([prefix]) => startsWithSegment(path, prefix))?.[1] ?? "content";
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/* ---- the cart, read as a series of changes -------------------------------- */
|
|
219
|
+
|
|
220
|
+
/** One line's quantity, keyed the way the cart store keys lines. */
|
|
221
|
+
export interface LineSnapshot {
|
|
222
|
+
key: string;
|
|
223
|
+
quantity: number;
|
|
224
|
+
line: CartItem;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
export const lineKeyOf = (item: CartItem): string => item.lineKey ?? `id-${item.id}`;
|
|
228
|
+
|
|
229
|
+
export function snapshotLines(items: readonly CartItem[]): Map<string, LineSnapshot> {
|
|
230
|
+
return new Map(items.map(item => [lineKeyOf(item), { key: lineKeyOf(item), quantity: item.quantity, line: { ...item } }]));
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* What changed between two readings of the cart, line by line: quantity that
|
|
235
|
+
* arrived and quantity that left. A line that vanished left whole; a new one
|
|
236
|
+
* arrived whole. Prices are the line's own at the moment it was read.
|
|
237
|
+
*/
|
|
238
|
+
export function diffLines(
|
|
239
|
+
before: Map<string, LineSnapshot>,
|
|
240
|
+
after: Map<string, LineSnapshot>,
|
|
241
|
+
): { added: ThemeEventItem[]; removed: ThemeEventItem[] } {
|
|
242
|
+
const added: ThemeEventItem[] = [];
|
|
243
|
+
const removed: ThemeEventItem[] = [];
|
|
244
|
+
for (const [key, now] of after) {
|
|
245
|
+
const delta = now.quantity - (before.get(key)?.quantity ?? 0);
|
|
246
|
+
if (delta > 0) {
|
|
247
|
+
added.push(cartLineToItem(now.line, delta));
|
|
248
|
+
}
|
|
249
|
+
else if (delta < 0) {
|
|
250
|
+
removed.push(cartLineToItem(now.line, -delta));
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
for (const [key, was] of before) {
|
|
254
|
+
if (!after.has(key) && was.quantity > 0) {
|
|
255
|
+
removed.push(cartLineToItem(was.line, was.quantity));
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
return { added, removed };
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/** The cart store actions whose effect is reported, and which way. */
|
|
262
|
+
export const CART_ADD_ACTIONS = ["addItem"] as const;
|
|
263
|
+
export const CART_CHANGE_ACTIONS = ["removeItem", "updateQuantity", "removeByKeys", "updateQuantityByKey"] as const;
|
|
264
|
+
|
|
265
|
+
interface CartLike {
|
|
266
|
+
items: CartItem[];
|
|
267
|
+
$onAction(callback: (context: {
|
|
268
|
+
name: string;
|
|
269
|
+
after: (cb: (result: unknown) => void) => void;
|
|
270
|
+
}) => void, detached?: boolean): () => void;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Report what the buyer did to their cart.
|
|
275
|
+
*
|
|
276
|
+
* - `add_to_cart` only for an add the store ACCEPTED: `addItem` returns false
|
|
277
|
+
* for a read-only punchout cart, a line at its ceiling or a full cart, and a
|
|
278
|
+
* refused add is not an add.
|
|
279
|
+
* - Raising a quantity is an add of the difference, lowering it a removal.
|
|
280
|
+
* - `clearCart` is never a removal: it runs after an order, a quote, a login and
|
|
281
|
+
* a logout, none of which is a buyer taking something out.
|
|
282
|
+
* - Changes made in one go (the product page adds one and then sets the
|
|
283
|
+
* quantity) are coalesced into one event per direction.
|
|
284
|
+
*
|
|
285
|
+
* Returns the unsubscribe function.
|
|
286
|
+
*/
|
|
287
|
+
export function trackCartChanges(
|
|
288
|
+
cart: CartLike,
|
|
289
|
+
report: (event: "add_to_cart" | "remove_from_cart", items: ThemeEventItem[]) => void,
|
|
290
|
+
options: { schedule?: (flush: () => void) => void } = {},
|
|
291
|
+
): () => void {
|
|
292
|
+
const schedule = options.schedule ?? ((flush: () => void) => { void Promise.resolve().then(flush); });
|
|
293
|
+
let pendingAdded: ThemeEventItem[] = [];
|
|
294
|
+
let pendingRemoved: ThemeEventItem[] = [];
|
|
295
|
+
let scheduled = false;
|
|
296
|
+
|
|
297
|
+
const merge = (into: ThemeEventItem[], items: ThemeEventItem[]): ThemeEventItem[] => {
|
|
298
|
+
const out = [...into];
|
|
299
|
+
for (const item of items) {
|
|
300
|
+
const same = out.find(o => o.sku === item.sku && o.price_net === item.price_net && o.variant === item.variant);
|
|
301
|
+
if (same) {
|
|
302
|
+
same.quantity += item.quantity;
|
|
303
|
+
}
|
|
304
|
+
else {
|
|
305
|
+
out.push({ ...item });
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
return out;
|
|
309
|
+
};
|
|
310
|
+
|
|
311
|
+
const flush = () => {
|
|
312
|
+
scheduled = false;
|
|
313
|
+
const added = pendingAdded;
|
|
314
|
+
const removed = pendingRemoved;
|
|
315
|
+
pendingAdded = [];
|
|
316
|
+
pendingRemoved = [];
|
|
317
|
+
if (added.length) {
|
|
318
|
+
report("add_to_cart", added);
|
|
319
|
+
}
|
|
320
|
+
if (removed.length) {
|
|
321
|
+
report("remove_from_cart", removed);
|
|
322
|
+
}
|
|
323
|
+
};
|
|
324
|
+
|
|
325
|
+
const queue = (added: ThemeEventItem[], removed: ThemeEventItem[]) => {
|
|
326
|
+
if (!added.length && !removed.length) {
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
329
|
+
pendingAdded = merge(pendingAdded, added);
|
|
330
|
+
pendingRemoved = merge(pendingRemoved, removed);
|
|
331
|
+
if (!scheduled) {
|
|
332
|
+
scheduled = true;
|
|
333
|
+
schedule(flush);
|
|
334
|
+
}
|
|
335
|
+
};
|
|
336
|
+
|
|
337
|
+
return cart.$onAction(({ name, after }) => {
|
|
338
|
+
const isAdd = (CART_ADD_ACTIONS as readonly string[]).includes(name);
|
|
339
|
+
const isChange = (CART_CHANGE_ACTIONS as readonly string[]).includes(name);
|
|
340
|
+
if (!isAdd && !isChange) {
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
const before = snapshotLines(cart.items);
|
|
344
|
+
after((result) => {
|
|
345
|
+
// addItem answers whether the cart took the article. Anything but a
|
|
346
|
+
// plain `true` is a refusal, and a refusal reports nothing.
|
|
347
|
+
if (isAdd && result !== true) {
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
350
|
+
const { added, removed } = diffLines(before, snapshotLines(cart.items));
|
|
351
|
+
queue(added, isAdd ? [] : removed);
|
|
352
|
+
});
|
|
353
|
+
}, true);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
/* ---- the order, from the checkout to the confirmation --------------------- */
|
|
357
|
+
|
|
358
|
+
const PURCHASE_STASH_KEY = "rvx_se_checkout";
|
|
359
|
+
const PURCHASE_STASH_TTL_MS = 60 * 60 * 1000;
|
|
360
|
+
|
|
361
|
+
export interface PurchaseSnapshot {
|
|
362
|
+
ecommerce: Omit<ThemeEventEcommerce, "transaction_id">;
|
|
363
|
+
at: number;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
interface StorageLike {
|
|
367
|
+
getItem(key: string): string | null;
|
|
368
|
+
setItem(key: string, value: string): void;
|
|
369
|
+
removeItem(key: string): void;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
/** Totals rows the cart calculation answers with, as far as a purchase needs them. */
|
|
373
|
+
interface TotalsRow {
|
|
374
|
+
key: string;
|
|
375
|
+
amount: number;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* The order as it is about to be placed: the lines and the money, read from
|
|
380
|
+
* the cart and its server calculation BEFORE the cart is cleared. Values fall
|
|
381
|
+
* back to the cart's own arithmetic where no calculation has arrived.
|
|
382
|
+
*/
|
|
383
|
+
export function purchaseFromCart(
|
|
384
|
+
lines: CartItem[],
|
|
385
|
+
totals: TotalsRow[] | null | undefined,
|
|
386
|
+
fallback: { subtotal: number; tax: number },
|
|
387
|
+
extra: Partial<ThemeEventEcommerce> = {},
|
|
388
|
+
): Omit<ThemeEventEcommerce, "transaction_id"> {
|
|
389
|
+
const items = lines.map(line => cartLineToItem(line));
|
|
390
|
+
const row = (key: string): number | undefined => {
|
|
391
|
+
const found = (totals ?? []).filter(r => r.key === key);
|
|
392
|
+
return found.length ? found.reduce((sum, r) => sum + (Number.isFinite(r.amount) ? r.amount : 0), 0) : undefined;
|
|
393
|
+
};
|
|
394
|
+
const tax = row("tax") ?? fallback.tax;
|
|
395
|
+
const shipping = row("shipping") ?? 0;
|
|
396
|
+
const gross = row("total") ?? fallback.subtotal + fallback.tax;
|
|
397
|
+
const nonNegative = (n: number): number => (Number.isFinite(n) && n > 0 ? round2(n) : 0);
|
|
398
|
+
return {
|
|
399
|
+
items,
|
|
400
|
+
value_net: nonNegative(gross - tax),
|
|
401
|
+
value_gross: nonNegative(gross),
|
|
402
|
+
tax: nonNegative(tax),
|
|
403
|
+
shipping: nonNegative(shipping),
|
|
404
|
+
...extra,
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
/** The tab's sessionStorage, or null where the browser refuses it (private modes, blocked storage). */
|
|
409
|
+
export function browserSession(): StorageLike | null {
|
|
410
|
+
try {
|
|
411
|
+
return (globalThis as { sessionStorage?: StorageLike }).sessionStorage ?? null;
|
|
412
|
+
}
|
|
413
|
+
catch {
|
|
414
|
+
return null;
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
/** Keep the order the checkout is about to place, for the confirmation page to report. */
|
|
419
|
+
export function stashPurchase(storage: StorageLike | null | undefined, ecommerce: PurchaseSnapshot["ecommerce"], now = Date.now()): void {
|
|
420
|
+
try {
|
|
421
|
+
storage?.setItem(PURCHASE_STASH_KEY, JSON.stringify({ ecommerce, at: now } satisfies PurchaseSnapshot));
|
|
422
|
+
}
|
|
423
|
+
catch {
|
|
424
|
+
// Storage blocked or full: the purchase goes unreported, the order does not.
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
/** Take the stashed order (once), if it is recent enough to be the one just placed. */
|
|
429
|
+
export function takePurchase(storage: StorageLike | null | undefined, now = Date.now()): PurchaseSnapshot["ecommerce"] | null {
|
|
430
|
+
try {
|
|
431
|
+
const raw = storage?.getItem(PURCHASE_STASH_KEY);
|
|
432
|
+
if (!raw) {
|
|
433
|
+
return null;
|
|
434
|
+
}
|
|
435
|
+
storage?.removeItem(PURCHASE_STASH_KEY);
|
|
436
|
+
const parsed = JSON.parse(raw) as Partial<PurchaseSnapshot>;
|
|
437
|
+
if (!parsed.ecommerce || typeof parsed.at !== "number" || now - parsed.at > PURCHASE_STASH_TTL_MS) {
|
|
438
|
+
return null;
|
|
439
|
+
}
|
|
440
|
+
return parsed.ecommerce;
|
|
441
|
+
}
|
|
442
|
+
catch {
|
|
443
|
+
return null;
|
|
444
|
+
}
|
|
445
|
+
}
|
|
@@ -580,6 +580,7 @@
|
|
|
580
580
|
"organization": {
|
|
581
581
|
"title": "Firmendaten",
|
|
582
582
|
"locked": "Ihre Firmendaten werden von uns gepflegt. Für eine Änderung wenden Sie sich bitte an Ihren Ansprechpartner.",
|
|
583
|
+
"lockedRole": "Ihre Rolle umfasst nicht das Ändern der Firmendaten. Bitte wenden Sie sich an einen Administrator Ihres Unternehmens.",
|
|
583
584
|
"description": "Daten Ihres Unternehmens ansehen und bearbeiten.",
|
|
584
585
|
"companySection": "Unternehmen",
|
|
585
586
|
"edit": "Bearbeiten",
|
|
@@ -607,6 +608,7 @@
|
|
|
607
608
|
"team": {
|
|
608
609
|
"title": "Benutzer",
|
|
609
610
|
"locked": "Die Benutzer Ihres Unternehmens werden von uns gepflegt. Für einen neuen Zugang wenden Sie sich bitte an Ihren Ansprechpartner.",
|
|
611
|
+
"lockedRole": "Ihre Rolle umfasst nicht die Verwaltung der Benutzer Ihres Unternehmens. Bitte wenden Sie sich an einen Administrator Ihres Unternehmens.",
|
|
610
612
|
"description": "Verwalten Sie die Benutzer Ihres Unternehmens und deren Rollen.",
|
|
611
613
|
"searchPlaceholder": "Nach Name, E-Mail oder Rolle suchen …",
|
|
612
614
|
"invite": "Benutzer einladen",
|
|
@@ -619,6 +621,11 @@
|
|
|
619
621
|
"cancel": "Abbrechen",
|
|
620
622
|
"saved": "Gespeichert",
|
|
621
623
|
"saveError": "Speichern fehlgeschlagen",
|
|
624
|
+
"refused": {
|
|
625
|
+
"roleAboveOwn": "Sie können niemandem eine Rolle über Ihrer eigenen geben.",
|
|
626
|
+
"ownRole": "Ihre eigene Rolle kann hier nicht geändert werden.",
|
|
627
|
+
"notFound": "Dieser Benutzer gehört nicht zu Ihrem Unternehmen."
|
|
628
|
+
},
|
|
622
629
|
"errorTitle": "Benutzer nicht verfügbar",
|
|
623
630
|
"errorDescription": "Die Benutzer konnten nicht geladen werden.",
|
|
624
631
|
"columns": {
|
|
@@ -99,6 +99,7 @@
|
|
|
99
99
|
"errors": {
|
|
100
100
|
"invalidCredentials": "E-Mail oder Passwort ist falsch.",
|
|
101
101
|
"accountBlocked": "Dieses Konto wurde gesperrt. Bitte wenden Sie sich an den Support.",
|
|
102
|
+
"organizationBlocked": "Ihr Unternehmen ist für diesen Shop gesperrt. Bitte wenden Sie sich an Ihren Ansprechpartner beim Händler.",
|
|
102
103
|
"rateLimited": "Zu viele Versuche. Bitte versuchen Sie es in ein paar Minuten erneut.",
|
|
103
104
|
"network": "Server nicht erreichbar. Bitte prüfen Sie Ihre Verbindung und versuchen Sie es erneut.",
|
|
104
105
|
"sessionExists": "Sie sind bereits angemeldet.",
|
|
@@ -135,7 +135,8 @@
|
|
|
135
135
|
"skuPlaceholder": "z. B. NK-G42…",
|
|
136
136
|
"quantityLabel": "Menge",
|
|
137
137
|
"add": "Hinzufügen",
|
|
138
|
-
"added": "{quantity}× {name} hinzugefügt"
|
|
138
|
+
"added": "{quantity}× {name} hinzugefügt",
|
|
139
|
+
"notFound": "Artikel {sku} ist nicht bestellbar."
|
|
139
140
|
},
|
|
140
141
|
"quickOrder": {
|
|
141
142
|
"title": "Schnell zur Bestellung",
|
|
@@ -173,7 +173,8 @@
|
|
|
173
173
|
"guestTitle": "Als Gast bestellen",
|
|
174
174
|
"guestDescription": "Bestellen Sie ohne Konto. Ihre Angaben werden nur für diese Bestellung verwendet.",
|
|
175
175
|
"guestBusiness": "Gastbestellung Geschäftskunde",
|
|
176
|
-
"guestPrivate": "Gastbestellung Privatkunde"
|
|
176
|
+
"guestPrivate": "Gastbestellung Privatkunde",
|
|
177
|
+
"backToSelection": "Zurück zur Auswahl"
|
|
177
178
|
},
|
|
178
179
|
"guest": {
|
|
179
180
|
"email": "E-Mail-Adresse",
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"knowledge": "Wissen",
|
|
14
14
|
"mainNavigation": "Hauptnavigation",
|
|
15
15
|
"backToShop": "Zurück zum Shop",
|
|
16
|
+
"backToCart": "Zurück zum Warenkorb",
|
|
16
17
|
"catalog": {
|
|
17
18
|
"loading": "Warengruppen werden geladen…",
|
|
18
19
|
"showAllGroups": "alle {count} Gruppen",
|
|
@@ -39,6 +40,7 @@
|
|
|
39
40
|
"footer": {
|
|
40
41
|
"tagline": "B2B-Lösungen für moderne Unternehmen.",
|
|
41
42
|
"copyright": "© {year} Cover Corp — Alle Rechte vorbehalten.",
|
|
43
|
+
"cookieSettings": "Cookie-Einstellungen",
|
|
42
44
|
"columns": {
|
|
43
45
|
"products": {
|
|
44
46
|
"heading": "Produkte",
|
|
@@ -29,5 +29,49 @@
|
|
|
29
29
|
},
|
|
30
30
|
"actions": {
|
|
31
31
|
"tryAgain": "Erneut versuchen"
|
|
32
|
+
},
|
|
33
|
+
"productMenu": {
|
|
34
|
+
"homeLabel": "Cover-Startseite",
|
|
35
|
+
"triggerLabel": "revenexx-Produkte und -Dienste",
|
|
36
|
+
"currentLabel": "Cover",
|
|
37
|
+
"closeLabel": "Menü schließen",
|
|
38
|
+
"items": {
|
|
39
|
+
"developerPortal": {
|
|
40
|
+
"title": "Developer Portal",
|
|
41
|
+
"subtitle": "Starte mit der Entwicklung für die Revenue Cloud."
|
|
42
|
+
},
|
|
43
|
+
"help": {
|
|
44
|
+
"title": "Hilfe",
|
|
45
|
+
"subtitle": "Erfahre, wie du die Revenue Cloud verwendest."
|
|
46
|
+
},
|
|
47
|
+
"cover": {
|
|
48
|
+
"title": "Cover",
|
|
49
|
+
"subtitle": "Unser Designsystem für B2B-Storefronts."
|
|
50
|
+
},
|
|
51
|
+
"studio": {
|
|
52
|
+
"title": "Studio",
|
|
53
|
+
"subtitle": "Einheitliche UI für Apps im Cockpit."
|
|
54
|
+
},
|
|
55
|
+
"schemas": {
|
|
56
|
+
"title": "Schemas",
|
|
57
|
+
"subtitle": "Klare Spezifikationen für Entwickler."
|
|
58
|
+
},
|
|
59
|
+
"changelog": {
|
|
60
|
+
"title": "Changelog",
|
|
61
|
+
"subtitle": "Bleib über unsere täglichen Änderungen auf dem Laufenden."
|
|
62
|
+
},
|
|
63
|
+
"status": {
|
|
64
|
+
"title": "Status",
|
|
65
|
+
"subtitle": "Statusinformationen und Berichte zu allen Diensten."
|
|
66
|
+
},
|
|
67
|
+
"support": {
|
|
68
|
+
"title": "Support",
|
|
69
|
+
"subtitle": "Kontaktiere uns, wenn du Hilfe brauchst."
|
|
70
|
+
},
|
|
71
|
+
"about": {
|
|
72
|
+
"title": "Über revenexx",
|
|
73
|
+
"subtitle": "Erfahre mehr über die Revenue Cloud."
|
|
74
|
+
}
|
|
75
|
+
}
|
|
32
76
|
}
|
|
33
77
|
}
|
|
@@ -41,7 +41,10 @@
|
|
|
41
41
|
"slugHelp": "Kleinbuchstaben, Zahlen, „-“ und „/“ für verschachtelte Pfade.",
|
|
42
42
|
"bundleHelp": "Lokal immer als „standard“ behandelt; der Wert greift erst, wenn die Seite übernommen und von der Live-API ausgeliefert wird.",
|
|
43
43
|
"warnings": {
|
|
44
|
-
"routeSlug": "Dieser Slug gehört
|
|
44
|
+
"routeSlug": "Dieser Slug gehört der Route {path} — dort wird die Seite ausgeliefert, nicht unter /{slug}."
|
|
45
|
+
},
|
|
46
|
+
"suggestions": {
|
|
47
|
+
"none": "Kein Routen-Slug passt — die Seite bekommt einen freien Slug."
|
|
45
48
|
},
|
|
46
49
|
"errors": {
|
|
47
50
|
"duplicate": "Es gibt bereits eine Seite mit diesem Slug.",
|
|
@@ -118,7 +121,50 @@
|
|
|
118
121
|
"serif": "Serif",
|
|
119
122
|
"mono": "Monospace",
|
|
120
123
|
"geometric": "Geometrisch"
|
|
124
|
+
},
|
|
125
|
+
"design": {
|
|
126
|
+
"title": "Shop-Design",
|
|
127
|
+
"brand": "Markenfarbe",
|
|
128
|
+
"neutral": "Neutralfarbe",
|
|
129
|
+
"radius": "Eckenradius",
|
|
130
|
+
"font": "Webfont",
|
|
131
|
+
"fontHint": "Name der Schriftfamilie und URL ihres Stylesheets (fonts.bunny.net, fonts.googleapis.com oder cdn.revenexx.com).",
|
|
132
|
+
"customCss": "Eigenes CSS",
|
|
133
|
+
"customCssHint": "Gilt für den ganzen Shop und überschreibt Theme-Styles. Keine Imports, externe URLs nur per https.",
|
|
134
|
+
"save": "Design speichern",
|
|
135
|
+
"saving": "Speichern …",
|
|
136
|
+
"saved": "Gespeichert — alle Seiten nutzen jetzt dieses Design.",
|
|
137
|
+
"failed": "Das Design konnte nicht gespeichert werden.",
|
|
138
|
+
"tenantScheme": "Eigenes Design"
|
|
121
139
|
}
|
|
140
|
+
},
|
|
141
|
+
"region": {
|
|
142
|
+
"title": "Region",
|
|
143
|
+
"hint": "Wie die Blöcke dieser Region mit dem Standard-Header bzw. -Footer des Themes kombiniert werden.",
|
|
144
|
+
"modes": {
|
|
145
|
+
"after": "Nach dem Standard",
|
|
146
|
+
"before": "Vor dem Standard",
|
|
147
|
+
"replace": "Standard ersetzen"
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
"accountNav": {
|
|
151
|
+
"title": "Kontonavigation",
|
|
152
|
+
"lead": "Gruppen und Links der Konto-Seitenleiste dieses Mandanten. Gilt für alle Kontoseiten.",
|
|
153
|
+
"save": "Speichern",
|
|
154
|
+
"loading": "Navigation wird geladen …",
|
|
155
|
+
"empty": "Noch keine eigene Navigation – es wird die Standardnavigation angezeigt.",
|
|
156
|
+
"seedDefault": "Standardnavigation übernehmen",
|
|
157
|
+
"groupLabel": "Gruppenname",
|
|
158
|
+
"linkLabel": "Linktext",
|
|
159
|
+
"linkTarget": "Ziel wählen",
|
|
160
|
+
"addLink": "Link hinzufügen",
|
|
161
|
+
"addGroup": "Gruppe hinzufügen",
|
|
162
|
+
"removeGroup": "Gruppe entfernen",
|
|
163
|
+
"removeLink": "Link entfernen",
|
|
164
|
+
"moveUp": "Nach oben",
|
|
165
|
+
"moveDown": "Nach unten",
|
|
166
|
+
"saved": "Navigation gespeichert",
|
|
167
|
+
"saveFailed": "Navigation konnte nicht gespeichert werden"
|
|
122
168
|
}
|
|
123
169
|
}
|
|
124
170
|
}
|
|
@@ -580,6 +580,7 @@
|
|
|
580
580
|
"organization": {
|
|
581
581
|
"title": "Company",
|
|
582
582
|
"locked": "Your company details are maintained by us. To change them, please contact your account manager.",
|
|
583
|
+
"lockedRole": "Your role does not include changing your company's details. Please ask an administrator of your company.",
|
|
583
584
|
"description": "View and edit your company details.",
|
|
584
585
|
"companySection": "Company",
|
|
585
586
|
"edit": "Edit",
|
|
@@ -607,6 +608,7 @@
|
|
|
607
608
|
"team": {
|
|
608
609
|
"title": "Users",
|
|
609
610
|
"locked": "Your company's users are maintained by us. For a new login, please contact your account manager.",
|
|
611
|
+
"lockedRole": "Your role does not include managing your company's users. Please ask an administrator of your company.",
|
|
610
612
|
"description": "Manage your company's users and their roles.",
|
|
611
613
|
"searchPlaceholder": "Search by name, email or role…",
|
|
612
614
|
"invite": "Invite user",
|
|
@@ -619,6 +621,11 @@
|
|
|
619
621
|
"cancel": "Cancel",
|
|
620
622
|
"saved": "Saved",
|
|
621
623
|
"saveError": "Save failed",
|
|
624
|
+
"refused": {
|
|
625
|
+
"roleAboveOwn": "You cannot give anybody a role above your own.",
|
|
626
|
+
"ownRole": "Your own role cannot be changed here.",
|
|
627
|
+
"notFound": "This user is not part of your company."
|
|
628
|
+
},
|
|
622
629
|
"errorTitle": "Users unavailable",
|
|
623
630
|
"errorDescription": "The users could not be loaded.",
|
|
624
631
|
"columns": {
|
|
@@ -99,6 +99,7 @@
|
|
|
99
99
|
"errors": {
|
|
100
100
|
"invalidCredentials": "Email or password is incorrect.",
|
|
101
101
|
"accountBlocked": "This account has been locked. Please contact support.",
|
|
102
|
+
"organizationBlocked": "Your company's account with this shop is on hold. Please contact your contact person at the merchant.",
|
|
102
103
|
"rateLimited": "Too many attempts. Please try again in a few minutes.",
|
|
103
104
|
"network": "Could not reach the server. Check your connection and try again.",
|
|
104
105
|
"sessionExists": "You are already logged in.",
|
|
@@ -135,7 +135,8 @@
|
|
|
135
135
|
"skuPlaceholder": "e.g. NK-G42…",
|
|
136
136
|
"quantityLabel": "Quantity",
|
|
137
137
|
"add": "Add",
|
|
138
|
-
"added": "Added {quantity}× {name}"
|
|
138
|
+
"added": "Added {quantity}× {name}",
|
|
139
|
+
"notFound": "Item {sku} cannot be ordered."
|
|
139
140
|
},
|
|
140
141
|
"quickOrder": {
|
|
141
142
|
"title": "Straight to your order",
|