@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
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/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,6 +31,8 @@ const props = defineProps<{
|
|
|
31
31
|
context?: Record<string, unknown>;
|
|
32
32
|
}>();
|
|
33
33
|
|
|
34
|
+
const themeEvents = useThemeEvents();
|
|
35
|
+
|
|
34
36
|
const { icon } = useIcons();
|
|
35
37
|
const { locale, t } = useI18n();
|
|
36
38
|
const route = useRoute();
|
|
@@ -208,6 +210,8 @@ async function onSubmit(values: Record<string, unknown>) {
|
|
|
208
210
|
}
|
|
209
211
|
successMessage.value = res.success_message || t("forms.success");
|
|
210
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" } });
|
|
211
215
|
}
|
|
212
216
|
catch {
|
|
213
217
|
submitError.value = t("forms.error");
|
|
@@ -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();
|
|
@@ -15,10 +15,12 @@ const { to } = useAppUrl();
|
|
|
15
15
|
const toast = useToast();
|
|
16
16
|
const cart = useCartStore();
|
|
17
17
|
const { settings } = useB2BContext();
|
|
18
|
+
const { isPunchout } = usePunchoutVisit();
|
|
18
19
|
const { formatCurrency } = useCartSummaryFormatting();
|
|
19
20
|
const { tableUi } = useDataTable();
|
|
20
21
|
|
|
21
|
-
|
|
22
|
+
// A punchout visit has exactly one cart, the one handed back (RAD-109).
|
|
23
|
+
const enabled = computed(() => settings.value?.cart.multipleCarts === true && !isPunchout.value);
|
|
22
24
|
|
|
23
25
|
/* ---- search ----------------------------------------------------------- */
|
|
24
26
|
const search = ref("");
|
|
@@ -113,7 +115,7 @@ function onDelete(): void {
|
|
|
113
115
|
color="neutral"
|
|
114
116
|
variant="subtle"
|
|
115
117
|
:icon="icon('info')"
|
|
116
|
-
:title="t('cart.multi.page.disabled')"
|
|
118
|
+
:title="isPunchout ? t('cart.multi.page.punchout') : t('cart.multi.page.disabled')"
|
|
117
119
|
/>
|
|
118
120
|
|
|
119
121
|
<template v-else>
|
|
@@ -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>
|
|
@@ -1,19 +1,37 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* Dashboard widget: quick-access links into the most-used account areas.
|
|
4
|
+
* `ids` is the authored selection (a block option), in its own order; omitted
|
|
5
|
+
* it shows the dashboard default. Either way the list is limited to what the
|
|
6
|
+
* account navigation in effect links — see `useQuickActions`.
|
|
7
|
+
*/
|
|
8
|
+
import { DASHBOARD_QUICK_ACTION_IDS } from "../../../config/quickActions";
|
|
9
|
+
|
|
10
|
+
const props = defineProps<{
|
|
11
|
+
/** Quick-action ids to show, in this order; omitted → the dashboard default. */
|
|
12
|
+
ids?: readonly string[];
|
|
13
|
+
}>();
|
|
14
|
+
|
|
3
15
|
const { icon } = useIcons();
|
|
4
16
|
const localePath = useLocalePath();
|
|
5
|
-
const { t
|
|
17
|
+
const { t } = useI18n();
|
|
18
|
+
const { resolveAllowed } = useQuickActions();
|
|
19
|
+
|
|
20
|
+
const actions = computed(() => resolveAllowed(props.ids ?? DASHBOARD_QUICK_ACTION_IDS));
|
|
6
21
|
</script>
|
|
7
22
|
|
|
8
23
|
<template>
|
|
9
|
-
<section
|
|
24
|
+
<section
|
|
25
|
+
v-if="actions.length"
|
|
26
|
+
class="border border-(--ui-border) rounded-xl overflow-hidden"
|
|
27
|
+
>
|
|
10
28
|
<h2 class="px-4 sm:px-5 py-3 text-sm font-semibold text-highlighted bg-elevated/60 border-b border-(--ui-border)">
|
|
11
29
|
{{ t('account.dashboard.quickAccess') }}
|
|
12
30
|
</h2>
|
|
13
31
|
<ul class="divide-y divide-(--ui-border)">
|
|
14
32
|
<li
|
|
15
|
-
v-for="action in
|
|
16
|
-
:key="action.
|
|
33
|
+
v-for="action in actions"
|
|
34
|
+
:key="action.id"
|
|
17
35
|
>
|
|
18
36
|
<NuxtLink
|
|
19
37
|
:to="localePath(action.to)"
|
|
@@ -21,7 +39,7 @@ const { t, quickActions } = useAccountDashboard();
|
|
|
21
39
|
hover:bg-elevated/40 transition-colors"
|
|
22
40
|
>
|
|
23
41
|
<UIcon
|
|
24
|
-
:name="icon(action.
|
|
42
|
+
:name="icon(action.icon)"
|
|
25
43
|
class="size-4.5 text-primary shrink-0"
|
|
26
44
|
/>
|
|
27
45
|
<span class="truncate">{{ t(action.labelKey) }}</span>
|
|
@@ -14,6 +14,8 @@ const { organization, status, error, updateOrganization } = useAccountOrganizati
|
|
|
14
14
|
// Company data another system owns is shown, never changed here (the BFF
|
|
15
15
|
// refuses the write as well — see account.organization.editable).
|
|
16
16
|
const editable = useMasterDataEditable("organization");
|
|
17
|
+
// Locked by the buyer's own role rather than by the merchant — said as such.
|
|
18
|
+
const roleLocked = useRoleGrants().lockedByRole("organization.manage");
|
|
17
19
|
|
|
18
20
|
const editing = ref(false);
|
|
19
21
|
const saving = ref(false);
|
|
@@ -92,7 +94,7 @@ async function save(): Promise<void> {
|
|
|
92
94
|
color="info"
|
|
93
95
|
variant="soft"
|
|
94
96
|
:icon="icon('info')"
|
|
95
|
-
:description="t('organization.locked')"
|
|
97
|
+
:description="roleLocked ? t('organization.lockedRole') : t('organization.locked')"
|
|
96
98
|
/>
|
|
97
99
|
<dl class="p-4 sm:p-5 grid grid-cols-1 sm:grid-cols-2 gap-x-6 gap-y-4">
|
|
98
100
|
<div>
|
|
@@ -17,6 +17,31 @@ const { members, status, error, inviteMember, updateMemberRole } = useAccountTea
|
|
|
17
17
|
// Contacts another system owns are listed, never invited or changed here
|
|
18
18
|
// (the BFF refuses the write as well — see account.team.editable).
|
|
19
19
|
const editable = useMasterDataEditable("team");
|
|
20
|
+
// A buyer whose role does not run the company's people is told so, rather than
|
|
21
|
+
// told the merchant maintains them; and nobody is offered a role above their
|
|
22
|
+
// own, their own role, or the role of somebody who outranks them (RAD-155).
|
|
23
|
+
const { lockedByRole, mayGrant, isSelf, outranks } = useRoleGrants();
|
|
24
|
+
const roleLocked = lockedByRole("contacts.manage");
|
|
25
|
+
const canEditMember = (member: AccountTeamMember): boolean =>
|
|
26
|
+
!isSelf(member.id) && !outranks(member.role);
|
|
27
|
+
|
|
28
|
+
/** The sentence for a refused save — the page's own words, keyed by the BFF's reason. */
|
|
29
|
+
function saveErrorTitle(err: unknown): string {
|
|
30
|
+
const failure = err as { statusCode?: number; data?: { data?: { type?: string } } };
|
|
31
|
+
const type = failure?.data?.data?.type;
|
|
32
|
+
if (failure?.statusCode === 404) {
|
|
33
|
+
return t("team.refused.notFound");
|
|
34
|
+
}
|
|
35
|
+
switch (type) {
|
|
36
|
+
case "role_above_own": return t("team.refused.roleAboveOwn");
|
|
37
|
+
case "own_role": return t("team.refused.ownRole");
|
|
38
|
+
case "permission_missing": return t("team.lockedRole");
|
|
39
|
+
case "field_merchant_owned":
|
|
40
|
+
case "not_self_service":
|
|
41
|
+
case "master_data_merchant_owned": return t("team.locked");
|
|
42
|
+
default: return t("team.saveError");
|
|
43
|
+
}
|
|
44
|
+
}
|
|
20
45
|
const { tableUi } = useDataTable();
|
|
21
46
|
|
|
22
47
|
const ROLES: AccountTeamRole[] = ["buyer", "approver", "admin", "requester"];
|
|
@@ -35,7 +60,7 @@ const statusColors: Record<AccountTeamStatus, "success" | "warning" | "error"> =
|
|
|
35
60
|
};
|
|
36
61
|
|
|
37
62
|
const roleItems = computed(() =>
|
|
38
|
-
ROLES.map(value => ({ value, label: t(`team.roles.${value}`) })),
|
|
63
|
+
ROLES.filter(value => mayGrant(value)).map(value => ({ value, label: t(`team.roles.${value}`) })),
|
|
39
64
|
);
|
|
40
65
|
|
|
41
66
|
/* ---- search ------------------------------------------------------------ */
|
|
@@ -95,8 +120,8 @@ async function saveInvite(): Promise<void> {
|
|
|
95
120
|
inviting.value = false;
|
|
96
121
|
toast.add({ title: t("team.saved"), color: "success", icon: icon("success"), duration: 2000 });
|
|
97
122
|
}
|
|
98
|
-
catch {
|
|
99
|
-
toast.add({ title:
|
|
123
|
+
catch (err) {
|
|
124
|
+
toast.add({ title: saveErrorTitle(err), color: "error", icon: icon("error"), duration: 3000 });
|
|
100
125
|
}
|
|
101
126
|
finally {
|
|
102
127
|
savingInvite.value = false;
|
|
@@ -125,8 +150,8 @@ async function saveEdit(): Promise<void> {
|
|
|
125
150
|
editing.value = false;
|
|
126
151
|
toast.add({ title: t("team.saved"), color: "success", icon: icon("success"), duration: 2000 });
|
|
127
152
|
}
|
|
128
|
-
catch {
|
|
129
|
-
toast.add({ title:
|
|
153
|
+
catch (err) {
|
|
154
|
+
toast.add({ title: saveErrorTitle(err), color: "error", icon: icon("error"), duration: 3000 });
|
|
130
155
|
}
|
|
131
156
|
finally {
|
|
132
157
|
savingEdit.value = false;
|
|
@@ -149,7 +174,7 @@ async function saveEdit(): Promise<void> {
|
|
|
149
174
|
color="info"
|
|
150
175
|
variant="soft"
|
|
151
176
|
:icon="icon('info')"
|
|
152
|
-
:description="t('team.locked')"
|
|
177
|
+
:description="roleLocked ? t('team.lockedRole') : t('team.locked')"
|
|
153
178
|
/>
|
|
154
179
|
<UiTableToolbar
|
|
155
180
|
v-model:search="search"
|
|
@@ -218,7 +243,7 @@ async function saveEdit(): Promise<void> {
|
|
|
218
243
|
</template>
|
|
219
244
|
<template #actions-cell="{ row }">
|
|
220
245
|
<div
|
|
221
|
-
v-if="editable"
|
|
246
|
+
v-if="editable && canEditMember(row.original)"
|
|
222
247
|
class="flex items-center justify-end gap-1"
|
|
223
248
|
>
|
|
224
249
|
<UTooltip :text="t('team.editTitle')">
|
|
@@ -32,7 +32,7 @@ async function onSubmit(): Promise<void> {
|
|
|
32
32
|
</script>
|
|
33
33
|
|
|
34
34
|
<template>
|
|
35
|
-
<div class="
|
|
35
|
+
<div class="w-full bg-(--ui-bg) border border-(--ui-border) rounded-xl p-6 space-y-6">
|
|
36
36
|
<h2 class="text-xl font-semibold text-highlighted">
|
|
37
37
|
{{ t('auth.forgotPassword.title') }}
|
|
38
38
|
</h2>
|
|
@@ -40,18 +40,23 @@ async function onSubmit(): Promise<void> {
|
|
|
40
40
|
<FormKit
|
|
41
41
|
type="form"
|
|
42
42
|
:actions="false"
|
|
43
|
-
class="space-y-4
|
|
43
|
+
class="space-y-4"
|
|
44
44
|
@submit="onSubmit"
|
|
45
45
|
>
|
|
46
46
|
<FormKit
|
|
47
47
|
v-model="state.email"
|
|
48
48
|
type="email"
|
|
49
|
-
:label="t('auth.forgotPassword.fields.email')"
|
|
50
49
|
name="email"
|
|
51
50
|
validation="required|email"
|
|
52
51
|
autocomplete="email"
|
|
52
|
+
input-class="h-8 py-1 bg-(--ui-bg)"
|
|
53
53
|
:placeholder="t('auth.forgotPassword.fields.emailPlaceholder')"
|
|
54
|
-
|
|
54
|
+
>
|
|
55
|
+
<template #label>
|
|
56
|
+
<span>{{ t('onepage.guest.email') }}</span>
|
|
57
|
+
<span class="text-error-500"> *</span>
|
|
58
|
+
</template>
|
|
59
|
+
</FormKit>
|
|
55
60
|
|
|
56
61
|
<UAlert
|
|
57
62
|
v-if="error"
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import type { LoginFormState } from "../../interfaces/auth";
|
|
3
|
+
import type { LoginIdentifierKind } from "../../interfaces/shopSettings";
|
|
4
|
+
import { loginIdentifierField, loginIdentifierKind, offeredLoginIdentifiers } from "../../interfaces/shopSettings";
|
|
3
5
|
|
|
4
6
|
/**
|
|
5
7
|
* "I already have an account" panel of the split login page. Owns the login
|
|
@@ -29,6 +31,17 @@ const magicLinkOffered = computed(() => signIn.value?.magicLink === true);
|
|
|
29
31
|
const otpOffered = computed(() => signIn.value?.emailOtp === true);
|
|
30
32
|
const anyMailedWay = computed(() => magicLinkOffered.value || otpOffered.value);
|
|
31
33
|
|
|
34
|
+
/**
|
|
35
|
+
* What the password field asks for (RAD-151): an address, a username, a
|
|
36
|
+
* customer number, or any mix the merchant switched on. Label, keyboard,
|
|
37
|
+
* autofill and validation follow it — a field that insists on an address would
|
|
38
|
+
* refuse a buyer the shop lets in by username before the shop ever saw it.
|
|
39
|
+
*/
|
|
40
|
+
const identifierField = computed(() => loginIdentifierField(signIn.value?.identifiers));
|
|
41
|
+
const identifierLabel = computed(() => t(`${identifierField.value.key}.label`));
|
|
42
|
+
/** Where it accepts only an address, the mailed ways share that one field. */
|
|
43
|
+
const identifierIsEmail = computed(() => identifierField.value.type === "email");
|
|
44
|
+
|
|
32
45
|
/* ---- signing in by mail ------------------------------------------------ */
|
|
33
46
|
|
|
34
47
|
/** Which mailed way the buyer is in the middle of, and how far. */
|
|
@@ -38,13 +51,21 @@ const mailSent = ref(false);
|
|
|
38
51
|
const otpUserId = ref<string | null>(null);
|
|
39
52
|
const otpCode = ref("");
|
|
40
53
|
|
|
54
|
+
/**
|
|
55
|
+
* The address a link or code goes to. The mailed ways only ever take an
|
|
56
|
+
* address, so where the sign-in field accepts a username too, they get a field
|
|
57
|
+
* of their own rather than mailing whatever was typed.
|
|
58
|
+
*/
|
|
59
|
+
const mailAddress = computed(() => (passwordOffered.value && identifierIsEmail.value ? state.identifier : state.email).trim());
|
|
60
|
+
const mailNeedsOwnField = computed(() => !passwordOffered.value || !identifierIsEmail.value);
|
|
61
|
+
|
|
41
62
|
async function requestMail(kind: "magic-link" | "otp"): Promise<void> {
|
|
42
|
-
if (!
|
|
63
|
+
if (!mailAddress.value) {
|
|
43
64
|
return;
|
|
44
65
|
}
|
|
45
66
|
mailedKind.value = kind;
|
|
46
67
|
try {
|
|
47
|
-
otpUserId.value = await auth.requestSignInMail(kind,
|
|
68
|
+
otpUserId.value = await auth.requestSignInMail(kind, mailAddress.value);
|
|
48
69
|
mailSent.value = true;
|
|
49
70
|
}
|
|
50
71
|
catch {
|
|
@@ -77,14 +98,41 @@ function startOver(): void {
|
|
|
77
98
|
}
|
|
78
99
|
|
|
79
100
|
const state = reactive<LoginFormState>({
|
|
80
|
-
|
|
101
|
+
identifier: "",
|
|
81
102
|
password: "",
|
|
103
|
+
email: "",
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
/** The kind of identifier last submitted — what a refusal is worded for. */
|
|
107
|
+
const submittedKind = ref<LoginIdentifierKind>("email");
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* The refusal, in the words of what was typed. Wrong credentials name the
|
|
111
|
+
* identifier the buyer used; a customer number adds that it signs in as the
|
|
112
|
+
* company's primary contact, which is why a buyer's own password does not
|
|
113
|
+
* open it. An identifier the shop does not take says which ones it does.
|
|
114
|
+
*/
|
|
115
|
+
const errorMessage = computed(() => {
|
|
116
|
+
if (!error.value) {
|
|
117
|
+
return "";
|
|
118
|
+
}
|
|
119
|
+
if (error.value === "auth.login.errors.invalidCredentials") {
|
|
120
|
+
return t(`auth.login.errors.invalidCredentialsBy.${submittedKind.value}`);
|
|
121
|
+
}
|
|
122
|
+
if (error.value === "auth.login.errors.identifierNotOffered") {
|
|
123
|
+
return t(error.value, { accepted: identifierLabel.value });
|
|
124
|
+
}
|
|
125
|
+
return t(error.value);
|
|
82
126
|
});
|
|
83
127
|
|
|
84
128
|
async function onSubmit(): Promise<void> {
|
|
129
|
+
const identifier = state.identifier.trim();
|
|
130
|
+
// One accepted kind is what was meant, whatever it looks like.
|
|
131
|
+
const offered = offeredLoginIdentifiers(signIn.value?.identifiers);
|
|
132
|
+
submittedKind.value = offered.length === 1 ? offered[0]! : loginIdentifierKind(identifier);
|
|
85
133
|
try {
|
|
86
134
|
await auth.login({
|
|
87
|
-
|
|
135
|
+
identifier,
|
|
88
136
|
password: state.password,
|
|
89
137
|
});
|
|
90
138
|
emit("success");
|
|
@@ -96,7 +144,7 @@ async function onSubmit(): Promise<void> {
|
|
|
96
144
|
</script>
|
|
97
145
|
|
|
98
146
|
<template>
|
|
99
|
-
<div class="bg-
|
|
147
|
+
<div class="bg-(--ui-bg) border border-(--ui-border) rounded-xl p-6 space-y-6">
|
|
100
148
|
<h2 class="text-xl font-semibold text-highlighted">
|
|
101
149
|
{{ t('auth.login.existingCustomer') }}
|
|
102
150
|
</h2>
|
|
@@ -123,7 +171,7 @@ async function onSubmit(): Promise<void> {
|
|
|
123
171
|
{{ t(passwordOffered ? 'auth.login.mailed.alternative' : 'auth.login.mailed.only') }}
|
|
124
172
|
</p>
|
|
125
173
|
<UInput
|
|
126
|
-
v-if="
|
|
174
|
+
v-if="mailNeedsOwnField"
|
|
127
175
|
v-model="state.email"
|
|
128
176
|
type="email"
|
|
129
177
|
class="w-full"
|
|
@@ -135,7 +183,7 @@ async function onSubmit(): Promise<void> {
|
|
|
135
183
|
v-if="magicLinkOffered"
|
|
136
184
|
color="neutral"
|
|
137
185
|
:variant="passwordOffered ? 'outline' : 'solid'"
|
|
138
|
-
:disabled="!
|
|
186
|
+
:disabled="!mailAddress || loading"
|
|
139
187
|
:label="t('auth.login.mailed.requestLink')"
|
|
140
188
|
@click="requestMail('magic-link')"
|
|
141
189
|
/>
|
|
@@ -143,7 +191,7 @@ async function onSubmit(): Promise<void> {
|
|
|
143
191
|
v-if="otpOffered"
|
|
144
192
|
color="neutral"
|
|
145
193
|
:variant="passwordOffered ? 'outline' : 'solid'"
|
|
146
|
-
:disabled="!
|
|
194
|
+
:disabled="!mailAddress || loading"
|
|
147
195
|
:label="t('auth.login.mailed.requestCode')"
|
|
148
196
|
@click="requestMail('otp')"
|
|
149
197
|
/>
|
|
@@ -155,7 +203,7 @@ async function onSubmit(): Promise<void> {
|
|
|
155
203
|
color="success"
|
|
156
204
|
variant="soft"
|
|
157
205
|
:title="t('auth.login.mailed.sentTitle')"
|
|
158
|
-
:description="t(mailedKind === 'otp' ? 'auth.login.mailed.sentCode' : 'auth.login.mailed.sentLink', { email:
|
|
206
|
+
:description="t(mailedKind === 'otp' ? 'auth.login.mailed.sentCode' : 'auth.login.mailed.sentLink', { email: mailAddress })"
|
|
159
207
|
/>
|
|
160
208
|
<!-- The code is typed back here; a link is followed instead. -->
|
|
161
209
|
<div
|
|
@@ -190,17 +238,25 @@ async function onSubmit(): Promise<void> {
|
|
|
190
238
|
v-if="passwordOffered"
|
|
191
239
|
type="form"
|
|
192
240
|
:actions="false"
|
|
193
|
-
class="space-y-4
|
|
241
|
+
class="space-y-4"
|
|
194
242
|
@submit="onSubmit"
|
|
195
243
|
>
|
|
244
|
+
<!-- Keyed on the type: FormKit fixes an input's type when it mounts. -->
|
|
196
245
|
<FormKit
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
:
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
:
|
|
246
|
+
:key="identifierField.type"
|
|
247
|
+
v-model="state.identifier"
|
|
248
|
+
:type="identifierField.type"
|
|
249
|
+
:label="identifierLabel"
|
|
250
|
+
name="identifier"
|
|
251
|
+
:validation="identifierField.validation"
|
|
252
|
+
:validation-label="identifierLabel"
|
|
253
|
+
:autocomplete="identifierField.autocomplete"
|
|
254
|
+
:inputmode="identifierField.inputmode"
|
|
255
|
+
autocapitalize="none"
|
|
256
|
+
spellcheck="false"
|
|
257
|
+
:help="identifierField.customerNumber ? t('auth.login.identifierHelp.customerNumber') : undefined"
|
|
258
|
+
input-class="h-8 py-1 bg-(--ui-bg)"
|
|
259
|
+
:placeholder="t(`${identifierField.key}.placeholder`)"
|
|
204
260
|
/>
|
|
205
261
|
|
|
206
262
|
<FormKit
|
|
@@ -210,6 +266,7 @@ async function onSubmit(): Promise<void> {
|
|
|
210
266
|
name="password"
|
|
211
267
|
validation="required|length:8"
|
|
212
268
|
autocomplete="current-password"
|
|
269
|
+
input-class="h-8 py-1 bg-(--ui-bg)"
|
|
213
270
|
:placeholder="t('auth.login.fields.passwordPlaceholder')"
|
|
214
271
|
/>
|
|
215
272
|
|
|
@@ -217,7 +274,7 @@ async function onSubmit(): Promise<void> {
|
|
|
217
274
|
v-if="error"
|
|
218
275
|
color="error"
|
|
219
276
|
variant="soft"
|
|
220
|
-
:title="
|
|
277
|
+
:title="errorMessage"
|
|
221
278
|
/>
|
|
222
279
|
|
|
223
280
|
<UButton
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import type { OrderList, OrderListKind, OrderListPosition } from "../../../interfaces/account/order-lists";
|
|
3
|
+
import { cartEcommerce } from "../../../shared/themeEvents";
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Saves positions to a shopping or label list (account order lists BFF).
|
|
@@ -16,6 +17,7 @@ const { t } = useI18n();
|
|
|
16
17
|
const toast = useToast();
|
|
17
18
|
const cart = useCartStore();
|
|
18
19
|
const authStore = useAuthStore();
|
|
20
|
+
const themeEvents = useThemeEvents();
|
|
19
21
|
|
|
20
22
|
type Mode = "existing" | "new";
|
|
21
23
|
|
|
@@ -98,6 +100,9 @@ async function save(): Promise<void> {
|
|
|
98
100
|
body: { name, kind: kind.value, public: false, positions },
|
|
99
101
|
});
|
|
100
102
|
}
|
|
103
|
+
if (positions.length) {
|
|
104
|
+
themeEvents.emit("add_to_orderlist", { ecommerce: cartEcommerce(positions) });
|
|
105
|
+
}
|
|
101
106
|
toast.add({
|
|
102
107
|
title: t("cart.saveToList.success", positions.length, { count: positions.length, list: name }),
|
|
103
108
|
color: "success",
|