@revenexx/cover 0.10.1 → 0.12.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/carts/AccountCartsTable.vue +4 -2
- 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 +75 -18
- package/app/components/auth/AuthRegisterPanel.vue +1 -1
- package/app/components/cart/actions/CartSaveToListModal.vue +5 -0
- package/app/components/cart/item/CartItem.vue +17 -75
- package/app/components/cart/position/CartPosition.vue +17 -30
- package/app/components/cart/quote/CartQuoteRequestModal.vue +9 -1
- package/app/components/cart/switcher/CartSwitcher.vue +5 -2
- 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 +6 -2
- 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 +25 -4
- package/app/interfaces/quantity-stepper.ts +17 -0
- package/app/interfaces/shopSettings.ts +84 -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 +42 -2
- package/i18n/locales/de/cart.json +4 -2
- 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 +42 -2
- package/i18n/locales/en/cart.json +4 -2
- 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 +22 -3
- 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 +8 -0
- package/server/api/carts/[id]/index.delete.ts +3 -0
- package/server/api/carts/[id]/index.put.ts +1 -0
- package/server/api/carts/[id]/items.post.ts +1 -0
- package/server/api/carts/index.post.ts +4 -0
- package/server/api/orders/index.post.ts +33 -0
- package/server/api/quick-actions.get.ts +6 -38
- package/server/interfaces/auth.ts +10 -1
- package/server/middleware/buyer-principal.ts +18 -0
- package/server/routes/punchout/start.get.ts +6 -15
- package/server/services/ApiAddressBookService.ts +43 -1
- package/server/services/ApiAuthService.ts +119 -22
- package/server/services/ApiCartService.ts +67 -32
- package/server/services/ApiOrganizationService.ts +7 -2
- package/server/services/ApiTeamService.ts +93 -21
- package/server/services/MockAuthService.ts +21 -2
- package/server/utils/buyerIdentity.ts +168 -0
- package/server/utils/cartOwnership.ts +67 -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
- package/server/utils/shopSettings.ts +5 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { ComputedRef } from "vue";
|
|
2
|
+
|
|
3
|
+
import type { AuthRole } from "../interfaces/auth";
|
|
4
|
+
|
|
5
|
+
/** Least → most privileged — the order the BFF ranks roles by. */
|
|
6
|
+
const ROLE_RANK: Record<AuthRole, number> = { requester: 0, buyer: 1, approver: 2, admin: 3 };
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* What the signed-in buyer's own role lets them do, as the platform stated it
|
|
10
|
+
* (RAD-155). The BFF refuses the write regardless; this only keeps the page from
|
|
11
|
+
* offering what it would refuse.
|
|
12
|
+
*
|
|
13
|
+
* Where the platform stated no grants — the demo personas — nothing is locked
|
|
14
|
+
* by role, which is how the shop behaved before anybody asked.
|
|
15
|
+
*/
|
|
16
|
+
export function useRoleGrants(): {
|
|
17
|
+
lockedByRole: (permission: string) => ComputedRef<boolean>;
|
|
18
|
+
mayGrant: (role: AuthRole) => boolean;
|
|
19
|
+
isSelf: (contactId: string) => boolean;
|
|
20
|
+
outranks: (role: AuthRole) => boolean;
|
|
21
|
+
} {
|
|
22
|
+
const auth = useAuthStore();
|
|
23
|
+
const stated = (): boolean => Array.isArray(auth.user?.permissions);
|
|
24
|
+
const ownRank = (): number => (auth.user?.role ? ROLE_RANK[auth.user.role] ?? -1 : -1);
|
|
25
|
+
|
|
26
|
+
return {
|
|
27
|
+
lockedByRole: permission => computed(() => stated() && !auth.user!.permissions!.includes(permission)),
|
|
28
|
+
mayGrant: role => !stated() || ROLE_RANK[role] <= ownRank(),
|
|
29
|
+
isSelf: contactId => !!auth.user?.contactId && auth.user.contactId === contactId,
|
|
30
|
+
outranks: role => stated() && ROLE_RANK[role] > ownRank(),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
@@ -57,6 +57,10 @@ export const useSearchListing = (options: SearchListingOptions) => {
|
|
|
57
57
|
key: "search",
|
|
58
58
|
query: () => query.value,
|
|
59
59
|
facetFields: ["category", "subcategory", "manufacturer", "available"],
|
|
60
|
+
// A search is reported as `search` (term + hit count), not as a list
|
|
61
|
+
// view: etracker reads both as `viewProductList` and would count twice.
|
|
62
|
+
// The match-all `*` is the catalogue, not a search, and is skipped.
|
|
63
|
+
listEvent: () => ({ event: "search", listId: "search", term: query.value }),
|
|
60
64
|
});
|
|
61
65
|
|
|
62
66
|
// `?q=*` is the match-all link (Typesense's native catch-all query): the
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { createThemeEvents } from "@revenexx/tag-manager-nuxt/events";
|
|
2
|
+
import type {
|
|
3
|
+
ThemeEventContext,
|
|
4
|
+
ThemeEventData,
|
|
5
|
+
ThemeEventEnvelope,
|
|
6
|
+
ThemeEventName,
|
|
7
|
+
ThemeEvents,
|
|
8
|
+
} from "@revenexx/tag-manager-nuxt/events";
|
|
9
|
+
|
|
10
|
+
import type { ShopMarket } from "../interfaces/market";
|
|
11
|
+
import { isEditorContext, pageTypeOf } from "../shared/themeEvents";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The storefront's voice in the event contract (`theme-events/1`).
|
|
15
|
+
*
|
|
16
|
+
* The theme says WHAT happened — `add_to_cart`, `purchase`, `request_quote` —
|
|
17
|
+
* once, and whoever listens (the Tag Manager module today, a theme extension
|
|
18
|
+
* through the DOM event, the Analytics Studio later) says it to each vendor in
|
|
19
|
+
* its own words. The emitter is the framework-free one from
|
|
20
|
+
* `@revenexx/tag-manager-nuxt/events`: importing it loads no module, so cover
|
|
21
|
+
* emits whether a theme installs the Tag Manager or not.
|
|
22
|
+
*
|
|
23
|
+
* Transport: `nuxtApp.callHook('revenexx:event', envelope)` and
|
|
24
|
+
* `window.dispatchEvent(new CustomEvent('revenexx:event', …))`.
|
|
25
|
+
*
|
|
26
|
+
* Nothing is emitted on the server, in the editor or in a preview — the editor
|
|
27
|
+
* seeds sample carts and renders sample products, and none of that is a buyer.
|
|
28
|
+
* Consent is NOT decided here: an event is a fact about the page, and each tag
|
|
29
|
+
* that hears it is gated by the consent provider on its own.
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
export interface UseThemeEvents {
|
|
33
|
+
/**
|
|
34
|
+
* Emit one event. Returns the envelope that went out, or null where nothing
|
|
35
|
+
* was emitted (server, editor/preview, an invalid envelope in dev, a repeated
|
|
36
|
+
* purchase).
|
|
37
|
+
*/
|
|
38
|
+
emit<E extends ThemeEventName>(event: E, data?: ThemeEventData): ThemeEventEnvelope<E> | null;
|
|
39
|
+
/** Whether events are emitted on this page at all (client, not editor/preview). */
|
|
40
|
+
active(): boolean;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const NOOP: UseThemeEvents = { emit: () => null, active: () => false };
|
|
44
|
+
|
|
45
|
+
const MARKET_RE = /^[a-z0-9][\w-]*$/;
|
|
46
|
+
const CURRENCY_RE = /^[A-Z]{3}$/;
|
|
47
|
+
const LOCALE_RE = /^[a-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/;
|
|
48
|
+
|
|
49
|
+
interface ThemeEventsHost {
|
|
50
|
+
_rvxThemeEvents?: UseThemeEvents;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Build the per-app emitter. Must run inside a Nuxt context (a plugin or a
|
|
55
|
+
* component's setup) — every ref it reads later is captured here.
|
|
56
|
+
*/
|
|
57
|
+
function createForApp(): UseThemeEvents {
|
|
58
|
+
const nuxtApp = useNuxtApp();
|
|
59
|
+
const router = useRouter();
|
|
60
|
+
const config = useRuntimeConfig().public as { locale?: string; currency?: string };
|
|
61
|
+
const marketCookie = useCookie<string>("cover-market", { default: () => "", watch: true });
|
|
62
|
+
const currencyCookie = useCookie<string>("cover-currency", { default: () => "", watch: true });
|
|
63
|
+
const { data: markets } = useNuxtData<ShopMarket[]>("shop-markets");
|
|
64
|
+
const auth = useAuthStore();
|
|
65
|
+
|
|
66
|
+
const i18n = nuxtApp.$i18n as unknown as {
|
|
67
|
+
locale: { value: string };
|
|
68
|
+
locales: { value: ({ code: string; language?: string } | string)[] };
|
|
69
|
+
} | undefined;
|
|
70
|
+
|
|
71
|
+
const localeCodes = (): string[] =>
|
|
72
|
+
(i18n?.locales.value ?? []).map(l => (typeof l === "string" ? l : l.code));
|
|
73
|
+
|
|
74
|
+
const activeMarket = (): ShopMarket | null => {
|
|
75
|
+
const list = markets.value ?? [];
|
|
76
|
+
return list.find(m => m.code === marketCookie.value)
|
|
77
|
+
?? list.find(m => m.isDefault)
|
|
78
|
+
?? list[0]
|
|
79
|
+
?? null;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const marketCode = (): string => {
|
|
83
|
+
const code = String(marketCookie.value || activeMarket()?.code || "default").toLowerCase();
|
|
84
|
+
return MARKET_RE.test(code) ? code : "default";
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const localeTag = (): string => {
|
|
88
|
+
const code = i18n?.locale.value ?? "";
|
|
89
|
+
const entry = (i18n?.locales.value ?? []).find(l => (typeof l === "string" ? l : l.code) === code);
|
|
90
|
+
const language = typeof entry === "object" ? entry.language : undefined;
|
|
91
|
+
const candidate = language || code || config.locale || "de";
|
|
92
|
+
// The contract wants a lower-case language subtag (`de-DE`, `en`).
|
|
93
|
+
const [lang, ...rest] = candidate.split("-");
|
|
94
|
+
const tag = [lang!.toLowerCase(), ...rest].join("-");
|
|
95
|
+
return LOCALE_RE.test(tag) ? tag : "de";
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
const currencyCode = (): string => {
|
|
99
|
+
const code = String(currencyCookie.value || activeMarket()?.currency || config.currency || "EUR").toUpperCase();
|
|
100
|
+
return CURRENCY_RE.test(code) ? code : "EUR";
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
const context = (): ThemeEventContext => {
|
|
104
|
+
const route = router.currentRoute.value;
|
|
105
|
+
return {
|
|
106
|
+
market: marketCode(),
|
|
107
|
+
locale: localeTag(),
|
|
108
|
+
currency: currencyCode(),
|
|
109
|
+
page: { path: route.path || "/", type: pageTypeOf(route.path || "/", localeCodes()) },
|
|
110
|
+
// Exactly the two booleans the contract allows — never who.
|
|
111
|
+
customer: { authenticated: auth.isLoggedIn, b2b: Boolean(auth.user?.organizationId) },
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
const events: ThemeEvents = createThemeEvents({
|
|
116
|
+
context,
|
|
117
|
+
callHook: (name, envelope) => nuxtApp.callHook(name as never, envelope as never),
|
|
118
|
+
validate: import.meta.dev,
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
const active = (): boolean => {
|
|
122
|
+
const route = router.currentRoute.value;
|
|
123
|
+
return !isEditorContext({
|
|
124
|
+
path: route.path || "/",
|
|
125
|
+
host: window.location.host,
|
|
126
|
+
query: route.query,
|
|
127
|
+
localeCodes: localeCodes(),
|
|
128
|
+
});
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
return {
|
|
132
|
+
active,
|
|
133
|
+
emit: (event, data) => (active() ? events.emit(event, data) : null),
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export function useThemeEvents(): UseThemeEvents {
|
|
138
|
+
if (import.meta.server) {
|
|
139
|
+
return NOOP;
|
|
140
|
+
}
|
|
141
|
+
const host = useNuxtApp() as unknown as ThemeEventsHost;
|
|
142
|
+
host._rvxThemeEvents ??= createForApp();
|
|
143
|
+
return host._rvxThemeEvents;
|
|
144
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { AccountDashboardKpiId } from "../interfaces/account/dashboard";
|
|
2
|
+
|
|
3
|
+
/** Every dashboard KPI, in the order the band renders them. */
|
|
4
|
+
export const ACCOUNT_DASHBOARD_KPI_IDS: readonly AccountDashboardKpiId[] = [
|
|
5
|
+
"openOrders",
|
|
6
|
+
"awaitingApproval",
|
|
7
|
+
"spend30",
|
|
8
|
+
"budgetUsed",
|
|
9
|
+
];
|
|
10
|
+
|
|
11
|
+
function isAccountDashboardKpiId(id: string): id is AccountDashboardKpiId {
|
|
12
|
+
return (ACCOUNT_DASHBOARD_KPI_IDS as readonly string[]).includes(id);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Narrows a requested KPI selection (a block option, a tenant setting) to the
|
|
17
|
+
* KPIs that exist, in canonical order and without duplicates. A selection that
|
|
18
|
+
* leaves nothing valid — empty, or only unknown ids — resolves to the full set:
|
|
19
|
+
* the band always shows at least one KPI, and an editor who unchecks every box
|
|
20
|
+
* gets the default rather than an empty frame.
|
|
21
|
+
*/
|
|
22
|
+
export function resolveAccountDashboardKpis(ids: readonly string[]): AccountDashboardKpiId[] {
|
|
23
|
+
const requested = new Set(ids.filter(isAccountDashboardKpiId));
|
|
24
|
+
const resolved = ACCOUNT_DASHBOARD_KPI_IDS.filter(id => requested.has(id));
|
|
25
|
+
return resolved.length > 0 ? resolved : [...ACCOUNT_DASHBOARD_KPI_IDS];
|
|
26
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AccountNavLink } from "./navigation";
|
|
1
|
+
import type { AccountNavGroup, AccountNavLink } from "./navigation";
|
|
2
2
|
|
|
3
3
|
import { accountNavigation } from "./navigation";
|
|
4
4
|
|
|
@@ -28,9 +28,9 @@ export interface QuickAction {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
31
|
+
* Catalogue order: what the picker overlay lists, and the order of a resolved
|
|
32
|
+
* allowed set. Tile order on the page is the editor's own — the picker stores
|
|
33
|
+
* its selection in authored order (see `resolveQuickActions`). It opens with
|
|
34
34
|
* the four shortcuts the live shop shows by default.
|
|
35
35
|
*/
|
|
36
36
|
const QUICK_ACTION_ORDER: readonly string[] = [
|
|
@@ -60,6 +60,18 @@ export const DEFAULT_QUICK_ACTION_IDS: readonly string[] = [
|
|
|
60
60
|
"cart",
|
|
61
61
|
];
|
|
62
62
|
|
|
63
|
+
/**
|
|
64
|
+
* The account dashboard's quick-access widget default — what an instance
|
|
65
|
+
* without an authored selection shows, in this order.
|
|
66
|
+
*/
|
|
67
|
+
export const DASHBOARD_QUICK_ACTION_IDS: readonly string[] = [
|
|
68
|
+
"direct-order",
|
|
69
|
+
"orders",
|
|
70
|
+
"order-lists",
|
|
71
|
+
"requisitions",
|
|
72
|
+
"cost-centers",
|
|
73
|
+
];
|
|
74
|
+
|
|
63
75
|
/**
|
|
64
76
|
* Shortcuts with no `accountNavigation` counterpart. The direct-order tile is
|
|
65
77
|
* labelled "Schnellerfassung" rather than the page's own "Direktbestellung":
|
|
@@ -87,7 +99,7 @@ const ICON_OVERRIDES: Record<string, string> = {
|
|
|
87
99
|
};
|
|
88
100
|
|
|
89
101
|
/** `/account` → `dashboard`, `/account/cost-centers` → `cost-centers`. */
|
|
90
|
-
function actionIdForPath(path: string): string {
|
|
102
|
+
export function actionIdForPath(path: string): string {
|
|
91
103
|
if (path === "/account") {
|
|
92
104
|
return "dashboard";
|
|
93
105
|
}
|
|
@@ -136,3 +148,26 @@ export const QUICK_ACTION_IDS: readonly string[] = quickActions.map(action => ac
|
|
|
136
148
|
export function resolveQuickActions(ids: readonly string[]): QuickAction[] {
|
|
137
149
|
return ids.flatMap(id => quickActions.find(action => action.id === id) ?? []);
|
|
138
150
|
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* The ids a given account navigation permits, in catalogue order. A shortcut
|
|
154
|
+
* is only offered — in the picker and on the page — when the sidebar links its
|
|
155
|
+
* target, so a tile never points where the tenant's nav does not: a tenant
|
|
156
|
+
* whose nav has no Kostenstellen gets no Kostenstellen tile.
|
|
157
|
+
*
|
|
158
|
+
* The two standalone shortcuts are exempt: they are never nav links by design,
|
|
159
|
+
* so the nav cannot vouch for them and does not need to. `null` stands for
|
|
160
|
+
* "no tenant nav" (the layer's static tree) and permits the whole catalogue.
|
|
161
|
+
*/
|
|
162
|
+
export function allowedQuickActionIds(nav: readonly AccountNavGroup[] | null): string[] {
|
|
163
|
+
if (nav === null) {
|
|
164
|
+
return [...QUICK_ACTION_IDS];
|
|
165
|
+
}
|
|
166
|
+
const permitted = new Set(Object.keys(STANDALONE_ACTIONS));
|
|
167
|
+
for (const group of nav) {
|
|
168
|
+
for (const link of group.links) {
|
|
169
|
+
permitted.add(actionIdForPath(link.to));
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
return QUICK_ACTION_IDS.filter(id => permitted.has(id));
|
|
173
|
+
}
|
package/app/interfaces/auth.ts
CHANGED
|
@@ -27,6 +27,13 @@ export interface AuthUser {
|
|
|
27
27
|
* meant before anybody asked.
|
|
28
28
|
*/
|
|
29
29
|
active?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* What this person's role lets them do in their organization
|
|
32
|
+
* (`contacts.manage`, `addresses.manage`, …), derived by the customers app on
|
|
33
|
+
* every read. Undefined where the source does not say — the demo personas;
|
|
34
|
+
* a live session always states it, an empty list included.
|
|
35
|
+
*/
|
|
36
|
+
permissions?: string[];
|
|
30
37
|
}
|
|
31
38
|
|
|
32
39
|
/**
|
|
@@ -62,7 +69,11 @@ export interface RegisterInput {
|
|
|
62
69
|
}
|
|
63
70
|
|
|
64
71
|
export interface LoginInput {
|
|
65
|
-
|
|
72
|
+
/**
|
|
73
|
+
* What the buyer signs in with: an address, a username or a customer
|
|
74
|
+
* number, whichever the shop accepts (RAD-151).
|
|
75
|
+
*/
|
|
76
|
+
identifier: string;
|
|
66
77
|
password: string;
|
|
67
78
|
}
|
|
68
79
|
|
|
@@ -73,15 +84,25 @@ export interface StoredSession {
|
|
|
73
84
|
personaId?: string;
|
|
74
85
|
/** Set for public-API sessions — the platform user behind the session. */
|
|
75
86
|
userId?: string;
|
|
76
|
-
/**
|
|
87
|
+
/**
|
|
88
|
+
* Written by sessions older than RAD-155 and IGNORED on read: the browser
|
|
89
|
+
* can rewrite this cookie, so the contact and organization are taken from
|
|
90
|
+
* the identity service per request instead (server/utils/buyerIdentity).
|
|
91
|
+
*/
|
|
77
92
|
contactId?: string;
|
|
78
|
-
/**
|
|
93
|
+
/** As contactId — legacy, never trusted. */
|
|
79
94
|
organizationId?: string;
|
|
80
95
|
}
|
|
81
96
|
|
|
82
97
|
export interface LoginFormState {
|
|
83
|
-
|
|
98
|
+
/** The password sign-in field — whatever identifiers the shop accepts. */
|
|
99
|
+
identifier: string;
|
|
84
100
|
password: string;
|
|
101
|
+
/**
|
|
102
|
+
* The address a mailed link or code goes to. Only its own field where the
|
|
103
|
+
* sign-in field accepts more than an address; otherwise it is that field.
|
|
104
|
+
*/
|
|
105
|
+
email: string;
|
|
85
106
|
}
|
|
86
107
|
|
|
87
108
|
export interface RegisterFormState {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** Why a quantity stepper refused or corrected an entry. */
|
|
2
|
+
export type QuantityStepperNotice = "max" | "invalid";
|
|
3
|
+
|
|
4
|
+
export interface QuantityStepperOptions {
|
|
5
|
+
/** The committed quantity — a cart line's, or a buy box's amount to add. */
|
|
6
|
+
readonly quantity: () => number;
|
|
7
|
+
/** Ceiling for this stepper; `undefined` falls back to CART_MAX_QUANTITY. */
|
|
8
|
+
readonly max: () => number | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* Lowest value the minus button reaches. 1 by default; the mini-cart uses 0,
|
|
11
|
+
* where the store reads a zero quantity as "remove this line". Typed input
|
|
12
|
+
* below 1 always reverts — nobody removes a position by typing.
|
|
13
|
+
*/
|
|
14
|
+
readonly min?: number;
|
|
15
|
+
/** Commits a validated, clamped quantity. */
|
|
16
|
+
readonly apply: (next: number) => void;
|
|
17
|
+
}
|
|
@@ -202,6 +202,24 @@ export interface SignInAppSettings {
|
|
|
202
202
|
emailOtp: boolean;
|
|
203
203
|
/** customers.email_verification — when the address has to be confirmed. */
|
|
204
204
|
emailVerification: "off" | "on_registration" | "required_for_login";
|
|
205
|
+
/**
|
|
206
|
+
* What a buyer may type into the password sign-in field (RAD-151). The
|
|
207
|
+
* mailed ways — link and code — always take an address, whatever is here.
|
|
208
|
+
*/
|
|
209
|
+
identifiers: LoginIdentifierAppSettings;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export interface LoginIdentifierAppSettings {
|
|
213
|
+
/** customers.login_identifier_email — on unless the merchant turned it off. */
|
|
214
|
+
email: boolean;
|
|
215
|
+
/** customers.login_identifier_username — off until asked for. */
|
|
216
|
+
username: boolean;
|
|
217
|
+
/**
|
|
218
|
+
* customers.login_identifier_customer_number — off until asked for. A
|
|
219
|
+
* customer number names a company, so it signs in as that company's
|
|
220
|
+
* primary contact.
|
|
221
|
+
*/
|
|
222
|
+
customerNumber: boolean;
|
|
205
223
|
}
|
|
206
224
|
|
|
207
225
|
/* ------------------------------------------------------------------ */
|
|
@@ -321,3 +339,69 @@ export function resolvePriceBasis(prices: PriceAppSettings): "net" | "gross" {
|
|
|
321
339
|
}
|
|
322
340
|
return prices.stored;
|
|
323
341
|
}
|
|
342
|
+
|
|
343
|
+
/* ------------------------------------------------------------------ */
|
|
344
|
+
/* What the sign-in field asks for */
|
|
345
|
+
/* ------------------------------------------------------------------ */
|
|
346
|
+
|
|
347
|
+
export type LoginIdentifierKind = "email" | "username" | "customerNumber";
|
|
348
|
+
|
|
349
|
+
/** In the order a label names them. */
|
|
350
|
+
const IDENTIFIER_ORDER: readonly LoginIdentifierKind[] = ["email", "username", "customerNumber"];
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* The identifiers this shop accepts, in label order.
|
|
354
|
+
*
|
|
355
|
+
* Never empty: the customers app takes the address when the merchant has
|
|
356
|
+
* switched every identifier off — a misconfiguration narrows a shop and never
|
|
357
|
+
* shuts it — so the field has to ask for the address in that case too.
|
|
358
|
+
*/
|
|
359
|
+
export function offeredLoginIdentifiers(identifiers?: LoginIdentifierAppSettings | null): LoginIdentifierKind[] {
|
|
360
|
+
const offered = IDENTIFIER_ORDER.filter(kind =>
|
|
361
|
+
kind === "email" ? identifiers?.email !== false : identifiers?.[kind] === true,
|
|
362
|
+
);
|
|
363
|
+
return offered.length > 0 ? offered : ["email"];
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* Which kind of identifier a typed value is, by the same rule the customers
|
|
368
|
+
* app applies: an `@` makes an address, digits alone a customer number, and
|
|
369
|
+
* anything else is a username.
|
|
370
|
+
*/
|
|
371
|
+
export function loginIdentifierKind(value: string): LoginIdentifierKind {
|
|
372
|
+
const trimmed = value.trim();
|
|
373
|
+
if (trimmed.includes("@")) {
|
|
374
|
+
return "email";
|
|
375
|
+
}
|
|
376
|
+
if (/^[0-9]+$/.test(trimmed)) {
|
|
377
|
+
return "customerNumber";
|
|
378
|
+
}
|
|
379
|
+
return "username";
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
/** How the password sign-in field presents itself for one set of identifiers. */
|
|
383
|
+
export interface LoginIdentifierField {
|
|
384
|
+
/** i18n key under which `.label` and `.placeholder` name the field. */
|
|
385
|
+
key: string;
|
|
386
|
+
type: "email" | "text";
|
|
387
|
+
autocomplete: "email" | "username";
|
|
388
|
+
inputmode: "email" | "numeric" | "text";
|
|
389
|
+
/** FormKit validation: the address format only where nothing else is accepted. */
|
|
390
|
+
validation: string;
|
|
391
|
+
/** Whether a customer number is accepted, which signs in as the company's primary contact. */
|
|
392
|
+
customerNumber: boolean;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
export function loginIdentifierField(identifiers?: LoginIdentifierAppSettings | null): LoginIdentifierField {
|
|
396
|
+
const offered = offeredLoginIdentifiers(identifiers);
|
|
397
|
+
const emailOnly = offered.length === 1 && offered[0] === "email";
|
|
398
|
+
const numberOnly = offered.length === 1 && offered[0] === "customerNumber";
|
|
399
|
+
return {
|
|
400
|
+
key: `auth.login.identifier.${offered.join("_")}`,
|
|
401
|
+
type: emailOnly ? "email" : "text",
|
|
402
|
+
autocomplete: emailOnly ? "email" : "username",
|
|
403
|
+
inputmode: emailOnly ? "email" : numberOnly ? "numeric" : "text",
|
|
404
|
+
validation: emailOnly ? "required|email" : "required",
|
|
405
|
+
customerNumber: offered.includes("customerNumber"),
|
|
406
|
+
};
|
|
407
|
+
}
|
package/app/layouts/default.vue
CHANGED
|
@@ -62,23 +62,32 @@ async function handleSearch(q: string): Promise<void> {
|
|
|
62
62
|
>
|
|
63
63
|
Skip to main content
|
|
64
64
|
</a>
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
<
|
|
68
|
-
<
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
65
|
+
<!-- Layout extension points (ADR-0111): the code header and footer are
|
|
66
|
+
the regions' default content; a theme may add to or replace them. -->
|
|
67
|
+
<LayoutRegion name="header">
|
|
68
|
+
<LayoutHeaderTopBar />
|
|
69
|
+
<LayoutHeaderAppBar />
|
|
70
|
+
<div class="md:hidden border-b border-(--ui-border) px-4 py-2">
|
|
71
|
+
<UiFormsSearchInput
|
|
72
|
+
class="w-full"
|
|
73
|
+
@search="handleSearch"
|
|
74
|
+
/>
|
|
75
|
+
</div>
|
|
76
|
+
<LayoutHeaderMainNav />
|
|
77
|
+
</LayoutRegion>
|
|
74
78
|
<UiDebugPiniaStateCard v-if="false" />
|
|
75
79
|
<UMain id="main-content">
|
|
76
80
|
<slot />
|
|
77
81
|
</UMain>
|
|
78
|
-
<
|
|
82
|
+
<LayoutRegion name="footer">
|
|
83
|
+
<LayoutFooter />
|
|
84
|
+
</LayoutRegion>
|
|
79
85
|
<CartDrawer v-if="!isCartOrCheckoutPage" />
|
|
80
86
|
<CartTargetModal />
|
|
81
87
|
</div>
|
|
88
|
+
<!-- The cookie choice (Consent Manager): rendered by this shop's own
|
|
89
|
+
server when one is owed, never in the editor or a preview. -->
|
|
90
|
+
<ConsentBanner />
|
|
82
91
|
</Body>
|
|
83
92
|
</Html>
|
|
84
93
|
</template>
|
package/app/layouts/focus.vue
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
import type { CheckoutCustomerType } from "../composables/useCheckoutOnePage";
|
|
2
3
|
import type { ShopContact } from "../config/navigation";
|
|
3
4
|
import { legalLinks as defaultLegalLinks, shopContact as noContact } from "../config/navigation";
|
|
4
5
|
|
|
@@ -18,7 +19,18 @@ const year = new Date().getFullYear();
|
|
|
18
19
|
// Checkout gets a subtly tinted page background so the white section
|
|
19
20
|
// cards and the summary stand out from the canvas.
|
|
20
21
|
const route = useRoute();
|
|
21
|
-
const
|
|
22
|
+
const isCheckoutRoute = computed(() => /\/checkout(\/|$)/.test(route.path));
|
|
23
|
+
const customerType = useState<CheckoutCustomerType>("checkout-customer-type", () => "account");
|
|
24
|
+
const isGuestCheckout = computed(() => isCheckoutRoute.value && customerType.value !== "account");
|
|
25
|
+
const tinted = computed(() => isCheckoutRoute.value || /\/forgot-password(\/|$)/.test(route.path));
|
|
26
|
+
|
|
27
|
+
function onHeaderBackClick(event: MouseEvent): void {
|
|
28
|
+
if (!isGuestCheckout.value) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
event.preventDefault();
|
|
32
|
+
customerType.value = "account";
|
|
33
|
+
}
|
|
22
34
|
</script>
|
|
23
35
|
|
|
24
36
|
<template>
|
|
@@ -34,14 +46,15 @@ const tinted = computed(() => /\/checkout(\/|$)/.test(route.path));
|
|
|
34
46
|
<div class="w-full max-w-(--ui-container) mx-auto px-4 sm:px-6 lg:px-8 flex-1 pb-20">
|
|
35
47
|
<header class="pt-10 flex items-center">
|
|
36
48
|
<div class="flex-1">
|
|
37
|
-
<LayoutAppLogo />
|
|
49
|
+
<LayoutAppLogo class="inline-flex min-h-11 items-center" />
|
|
38
50
|
</div>
|
|
39
51
|
<NuxtLink
|
|
40
|
-
:to="localePath('/')"
|
|
52
|
+
:to="isGuestCheckout ? '#' : localePath(isCheckoutRoute ? '/cart' : '/')"
|
|
41
53
|
tabindex="0"
|
|
42
|
-
class="
|
|
54
|
+
class="inline-flex min-h-11 items-center text-sm decoration-2 underline-offset-4 hover:underline"
|
|
55
|
+
@click="onHeaderBackClick"
|
|
43
56
|
>
|
|
44
|
-
{{ t('nav.backToShop') }}
|
|
57
|
+
{{ t(isGuestCheckout ? 'onepage.gate.backToSelection' : isCheckoutRoute ? 'nav.backToCart' : 'nav.backToShop') }}
|
|
45
58
|
</NuxtLink>
|
|
46
59
|
</header>
|
|
47
60
|
<main>
|
|
@@ -64,7 +77,7 @@ const tinted = computed(() => /\/checkout(\/|$)/.test(route.path));
|
|
|
64
77
|
<a
|
|
65
78
|
v-if="shopContact.email"
|
|
66
79
|
:href="`mailto:${shopContact.email}`"
|
|
67
|
-
class="text-xs text-dimmed hover:text-default
|
|
80
|
+
class="inline-flex min-h-11 items-center text-xs text-dimmed transition-colors hover:text-default"
|
|
68
81
|
>
|
|
69
82
|
{{ shopContact.email }}
|
|
70
83
|
</a>
|
|
@@ -73,14 +86,22 @@ const tinted = computed(() => /\/checkout(\/|$)/.test(route.path));
|
|
|
73
86
|
:key="link.to"
|
|
74
87
|
:to="localePath(link.to)"
|
|
75
88
|
tabindex="0"
|
|
76
|
-
class="text-xs text-dimmed hover:text-default
|
|
89
|
+
class="inline-flex min-h-11 items-center text-xs text-dimmed transition-colors hover:text-default"
|
|
77
90
|
>
|
|
78
91
|
{{ link.label }}
|
|
79
92
|
</NuxtLink>
|
|
93
|
+
<ConsentPreferencesLink
|
|
94
|
+
class="text-xs text-dimmed hover:text-default transition-colors cursor-pointer"
|
|
95
|
+
>
|
|
96
|
+
{{ t('footer.cookieSettings') }}
|
|
97
|
+
</ConsentPreferencesLink>
|
|
80
98
|
</nav>
|
|
81
99
|
</div>
|
|
82
100
|
</footer>
|
|
83
101
|
</div>
|
|
102
|
+
<!-- The cookie choice (Consent Manager): rendered by this shop's own
|
|
103
|
+
server when one is owed, never in the editor or a preview. -->
|
|
104
|
+
<ConsentBanner />
|
|
84
105
|
</Body>
|
|
85
106
|
</Html>
|
|
86
107
|
</template>
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
export default defineNuxtRouteMiddleware(() => {
|
|
1
|
+
export default defineNuxtRouteMiddleware((to, from) => {
|
|
2
2
|
const localePath = useLocalePath();
|
|
3
3
|
|
|
4
|
+
// A new checkout started from the cart must show the account/guest choice
|
|
5
|
+
// again; the selection is intentionally kept only within the current flow.
|
|
6
|
+
if (from.path !== to.path && /\/cart(?:\/|$)/.test(from.path)) {
|
|
7
|
+
useState("checkout-customer-type", () => "account").value = "account";
|
|
8
|
+
}
|
|
9
|
+
|
|
4
10
|
// Authentication is handled on the page itself (checkout gate with
|
|
5
11
|
// login + guest ordering per organization flags) — the guard only
|
|
6
12
|
// ensures there is something to check out.
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import type { PunchoutReturnPayload } from "../../interfaces/punchout";
|
|
3
|
+
import { cartEcommerce } from "../../shared/themeEvents";
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* The interstitial — the buyer is leaving.
|
|
@@ -31,6 +32,26 @@ const { t } = useI18n();
|
|
|
31
32
|
const { icon } = useIcons();
|
|
32
33
|
const { to } = useAppUrl();
|
|
33
34
|
const { protocol } = usePunchoutVisit();
|
|
35
|
+
const cart = useCartStore();
|
|
36
|
+
const themeEvents = useThemeEvents();
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* `punchout_transfer` — the cart leaves for the procurement system. Not for a
|
|
40
|
+
* replayed hand-back (the same cart answered again) nor for a back-channel
|
|
41
|
+
* visit, where the browser posts nothing; and only for the two protocols the
|
|
42
|
+
* contract names.
|
|
43
|
+
*/
|
|
44
|
+
function reportTransfer(): void {
|
|
45
|
+
const kind = protocol.value;
|
|
46
|
+
if (payload.value?.replayed || isBackChannel.value || (kind !== "oci" && kind !== "cxml") || !cart.items.length) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const ecommerce = cartEcommerce(cart.items);
|
|
50
|
+
themeEvents.emit("punchout_transfer", {
|
|
51
|
+
ecommerce: { ...ecommerce, value_net: ecommerce.value_net ?? 0, value_gross: ecommerce.value_gross ?? 0 },
|
|
52
|
+
punchout: { protocol: kind },
|
|
53
|
+
});
|
|
54
|
+
}
|
|
34
55
|
|
|
35
56
|
definePageMeta({
|
|
36
57
|
// The buyer is on their way out; this page is not part of the shop's
|
|
@@ -72,6 +93,7 @@ onMounted(async () => {
|
|
|
72
93
|
|
|
73
94
|
// One tick so the form is in the DOM, and a beat so the buyer sees where
|
|
74
95
|
// they are going rather than a flash of a page they cannot read.
|
|
96
|
+
reportTransfer();
|
|
75
97
|
await nextTick();
|
|
76
98
|
window.setTimeout(() => form.value?.submit(), 400);
|
|
77
99
|
});
|