@revenexx/cover 0.7.1 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app/api/account.ts +4 -0
- package/app/api/forms.ts +1 -0
- package/app/app.config.ts +17 -12
- package/app/assets/css/cover.css +9 -0
- package/app/components/RevenexxForm.vue +84 -12
- package/app/components/account/AccountShell.vue +18 -0
- package/app/components/account/AccountSidebar.vue +2 -5
- package/app/components/account/approvals/AccountPendingApprovals.vue +178 -0
- package/app/components/account/dashboard/AccountDashboardKpis.vue +74 -34
- package/app/components/account/dashboard/AccountDashboardQuickActions.vue +24 -6
- package/app/components/account/orderlists/AccountOrderListDetail.vue +47 -4
- package/app/components/account/orders/AccountOrderDetail.vue +186 -1
- package/app/components/account/organization/AccountOrganization.vue +3 -1
- package/app/components/account/payments/AccountPayments.vue +129 -0
- package/app/components/account/quotes/AccountQuoteDetail.vue +48 -16
- package/app/components/account/team/AccountTeam.vue +32 -7
- package/app/components/auth/AuthForgotPasswordPanel.vue +9 -4
- package/app/components/auth/AuthLoginPanel.vue +136 -18
- package/app/components/auth/AuthMagicLinkPanel.vue +70 -0
- package/app/components/cart/actions/CartSaveToListModal.vue +5 -0
- package/app/components/cart/item/CartItem.vue +17 -75
- package/app/components/cart/position/CartPosition.vue +17 -30
- package/app/components/cart/quote/CartQuoteRequestModal.vue +9 -1
- package/app/components/cart/view/CartSummaryPanel.vue +54 -0
- package/app/components/category/view/GridView.vue +10 -1
- package/app/components/category/view/ListView.vue +10 -1
- package/app/components/checkout/confirmation/CheckoutConfirmationActions.vue +2 -0
- package/app/components/checkout/onepage/CheckoutAddressSection.vue +4 -4
- package/app/components/checkout/onepage/CheckoutDeliverySection.vue +31 -3
- package/app/components/checkout/onepage/CheckoutGate.vue +10 -7
- package/app/components/checkout/onepage/CheckoutOnePageView.vue +1 -1
- package/app/components/checkout/onepage/CheckoutPaymentSection.vue +10 -0
- package/app/components/checkout/onepage/CheckoutSummarySection.vue +7 -1
- package/app/components/form/FormPage.vue +40 -0
- package/app/components/layout/Region.vue +13 -0
- package/app/components/layout/footer/Footer.vue +8 -0
- package/app/components/layout/header/AppBar.vue +11 -4
- package/app/components/layout/header/MainNav.vue +26 -4
- package/app/components/layout/header/MobileMenu.vue +12 -0
- package/app/components/listing/ListingResults.vue +3 -1
- package/app/components/product/card/Compact.vue +10 -1
- package/app/components/product/detail/ProductDetailAddToCart.vue +51 -18
- package/app/components/product/detail/ProductDetailIdentity.vue +1 -1
- package/app/components/product/detail/ProductDetailPriceRequest.vue +39 -0
- package/app/components/product/detail/ProductDetailSaveToList.vue +10 -0
- package/app/components/product/detail/ProductDetailView.vue +57 -0
- package/app/composables/useAccountDashboard.ts +0 -10
- package/app/composables/useAccountHold.ts +45 -0
- package/app/composables/useAccountNavigation.ts +35 -0
- package/app/composables/useAccountPayments.ts +21 -0
- package/app/composables/useAccountQuotes.ts +15 -2
- package/app/composables/useAuthStore.ts +84 -2
- package/app/composables/useAuthoredForms.ts +26 -0
- package/app/composables/useAvailableOffers.ts +42 -0
- package/app/composables/useCategoryListing.ts +6 -0
- package/app/composables/useCheckoutOnePage.ts +21 -2
- package/app/composables/useGuestOrdering.ts +28 -0
- package/app/composables/useMasterDataEditable.ts +45 -7
- package/app/composables/useOrderListRules.ts +21 -1
- package/app/composables/usePendingApprovals.ts +37 -0
- package/app/composables/useProductCard.ts +29 -2
- package/app/composables/useProductListing.ts +79 -0
- package/app/composables/useQuantityStepper.ts +90 -0
- package/app/composables/useQuickActions.ts +35 -0
- package/app/composables/useRoleGrants.ts +32 -0
- package/app/composables/useSearchListing.ts +4 -0
- package/app/composables/useThemeEvents.ts +144 -0
- package/app/config/accountDashboard.ts +26 -0
- package/app/config/icons.ts +2 -0
- package/app/config/navigation.ts +2 -2
- package/app/config/quickActions.ts +40 -5
- package/app/formkit.config.ts +14 -0
- package/app/interfaces/account/approvals.ts +37 -0
- package/app/interfaces/account/dashboard.ts +2 -0
- package/app/interfaces/account/order-list.ts +29 -0
- package/app/interfaces/account/order-lists.ts +9 -0
- package/app/interfaces/account/payments.ts +48 -0
- package/app/interfaces/auth.ts +24 -2
- package/app/interfaces/b2b.ts +8 -8
- package/app/interfaces/offers.ts +35 -0
- package/app/interfaces/quantity-stepper.ts +17 -0
- package/app/interfaces/shopSettings.ts +77 -0
- package/app/layouts/default.vue +19 -10
- package/app/layouts/focus.vue +28 -7
- package/app/middleware/checkout-guard.ts +7 -1
- package/app/pages/punchout/transfer.vue +22 -0
- package/app/plugins/account-hold.client.ts +20 -0
- package/app/plugins/shop-settings.ts +27 -12
- package/app/plugins/theme-events.client.ts +132 -0
- package/app/shared/themeEvents.ts +445 -0
- package/i18n/locales/de/account.json +87 -0
- package/i18n/locales/de/auth.json +30 -0
- package/i18n/locales/de/cart.json +9 -1
- package/i18n/locales/de/checkout.json +4 -2
- package/i18n/locales/de/common.json +4 -0
- package/i18n/locales/de/cover.json +44 -0
- package/i18n/locales/de/editor.json +47 -1
- package/i18n/locales/de/forms.json +27 -0
- package/i18n/locales/en/account.json +87 -0
- package/i18n/locales/en/auth.json +30 -0
- package/i18n/locales/en/cart.json +9 -1
- package/i18n/locales/en/checkout.json +4 -2
- package/i18n/locales/en/common.json +4 -0
- package/i18n/locales/en/cover.json +44 -0
- package/i18n/locales/en/editor.json +47 -1
- package/i18n/locales/en/forms.json +27 -0
- package/nuxt.config.ts +15 -1
- package/package.json +6 -2
- package/server/api/account/address/[id].delete.ts +1 -1
- package/server/api/account/address/[id].put.ts +1 -1
- package/server/api/account/address/index.post.ts +1 -1
- package/server/api/account/order-lists/[id].get.ts +37 -3
- package/server/api/account/orders/[id]/cancel.post.ts +54 -0
- package/server/api/account/orders/[id]/messages.get.ts +63 -0
- package/server/api/account/orders/[id]/messages.post.ts +44 -0
- package/server/api/account/orders/[id]/return.post.ts +1 -0
- package/server/api/account/orders/[id].get.ts +1 -1
- package/server/api/account/organization.put.ts +1 -1
- package/server/api/account/payments.get.ts +54 -0
- package/server/api/account/pending-approvals/[id]/approve.post.ts +10 -0
- package/server/api/account/pending-approvals/[id]/decline.post.ts +10 -0
- package/server/api/account/pending-approvals/index.get.ts +26 -0
- package/server/api/account/profile.get.ts +3 -1
- package/server/api/account/profile.put.ts +1 -1
- package/server/api/account/quotes/[id]/decline.post.ts +35 -6
- package/server/api/account/team/[id].put.ts +1 -1
- package/server/api/account/team.post.ts +1 -1
- package/server/api/auth/login.post.ts +6 -0
- package/server/api/auth/magic-link.post.ts +32 -0
- package/server/api/auth/magic-link.put.ts +35 -0
- package/server/api/auth/otp.post.ts +33 -0
- package/server/api/auth/otp.put.ts +33 -0
- package/server/api/carts/[id]/activate.post.ts +1 -0
- package/server/api/carts/[id]/index.delete.ts +1 -0
- package/server/api/carts/[id]/index.put.ts +1 -0
- package/server/api/carts/[id]/items.post.ts +1 -0
- package/server/api/checkout/profile.get.ts +6 -3
- package/server/api/forms/[slug]/submit.post.ts +27 -16
- package/server/api/forms/[slug].get.ts +9 -1
- package/server/api/forms/index.get.ts +23 -0
- package/server/api/orders/index.post.ts +41 -0
- package/server/api/promotions/available.post.ts +37 -0
- package/server/api/quick-actions.get.ts +6 -38
- package/server/config/account/organization.json +0 -4
- package/server/config/shop/app-settings.json +4 -0
- package/server/data/forms/authored.json +337 -0
- package/server/interfaces/forms.ts +51 -0
- package/server/middleware/buyer-principal.ts +18 -0
- package/server/routes/punchout/start.get.ts +2 -2
- package/server/services/ApiAddressBookService.ts +43 -1
- package/server/services/ApiAuthService.ts +101 -10
- package/server/services/ApiCartService.ts +3 -10
- package/server/services/ApiFormsService.ts +56 -0
- package/server/services/ApiOrganizationService.ts +7 -2
- package/server/services/ApiTeamService.ts +93 -21
- package/server/services/MockB2BContextService.ts +1 -5
- package/server/services/MockFormsService.ts +63 -0
- package/server/utils/accountPayments.ts +45 -0
- package/server/utils/appSettings.ts +69 -4
- package/server/utils/buyerIdentity.ts +168 -0
- package/server/utils/cartOwnership.ts +27 -0
- package/server/utils/forms.ts +62 -14
- package/server/utils/formsService.ts +29 -0
- package/server/utils/liveOrderLists.ts +50 -23
- package/server/utils/liveOrders.ts +65 -24
- package/server/utils/livePrices.ts +7 -15
- package/server/utils/masterData.ts +60 -11
- package/server/utils/passwordlessSignIn.ts +82 -0
- package/server/utils/pendingApprovals.ts +175 -0
- package/server/utils/procurementCheckout.ts +2 -0
- package/server/utils/promotionsService.ts +90 -0
- package/server/utils/quickActionCatalogue.ts +53 -0
- package/server/utils/quotesService.ts +15 -0
- package/server/utils/revenexxSdk.ts +116 -2
- package/server/utils/shopSettings.ts +35 -4
package/app/api/account.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
export const accountApi = {
|
|
2
2
|
profile: () => "/api/account/profile",
|
|
3
|
+
/** The user's B2B context: organization settings, cost centers, workflows. */
|
|
4
|
+
context: () => "/api/account/context",
|
|
3
5
|
orders: () => "/api/account/orders",
|
|
6
|
+
orderLists: () => "/api/account/order-lists",
|
|
7
|
+
requisitions: () => "/api/account/requisitions",
|
|
4
8
|
orderReturn: (id: string) => `/api/account/orders/${id}/return`,
|
|
5
9
|
addresses: () => "/api/account/addresses",
|
|
6
10
|
addressUpdate: (id: string) => `/api/account/address/${id}`,
|
package/app/api/forms.ts
CHANGED
package/app/app.config.ts
CHANGED
|
@@ -35,6 +35,11 @@ export default defineAppConfig({
|
|
|
35
35
|
// The quotes app (RX-783): a cart the shop cannot order as it is becomes a
|
|
36
36
|
// quotation request, priced in the Cockpit and ordered from the account.
|
|
37
37
|
quotesService: "mock",
|
|
38
|
+
// The forms app: the contact, price-request and return-request forms an
|
|
39
|
+
// operator authors in the Cockpit. `mock` serves the three bundled demo
|
|
40
|
+
// forms, so a storefront without gateway credentials still has a contact
|
|
41
|
+
// page and a browser test still has something to submit.
|
|
42
|
+
formsService: "mock",
|
|
38
43
|
themeService: "mock",
|
|
39
44
|
// What the shop was CONFIGURED to do — the platform apps' own tenant
|
|
40
45
|
// settings, read through the gateway's settings resolver. Mock answers
|
|
@@ -107,6 +112,12 @@ export default defineAppConfig({
|
|
|
107
112
|
support: true,
|
|
108
113
|
},
|
|
109
114
|
},
|
|
115
|
+
// The way into the catalogue, in the header of every storefront. The panel is
|
|
116
|
+
// built from the tenant's own category tree and needs no content backend; what
|
|
117
|
+
// it needs is an entry that opens it, and a storefront writing its own
|
|
118
|
+
// navigation had no reason to know that. On by default, so a shop without a
|
|
119
|
+
// path to its own catalogue is a decision rather than an oversight.
|
|
120
|
+
catalogueMenu: true,
|
|
110
121
|
// The shipping app states its order cut-off in UTC — it has to, it serves
|
|
111
122
|
// every market. Which zone a storefront quotes it back in is the shop's own
|
|
112
123
|
// decision, so it is named here. UTC by default: a shop that has not said
|
|
@@ -121,18 +132,12 @@ export default defineAppConfig({
|
|
|
121
132
|
checkout: {
|
|
122
133
|
earliestDeliveryDays: 0,
|
|
123
134
|
},
|
|
124
|
-
// Master data another system owns — an ERP, usually — is shown in the
|
|
125
|
-
//
|
|
126
|
-
//
|
|
127
|
-
//
|
|
128
|
-
//
|
|
129
|
-
//
|
|
130
|
-
account: {
|
|
131
|
-
addresses: { editable: true },
|
|
132
|
-
profile: { editable: true },
|
|
133
|
-
organization: { editable: true },
|
|
134
|
-
team: { editable: true },
|
|
135
|
-
},
|
|
135
|
+
// Master data another system owns — an ERP, usually — is shown in the account
|
|
136
|
+
// and not changed there. That used to be four flags here, which was a guess in
|
|
137
|
+
// both directions: the shop hid a form while the platform went on accepting
|
|
138
|
+
// the write, and a storefront could allow what the platform refused. The
|
|
139
|
+
// customers app holds the answer now (`self_service_master_data`) and refuses
|
|
140
|
+
// the write itself; the shop reads it and offers accordingly.
|
|
136
141
|
ui: {
|
|
137
142
|
icons: nuxtUiIcons(DEFAULT_ICON_WEIGHT),
|
|
138
143
|
},
|
package/app/assets/css/cover.css
CHANGED
|
@@ -23,3 +23,12 @@
|
|
|
23
23
|
.dark.dark {
|
|
24
24
|
--ui-warning: var(--ui-color-warning-400);
|
|
25
25
|
}
|
|
26
|
+
|
|
27
|
+
/* Keep browser autofill visually consistent with the checkout fields. */
|
|
28
|
+
input:-webkit-autofill,
|
|
29
|
+
input:-webkit-autofill:hover,
|
|
30
|
+
input:-webkit-autofill:focus {
|
|
31
|
+
-webkit-text-fill-color: var(--ui-text-highlighted);
|
|
32
|
+
-webkit-box-shadow: 0 0 0 1000px var(--ui-bg) inset;
|
|
33
|
+
box-shadow: 0 0 0 1000px var(--ui-bg) inset;
|
|
34
|
+
}
|
|
@@ -31,8 +31,10 @@ const props = defineProps<{
|
|
|
31
31
|
context?: Record<string, unknown>;
|
|
32
32
|
}>();
|
|
33
33
|
|
|
34
|
+
const themeEvents = useThemeEvents();
|
|
35
|
+
|
|
34
36
|
const { icon } = useIcons();
|
|
35
|
-
const { locale } = useI18n();
|
|
37
|
+
const { locale, t } = useI18n();
|
|
36
38
|
const route = useRoute();
|
|
37
39
|
|
|
38
40
|
interface FormPayload {
|
|
@@ -40,6 +42,8 @@ interface FormPayload {
|
|
|
40
42
|
slug: string;
|
|
41
43
|
definition: Record<string, unknown>[];
|
|
42
44
|
settings?: { submit_label?: string; success_message?: string } | null;
|
|
45
|
+
/** The decoy field the tenant configured, when there is one. */
|
|
46
|
+
honeypot?: string | null;
|
|
43
47
|
}
|
|
44
48
|
|
|
45
49
|
interface FormStep {
|
|
@@ -72,12 +76,29 @@ function normalizeSteps(definition: Record<string, unknown>[]): FormStep[] {
|
|
|
72
76
|
return steps;
|
|
73
77
|
}
|
|
74
78
|
|
|
79
|
+
/**
|
|
80
|
+
* The headers an internal call has to carry, and why.
|
|
81
|
+
*
|
|
82
|
+
* An internal `$fetch` during SSR gets a FRESH event that inherits nothing from
|
|
83
|
+
* the navigation that triggered it. Without the brokered tenant headers a
|
|
84
|
+
* deployed multi-tenant Site has no credentials at all, so the read falls back to
|
|
85
|
+
* whatever the process was configured with — which is how a live storefront
|
|
86
|
+
* rendered the bundled demo form. The cookie carries the market the visitor
|
|
87
|
+
* chose and the dev panel's live/demo switch.
|
|
88
|
+
*
|
|
89
|
+
* On the client this is {} and the browser's own request already carries all of
|
|
90
|
+
* it, so the same call works there unchanged.
|
|
91
|
+
*/
|
|
92
|
+
function forwardedHeaders(): Record<string, string> {
|
|
93
|
+
return useRequestHeaders(["cookie", "x-revenexx-tenant", "x-revenexx-context"]);
|
|
94
|
+
}
|
|
95
|
+
|
|
75
96
|
// No top-level await — keep this a sync component so it renders its own
|
|
76
97
|
// pending/empty states. Re-fetches on locale change (BFF localises labels).
|
|
77
98
|
const { data: form, pending } = useAsyncData(
|
|
78
99
|
() => `revenexx-form-${props.slug}-${locale.value}`,
|
|
79
100
|
() => $fetch<FormPayload>(formsApi.schema(props.slug), {
|
|
80
|
-
headers: { "x-locale": locale.value },
|
|
101
|
+
headers: { ...forwardedHeaders(), "x-locale": locale.value },
|
|
81
102
|
}).catch(() => null),
|
|
82
103
|
{ watch: [() => props.slug, locale] },
|
|
83
104
|
);
|
|
@@ -85,7 +106,16 @@ const { data: form, pending } = useAsyncData(
|
|
|
85
106
|
const steps = computed(() => normalizeSteps(form.value?.definition ?? []));
|
|
86
107
|
const fieldSteps = computed(() => steps.value.filter(s => s.kind === "fields"));
|
|
87
108
|
const thankStep = computed(() => steps.value.find(s => s.kind === "thankyou") ?? null);
|
|
88
|
-
const submitLabel = computed(() => form.value?.settings?.submit_label || "
|
|
109
|
+
const submitLabel = computed(() => form.value?.settings?.submit_label || t("forms.submit"));
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* The tenant's decoy field. The forms app expects the STOREFRONT to render it —
|
|
113
|
+
* it can only judge what it is sent — so a tenant who configured a trap and a
|
|
114
|
+
* shop that never rendered the field add up to no trap at all, which is exactly
|
|
115
|
+
* what shipped. Hidden from sight, from the tab order and from a screen reader;
|
|
116
|
+
* a human therefore never fills it, and a bot fills everything.
|
|
117
|
+
*/
|
|
118
|
+
const honeypot = computed(() => form.value?.honeypot ?? null);
|
|
89
119
|
|
|
90
120
|
// Product (reference) fields pre-fill from the `context` prop or the matching
|
|
91
121
|
// URL query param — so a price request linked from a product page carries it.
|
|
@@ -120,13 +150,16 @@ function cleanNodes(nodes: Record<string, unknown>[]): FormKitSchemaDefinition {
|
|
|
120
150
|
|
|
121
151
|
const formId = useId();
|
|
122
152
|
const stepIndex = ref(0);
|
|
153
|
+
/** Whatever filled the decoy. Kept outside FormKit's value tree so the field
|
|
154
|
+
* never appears in a step, a validation message or the tab order. */
|
|
155
|
+
const honeypotValue = ref("");
|
|
123
156
|
const tick = ref(0);
|
|
124
157
|
const submitting = ref(false);
|
|
125
158
|
const submitted = ref(false);
|
|
126
159
|
const successMessage = ref<string | null>(null);
|
|
127
160
|
const submitError = ref<string | null>(null);
|
|
128
161
|
|
|
129
|
-
watch(() => props.slug, () => { stepIndex.value = 0; submitted.value = false; });
|
|
162
|
+
watch(() => props.slug, () => { stepIndex.value = 0; submitted.value = false; honeypotValue.value = ""; });
|
|
130
163
|
|
|
131
164
|
const isLastStep = computed(() => stepIndex.value >= fieldSteps.value.length - 1);
|
|
132
165
|
|
|
@@ -156,21 +189,32 @@ async function onSubmit(values: Record<string, unknown>) {
|
|
|
156
189
|
submitError.value = null;
|
|
157
190
|
submitting.value = true;
|
|
158
191
|
try {
|
|
159
|
-
const res = await $fetch<{ ok: boolean; success_message: string | null }>(
|
|
192
|
+
const res = await $fetch<{ ok: boolean; outcome: string; success_message: string | null }>(
|
|
160
193
|
formsApi.submit(props.slug),
|
|
161
194
|
{
|
|
162
195
|
method: "POST",
|
|
196
|
+
headers: forwardedHeaders(),
|
|
163
197
|
body: {
|
|
164
|
-
data:
|
|
198
|
+
data: honeypot.value
|
|
199
|
+
? { ...values, [honeypot.value]: honeypotValue.value }
|
|
200
|
+
: values,
|
|
165
201
|
source: props.source ?? (import.meta.client ? window.location.pathname : undefined),
|
|
166
202
|
},
|
|
167
203
|
},
|
|
168
204
|
);
|
|
169
|
-
|
|
205
|
+
// A tenant who chose to refuse a caught submission stored nothing, so
|
|
206
|
+
// there is nothing to thank anybody for.
|
|
207
|
+
if (!res.ok) {
|
|
208
|
+
submitError.value = t("forms.rejected");
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
successMessage.value = res.success_message || t("forms.success");
|
|
170
212
|
submitted.value = true;
|
|
213
|
+
// Which form was sent — never a word of what was typed into it.
|
|
214
|
+
themeEvents.emit("form_submit", { form: { form_code: props.slug.slice(0, 128), outcome: "accepted" } });
|
|
171
215
|
}
|
|
172
216
|
catch {
|
|
173
|
-
submitError.value = "
|
|
217
|
+
submitError.value = t("forms.error");
|
|
174
218
|
}
|
|
175
219
|
finally {
|
|
176
220
|
submitting.value = false;
|
|
@@ -206,8 +250,15 @@ async function onSubmit(values: Record<string, unknown>) {
|
|
|
206
250
|
/>
|
|
207
251
|
</div>
|
|
208
252
|
|
|
253
|
+
<UiFeedbackEmptyState
|
|
254
|
+
v-else-if="!form"
|
|
255
|
+
icon="file"
|
|
256
|
+
:title="t('forms.missingTitle')"
|
|
257
|
+
:description="t('forms.missingDescription')"
|
|
258
|
+
/>
|
|
259
|
+
|
|
209
260
|
<FormKit
|
|
210
|
-
v-else
|
|
261
|
+
v-else
|
|
211
262
|
:id="formId"
|
|
212
263
|
type="form"
|
|
213
264
|
:value="prefill"
|
|
@@ -221,7 +272,7 @@ async function onSubmit(values: Record<string, unknown>) {
|
|
|
221
272
|
v-if="fieldSteps.length > 1"
|
|
222
273
|
class="mb-4 text-sm text-muted"
|
|
223
274
|
>
|
|
224
|
-
|
|
275
|
+
{{ t('forms.step', { current: stepIndex + 1, total: fieldSteps.length }) }}<template v-if="fieldSteps[stepIndex]?.title"> · {{ fieldSteps[stepIndex]?.title }}</template>
|
|
225
276
|
</p>
|
|
226
277
|
|
|
227
278
|
<div
|
|
@@ -232,13 +283,34 @@ async function onSubmit(values: Record<string, unknown>) {
|
|
|
232
283
|
<FormKitSchema :schema="cleanNodes(step.nodes)" />
|
|
233
284
|
</div>
|
|
234
285
|
|
|
286
|
+
<!--
|
|
287
|
+
The decoy. Off-screen rather than display:none, because a bot that
|
|
288
|
+
reads the stylesheet skips a hidden input; aria-hidden and tabindex
|
|
289
|
+
keep it away from everybody it is not meant for.
|
|
290
|
+
-->
|
|
291
|
+
<div
|
|
292
|
+
v-if="honeypot"
|
|
293
|
+
aria-hidden="true"
|
|
294
|
+
class="absolute -left-[9999px] w-px h-px overflow-hidden"
|
|
295
|
+
>
|
|
296
|
+
<label :for="`${formId}-hp`">{{ t('forms.honeypotLabel') }}</label>
|
|
297
|
+
<input
|
|
298
|
+
:id="`${formId}-hp`"
|
|
299
|
+
v-model="honeypotValue"
|
|
300
|
+
:name="honeypot"
|
|
301
|
+
type="text"
|
|
302
|
+
tabindex="-1"
|
|
303
|
+
autocomplete="off"
|
|
304
|
+
>
|
|
305
|
+
</div>
|
|
306
|
+
|
|
235
307
|
<div class="mt-6 flex items-center justify-between gap-3">
|
|
236
308
|
<UButton
|
|
237
309
|
v-if="stepIndex > 0"
|
|
238
310
|
type="button"
|
|
239
311
|
color="neutral"
|
|
240
312
|
variant="ghost"
|
|
241
|
-
:label="'
|
|
313
|
+
:label="t('forms.back')"
|
|
242
314
|
@click="back"
|
|
243
315
|
/>
|
|
244
316
|
<span v-else />
|
|
@@ -248,7 +320,7 @@ async function onSubmit(values: Record<string, unknown>) {
|
|
|
248
320
|
type="button"
|
|
249
321
|
color="primary"
|
|
250
322
|
:disabled="!activeStepValid"
|
|
251
|
-
:label="'
|
|
323
|
+
:label="t('forms.continue')"
|
|
252
324
|
@click="next"
|
|
253
325
|
/>
|
|
254
326
|
<UButton
|
|
@@ -2,12 +2,30 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Account area shell: sidebar with the full B2B navigation tree next to the
|
|
4
4
|
* page content. Account pages wrap their content in this component.
|
|
5
|
+
*
|
|
6
|
+
* It is also where an account on hold is said out loud. Every account page passes
|
|
7
|
+
* through here, so the one sentence that explains why nothing works belongs at
|
|
8
|
+
* this level rather than on each of twenty pages — and a buyer who reads it stops
|
|
9
|
+
* filling a cart they cannot order.
|
|
5
10
|
*/
|
|
6
11
|
defineSlots<{ default(): unknown }>();
|
|
12
|
+
|
|
13
|
+
const { t } = useI18n();
|
|
14
|
+
const { icon } = useIcons();
|
|
15
|
+
const { onHold, stillAllowed } = useAccountHold();
|
|
7
16
|
</script>
|
|
8
17
|
|
|
9
18
|
<template>
|
|
10
19
|
<UContainer class="py-6 lg:py-8">
|
|
20
|
+
<UAlert
|
|
21
|
+
v-if="onHold"
|
|
22
|
+
class="mb-6"
|
|
23
|
+
:color="stillAllowed === 'nothing' ? 'error' : 'warning'"
|
|
24
|
+
variant="subtle"
|
|
25
|
+
:icon="icon('warning')"
|
|
26
|
+
:title="t('account.hold.title')"
|
|
27
|
+
:description="t(`account.hold.${stillAllowed}`)"
|
|
28
|
+
/>
|
|
11
29
|
<div class="flex flex-col lg:flex-row gap-6">
|
|
12
30
|
<AccountSidebar />
|
|
13
31
|
<div class="flex-1 min-w-0">
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { accountNavigation } from "../../config/navigation";
|
|
3
2
|
import type { AccountNavGroup } from "../../config/navigation";
|
|
4
3
|
|
|
5
4
|
const { icon } = useIcons();
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
const navigation =
|
|
9
|
-
(appConfig.accountNavigation as AccountNavGroup[] | undefined) ?? accountNavigation,
|
|
10
|
-
);
|
|
6
|
+
// Live tenant menu → app.config override → the layer's full B2B tree.
|
|
7
|
+
const { navigation } = useAccountNavigation();
|
|
11
8
|
|
|
12
9
|
const { t } = useI18n();
|
|
13
10
|
const localePath = useLocalePath();
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* The approver's own queue: what is waiting on them, and yes or no.
|
|
4
|
+
*
|
|
5
|
+
* This is the one surface an approver signs in for, and the shop had none — it
|
|
6
|
+
* listed what the company had asked for, which is a different question, and offered
|
|
7
|
+
* no way to decide anything. So the deciding happened in the Cockpit, an operator's
|
|
8
|
+
* tool a buying organisation's approver has no business being in.
|
|
9
|
+
*
|
|
10
|
+
* A decline asks for a reason. An approval does not: "yes" needs no explaining, and
|
|
11
|
+
* a required field in front of it would be a toll on the common case. A refusal the
|
|
12
|
+
* requester cannot read is one they will simply ask for again.
|
|
13
|
+
*/
|
|
14
|
+
const { t, d } = useI18n();
|
|
15
|
+
const { icon } = useIcons();
|
|
16
|
+
const toast = useToast();
|
|
17
|
+
const { approvals, deciding, decide, status } = usePendingApprovals();
|
|
18
|
+
const { formatCurrency } = useCartSummaryFormatting();
|
|
19
|
+
|
|
20
|
+
const declineFor = ref<string | null>(null);
|
|
21
|
+
const declineReason = ref("");
|
|
22
|
+
|
|
23
|
+
async function approve(id: string): Promise<void> {
|
|
24
|
+
try {
|
|
25
|
+
await decide(id, "approve");
|
|
26
|
+
toast.add({ title: t("approvals.queue.approved"), color: "success", icon: icon("success") });
|
|
27
|
+
}
|
|
28
|
+
catch (err) {
|
|
29
|
+
toast.add({
|
|
30
|
+
title: t("approvals.queue.failed"),
|
|
31
|
+
description: (err as { data?: { message?: string } })?.data?.message,
|
|
32
|
+
color: "error",
|
|
33
|
+
icon: icon("error"),
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async function submitDecline(): Promise<void> {
|
|
39
|
+
const id = declineFor.value;
|
|
40
|
+
if (!id) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
try {
|
|
44
|
+
await decide(id, "decline", declineReason.value);
|
|
45
|
+
declineFor.value = null;
|
|
46
|
+
declineReason.value = "";
|
|
47
|
+
toast.add({ title: t("approvals.queue.declined"), color: "success", icon: icon("success") });
|
|
48
|
+
}
|
|
49
|
+
catch (err) {
|
|
50
|
+
toast.add({
|
|
51
|
+
title: t("approvals.queue.failed"),
|
|
52
|
+
description: (err as { data?: { message?: string } })?.data?.message,
|
|
53
|
+
color: "error",
|
|
54
|
+
icon: icon("error"),
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
</script>
|
|
59
|
+
|
|
60
|
+
<template>
|
|
61
|
+
<section class="space-y-4">
|
|
62
|
+
<div class="flex items-baseline justify-between gap-3">
|
|
63
|
+
<h2 class="text-lg font-semibold text-highlighted">
|
|
64
|
+
{{ t('approvals.queue.title') }}
|
|
65
|
+
</h2>
|
|
66
|
+
<UBadge
|
|
67
|
+
v-if="approvals.length"
|
|
68
|
+
color="warning"
|
|
69
|
+
variant="subtle"
|
|
70
|
+
:label="String(approvals.length)"
|
|
71
|
+
/>
|
|
72
|
+
</div>
|
|
73
|
+
|
|
74
|
+
<p
|
|
75
|
+
v-if="status === 'pending'"
|
|
76
|
+
class="text-sm text-muted"
|
|
77
|
+
>
|
|
78
|
+
{{ t('approvals.queue.loading') }}
|
|
79
|
+
</p>
|
|
80
|
+
|
|
81
|
+
<UiFeedbackEmptyState
|
|
82
|
+
v-else-if="!approvals.length"
|
|
83
|
+
:icon="icon('check')"
|
|
84
|
+
:title="t('approvals.queue.empty.title')"
|
|
85
|
+
:description="t('approvals.queue.empty.description')"
|
|
86
|
+
/>
|
|
87
|
+
|
|
88
|
+
<ul
|
|
89
|
+
v-else
|
|
90
|
+
class="border border-(--ui-border) rounded-xl divide-y divide-(--ui-border) overflow-hidden"
|
|
91
|
+
>
|
|
92
|
+
<li
|
|
93
|
+
v-for="approval in approvals"
|
|
94
|
+
:key="approval.id"
|
|
95
|
+
class="px-4 sm:px-5 py-4 flex flex-wrap items-center gap-x-4 gap-y-2"
|
|
96
|
+
>
|
|
97
|
+
<div class="min-w-0 flex-1">
|
|
98
|
+
<p class="text-sm font-medium text-highlighted">
|
|
99
|
+
{{ approval.requestNumber ?? t('approvals.queue.unnamedRequest') }}
|
|
100
|
+
<!-- Which signature this is. Hiding it would let an approver
|
|
101
|
+
think theirs was the only one needed. -->
|
|
102
|
+
<span class="text-xs font-normal text-muted">
|
|
103
|
+
· {{ t('approvals.queue.layer', { layer: approval.layer }) }}
|
|
104
|
+
</span>
|
|
105
|
+
</p>
|
|
106
|
+
<p class="text-xs text-muted">
|
|
107
|
+
<template v-if="approval.requestedBy">{{ approval.requestedBy }} · </template>
|
|
108
|
+
<template v-if="approval.costCentreCode">{{ approval.costCentreCode }} · </template>
|
|
109
|
+
{{ approval.at ? d(new Date(approval.at), { dateStyle: 'medium' }) : '' }}
|
|
110
|
+
</p>
|
|
111
|
+
</div>
|
|
112
|
+
|
|
113
|
+
<!-- The figure, where the request states one. A confident 0,00 € beside
|
|
114
|
+
a signature would be worse than a blank. -->
|
|
115
|
+
<p class="text-sm font-medium text-highlighted tabular-nums">
|
|
116
|
+
{{ approval.total !== null ? formatCurrency(approval.total) : '—' }}
|
|
117
|
+
</p>
|
|
118
|
+
|
|
119
|
+
<div class="flex items-center gap-2">
|
|
120
|
+
<UButton
|
|
121
|
+
size="sm"
|
|
122
|
+
color="neutral"
|
|
123
|
+
variant="outline"
|
|
124
|
+
:disabled="deciding === approval.id"
|
|
125
|
+
:label="t('approvals.queue.decline')"
|
|
126
|
+
@click="declineFor = approval.id"
|
|
127
|
+
/>
|
|
128
|
+
<UButton
|
|
129
|
+
size="sm"
|
|
130
|
+
color="primary"
|
|
131
|
+
:loading="deciding === approval.id"
|
|
132
|
+
:label="t('approvals.queue.approve')"
|
|
133
|
+
@click="approve(approval.id)"
|
|
134
|
+
/>
|
|
135
|
+
</div>
|
|
136
|
+
</li>
|
|
137
|
+
</ul>
|
|
138
|
+
|
|
139
|
+
<!-- A decline ends the whole request, so the reason is asked for: the
|
|
140
|
+
requester has to know whether to ask again differently. -->
|
|
141
|
+
<UModal
|
|
142
|
+
:open="declineFor !== null"
|
|
143
|
+
:title="t('approvals.queue.declineTitle')"
|
|
144
|
+
@update:open="(open: boolean) => { if (!open) declineFor = null; }"
|
|
145
|
+
>
|
|
146
|
+
<template #body>
|
|
147
|
+
<div class="space-y-4">
|
|
148
|
+
<p class="text-sm text-default">
|
|
149
|
+
{{ t('approvals.queue.declineIntro') }}
|
|
150
|
+
</p>
|
|
151
|
+
<UFormField :label="t('approvals.queue.declineReason')">
|
|
152
|
+
<UTextarea
|
|
153
|
+
v-model="declineReason"
|
|
154
|
+
class="w-full"
|
|
155
|
+
:rows="2"
|
|
156
|
+
:placeholder="t('approvals.queue.declineReasonPlaceholder')"
|
|
157
|
+
/>
|
|
158
|
+
</UFormField>
|
|
159
|
+
</div>
|
|
160
|
+
</template>
|
|
161
|
+
<template #footer>
|
|
162
|
+
<div class="flex items-center justify-end gap-2 w-full">
|
|
163
|
+
<UButton
|
|
164
|
+
color="neutral"
|
|
165
|
+
variant="ghost"
|
|
166
|
+
:label="t('cart.item.cancel')"
|
|
167
|
+
@click="declineFor = null"
|
|
168
|
+
/>
|
|
169
|
+
<UButton
|
|
170
|
+
color="error"
|
|
171
|
+
:label="t('approvals.queue.decline')"
|
|
172
|
+
@click="submitDecline"
|
|
173
|
+
/>
|
|
174
|
+
</div>
|
|
175
|
+
</template>
|
|
176
|
+
</UModal>
|
|
177
|
+
</section>
|
|
178
|
+
</template>
|
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* Dashboard KPI band: open orders, awaiting approval, 30-day spend, budget %.
|
|
4
|
+
* `kpis` picks which of them render (a block option, a tenant setting); the
|
|
5
|
+
* selection is narrowed through `resolveAccountDashboardKpis`, so an empty or
|
|
6
|
+
* unknown selection still shows the full band — never an empty frame.
|
|
7
|
+
*/
|
|
8
|
+
import { ACCOUNT_DASHBOARD_KPI_IDS, resolveAccountDashboardKpis } from "../../../config/accountDashboard";
|
|
9
|
+
import type { AccountDashboardKpiId } from "../../../interfaces/account/dashboard";
|
|
10
|
+
|
|
11
|
+
interface KpiCell {
|
|
12
|
+
readonly id: AccountDashboardKpiId;
|
|
13
|
+
readonly labelKey: string;
|
|
14
|
+
readonly value: string;
|
|
15
|
+
readonly isWarning: boolean;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const props = defineProps<{
|
|
19
|
+
/** KPIs to show, in any order; omitted → all four. */
|
|
20
|
+
kpis?: readonly AccountDashboardKpiId[];
|
|
21
|
+
}>();
|
|
22
|
+
|
|
3
23
|
const {
|
|
4
24
|
t,
|
|
5
25
|
formatCurrency,
|
|
@@ -15,7 +35,50 @@ const {
|
|
|
15
35
|
const pending = computed(() =>
|
|
16
36
|
ordersPending.value || contextPending.value || requisitionsPending.value);
|
|
17
37
|
|
|
18
|
-
|
|
38
|
+
const visibleKpis = computed(() => resolveAccountDashboardKpis(props.kpis ?? ACCOUNT_DASHBOARD_KPI_IDS));
|
|
39
|
+
|
|
40
|
+
const cellsById = computed<Record<AccountDashboardKpiId, KpiCell>>(() => ({
|
|
41
|
+
openOrders: {
|
|
42
|
+
id: "openOrders",
|
|
43
|
+
labelKey: "account.dashboard.stats.openOrders",
|
|
44
|
+
value: String(openOrdersCount.value),
|
|
45
|
+
isWarning: false,
|
|
46
|
+
},
|
|
47
|
+
awaitingApproval: {
|
|
48
|
+
id: "awaitingApproval",
|
|
49
|
+
labelKey: "account.dashboard.stats.awaitingApproval",
|
|
50
|
+
value: String(awaitingApprovalCount.value),
|
|
51
|
+
isWarning: awaitingApprovalCount.value > 0,
|
|
52
|
+
},
|
|
53
|
+
spend30: {
|
|
54
|
+
id: "spend30",
|
|
55
|
+
labelKey: "account.dashboard.stats.spend30",
|
|
56
|
+
value: formatCurrency(spend30.value),
|
|
57
|
+
isWarning: false,
|
|
58
|
+
},
|
|
59
|
+
budgetUsed: {
|
|
60
|
+
id: "budgetUsed",
|
|
61
|
+
labelKey: "account.dashboard.stats.budgetUsed",
|
|
62
|
+
value: budgetUtilization.value !== null ? `${budgetUtilization.value} %` : "—",
|
|
63
|
+
isWarning: (budgetUtilization.value ?? 0) >= 90,
|
|
64
|
+
},
|
|
65
|
+
}));
|
|
66
|
+
|
|
67
|
+
const cells = computed(() => visibleKpis.value.map(id => cellsById.value[id]));
|
|
68
|
+
|
|
69
|
+
// Static map so Tailwind's JIT emits every utility — the count is computed and
|
|
70
|
+
// a built class name would be purged. Two columns on mobile once there is a
|
|
71
|
+
// pair to show; from lg every KPI gets its own column.
|
|
72
|
+
const COLUMNS_CLASS: Record<number, string> = {
|
|
73
|
+
1: "grid-cols-1 lg:grid-cols-1",
|
|
74
|
+
2: "grid-cols-2 lg:grid-cols-2",
|
|
75
|
+
3: "grid-cols-2 lg:grid-cols-3",
|
|
76
|
+
4: "grid-cols-2 lg:grid-cols-4",
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const columnsClass = computed(() => COLUMNS_CLASS[cells.value.length] ?? COLUMNS_CLASS[4]);
|
|
80
|
+
|
|
81
|
+
/** Divider-separated KPI cells: 2-col grid on mobile, one row from lg. */
|
|
19
82
|
const statCell = `p-4 sm:p-5 border-(--ui-border)
|
|
20
83
|
max-lg:nth-[n+3]:border-t max-lg:nth-[2n]:border-l lg:not-first:border-l`;
|
|
21
84
|
</script>
|
|
@@ -27,44 +90,21 @@ const statCell = `p-4 sm:p-5 border-(--ui-border)
|
|
|
27
90
|
/>
|
|
28
91
|
<dl
|
|
29
92
|
v-else
|
|
30
|
-
class="border border-(--ui-border) rounded-xl grid
|
|
93
|
+
:class="['border border-(--ui-border) rounded-xl grid', columnsClass]"
|
|
31
94
|
>
|
|
32
|
-
<div
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
{{ openOrdersCount }}
|
|
38
|
-
</dd>
|
|
39
|
-
</div>
|
|
40
|
-
<div :class="statCell">
|
|
41
|
-
<dt class="text-sm text-muted truncate">
|
|
42
|
-
{{ t('account.dashboard.stats.awaitingApproval') }}
|
|
43
|
-
</dt>
|
|
44
|
-
<dd
|
|
45
|
-
class="mt-1 text-2xl font-semibold tabular-nums"
|
|
46
|
-
:class="awaitingApprovalCount > 0 ? 'text-warning' : 'text-highlighted'"
|
|
47
|
-
>
|
|
48
|
-
{{ awaitingApprovalCount }}
|
|
49
|
-
</dd>
|
|
50
|
-
</div>
|
|
51
|
-
<div :class="statCell">
|
|
52
|
-
<dt class="text-sm text-muted truncate">
|
|
53
|
-
{{ t('account.dashboard.stats.spend30') }}
|
|
54
|
-
</dt>
|
|
55
|
-
<dd class="mt-1 text-2xl font-semibold text-highlighted tabular-nums">
|
|
56
|
-
{{ formatCurrency(spend30) }}
|
|
57
|
-
</dd>
|
|
58
|
-
</div>
|
|
59
|
-
<div :class="statCell">
|
|
95
|
+
<div
|
|
96
|
+
v-for="cell in cells"
|
|
97
|
+
:key="cell.id"
|
|
98
|
+
:class="statCell"
|
|
99
|
+
>
|
|
60
100
|
<dt class="text-sm text-muted truncate">
|
|
61
|
-
{{ t(
|
|
101
|
+
{{ t(cell.labelKey) }}
|
|
62
102
|
</dt>
|
|
63
103
|
<dd
|
|
64
104
|
class="mt-1 text-2xl font-semibold tabular-nums"
|
|
65
|
-
:class="
|
|
105
|
+
:class="cell.isWarning ? 'text-warning' : 'text-highlighted'"
|
|
66
106
|
>
|
|
67
|
-
{{
|
|
107
|
+
{{ cell.value }}
|
|
68
108
|
</dd>
|
|
69
109
|
</div>
|
|
70
110
|
</dl>
|