@revenexx/cover 0.2.40 → 0.2.41
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 +6 -0
- package/app/app.config.ts +9 -0
- package/app/components/account/quotes/AccountQuoteDetail.vue +428 -0
- package/app/components/account/quotes/AccountQuotesTable.vue +157 -0
- package/app/components/cart/quote/CartQuoteRequestModal.vue +146 -0
- package/app/components/cart/view/CartView.vue +28 -1
- package/app/composables/useAccountQuotes.ts +75 -0
- package/app/config/navigation.ts +1 -1
- package/app/config/quickActions.ts +1 -0
- package/app/interfaces/account/quotes.ts +107 -0
- package/app/interfaces/cart-calculation.ts +6 -0
- package/i18n/locales/de/account.json +95 -0
- package/i18n/locales/de/cart.json +20 -0
- package/i18n/locales/en/account.json +95 -0
- package/i18n/locales/en/cart.json +20 -0
- package/package.json +1 -1
- package/server/api/account/quotes/[id]/decline.post.ts +39 -0
- package/server/api/account/quotes/[id]/order.post.ts +153 -0
- package/server/api/account/quotes/[id].get.ts +11 -0
- package/server/api/account/quotes.get.ts +26 -0
- package/server/api/quotes/request.post.ts +176 -0
- package/server/data/account/quotes.json +34 -0
- package/server/utils/quotesService.ts +274 -0
package/app/api/account.ts
CHANGED
|
@@ -9,4 +9,10 @@ export const accountApi = {
|
|
|
9
9
|
organization: () => "/api/account/organization",
|
|
10
10
|
team: () => "/api/account/team",
|
|
11
11
|
teamMemberUpdate: (id: string) => `/api/account/team/${id}`,
|
|
12
|
+
quotes: () => "/api/account/quotes",
|
|
13
|
+
quote: (id: string) => `/api/account/quotes/${id}`,
|
|
14
|
+
quoteOrder: (id: string) => `/api/account/quotes/${id}/order`,
|
|
15
|
+
quoteDecline: (id: string) => `/api/account/quotes/${id}/decline`,
|
|
16
|
+
/** Turn the active cart into a quotation request. */
|
|
17
|
+
quoteRequest: () => "/api/quotes/request",
|
|
12
18
|
};
|
package/app/app.config.ts
CHANGED
|
@@ -32,7 +32,16 @@ export default defineAppConfig({
|
|
|
32
32
|
// its own mockKey, so promotions worked, but a storefront reading this list
|
|
33
33
|
// to see what it may switch on could not find it.
|
|
34
34
|
promotionsService: "mock",
|
|
35
|
+
// The quotes app (RX-783): a cart the shop cannot order as it is becomes a
|
|
36
|
+
// quotation request, priced in the Cockpit and ordered from the account.
|
|
37
|
+
quotesService: "mock",
|
|
35
38
|
themeService: "mock",
|
|
39
|
+
// How an ordered quote is paid. A quote is a negotiated B2B price, so the
|
|
40
|
+
// order it becomes goes on account; a storefront that takes quotes on
|
|
41
|
+
// another method names its code here.
|
|
42
|
+
quotes: {
|
|
43
|
+
paymentMethod: "invoice",
|
|
44
|
+
},
|
|
36
45
|
// Where a live catalogue keeps a manufacturer's logo. This is a per-tenant
|
|
37
46
|
// PIM attribute on the product document, not a platform contract, so a
|
|
38
47
|
// storefront whose catalogue names it differently overrides the code here.
|
|
@@ -0,0 +1,428 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { AccountQuoteStatus } from "../../../interfaces/account/quotes";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* One quote, as its buyer reads it (RX-783): where it stands, what is on it,
|
|
6
|
+
* what the carriage came to, and the two answers — order it at the quoted
|
|
7
|
+
* figures, or decline it. Ordering places the order straight away with the
|
|
8
|
+
* addresses the carriage was priced for; there is no second checkout.
|
|
9
|
+
*/
|
|
10
|
+
const props = defineProps<{
|
|
11
|
+
quoteId: string;
|
|
12
|
+
}>();
|
|
13
|
+
|
|
14
|
+
const { icon } = useIcons();
|
|
15
|
+
const { t, d } = useI18n();
|
|
16
|
+
const localePath = useLocalePath();
|
|
17
|
+
const toast = useToast();
|
|
18
|
+
const { formatCurrency } = useCartSummaryFormatting();
|
|
19
|
+
const { quote, status, error, order, decline, ordering, declining } = useAccountQuote(props.quoteId);
|
|
20
|
+
|
|
21
|
+
const statusColors: Record<AccountQuoteStatus, "info" | "warning" | "primary" | "success" | "error" | "neutral"> = {
|
|
22
|
+
requested: "info",
|
|
23
|
+
in_review: "info",
|
|
24
|
+
quoted: "warning",
|
|
25
|
+
partially_accepted: "warning",
|
|
26
|
+
accepted: "success",
|
|
27
|
+
declined: "neutral",
|
|
28
|
+
rejected: "error",
|
|
29
|
+
expired: "neutral",
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const formatDate = (value: string | null | undefined) => {
|
|
33
|
+
if (!value) return "–";
|
|
34
|
+
const parsed = new Date(value);
|
|
35
|
+
return Number.isNaN(parsed.getTime()) ? value : d(parsed, { dateStyle: "medium" });
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const addressLines = (a: Record<string, unknown> | null | undefined): string[] => {
|
|
39
|
+
if (!a) return [];
|
|
40
|
+
return [
|
|
41
|
+
a.companyName,
|
|
42
|
+
a.contactName,
|
|
43
|
+
a.street,
|
|
44
|
+
`${a.postalCode ?? ""} ${a.city ?? ""}`.trim(),
|
|
45
|
+
a.country,
|
|
46
|
+
].map(v => String(v ?? "").trim()).filter(Boolean);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/** The sentence under the head: what the buyer is waiting for, or what is waiting on them. */
|
|
50
|
+
const stateHint = computed(() => {
|
|
51
|
+
const q = quote.value;
|
|
52
|
+
if (!q) return null;
|
|
53
|
+
if (q.canOrder) {
|
|
54
|
+
return { color: "success" as const, text: t("quotes.detail.hint.ready", { date: formatDate(q.validUntil) }) };
|
|
55
|
+
}
|
|
56
|
+
switch (q.status) {
|
|
57
|
+
case "requested":
|
|
58
|
+
case "in_review":
|
|
59
|
+
return { color: "info" as const, text: t("quotes.detail.hint.pending") };
|
|
60
|
+
case "expired":
|
|
61
|
+
return { color: "neutral" as const, text: t("quotes.detail.hint.expired") };
|
|
62
|
+
case "rejected":
|
|
63
|
+
return { color: "error" as const, text: t("quotes.detail.hint.rejected", { reason: q.reason ?? "" }) };
|
|
64
|
+
case "accepted":
|
|
65
|
+
return { color: "success" as const, text: t("quotes.detail.hint.ordered") };
|
|
66
|
+
default:
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
const seller = computed(() => quote.value?.trail.filter(e => e.actor === "seller" && e.body) ?? []);
|
|
72
|
+
|
|
73
|
+
/* ---- order ------------------------------------------------------------- */
|
|
74
|
+
const orderOpen = ref(false);
|
|
75
|
+
const customerOrderNumber = ref("");
|
|
76
|
+
const orderNote = ref("");
|
|
77
|
+
|
|
78
|
+
async function submitOrder(): Promise<void> {
|
|
79
|
+
try {
|
|
80
|
+
const result = await order({
|
|
81
|
+
...(customerOrderNumber.value.trim() ? { customerOrderNumber: customerOrderNumber.value.trim() } : {}),
|
|
82
|
+
...(orderNote.value.trim() ? { orderNote: orderNote.value.trim() } : {}),
|
|
83
|
+
});
|
|
84
|
+
orderOpen.value = false;
|
|
85
|
+
toast.add({
|
|
86
|
+
title: t("quotes.order.success", { number: result.orderNumber }),
|
|
87
|
+
color: "success",
|
|
88
|
+
icon: icon("success"),
|
|
89
|
+
});
|
|
90
|
+
await navigateTo(localePath(`/account/orders/${result.orderNumber}`));
|
|
91
|
+
}
|
|
92
|
+
catch (err) {
|
|
93
|
+
const message = (err as { data?: { message?: string } })?.data?.message;
|
|
94
|
+
toast.add({ title: t("quotes.order.failed"), description: message, color: "error", icon: icon("error") });
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/* ---- decline ------------------------------------------------------------ */
|
|
99
|
+
const declineOpen = ref(false);
|
|
100
|
+
const declineReason = ref("");
|
|
101
|
+
|
|
102
|
+
async function submitDecline(): Promise<void> {
|
|
103
|
+
try {
|
|
104
|
+
await decline(declineReason.value.trim() || undefined);
|
|
105
|
+
declineOpen.value = false;
|
|
106
|
+
toast.add({ title: t("quotes.decline.success"), color: "neutral", icon: icon("success") });
|
|
107
|
+
}
|
|
108
|
+
catch (err) {
|
|
109
|
+
const message = (err as { data?: { message?: string } })?.data?.message;
|
|
110
|
+
toast.add({ title: t("quotes.decline.failed"), description: message, color: "error", icon: icon("error") });
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
</script>
|
|
114
|
+
|
|
115
|
+
<template>
|
|
116
|
+
<div>
|
|
117
|
+
<USkeleton
|
|
118
|
+
v-if="status === 'pending'"
|
|
119
|
+
class="h-64 w-full rounded-xl"
|
|
120
|
+
/>
|
|
121
|
+
|
|
122
|
+
<UiFeedbackErrorBoundary
|
|
123
|
+
v-else-if="error || !quote"
|
|
124
|
+
:title="t('quotes.notFound')"
|
|
125
|
+
:show-retry="false"
|
|
126
|
+
/>
|
|
127
|
+
|
|
128
|
+
<div
|
|
129
|
+
v-else
|
|
130
|
+
class="space-y-6"
|
|
131
|
+
>
|
|
132
|
+
<!-- Head -->
|
|
133
|
+
<div
|
|
134
|
+
class="border border-(--ui-border) rounded-xl p-4 sm:p-5
|
|
135
|
+
flex flex-wrap items-center gap-x-8 gap-y-3"
|
|
136
|
+
>
|
|
137
|
+
<div>
|
|
138
|
+
<p class="text-xs text-muted">
|
|
139
|
+
{{ t('quotes.detail.requestedAt') }}
|
|
140
|
+
</p>
|
|
141
|
+
<p class="text-sm font-medium text-highlighted">
|
|
142
|
+
{{ formatDate(quote.createdAt) }}
|
|
143
|
+
</p>
|
|
144
|
+
</div>
|
|
145
|
+
<div v-if="quote.validUntil">
|
|
146
|
+
<p class="text-xs text-muted">
|
|
147
|
+
{{ t('quotes.detail.validUntil') }}
|
|
148
|
+
</p>
|
|
149
|
+
<p class="text-sm font-medium text-highlighted">
|
|
150
|
+
{{ formatDate(quote.validUntil) }}
|
|
151
|
+
</p>
|
|
152
|
+
</div>
|
|
153
|
+
<div>
|
|
154
|
+
<p class="text-xs text-muted">
|
|
155
|
+
{{ t('quotes.detail.total') }}
|
|
156
|
+
</p>
|
|
157
|
+
<p class="text-sm font-semibold text-highlighted tabular-nums">
|
|
158
|
+
{{ formatCurrency(quote.grandTotal) }}
|
|
159
|
+
</p>
|
|
160
|
+
</div>
|
|
161
|
+
<div class="ms-auto">
|
|
162
|
+
<UBadge
|
|
163
|
+
:color="statusColors[quote.status]"
|
|
164
|
+
variant="subtle"
|
|
165
|
+
:label="t(`quotes.status.${quote.status}`)"
|
|
166
|
+
/>
|
|
167
|
+
</div>
|
|
168
|
+
</div>
|
|
169
|
+
|
|
170
|
+
<UAlert
|
|
171
|
+
v-if="stateHint"
|
|
172
|
+
:color="stateHint.color"
|
|
173
|
+
variant="soft"
|
|
174
|
+
:icon="icon(stateHint.color === 'error' ? 'error' : 'info')"
|
|
175
|
+
:title="stateHint.text"
|
|
176
|
+
/>
|
|
177
|
+
|
|
178
|
+
<!-- Message from the merchant -->
|
|
179
|
+
<section
|
|
180
|
+
v-if="quote.sellerNote || seller.length"
|
|
181
|
+
class="border border-(--ui-border) rounded-xl p-4 sm:p-5"
|
|
182
|
+
>
|
|
183
|
+
<h2 class="text-sm font-semibold text-highlighted mb-2">
|
|
184
|
+
{{ t('quotes.detail.sellerNote') }}
|
|
185
|
+
</h2>
|
|
186
|
+
<p class="text-sm text-default whitespace-pre-line">
|
|
187
|
+
{{ quote.sellerNote ?? seller[seller.length - 1]?.body }}
|
|
188
|
+
</p>
|
|
189
|
+
</section>
|
|
190
|
+
|
|
191
|
+
<!-- Positions -->
|
|
192
|
+
<section class="border border-(--ui-border) rounded-xl overflow-hidden">
|
|
193
|
+
<h2 class="px-4 sm:px-5 py-3 text-sm font-semibold text-highlighted bg-elevated/60 border-b border-(--ui-border)">
|
|
194
|
+
{{ t('quotes.detail.positions') }}
|
|
195
|
+
</h2>
|
|
196
|
+
<ul class="divide-y divide-(--ui-border)">
|
|
197
|
+
<li
|
|
198
|
+
v-for="line in quote.lines"
|
|
199
|
+
:key="line.id"
|
|
200
|
+
class="px-4 sm:px-5 py-3 flex flex-wrap items-center gap-x-4 gap-y-1"
|
|
201
|
+
>
|
|
202
|
+
<div class="min-w-0 flex-1">
|
|
203
|
+
<p class="text-sm font-medium text-highlighted">
|
|
204
|
+
{{ line.name }}
|
|
205
|
+
</p>
|
|
206
|
+
<p class="text-xs text-muted">
|
|
207
|
+
{{ line.sku }}
|
|
208
|
+
</p>
|
|
209
|
+
</div>
|
|
210
|
+
<p class="text-sm text-muted tabular-nums w-20 text-right">
|
|
211
|
+
{{ line.quantity }} ×
|
|
212
|
+
</p>
|
|
213
|
+
<div class="w-28 text-right">
|
|
214
|
+
<p class="text-sm text-default tabular-nums">
|
|
215
|
+
{{ line.unitPrice !== null ? formatCurrency(line.unitPrice) : t('quotes.detail.onRequest') }}
|
|
216
|
+
</p>
|
|
217
|
+
<p
|
|
218
|
+
v-if="line.quotedPrice !== null && line.listPrice !== null && line.quotedPrice !== line.listPrice"
|
|
219
|
+
class="text-xs text-muted line-through tabular-nums"
|
|
220
|
+
>
|
|
221
|
+
{{ formatCurrency(line.listPrice) }}
|
|
222
|
+
</p>
|
|
223
|
+
</div>
|
|
224
|
+
<p class="text-sm font-medium text-highlighted tabular-nums w-28 text-right">
|
|
225
|
+
{{ formatCurrency(line.lineTotal) }}
|
|
226
|
+
</p>
|
|
227
|
+
</li>
|
|
228
|
+
</ul>
|
|
229
|
+
<dl class="px-4 sm:px-5 py-3 border-t border-(--ui-border) space-y-1.5 text-sm">
|
|
230
|
+
<div class="flex justify-between">
|
|
231
|
+
<dt class="text-muted">
|
|
232
|
+
{{ t('quotes.detail.goods') }}
|
|
233
|
+
</dt>
|
|
234
|
+
<dd class="tabular-nums text-default">
|
|
235
|
+
{{ formatCurrency(quote.goodsTotal) }}
|
|
236
|
+
</dd>
|
|
237
|
+
</div>
|
|
238
|
+
<div class="flex justify-between">
|
|
239
|
+
<dt class="text-muted">
|
|
240
|
+
{{ t('quotes.detail.carriage') }}
|
|
241
|
+
</dt>
|
|
242
|
+
<dd class="tabular-nums text-default">
|
|
243
|
+
{{ quote.shippingAmount !== null ? formatCurrency(quote.shippingAmount) : t('quotes.shippingPending') }}
|
|
244
|
+
</dd>
|
|
245
|
+
</div>
|
|
246
|
+
<div class="flex justify-between font-semibold text-highlighted pt-1.5 border-t border-(--ui-border)">
|
|
247
|
+
<dt>{{ t('quotes.detail.totalNet') }}</dt>
|
|
248
|
+
<dd class="tabular-nums">
|
|
249
|
+
{{ formatCurrency(quote.grandTotal) }}
|
|
250
|
+
</dd>
|
|
251
|
+
</div>
|
|
252
|
+
<p class="text-xs text-muted">
|
|
253
|
+
{{ t('quotes.detail.taxHint') }}
|
|
254
|
+
</p>
|
|
255
|
+
</dl>
|
|
256
|
+
</section>
|
|
257
|
+
|
|
258
|
+
<!-- Addresses -->
|
|
259
|
+
<div class="grid gap-4 sm:grid-cols-2">
|
|
260
|
+
<section
|
|
261
|
+
v-for="block in [
|
|
262
|
+
{ key: 'shipping', label: t('quotes.detail.shippingAddress'), lines: addressLines(quote.shippingAddress) },
|
|
263
|
+
{ key: 'billing', label: t('quotes.detail.billingAddress'), lines: addressLines(quote.billingAddress) },
|
|
264
|
+
]"
|
|
265
|
+
:key="block.key"
|
|
266
|
+
class="border border-(--ui-border) rounded-xl p-4 sm:p-5"
|
|
267
|
+
>
|
|
268
|
+
<h2 class="text-sm font-semibold text-highlighted mb-2">
|
|
269
|
+
{{ block.label }}
|
|
270
|
+
</h2>
|
|
271
|
+
<p
|
|
272
|
+
v-for="(line, i) in block.lines"
|
|
273
|
+
:key="i"
|
|
274
|
+
class="text-sm text-default"
|
|
275
|
+
>
|
|
276
|
+
{{ line }}
|
|
277
|
+
</p>
|
|
278
|
+
<p
|
|
279
|
+
v-if="!block.lines.length"
|
|
280
|
+
class="text-sm text-muted"
|
|
281
|
+
>
|
|
282
|
+
–
|
|
283
|
+
</p>
|
|
284
|
+
</section>
|
|
285
|
+
</div>
|
|
286
|
+
|
|
287
|
+
<!-- Your note -->
|
|
288
|
+
<section
|
|
289
|
+
v-if="quote.buyerNote"
|
|
290
|
+
class="border border-(--ui-border) rounded-xl p-4 sm:p-5"
|
|
291
|
+
>
|
|
292
|
+
<h2 class="text-sm font-semibold text-highlighted mb-2">
|
|
293
|
+
{{ t('quotes.detail.buyerNote') }}
|
|
294
|
+
</h2>
|
|
295
|
+
<p class="text-sm text-default whitespace-pre-line">
|
|
296
|
+
{{ quote.buyerNote }}
|
|
297
|
+
</p>
|
|
298
|
+
</section>
|
|
299
|
+
|
|
300
|
+
<!-- Trail -->
|
|
301
|
+
<section
|
|
302
|
+
v-if="quote.trail.length"
|
|
303
|
+
class="border border-(--ui-border) rounded-xl p-4 sm:p-5"
|
|
304
|
+
>
|
|
305
|
+
<h2 class="text-sm font-semibold text-highlighted mb-3">
|
|
306
|
+
{{ t('quotes.detail.trail') }}
|
|
307
|
+
</h2>
|
|
308
|
+
<ol class="space-y-2">
|
|
309
|
+
<li
|
|
310
|
+
v-for="(entry, i) in quote.trail"
|
|
311
|
+
:key="i"
|
|
312
|
+
class="flex gap-3 text-sm"
|
|
313
|
+
>
|
|
314
|
+
<span class="text-muted tabular-nums w-28 shrink-0">{{ formatDate(entry.at) }}</span>
|
|
315
|
+
<span class="text-default">
|
|
316
|
+
{{ t(`quotes.trail.${entry.kind}`, t('quotes.trail.note')) }}
|
|
317
|
+
<span
|
|
318
|
+
v-if="entry.body && entry.kind !== 'quoted'"
|
|
319
|
+
class="text-muted"
|
|
320
|
+
>— {{ entry.body }}</span>
|
|
321
|
+
</span>
|
|
322
|
+
</li>
|
|
323
|
+
</ol>
|
|
324
|
+
</section>
|
|
325
|
+
|
|
326
|
+
<!-- Answers -->
|
|
327
|
+
<div
|
|
328
|
+
v-if="quote.canOrder || quote.canDecline"
|
|
329
|
+
class="flex flex-wrap items-center justify-end gap-2"
|
|
330
|
+
>
|
|
331
|
+
<UButton
|
|
332
|
+
v-if="quote.canDecline"
|
|
333
|
+
color="neutral"
|
|
334
|
+
variant="outline"
|
|
335
|
+
:label="t('quotes.actions.decline')"
|
|
336
|
+
@click="declineOpen = true"
|
|
337
|
+
/>
|
|
338
|
+
<UButton
|
|
339
|
+
v-if="quote.canOrder"
|
|
340
|
+
color="primary"
|
|
341
|
+
:icon="icon('cart')"
|
|
342
|
+
:label="t('quotes.actions.order', { total: formatCurrency(quote.grandTotal) })"
|
|
343
|
+
@click="orderOpen = true"
|
|
344
|
+
/>
|
|
345
|
+
</div>
|
|
346
|
+
|
|
347
|
+
<!-- Order modal -->
|
|
348
|
+
<UModal
|
|
349
|
+
v-model:open="orderOpen"
|
|
350
|
+
:title="t('quotes.order.title', { number: quote.number })"
|
|
351
|
+
>
|
|
352
|
+
<template #body>
|
|
353
|
+
<div class="space-y-4">
|
|
354
|
+
<p class="text-sm text-default">
|
|
355
|
+
{{ t('quotes.order.intro', { total: formatCurrency(quote.grandTotal) }) }}
|
|
356
|
+
</p>
|
|
357
|
+
<UFormField :label="t('quotes.order.customerOrderNumber')">
|
|
358
|
+
<UInput
|
|
359
|
+
v-model="customerOrderNumber"
|
|
360
|
+
class="w-full"
|
|
361
|
+
:placeholder="t('quotes.order.customerOrderNumberPlaceholder')"
|
|
362
|
+
/>
|
|
363
|
+
</UFormField>
|
|
364
|
+
<UFormField :label="t('quotes.order.note')">
|
|
365
|
+
<UTextarea
|
|
366
|
+
v-model="orderNote"
|
|
367
|
+
class="w-full"
|
|
368
|
+
:rows="3"
|
|
369
|
+
/>
|
|
370
|
+
</UFormField>
|
|
371
|
+
<p class="text-xs text-muted">
|
|
372
|
+
{{ t('quotes.order.terms') }}
|
|
373
|
+
</p>
|
|
374
|
+
</div>
|
|
375
|
+
</template>
|
|
376
|
+
<template #footer>
|
|
377
|
+
<div class="flex items-center justify-end gap-2 w-full">
|
|
378
|
+
<UButton
|
|
379
|
+
color="neutral"
|
|
380
|
+
variant="ghost"
|
|
381
|
+
:label="t('quotes.order.cancel')"
|
|
382
|
+
@click="orderOpen = false"
|
|
383
|
+
/>
|
|
384
|
+
<UButton
|
|
385
|
+
color="primary"
|
|
386
|
+
:loading="ordering"
|
|
387
|
+
:label="t('quotes.order.submit')"
|
|
388
|
+
@click="submitOrder"
|
|
389
|
+
/>
|
|
390
|
+
</div>
|
|
391
|
+
</template>
|
|
392
|
+
</UModal>
|
|
393
|
+
|
|
394
|
+
<!-- Decline modal -->
|
|
395
|
+
<UModal
|
|
396
|
+
v-model:open="declineOpen"
|
|
397
|
+
:title="t('quotes.decline.title')"
|
|
398
|
+
>
|
|
399
|
+
<template #body>
|
|
400
|
+
<UFormField :label="t('quotes.decline.reason')">
|
|
401
|
+
<UTextarea
|
|
402
|
+
v-model="declineReason"
|
|
403
|
+
class="w-full"
|
|
404
|
+
:rows="3"
|
|
405
|
+
:placeholder="t('quotes.decline.reasonPlaceholder')"
|
|
406
|
+
/>
|
|
407
|
+
</UFormField>
|
|
408
|
+
</template>
|
|
409
|
+
<template #footer>
|
|
410
|
+
<div class="flex items-center justify-end gap-2 w-full">
|
|
411
|
+
<UButton
|
|
412
|
+
color="neutral"
|
|
413
|
+
variant="ghost"
|
|
414
|
+
:label="t('quotes.decline.cancel')"
|
|
415
|
+
@click="declineOpen = false"
|
|
416
|
+
/>
|
|
417
|
+
<UButton
|
|
418
|
+
color="error"
|
|
419
|
+
:loading="declining"
|
|
420
|
+
:label="t('quotes.decline.submit')"
|
|
421
|
+
@click="submitDecline"
|
|
422
|
+
/>
|
|
423
|
+
</div>
|
|
424
|
+
</template>
|
|
425
|
+
</UModal>
|
|
426
|
+
</div>
|
|
427
|
+
</div>
|
|
428
|
+
</template>
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { TableColumn } from "@nuxt/ui";
|
|
3
|
+
|
|
4
|
+
import type { AccountQuote, AccountQuoteStatus } from "../../../interfaces/account/quotes";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The buyer's quotes (RX-783): what they asked for, what is priced and
|
|
8
|
+
* waiting on them, and what became an order. Details — positions, carriage,
|
|
9
|
+
* the answer — live on the quote's own page.
|
|
10
|
+
*/
|
|
11
|
+
const { t, d } = useI18n();
|
|
12
|
+
const localePath = useLocalePath();
|
|
13
|
+
const { quotes, status, error } = useAccountQuotes();
|
|
14
|
+
const { formatCurrency } = useCartSummaryFormatting();
|
|
15
|
+
const { tableUi } = useDataTable();
|
|
16
|
+
|
|
17
|
+
const statusColors: Record<AccountQuoteStatus, "info" | "warning" | "primary" | "success" | "error" | "neutral"> = {
|
|
18
|
+
requested: "info",
|
|
19
|
+
in_review: "info",
|
|
20
|
+
quoted: "warning",
|
|
21
|
+
partially_accepted: "warning",
|
|
22
|
+
accepted: "success",
|
|
23
|
+
declined: "neutral",
|
|
24
|
+
rejected: "error",
|
|
25
|
+
expired: "neutral",
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const search = ref("");
|
|
29
|
+
const statusFilter = ref<string>("all");
|
|
30
|
+
|
|
31
|
+
const searched = computed(() => {
|
|
32
|
+
const query = search.value.trim().toLowerCase();
|
|
33
|
+
if (!query) {
|
|
34
|
+
return quotes.value;
|
|
35
|
+
}
|
|
36
|
+
return quotes.value.filter(quote => quote.number.toLowerCase().includes(query));
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const filtered = computed(() => {
|
|
40
|
+
if (statusFilter.value === "all") return searched.value;
|
|
41
|
+
if (statusFilter.value === "waiting") return searched.value.filter(q => q.canOrder);
|
|
42
|
+
return searched.value.filter(q => q.status === statusFilter.value);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
const filterItems = computed(() => [
|
|
46
|
+
{ value: "all", label: t("table.filterAll"), count: searched.value.length },
|
|
47
|
+
{ value: "waiting", label: t("quotes.filter.waiting"), count: searched.value.filter(q => q.canOrder).length },
|
|
48
|
+
...(["requested", "in_review", "accepted", "rejected", "expired"] as AccountQuoteStatus[])
|
|
49
|
+
.map(value => ({
|
|
50
|
+
value,
|
|
51
|
+
label: t(`quotes.status.${value}`),
|
|
52
|
+
count: searched.value.filter(q => q.status === value).length,
|
|
53
|
+
}))
|
|
54
|
+
.filter(item => item.count > 0),
|
|
55
|
+
]);
|
|
56
|
+
|
|
57
|
+
const sorting = ref([{ id: "createdAt", desc: true }]);
|
|
58
|
+
|
|
59
|
+
const columns = computed<TableColumn<AccountQuote>[]>(() => [
|
|
60
|
+
{ accessorKey: "number", header: t("quotes.columns.number") },
|
|
61
|
+
{ accessorKey: "createdAt", header: t("quotes.columns.date") },
|
|
62
|
+
{ accessorKey: "status", header: t("quotes.columns.status"), enableSorting: false },
|
|
63
|
+
{ accessorKey: "validUntil", header: t("quotes.columns.validUntil") },
|
|
64
|
+
{
|
|
65
|
+
accessorKey: "grandTotal",
|
|
66
|
+
header: t("quotes.columns.total"),
|
|
67
|
+
meta: { class: { th: "text-right", td: "text-right" } },
|
|
68
|
+
},
|
|
69
|
+
{ id: "actions", header: "", enableSorting: false },
|
|
70
|
+
]);
|
|
71
|
+
|
|
72
|
+
const formatDate = (value: string | null) => {
|
|
73
|
+
if (!value) return "–";
|
|
74
|
+
const parsed = new Date(value);
|
|
75
|
+
return Number.isNaN(parsed.getTime()) ? value : d(parsed, { dateStyle: "medium" });
|
|
76
|
+
};
|
|
77
|
+
</script>
|
|
78
|
+
|
|
79
|
+
<template>
|
|
80
|
+
<div>
|
|
81
|
+
<UiFeedbackErrorBoundary
|
|
82
|
+
v-if="error"
|
|
83
|
+
:title="t('quotes.errorTitle')"
|
|
84
|
+
:description="t('quotes.errorDescription')"
|
|
85
|
+
:show-retry="false"
|
|
86
|
+
/>
|
|
87
|
+
|
|
88
|
+
<template v-else>
|
|
89
|
+
<UiTableToolbar
|
|
90
|
+
v-model:search="search"
|
|
91
|
+
v-model:filter="statusFilter"
|
|
92
|
+
:search-placeholder="t('quotes.searchPlaceholder')"
|
|
93
|
+
:filter-items="filterItems"
|
|
94
|
+
/>
|
|
95
|
+
|
|
96
|
+
<UTable
|
|
97
|
+
v-model:sorting="sorting"
|
|
98
|
+
:data="filtered"
|
|
99
|
+
:columns="columns"
|
|
100
|
+
:loading="status === 'pending'"
|
|
101
|
+
:ui="tableUi"
|
|
102
|
+
>
|
|
103
|
+
<template #number-cell="{ row }">
|
|
104
|
+
<ULink
|
|
105
|
+
class="font-semibold text-highlighted hover:text-primary transition-colors"
|
|
106
|
+
:to="localePath(`/account/quotes/${row.original.id}`)"
|
|
107
|
+
>
|
|
108
|
+
{{ row.original.number }}
|
|
109
|
+
</ULink>
|
|
110
|
+
</template>
|
|
111
|
+
<template #createdAt-cell="{ row }">
|
|
112
|
+
<span class="text-sm text-muted">{{ formatDate(row.original.createdAt) }}</span>
|
|
113
|
+
</template>
|
|
114
|
+
<template #status-cell="{ row }">
|
|
115
|
+
<UBadge
|
|
116
|
+
:color="statusColors[row.original.status]"
|
|
117
|
+
variant="subtle"
|
|
118
|
+
:label="t(`quotes.status.${row.original.status}`)"
|
|
119
|
+
/>
|
|
120
|
+
</template>
|
|
121
|
+
<template #validUntil-cell="{ row }">
|
|
122
|
+
<span class="text-sm text-muted">{{ formatDate(row.original.validUntil) }}</span>
|
|
123
|
+
</template>
|
|
124
|
+
<template #grandTotal-cell="{ row }">
|
|
125
|
+
<span class="font-medium text-highlighted tabular-nums">
|
|
126
|
+
{{ formatCurrency(row.original.grandTotal) }}
|
|
127
|
+
</span>
|
|
128
|
+
<p
|
|
129
|
+
v-if="row.original.shippingAmount === null && !['rejected', 'declined', 'expired'].includes(row.original.status)"
|
|
130
|
+
class="text-xs text-muted"
|
|
131
|
+
>
|
|
132
|
+
{{ t('quotes.shippingPending') }}
|
|
133
|
+
</p>
|
|
134
|
+
</template>
|
|
135
|
+
<template #actions-cell="{ row }">
|
|
136
|
+
<UButton
|
|
137
|
+
:to="localePath(`/account/quotes/${row.original.id}`)"
|
|
138
|
+
:color="row.original.canOrder ? 'primary' : 'neutral'"
|
|
139
|
+
:variant="row.original.canOrder ? 'solid' : 'ghost'"
|
|
140
|
+
size="xs"
|
|
141
|
+
:label="row.original.canOrder ? t('quotes.actions.review') : t('quotes.actions.open')"
|
|
142
|
+
/>
|
|
143
|
+
</template>
|
|
144
|
+
<template #empty>
|
|
145
|
+
<div class="py-10 text-center">
|
|
146
|
+
<p class="text-sm font-medium text-highlighted">
|
|
147
|
+
{{ t('quotes.empty.title') }}
|
|
148
|
+
</p>
|
|
149
|
+
<p class="text-sm text-muted mt-1">
|
|
150
|
+
{{ t('quotes.empty.description') }}
|
|
151
|
+
</p>
|
|
152
|
+
</div>
|
|
153
|
+
</template>
|
|
154
|
+
</UTable>
|
|
155
|
+
</template>
|
|
156
|
+
</div>
|
|
157
|
+
</template>
|