@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
|
@@ -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>
|
|
@@ -26,7 +26,9 @@ const { data: list, status, error, refresh } = useFetch<OrderList>(
|
|
|
26
26
|
// Two different permissions, because the orderlists app grants two. What is ON
|
|
27
27
|
// a shared list is the company's to change where the merchant allows it; the
|
|
28
28
|
// list itself — its name, its sharing, its existence — stays with its owner.
|
|
29
|
-
const { canEditPositions, canManage, maxPositions, cartMergeMode } = useOrderListRules();
|
|
29
|
+
const { canEditPositions, canManage, maxPositions, cartMergeMode, onMissingArticle } = useOrderListRules();
|
|
30
|
+
/** Positions the shop no longer carries — the buyer maintaining the list needs them named. */
|
|
31
|
+
const discontinued = computed(() => (list.value?.positions ?? []).filter(p => p.available === false));
|
|
30
32
|
const isOwner = computed(() => !!list.value && canManage(list.value));
|
|
31
33
|
const mayEditPositions = computed(() => !!list.value && canEditPositions(list.value));
|
|
32
34
|
const positionsFull = computed(() =>
|
|
@@ -116,8 +118,25 @@ async function addToCart(): Promise<void> {
|
|
|
116
118
|
if (cartMergeMode.value === "replace") {
|
|
117
119
|
cart.clearCart();
|
|
118
120
|
}
|
|
121
|
+
// A part the shop no longer carries. What becomes of it is the merchant's
|
|
122
|
+
// answer, not this shop's: take it anyway (and let the cart object), leave it
|
|
123
|
+
// out, or refuse the whole list. Told before anything moves, because a buyer
|
|
124
|
+
// who finds out afterwards has a cart they did not assemble.
|
|
125
|
+
const missing = list.value.positions.filter(p => p.available === false);
|
|
126
|
+
if (missing.length > 0 && onMissingArticle.value === "fail") {
|
|
127
|
+
toast.add({
|
|
128
|
+
title: t("orderLists.missing.blocked", { count: missing.length }),
|
|
129
|
+
color: "error",
|
|
130
|
+
icon: icon("error"),
|
|
131
|
+
});
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
const takeable = onMissingArticle.value === "skip"
|
|
135
|
+
? list.value.positions.filter(p => p.available !== false)
|
|
136
|
+
: list.value.positions;
|
|
137
|
+
|
|
119
138
|
let added = 0;
|
|
120
|
-
for (const position of
|
|
139
|
+
for (const position of takeable) {
|
|
121
140
|
const ok = cart.addItem({
|
|
122
141
|
id: position.id,
|
|
123
142
|
name: position.name,
|
|
@@ -143,10 +162,12 @@ async function addToCart(): Promise<void> {
|
|
|
143
162
|
}
|
|
144
163
|
}
|
|
145
164
|
toast.add({
|
|
146
|
-
title:
|
|
165
|
+
title: missing.length > 0 && onMissingArticle.value === "skip"
|
|
166
|
+
? t("orderLists.missing.skipped", { count: added, skipped: missing.length })
|
|
167
|
+
: t("orderLists.addedToCart", { count: added }),
|
|
147
168
|
color: "success",
|
|
148
169
|
icon: icon("success"),
|
|
149
|
-
duration:
|
|
170
|
+
duration: 2500,
|
|
150
171
|
});
|
|
151
172
|
await navigateTo(to("/cart"));
|
|
152
173
|
}
|
|
@@ -232,6 +253,16 @@ async function addToCart(): Promise<void> {
|
|
|
232
253
|
</div>
|
|
233
254
|
|
|
234
255
|
<!-- Positions -->
|
|
256
|
+
<UAlert
|
|
257
|
+
v-if="discontinued.length"
|
|
258
|
+
color="warning"
|
|
259
|
+
variant="subtle"
|
|
260
|
+
:icon="icon('warning')"
|
|
261
|
+
:description="onMissingArticle === 'fail'
|
|
262
|
+
? t('orderLists.missing.blocked', { count: discontinued.length })
|
|
263
|
+
: t('orderLists.missing.gone') + ': ' + discontinued.map(p => p.name).join(', ')"
|
|
264
|
+
/>
|
|
265
|
+
|
|
235
266
|
<section class="border border-(--ui-border) rounded-xl overflow-hidden">
|
|
236
267
|
<h2 class="px-4 sm:px-5 py-3 text-sm font-semibold text-highlighted bg-elevated/60 border-b border-(--ui-border)">
|
|
237
268
|
{{ t('orderLists.columns.positions') }} ({{ list.positions.length }})
|
|
@@ -241,6 +272,7 @@ async function addToCart(): Promise<void> {
|
|
|
241
272
|
v-for="(position, index) in list.positions"
|
|
242
273
|
:key="`${list.id}-${index}`"
|
|
243
274
|
class="flex items-center gap-3 py-3"
|
|
275
|
+
:class="position.available === false ? 'opacity-60' : ''"
|
|
244
276
|
>
|
|
245
277
|
<span
|
|
246
278
|
class="w-14 h-14 shrink-0 flex items-center justify-center rounded-lg
|
|
@@ -255,6 +287,17 @@ async function addToCart(): Promise<void> {
|
|
|
255
287
|
<p class="text-sm font-medium text-highlighted truncate">
|
|
256
288
|
{{ position.name }}
|
|
257
289
|
</p>
|
|
290
|
+
<!-- A part the shop no longer carries. Said on the list rather
|
|
291
|
+
than only when it reaches the cart: by then it is too late
|
|
292
|
+
to fix the list, and the buyer keeping it is the one who can. -->
|
|
293
|
+
<UBadge
|
|
294
|
+
v-if="position.available === false"
|
|
295
|
+
size="sm"
|
|
296
|
+
color="warning"
|
|
297
|
+
variant="subtle"
|
|
298
|
+
class="my-0.5"
|
|
299
|
+
:label="t('orderLists.missing.gone')"
|
|
300
|
+
/>
|
|
258
301
|
<p class="text-xs text-muted">
|
|
259
302
|
{{ position.sku }}
|
|
260
303
|
<template v-if="position.customSku">
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { accountApi } from "../../../api/account";
|
|
3
|
-
import type { AccountOrder, AccountOrderStatus, AccountOrderPaymentStatus } from "../../../interfaces/account/order-list";
|
|
3
|
+
import type { AccountOrder, AccountOrderMessage, AccountOrderStatus, AccountOrderPaymentStatus } from "../../../interfaces/account/order-list";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Detail page content of one order (account pattern: detail = own page):
|
|
7
7
|
* head facts, fulfillment progress with carrier tracking, positions and
|
|
8
8
|
* the delivery/billing/payment block — everything a buyer needs to answer
|
|
9
9
|
* "where is my order?" without contacting support.
|
|
10
|
+
*
|
|
11
|
+
* And the two things they previously had to telephone about: calling the order off
|
|
12
|
+
* while nothing has shipped, and saying something about it. The orders app has
|
|
13
|
+
* taken both all along — a comment thread with a customer-visible half, and a
|
|
14
|
+
* cancellation it refuses once goods are with a carrier.
|
|
10
15
|
*/
|
|
11
16
|
const props = defineProps<{
|
|
12
17
|
orderId: string;
|
|
@@ -24,6 +29,79 @@ const { data: order, status, error, refresh } = useFetch<AccountOrder>(
|
|
|
24
29
|
{ key: `account-order:${props.orderId}` },
|
|
25
30
|
);
|
|
26
31
|
|
|
32
|
+
/* ---- talking about this order ------------------------------------------ */
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* What has been said, both ways.
|
|
36
|
+
*
|
|
37
|
+
* Only the customer-visible half reaches this: the desk keeps its own notes about
|
|
38
|
+
* a customer beside them and those are not part of a conversation with the buyer.
|
|
39
|
+
*/
|
|
40
|
+
const { data: messageData, refresh: refreshMessages } = useFetch<{ messages: AccountOrderMessage[] }>(
|
|
41
|
+
`/api/account/orders/${props.orderId}/messages`,
|
|
42
|
+
{ key: `account-order-messages:${props.orderId}`, default: () => ({ messages: [] }) },
|
|
43
|
+
);
|
|
44
|
+
const messages = computed(() => messageData.value?.messages ?? []);
|
|
45
|
+
|
|
46
|
+
const draft = ref("");
|
|
47
|
+
const sending = ref(false);
|
|
48
|
+
|
|
49
|
+
async function sendMessage(): Promise<void> {
|
|
50
|
+
const body = draft.value.trim();
|
|
51
|
+
if (!body) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
sending.value = true;
|
|
55
|
+
try {
|
|
56
|
+
await $fetch(`/api/account/orders/${props.orderId}/messages`, { method: "POST", body: { body } });
|
|
57
|
+
draft.value = "";
|
|
58
|
+
await refreshMessages();
|
|
59
|
+
}
|
|
60
|
+
catch (err) {
|
|
61
|
+
toast.add({
|
|
62
|
+
title: t("orders.messages.failed"),
|
|
63
|
+
description: (err as { data?: { message?: string } })?.data?.message,
|
|
64
|
+
color: "error",
|
|
65
|
+
icon: icon("error"),
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
finally {
|
|
69
|
+
sending.value = false;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/* ---- calling it off ---------------------------------------------------- */
|
|
74
|
+
|
|
75
|
+
const cancelOpen = ref(false);
|
|
76
|
+
const cancelReason = ref("");
|
|
77
|
+
const cancelling = ref(false);
|
|
78
|
+
|
|
79
|
+
async function submitCancel(): Promise<void> {
|
|
80
|
+
cancelling.value = true;
|
|
81
|
+
try {
|
|
82
|
+
await $fetch(`/api/account/orders/${props.orderId}/cancel`, {
|
|
83
|
+
method: "POST",
|
|
84
|
+
body: cancelReason.value.trim() ? { reason: cancelReason.value.trim() } : {},
|
|
85
|
+
});
|
|
86
|
+
cancelOpen.value = false;
|
|
87
|
+
await refresh();
|
|
88
|
+
toast.add({ title: t("orders.cancel.done"), color: "success", icon: icon("success") });
|
|
89
|
+
}
|
|
90
|
+
catch (err) {
|
|
91
|
+
// The merchant requiring a reason, or the order having moved on since the
|
|
92
|
+
// page was drawn. Both are the buyer's to read.
|
|
93
|
+
toast.add({
|
|
94
|
+
title: t("orders.cancel.failed"),
|
|
95
|
+
description: (err as { data?: { message?: string } })?.data?.message,
|
|
96
|
+
color: "error",
|
|
97
|
+
icon: icon("error"),
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
finally {
|
|
101
|
+
cancelling.value = false;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
27
105
|
const statusColors: Record<AccountOrderStatus, "info" | "warning" | "primary" | "success" | "error"> = {
|
|
28
106
|
"processing": "info",
|
|
29
107
|
"approval-pending": "warning",
|
|
@@ -512,6 +590,18 @@ async function submitReturn(): Promise<void> {
|
|
|
512
590
|
:label="t('orders.returns.requestReturn')"
|
|
513
591
|
@click="openReturn"
|
|
514
592
|
/>
|
|
593
|
+
<!-- Calling it off, while nothing has shipped. The orders app answers
|
|
594
|
+
that question and this button follows it rather than guessing:
|
|
595
|
+
one that produced an error would be worse than none. -->
|
|
596
|
+
<UButton
|
|
597
|
+
v-if="order.cancellable"
|
|
598
|
+
color="error"
|
|
599
|
+
variant="outline"
|
|
600
|
+
tabindex="0"
|
|
601
|
+
:icon="icon('close')"
|
|
602
|
+
:label="t('orders.cancel.action')"
|
|
603
|
+
@click="cancelOpen = true"
|
|
604
|
+
/>
|
|
515
605
|
<UButton
|
|
516
606
|
v-if="order.status !== 'cancelled'"
|
|
517
607
|
color="primary"
|
|
@@ -523,6 +613,101 @@ async function submitReturn(): Promise<void> {
|
|
|
523
613
|
/>
|
|
524
614
|
</div>
|
|
525
615
|
|
|
616
|
+
<!-- Saying something about this order. The desk's own notes about a
|
|
617
|
+
customer are not in here: a trail is a record of a conversation WITH
|
|
618
|
+
the buyer, and only the customer-visible half reaches this page. -->
|
|
619
|
+
<section class="border border-(--ui-border) rounded-xl overflow-hidden">
|
|
620
|
+
<h2 class="px-4 sm:px-5 py-3 text-sm font-semibold text-highlighted bg-elevated/60 border-b border-(--ui-border)">
|
|
621
|
+
{{ t('orders.messages.title') }}
|
|
622
|
+
</h2>
|
|
623
|
+
|
|
624
|
+
<ul
|
|
625
|
+
v-if="messages.length"
|
|
626
|
+
class="divide-y divide-(--ui-border)"
|
|
627
|
+
>
|
|
628
|
+
<li
|
|
629
|
+
v-for="message in messages"
|
|
630
|
+
:key="message.id"
|
|
631
|
+
class="px-4 sm:px-5 py-3"
|
|
632
|
+
>
|
|
633
|
+
<div class="flex items-baseline justify-between gap-3">
|
|
634
|
+
<span class="text-xs font-medium text-highlighted">
|
|
635
|
+
{{ message.fromBuyer ? t('orders.messages.you') : t('orders.messages.merchant') }}
|
|
636
|
+
</span>
|
|
637
|
+
<span class="text-xs text-muted">
|
|
638
|
+
{{ message.at ? d(new Date(message.at), { dateStyle: 'medium' }) : '' }}
|
|
639
|
+
</span>
|
|
640
|
+
</div>
|
|
641
|
+
<p class="text-sm text-default mt-1 whitespace-pre-line">
|
|
642
|
+
{{ message.body }}
|
|
643
|
+
</p>
|
|
644
|
+
</li>
|
|
645
|
+
</ul>
|
|
646
|
+
<p
|
|
647
|
+
v-else
|
|
648
|
+
class="px-4 sm:px-5 py-3 text-sm text-muted"
|
|
649
|
+
>
|
|
650
|
+
{{ t('orders.messages.empty') }}
|
|
651
|
+
</p>
|
|
652
|
+
|
|
653
|
+
<div class="px-4 sm:px-5 py-3 border-t border-(--ui-border) space-y-2">
|
|
654
|
+
<UTextarea
|
|
655
|
+
v-model="draft"
|
|
656
|
+
class="w-full"
|
|
657
|
+
:rows="2"
|
|
658
|
+
:placeholder="t('orders.messages.placeholder')"
|
|
659
|
+
/>
|
|
660
|
+
<UButton
|
|
661
|
+
size="sm"
|
|
662
|
+
color="primary"
|
|
663
|
+
:disabled="!draft.trim() || sending"
|
|
664
|
+
:loading="sending"
|
|
665
|
+
:label="t('orders.messages.send')"
|
|
666
|
+
@click="sendMessage"
|
|
667
|
+
/>
|
|
668
|
+
</div>
|
|
669
|
+
</section>
|
|
670
|
+
|
|
671
|
+
<!-- Cancel modal. The reason is asked for up front because the merchant
|
|
672
|
+
may require it, and a form that could have said so beats an error
|
|
673
|
+
that has to. -->
|
|
674
|
+
<UModal
|
|
675
|
+
v-model:open="cancelOpen"
|
|
676
|
+
:title="t('orders.cancel.title', { number: order.id })"
|
|
677
|
+
>
|
|
678
|
+
<template #body>
|
|
679
|
+
<div class="space-y-4">
|
|
680
|
+
<p class="text-sm text-default">
|
|
681
|
+
{{ t('orders.cancel.intro') }}
|
|
682
|
+
</p>
|
|
683
|
+
<UFormField :label="t('orders.cancel.reason')">
|
|
684
|
+
<UTextarea
|
|
685
|
+
v-model="cancelReason"
|
|
686
|
+
class="w-full"
|
|
687
|
+
:rows="2"
|
|
688
|
+
:placeholder="t('orders.cancel.reasonPlaceholder')"
|
|
689
|
+
/>
|
|
690
|
+
</UFormField>
|
|
691
|
+
</div>
|
|
692
|
+
</template>
|
|
693
|
+
<template #footer>
|
|
694
|
+
<div class="flex items-center justify-end gap-2 w-full">
|
|
695
|
+
<UButton
|
|
696
|
+
color="neutral"
|
|
697
|
+
variant="ghost"
|
|
698
|
+
:label="t('cart.item.cancel')"
|
|
699
|
+
@click="cancelOpen = false"
|
|
700
|
+
/>
|
|
701
|
+
<UButton
|
|
702
|
+
color="error"
|
|
703
|
+
:loading="cancelling"
|
|
704
|
+
:label="t('orders.cancel.confirm')"
|
|
705
|
+
@click="submitCancel"
|
|
706
|
+
/>
|
|
707
|
+
</div>
|
|
708
|
+
</template>
|
|
709
|
+
</UModal>
|
|
710
|
+
|
|
526
711
|
<!-- Request return modal -->
|
|
527
712
|
<UModal
|
|
528
713
|
v-model:open="returnOpen"
|
|
@@ -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>
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { TableColumn } from "@nuxt/ui";
|
|
3
|
+
|
|
4
|
+
import type { AccountPayment } from "../../../interfaces/account/payments";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* What the buyer owes and what they have settled.
|
|
8
|
+
*
|
|
9
|
+
* Overdue first, because that is the row somebody in their accounts department is
|
|
10
|
+
* asking them about. The outstanding total is stated per currency and never as one
|
|
11
|
+
* figure: a buyer trading in two has two answers, and adding them would produce a
|
|
12
|
+
* third that is true of nothing.
|
|
13
|
+
*/
|
|
14
|
+
const { t, d } = useI18n();
|
|
15
|
+
const { icon } = useIcons();
|
|
16
|
+
const { payments, outstanding, overdue, status } = useAccountPayments();
|
|
17
|
+
const { formatCurrency } = useCartSummaryFormatting();
|
|
18
|
+
|
|
19
|
+
const STATE_COLOR: Record<AccountPayment["state"], "success" | "warning" | "error" | "neutral" | "info"> = {
|
|
20
|
+
paid: "success",
|
|
21
|
+
partially_paid: "warning",
|
|
22
|
+
authorized: "info",
|
|
23
|
+
pending: "info",
|
|
24
|
+
open: "neutral",
|
|
25
|
+
refunded: "neutral",
|
|
26
|
+
failed: "error",
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/** Overdue first, then what is still open, then the settled ones by date. */
|
|
30
|
+
const rows = computed(() => [...payments.value].sort((a, b) => {
|
|
31
|
+
if (a.overdue !== b.overdue) {
|
|
32
|
+
return a.overdue ? -1 : 1;
|
|
33
|
+
}
|
|
34
|
+
const aSettled = a.state === "paid" || a.state === "refunded";
|
|
35
|
+
const bSettled = b.state === "paid" || b.state === "refunded";
|
|
36
|
+
if (aSettled !== bSettled) {
|
|
37
|
+
return aSettled ? 1 : -1;
|
|
38
|
+
}
|
|
39
|
+
return (b.dueAt ?? b.paidAt ?? "").localeCompare(a.dueAt ?? a.paidAt ?? "");
|
|
40
|
+
}));
|
|
41
|
+
|
|
42
|
+
const columns: TableColumn<AccountPayment>[] = [
|
|
43
|
+
{ accessorKey: "orderNumber", header: t("payments.columns.order") },
|
|
44
|
+
{ accessorKey: "amount", header: t("payments.columns.amount") },
|
|
45
|
+
{ accessorKey: "state", header: t("payments.columns.state") },
|
|
46
|
+
{ accessorKey: "dueAt", header: t("payments.columns.due") },
|
|
47
|
+
];
|
|
48
|
+
|
|
49
|
+
const date = (value: string | null) => (value ? d(new Date(value), { dateStyle: "medium" }) : "–");
|
|
50
|
+
</script>
|
|
51
|
+
|
|
52
|
+
<template>
|
|
53
|
+
<div class="space-y-6">
|
|
54
|
+
<div>
|
|
55
|
+
<h1 class="text-2xl font-semibold text-highlighted">
|
|
56
|
+
{{ t('payments.title') }}
|
|
57
|
+
</h1>
|
|
58
|
+
<p class="text-muted">
|
|
59
|
+
{{ t('payments.description') }}
|
|
60
|
+
</p>
|
|
61
|
+
</div>
|
|
62
|
+
|
|
63
|
+
<!-- What is still owed, per currency. A buyer trading in two has two
|
|
64
|
+
answers, and one figure across both would be true of neither. -->
|
|
65
|
+
<div
|
|
66
|
+
v-if="outstanding.length"
|
|
67
|
+
class="flex flex-wrap gap-3"
|
|
68
|
+
>
|
|
69
|
+
<div
|
|
70
|
+
v-for="sum in outstanding"
|
|
71
|
+
:key="sum.currency"
|
|
72
|
+
class="rounded-xl border border-(--ui-border) px-4 py-3"
|
|
73
|
+
>
|
|
74
|
+
<p class="text-xs text-muted">
|
|
75
|
+
{{ t('payments.outstanding') }}
|
|
76
|
+
</p>
|
|
77
|
+
<p class="text-lg font-semibold text-highlighted tabular-nums">
|
|
78
|
+
{{ sum.amount.toLocaleString(undefined, { style: 'currency', currency: sum.currency }) }}
|
|
79
|
+
</p>
|
|
80
|
+
</div>
|
|
81
|
+
</div>
|
|
82
|
+
|
|
83
|
+
<UAlert
|
|
84
|
+
v-if="overdue.length"
|
|
85
|
+
color="warning"
|
|
86
|
+
variant="subtle"
|
|
87
|
+
:icon="icon('warning')"
|
|
88
|
+
:title="t('payments.overdueTitle', { count: overdue.length })"
|
|
89
|
+
:description="t('payments.overdueDescription')"
|
|
90
|
+
/>
|
|
91
|
+
|
|
92
|
+
<UTable
|
|
93
|
+
:data="rows"
|
|
94
|
+
:columns="columns"
|
|
95
|
+
:loading="status === 'pending'"
|
|
96
|
+
>
|
|
97
|
+
<template #orderNumber-cell="{ row }">
|
|
98
|
+
<span class="text-sm font-medium text-highlighted">
|
|
99
|
+
{{ row.original.orderNumber ?? '–' }}
|
|
100
|
+
</span>
|
|
101
|
+
</template>
|
|
102
|
+
<template #amount-cell="{ row }">
|
|
103
|
+
<span class="text-sm tabular-nums">{{ formatCurrency(row.original.amount) }}</span>
|
|
104
|
+
</template>
|
|
105
|
+
<template #state-cell="{ row }">
|
|
106
|
+
<UBadge
|
|
107
|
+
size="sm"
|
|
108
|
+
variant="subtle"
|
|
109
|
+
:color="row.original.overdue ? 'error' : STATE_COLOR[row.original.state]"
|
|
110
|
+
:label="row.original.overdue
|
|
111
|
+
? t('payments.states.overdue')
|
|
112
|
+
: t(`payments.states.${row.original.state}`)"
|
|
113
|
+
/>
|
|
114
|
+
</template>
|
|
115
|
+
<template #dueAt-cell="{ row }">
|
|
116
|
+
<span class="text-sm text-muted">
|
|
117
|
+
{{ row.original.state === 'paid' ? date(row.original.paidAt) : date(row.original.dueAt) }}
|
|
118
|
+
</span>
|
|
119
|
+
</template>
|
|
120
|
+
<template #empty>
|
|
121
|
+
<UiFeedbackEmptyState
|
|
122
|
+
:icon="icon('payment')"
|
|
123
|
+
:title="t('payments.empty.title')"
|
|
124
|
+
:description="t('payments.empty.description')"
|
|
125
|
+
/>
|
|
126
|
+
</template>
|
|
127
|
+
</UTable>
|
|
128
|
+
</div>
|
|
129
|
+
</template>
|
|
@@ -91,25 +91,39 @@ const openLines = computed(() => quote.value?.lines.filter(line => line.decision
|
|
|
91
91
|
const selectable = computed(() =>
|
|
92
92
|
Boolean(quote.value?.partialAcceptance) && quote.value?.canOrder === true && openLines.value.length > 1,
|
|
93
93
|
);
|
|
94
|
-
|
|
94
|
+
/**
|
|
95
|
+
* What the buyer decided per open position: order it, refuse it, or leave it be.
|
|
96
|
+
*
|
|
97
|
+
* Three states and not a checkbox, because leaving a position open and refusing it
|
|
98
|
+
* are different answers with different consequences — one can be ordered next
|
|
99
|
+
* week, the other closes. The platform takes both through the same call.
|
|
100
|
+
*/
|
|
101
|
+
type LineChoice = "order" | "decline" | "open";
|
|
102
|
+
const choices = ref<Record<string, LineChoice>>({});
|
|
95
103
|
|
|
96
|
-
// Everything
|
|
97
|
-
// total of nothing and an order button that does nothing.
|
|
104
|
+
// Everything to order, until the buyer says otherwise. Starting on "open" would
|
|
105
|
+
// show a total of nothing and an order button that does nothing.
|
|
98
106
|
watch(openLines, (lines) => {
|
|
99
|
-
|
|
107
|
+
choices.value = Object.fromEntries(lines.map(line => [line.id, "order" as LineChoice]));
|
|
100
108
|
}, { immediate: true });
|
|
101
109
|
|
|
102
|
-
const
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
: [...selected.value, id];
|
|
110
|
+
const choiceOf = (id: string): LineChoice => choices.value[id] ?? "order";
|
|
111
|
+
const isSelected = (id: string) => choiceOf(id) === "order";
|
|
112
|
+
function setChoice(id: string, choice: LineChoice): void {
|
|
113
|
+
choices.value = { ...choices.value, [id]: choice };
|
|
107
114
|
}
|
|
108
115
|
|
|
116
|
+
const selected = computed(() => openLines.value.filter(line => choiceOf(line.id) === "order").map(line => line.id));
|
|
117
|
+
const refused = computed(() => openLines.value.filter(line => choiceOf(line.id) === "decline").map(line => line.id));
|
|
118
|
+
|
|
109
119
|
/** A partial pick: some of what is open, not all of it. */
|
|
110
120
|
const partialPick = computed(() =>
|
|
111
121
|
selectable.value && selected.value.length > 0 && selected.value.length < openLines.value.length,
|
|
112
122
|
);
|
|
123
|
+
/** Some positions refused, but not every open one — that would be a plain no. */
|
|
124
|
+
const partialRefusal = computed(() =>
|
|
125
|
+
selectable.value && refused.value.length > 0 && refused.value.length < openLines.value.length,
|
|
126
|
+
);
|
|
113
127
|
|
|
114
128
|
/** What the buyer is about to order — their pick, or the whole quote. */
|
|
115
129
|
const selectedTotal = computed(() => {
|
|
@@ -155,7 +169,12 @@ const declineReason = ref("");
|
|
|
155
169
|
|
|
156
170
|
async function submitDecline(): Promise<void> {
|
|
157
171
|
try {
|
|
158
|
-
|
|
172
|
+
// Only a real subset travels: refusing every open position is a refusal of
|
|
173
|
+
// the offer, and the whole-quote path says that more plainly.
|
|
174
|
+
await decline(
|
|
175
|
+
declineReason.value.trim() || undefined,
|
|
176
|
+
partialRefusal.value ? refused.value : undefined,
|
|
177
|
+
);
|
|
159
178
|
declineOpen.value = false;
|
|
160
179
|
toast.add({ title: t("quotes.decline.success"), color: "neutral", icon: icon("success") });
|
|
161
180
|
}
|
|
@@ -254,12 +273,23 @@ async function submitDecline(): Promise<void> {
|
|
|
254
273
|
class="px-4 sm:px-5 py-3 flex flex-wrap items-center gap-x-4 gap-y-1"
|
|
255
274
|
:class="selectable && line.decision === 'open' && !isSelected(line.id) ? 'opacity-55' : ''"
|
|
256
275
|
>
|
|
257
|
-
<
|
|
276
|
+
<div
|
|
258
277
|
v-if="selectable && line.decision === 'open'"
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
278
|
+
class="flex shrink-0 gap-1"
|
|
279
|
+
>
|
|
280
|
+
<UButton
|
|
281
|
+
v-for="option in (['order', 'decline', 'open'] as const)"
|
|
282
|
+
:key="option"
|
|
283
|
+
size="xs"
|
|
284
|
+
:color="choiceOf(line.id) === option ? (option === 'decline' ? 'error' : 'primary') : 'neutral'"
|
|
285
|
+
:variant="choiceOf(line.id) === option ? 'solid' : 'outline'"
|
|
286
|
+
tabindex="0"
|
|
287
|
+
:title="t(`quotes.detail.choice.${option}`)"
|
|
288
|
+
:aria-label="t(`quotes.detail.choice.${option}`) + ': ' + line.name"
|
|
289
|
+
:icon="icon(option === 'order' ? 'cart' : option === 'decline' ? 'close' : 'clock')"
|
|
290
|
+
@click="setChoice(line.id, option)"
|
|
291
|
+
/>
|
|
292
|
+
</div>
|
|
263
293
|
<div class="min-w-0 flex-1">
|
|
264
294
|
<p class="text-sm font-medium text-highlighted">
|
|
265
295
|
{{ line.name }}
|
|
@@ -393,7 +423,9 @@ async function submitDecline(): Promise<void> {
|
|
|
393
423
|
v-if="quote.canDecline"
|
|
394
424
|
color="neutral"
|
|
395
425
|
variant="outline"
|
|
396
|
-
:label="
|
|
426
|
+
:label="partialRefusal
|
|
427
|
+
? t('quotes.actions.declineSelected', { count: refused.length })
|
|
428
|
+
: t('quotes.actions.decline')"
|
|
397
429
|
@click="declineOpen = true"
|
|
398
430
|
/>
|
|
399
431
|
<UButton
|