@revenexx/cover 0.2.17 → 0.2.19
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/components/account/address/AccountAddressView.vue +433 -0
- package/app/components/account/dashboard/AccountDashboard.vue +10 -330
- package/app/components/account/dashboard/AccountDashboardBudgets.vue +71 -0
- package/app/components/account/dashboard/AccountDashboardGreeting.vue +17 -0
- package/app/components/account/dashboard/AccountDashboardKpis.vue +71 -0
- package/app/components/account/dashboard/AccountDashboardQuickActions.vue +36 -0
- package/app/components/account/dashboard/AccountDashboardRecentOrders.vue +70 -0
- package/app/components/account/dashboard/AccountDashboardRequisitions.vue +60 -0
- package/app/components/account/profile/AccountPasswordForm.vue +155 -0
- package/app/components/account/profile/AccountProfileForm.vue +159 -0
- package/app/components/auth/AuthLoginTeaser.vue +1 -1
- package/app/components/auth/AuthRegisterPanel.vue +123 -119
- package/app/components/cart/position/CartPosition.vue +26 -17
- package/app/components/cart/recommend/CartReorderStrip.vue +27 -12
- package/app/components/cart/view/CartView.vue +1 -8
- package/app/components/checkout/confirmation/CheckoutConfirmationActions.vue +52 -0
- package/app/components/checkout/confirmation/CheckoutConfirmationHero.vue +41 -0
- package/app/components/checkout/confirmation/CheckoutConfirmationNextSteps.vue +60 -0
- package/app/components/checkout/confirmation/CheckoutConfirmationOrderRecap.vue +102 -0
- package/app/components/checkout/confirmation/CheckoutConfirmationView.vue +30 -265
- package/app/components/listing/ListingActiveFilters.vue +59 -0
- package/app/components/listing/ListingFilterBar.vue +24 -0
- package/app/components/listing/ListingFilterDrawer.vue +72 -0
- package/app/components/listing/ListingFilterRail.vue +23 -0
- package/app/components/listing/ListingResults.vue +88 -0
- package/app/components/listing/ListingToolbar.vue +46 -0
- package/app/components/listing/ListingView.vue +14 -204
- package/app/components/product/detail/ProductDetailIdentity.vue +44 -0
- package/app/components/product/detail/ProductDetailPrice.vue +39 -0
- package/app/components/search/filter/SearchFacets.vue +12 -102
- package/app/components/search/filter/SearchFacetsBar.vue +161 -0
- package/app/composables/useAccountDashboard.ts +112 -0
- package/app/composables/useCategoryListing.ts +92 -0
- package/app/composables/useCheckoutConfirmation.ts +63 -0
- package/app/composables/useFacetFilters.ts +122 -0
- package/app/composables/useProduct.ts +11 -0
- package/app/composables/useProductListing.ts +5 -1
- package/app/composables/useSearchListing.ts +71 -0
- package/app/interfaces/checkout.ts +27 -0
- package/i18n/locales/de/auth.json +1 -1
- package/i18n/locales/de/editor.json +33 -0
- package/i18n/locales/en/editor.json +33 -0
- package/package.json +1 -1
- package/server/data/media/60794300.jpg +0 -0
- package/server/data/media/aussen-rueckwaertsdrehen.jpg +0 -0
- package/server/data/media/bohrtiefe-8.jpg +0 -0
- package/server/data/media/dummy-brw-image.png +0 -0
- package/server/data/media/feindrehen.jpg +0 -0
- package/server/data/media/header-aktuelles.jpg +0 -0
- package/server/data/media/sternsiebeinsatz-gr-3-000028480.stp +19039 -0
- package/server/data/media/zaehnezahl-z4.jpg +0 -0
- package/server/data/media/zaehnezahl-z6.jpg +0 -0
- package/server/services/ApiProductService.ts +4 -1
|
@@ -1,349 +1,29 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import type { Requisition } from "../../../interfaces/b2b";
|
|
3
|
-
import type { AccountOrderStatus } from "../../../interfaces/account/order-list";
|
|
4
|
-
|
|
5
2
|
/**
|
|
6
3
|
* The account dashboard: KPI band (open orders, awaiting approval, 30-day
|
|
7
4
|
* spend, budget utilization), recent orders, open requisitions, cost
|
|
8
5
|
* center budget bars and quick actions — the buyer's daily starting point.
|
|
6
|
+
*
|
|
7
|
+
* Composed from per-section widget components so the same sections can be
|
|
8
|
+
* rearranged as individual blocks in the page editor (see cover-theme).
|
|
9
9
|
*/
|
|
10
|
-
const { icon } = useIcons();
|
|
11
|
-
const { t, d } = useI18n();
|
|
12
|
-
const localePath = useLocalePath();
|
|
13
|
-
const auth = useAuthStore();
|
|
14
|
-
const { orders, status: ordersStatus } = useAccountOrders();
|
|
15
|
-
const { costCenters, status: contextStatus } = useB2BContext();
|
|
16
|
-
const { formatCurrency } = useCartSummaryFormatting();
|
|
17
|
-
|
|
18
|
-
const { data: requisitions, status: requisitionsStatus } = useFetch<Requisition[]>(
|
|
19
|
-
"/api/account/requisitions",
|
|
20
|
-
{ key: "account-requisitions", default: () => [] },
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
const pending = computed(() =>
|
|
24
|
-
ordersStatus.value === "pending"
|
|
25
|
-
|| contextStatus.value === "pending"
|
|
26
|
-
|| requisitionsStatus.value === "pending");
|
|
27
|
-
|
|
28
|
-
/* ---- KPIs ------------------------------------------------------------ */
|
|
29
|
-
const OPEN_STATUSES: AccountOrderStatus[] = ["processing", "approval-pending", "shipped"];
|
|
30
|
-
|
|
31
|
-
const openOrdersCount = computed(() =>
|
|
32
|
-
orders.value.filter(order => OPEN_STATUSES.includes(order.status)).length);
|
|
33
|
-
|
|
34
|
-
const awaitingApprovalCount = computed(() =>
|
|
35
|
-
orders.value.filter(order => order.status === "approval-pending").length
|
|
36
|
-
+ requisitions.value.filter(requisition => requisition.status === "open").length);
|
|
37
|
-
|
|
38
|
-
const spend30 = computed(() => {
|
|
39
|
-
const cutoff = Date.now() - 30 * 24 * 60 * 60 * 1000;
|
|
40
|
-
return orders.value
|
|
41
|
-
.filter(order => order.status !== "cancelled" && new Date(order.date).getTime() >= cutoff)
|
|
42
|
-
.reduce((sum, order) => sum + order.total, 0);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
const budgetedCostCenters = computed(() =>
|
|
46
|
-
costCenters.value.filter(cc =>
|
|
47
|
-
cc.limit?.totalBudget !== undefined && cc.limit.availableBudget !== undefined));
|
|
48
|
-
|
|
49
|
-
const budgetUtilization = computed(() => {
|
|
50
|
-
const total = budgetedCostCenters.value.reduce((sum, cc) => sum + (cc.limit?.totalBudget ?? 0), 0);
|
|
51
|
-
if (!total) {
|
|
52
|
-
return null;
|
|
53
|
-
}
|
|
54
|
-
const available = budgetedCostCenters.value.reduce((sum, cc) => sum + (cc.limit?.availableBudget ?? 0), 0);
|
|
55
|
-
return Math.round(((total - available) / total) * 100);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
/* ---- lists ------------------------------------------------------------ */
|
|
59
|
-
const recentOrders = computed(() => orders.value.slice(0, 5));
|
|
60
|
-
|
|
61
|
-
const openRequisitions = computed(() =>
|
|
62
|
-
requisitions.value.filter(requisition => requisition.status === "open").slice(0, 4));
|
|
63
|
-
|
|
64
|
-
const statusColors: Record<AccountOrderStatus, "info" | "warning" | "primary" | "success" | "error"> = {
|
|
65
|
-
"processing": "info",
|
|
66
|
-
"approval-pending": "warning",
|
|
67
|
-
"shipped": "primary",
|
|
68
|
-
"delivered": "success",
|
|
69
|
-
"cancelled": "error",
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
const utilization = (used: number, total: number): number =>
|
|
73
|
-
total > 0 ? Math.min(100, Math.round((used / total) * 100)) : 0;
|
|
74
|
-
|
|
75
|
-
const budgetBars = computed(() =>
|
|
76
|
-
budgetedCostCenters.value.map((cc) => {
|
|
77
|
-
const total = cc.limit?.totalBudget ?? 0;
|
|
78
|
-
const available = cc.limit?.availableBudget ?? 0;
|
|
79
|
-
return { id: cc.id, label: cc.label, total, available, used: utilization(total - available, total) };
|
|
80
|
-
}));
|
|
81
|
-
|
|
82
|
-
const formatDate = (value: string) => {
|
|
83
|
-
const parsed = new Date(value);
|
|
84
|
-
return Number.isNaN(parsed.getTime()) ? value : d(parsed, { dateStyle: "medium" });
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
/* ---- quick actions ----------------------------------------------------- */
|
|
88
|
-
const quickActions = [
|
|
89
|
-
{ to: "/account/direct-order", labelKey: "directOrder.title", token: "direct-order" },
|
|
90
|
-
{ to: "/account/orders", labelKey: "account.nav.orders", token: "orders" },
|
|
91
|
-
{ to: "/account/order-lists", labelKey: "account.nav.orderLists", token: "order-list" },
|
|
92
|
-
{ to: "/account/requisitions", labelKey: "account.nav.requisitions", token: "check" },
|
|
93
|
-
{ to: "/account/cost-centers", labelKey: "account.nav.costCenters", token: "briefcase" },
|
|
94
|
-
];
|
|
95
|
-
|
|
96
|
-
/** Divider-separated KPI cells: 2-col grid on mobile, 4-col from lg. */
|
|
97
|
-
const statCell = `p-4 sm:p-5 border-(--ui-border)
|
|
98
|
-
max-lg:nth-[n+3]:border-t max-lg:nth-[2n]:border-l lg:not-first:border-l`;
|
|
99
10
|
</script>
|
|
100
11
|
|
|
101
12
|
<template>
|
|
102
13
|
<div>
|
|
103
|
-
|
|
104
|
-
<div class="mb-8">
|
|
105
|
-
<h1 class="text-2xl font-semibold text-highlighted">
|
|
106
|
-
{{ auth.user?.name
|
|
107
|
-
? t('account.dashboard.greeting', { name: auth.user.name })
|
|
108
|
-
: t('account.dashboard.title') }}
|
|
109
|
-
</h1>
|
|
110
|
-
<p class="text-sm text-muted mt-1">
|
|
111
|
-
{{ t('account.dashboard.description') }}
|
|
112
|
-
</p>
|
|
113
|
-
</div>
|
|
114
|
-
|
|
115
|
-
<div
|
|
116
|
-
v-if="pending"
|
|
117
|
-
class="space-y-6"
|
|
118
|
-
>
|
|
119
|
-
<USkeleton class="h-28 w-full rounded-xl" />
|
|
120
|
-
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
|
|
121
|
-
<USkeleton class="h-72 rounded-xl lg:col-span-2" />
|
|
122
|
-
<USkeleton class="h-72 rounded-xl" />
|
|
123
|
-
</div>
|
|
124
|
-
</div>
|
|
14
|
+
<AccountDashboardGreeting class="mb-8" />
|
|
125
15
|
|
|
126
|
-
<div
|
|
127
|
-
|
|
128
|
-
class="space-y-6"
|
|
129
|
-
>
|
|
130
|
-
<!-- KPI band -->
|
|
131
|
-
<dl class="border border-(--ui-border) rounded-xl grid grid-cols-2 lg:grid-cols-4">
|
|
132
|
-
<div :class="statCell">
|
|
133
|
-
<dt class="text-sm text-muted truncate">
|
|
134
|
-
{{ t('account.dashboard.stats.openOrders') }}
|
|
135
|
-
</dt>
|
|
136
|
-
<dd class="mt-1 text-2xl font-semibold text-highlighted tabular-nums">
|
|
137
|
-
{{ openOrdersCount }}
|
|
138
|
-
</dd>
|
|
139
|
-
</div>
|
|
140
|
-
<div :class="statCell">
|
|
141
|
-
<dt class="text-sm text-muted truncate">
|
|
142
|
-
{{ t('account.dashboard.stats.awaitingApproval') }}
|
|
143
|
-
</dt>
|
|
144
|
-
<dd
|
|
145
|
-
class="mt-1 text-2xl font-semibold tabular-nums"
|
|
146
|
-
:class="awaitingApprovalCount > 0 ? 'text-warning' : 'text-highlighted'"
|
|
147
|
-
>
|
|
148
|
-
{{ awaitingApprovalCount }}
|
|
149
|
-
</dd>
|
|
150
|
-
</div>
|
|
151
|
-
<div :class="statCell">
|
|
152
|
-
<dt class="text-sm text-muted truncate">
|
|
153
|
-
{{ t('account.dashboard.stats.spend30') }}
|
|
154
|
-
</dt>
|
|
155
|
-
<dd class="mt-1 text-2xl font-semibold text-highlighted tabular-nums">
|
|
156
|
-
{{ formatCurrency(spend30) }}
|
|
157
|
-
</dd>
|
|
158
|
-
</div>
|
|
159
|
-
<div :class="statCell">
|
|
160
|
-
<dt class="text-sm text-muted truncate">
|
|
161
|
-
{{ t('account.dashboard.stats.budgetUsed') }}
|
|
162
|
-
</dt>
|
|
163
|
-
<dd
|
|
164
|
-
class="mt-1 text-2xl font-semibold tabular-nums"
|
|
165
|
-
:class="(budgetUtilization ?? 0) >= 90 ? 'text-warning' : 'text-highlighted'"
|
|
166
|
-
>
|
|
167
|
-
{{ budgetUtilization !== null ? `${budgetUtilization} %` : '—' }}
|
|
168
|
-
</dd>
|
|
169
|
-
</div>
|
|
170
|
-
</dl>
|
|
16
|
+
<div class="space-y-6">
|
|
17
|
+
<AccountDashboardKpis />
|
|
171
18
|
|
|
172
19
|
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6 items-start">
|
|
173
|
-
<!-- Left column: recent orders + open requisitions -->
|
|
174
20
|
<div class="lg:col-span-2 space-y-6">
|
|
175
|
-
<
|
|
176
|
-
|
|
177
|
-
<h2 class="text-sm font-semibold text-highlighted">
|
|
178
|
-
{{ t('account.dashboard.recentOrders') }}
|
|
179
|
-
</h2>
|
|
180
|
-
<ULink
|
|
181
|
-
class="text-xs font-medium text-primary hover:underline"
|
|
182
|
-
:to="localePath('/account/orders')"
|
|
183
|
-
>
|
|
184
|
-
{{ t('account.dashboard.viewAll') }} →
|
|
185
|
-
</ULink>
|
|
186
|
-
</header>
|
|
187
|
-
<ul
|
|
188
|
-
v-if="recentOrders.length"
|
|
189
|
-
class="divide-y divide-(--ui-border)"
|
|
190
|
-
>
|
|
191
|
-
<li
|
|
192
|
-
v-for="order in recentOrders"
|
|
193
|
-
:key="order.id"
|
|
194
|
-
>
|
|
195
|
-
<NuxtLink
|
|
196
|
-
:to="localePath(`/account/orders/${order.id}`)"
|
|
197
|
-
class="flex flex-wrap items-center gap-x-4 gap-y-1 px-4 sm:px-5 py-3
|
|
198
|
-
hover:bg-elevated/40 transition-colors"
|
|
199
|
-
>
|
|
200
|
-
<span class="text-sm font-semibold text-highlighted">{{ order.id }}</span>
|
|
201
|
-
<span class="text-xs text-muted">{{ formatDate(order.date) }}</span>
|
|
202
|
-
<span class="flex items-center gap-3 ms-auto">
|
|
203
|
-
<UBadge
|
|
204
|
-
:color="statusColors[order.status]"
|
|
205
|
-
variant="subtle"
|
|
206
|
-
size="sm"
|
|
207
|
-
:label="t(`orders.status.${order.status}`)"
|
|
208
|
-
/>
|
|
209
|
-
<span class="text-sm tabular-nums text-highlighted min-w-20 text-right">
|
|
210
|
-
{{ formatCurrency(order.total) }}
|
|
211
|
-
</span>
|
|
212
|
-
</span>
|
|
213
|
-
</NuxtLink>
|
|
214
|
-
</li>
|
|
215
|
-
</ul>
|
|
216
|
-
<p
|
|
217
|
-
v-else
|
|
218
|
-
class="px-4 sm:px-5 py-6 text-sm text-muted"
|
|
219
|
-
>
|
|
220
|
-
{{ t('account.dashboard.noOrders') }}
|
|
221
|
-
</p>
|
|
222
|
-
</section>
|
|
223
|
-
|
|
224
|
-
<section class="border border-(--ui-border) rounded-xl overflow-hidden">
|
|
225
|
-
<header class="flex items-center justify-between px-4 sm:px-5 py-3 bg-elevated/60 border-b border-(--ui-border)">
|
|
226
|
-
<h2 class="text-sm font-semibold text-highlighted">
|
|
227
|
-
{{ t('account.dashboard.openRequisitions') }}
|
|
228
|
-
</h2>
|
|
229
|
-
<ULink
|
|
230
|
-
class="text-xs font-medium text-primary hover:underline"
|
|
231
|
-
:to="localePath('/account/requisitions')"
|
|
232
|
-
>
|
|
233
|
-
{{ t('account.dashboard.viewAll') }} →
|
|
234
|
-
</ULink>
|
|
235
|
-
</header>
|
|
236
|
-
<ul
|
|
237
|
-
v-if="openRequisitions.length"
|
|
238
|
-
class="divide-y divide-(--ui-border)"
|
|
239
|
-
>
|
|
240
|
-
<li
|
|
241
|
-
v-for="requisition in openRequisitions"
|
|
242
|
-
:key="requisition.id"
|
|
243
|
-
>
|
|
244
|
-
<NuxtLink
|
|
245
|
-
:to="localePath(`/account/requisitions/${requisition.id}`)"
|
|
246
|
-
class="flex flex-wrap items-center gap-x-4 gap-y-1 px-4 sm:px-5 py-3
|
|
247
|
-
hover:bg-elevated/40 transition-colors"
|
|
248
|
-
>
|
|
249
|
-
<span class="text-sm font-semibold text-highlighted">{{ requisition.id }}</span>
|
|
250
|
-
<span class="text-xs text-muted">{{ requisition.requestedBy.name }}</span>
|
|
251
|
-
<span class="text-sm tabular-nums text-highlighted ms-auto">
|
|
252
|
-
{{ formatCurrency(requisition.totalValue) }}
|
|
253
|
-
</span>
|
|
254
|
-
</NuxtLink>
|
|
255
|
-
</li>
|
|
256
|
-
</ul>
|
|
257
|
-
<p
|
|
258
|
-
v-else
|
|
259
|
-
class="px-4 sm:px-5 py-6 text-sm text-muted"
|
|
260
|
-
>
|
|
261
|
-
{{ t('account.dashboard.noRequisitions') }}
|
|
262
|
-
</p>
|
|
263
|
-
</section>
|
|
21
|
+
<AccountDashboardRecentOrders />
|
|
22
|
+
<AccountDashboardRequisitions />
|
|
264
23
|
</div>
|
|
265
|
-
|
|
266
|
-
<!-- Right column: budgets + quick actions -->
|
|
267
24
|
<div class="space-y-6">
|
|
268
|
-
<
|
|
269
|
-
|
|
270
|
-
<h2 class="text-sm font-semibold text-highlighted">
|
|
271
|
-
{{ t('account.dashboard.budgets') }}
|
|
272
|
-
</h2>
|
|
273
|
-
<ULink
|
|
274
|
-
class="text-xs font-medium text-primary hover:underline"
|
|
275
|
-
:to="localePath('/account/cost-centers')"
|
|
276
|
-
>
|
|
277
|
-
{{ t('account.dashboard.viewAll') }} →
|
|
278
|
-
</ULink>
|
|
279
|
-
</header>
|
|
280
|
-
<ul
|
|
281
|
-
v-if="budgetBars.length"
|
|
282
|
-
class="divide-y divide-(--ui-border)"
|
|
283
|
-
>
|
|
284
|
-
<li
|
|
285
|
-
v-for="bar in budgetBars"
|
|
286
|
-
:key="bar.id"
|
|
287
|
-
class="px-4 sm:px-5 py-3"
|
|
288
|
-
>
|
|
289
|
-
<div class="flex items-baseline justify-between gap-2">
|
|
290
|
-
<p class="text-sm font-medium text-highlighted truncate">
|
|
291
|
-
{{ bar.label }}
|
|
292
|
-
</p>
|
|
293
|
-
<p class="text-xs text-muted tabular-nums shrink-0">
|
|
294
|
-
{{ bar.used }} %
|
|
295
|
-
</p>
|
|
296
|
-
</div>
|
|
297
|
-
<div class="mt-2 h-1.5 rounded-full bg-elevated overflow-hidden">
|
|
298
|
-
<div
|
|
299
|
-
class="h-full rounded-full w-(--budget-used)"
|
|
300
|
-
:class="bar.used >= 90 ? 'bg-warning' : 'bg-primary'"
|
|
301
|
-
:style="{ '--budget-used': `${bar.used}%` }"
|
|
302
|
-
/>
|
|
303
|
-
</div>
|
|
304
|
-
<p class="mt-1.5 text-xs text-muted tabular-nums">
|
|
305
|
-
{{ t('account.dashboard.budgetAvailable', {
|
|
306
|
-
available: formatCurrency(bar.available),
|
|
307
|
-
total: formatCurrency(bar.total),
|
|
308
|
-
}) }}
|
|
309
|
-
</p>
|
|
310
|
-
</li>
|
|
311
|
-
</ul>
|
|
312
|
-
<p
|
|
313
|
-
v-else
|
|
314
|
-
class="px-4 sm:px-5 py-6 text-sm text-muted"
|
|
315
|
-
>
|
|
316
|
-
{{ t('account.dashboard.noBudgets') }}
|
|
317
|
-
</p>
|
|
318
|
-
</section>
|
|
319
|
-
|
|
320
|
-
<section class="border border-(--ui-border) rounded-xl overflow-hidden">
|
|
321
|
-
<h2 class="px-4 sm:px-5 py-3 text-sm font-semibold text-highlighted bg-elevated/60 border-b border-(--ui-border)">
|
|
322
|
-
{{ t('account.dashboard.quickAccess') }}
|
|
323
|
-
</h2>
|
|
324
|
-
<ul class="divide-y divide-(--ui-border)">
|
|
325
|
-
<li
|
|
326
|
-
v-for="action in quickActions"
|
|
327
|
-
:key="action.to"
|
|
328
|
-
>
|
|
329
|
-
<NuxtLink
|
|
330
|
-
:to="localePath(action.to)"
|
|
331
|
-
class="flex items-center gap-3 px-4 sm:px-5 py-3 text-sm text-highlighted
|
|
332
|
-
hover:bg-elevated/40 transition-colors"
|
|
333
|
-
>
|
|
334
|
-
<UIcon
|
|
335
|
-
:name="icon(action.token)"
|
|
336
|
-
class="size-4.5 text-primary shrink-0"
|
|
337
|
-
/>
|
|
338
|
-
<span class="truncate">{{ t(action.labelKey) }}</span>
|
|
339
|
-
<UIcon
|
|
340
|
-
:name="icon('chevron-right')"
|
|
341
|
-
class="size-4 text-dimmed ms-auto shrink-0"
|
|
342
|
-
/>
|
|
343
|
-
</NuxtLink>
|
|
344
|
-
</li>
|
|
345
|
-
</ul>
|
|
346
|
-
</section>
|
|
25
|
+
<AccountDashboardBudgets />
|
|
26
|
+
<AccountDashboardQuickActions />
|
|
347
27
|
</div>
|
|
348
28
|
</div>
|
|
349
29
|
</div>
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/** Dashboard widget: cost-center budget utilization bars. */
|
|
3
|
+
const localePath = useLocalePath();
|
|
4
|
+
const {
|
|
5
|
+
t,
|
|
6
|
+
formatCurrency,
|
|
7
|
+
budgetBars,
|
|
8
|
+
contextPending,
|
|
9
|
+
} = useAccountDashboard();
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<template>
|
|
13
|
+
<USkeleton
|
|
14
|
+
v-if="contextPending"
|
|
15
|
+
class="h-72 w-full rounded-xl"
|
|
16
|
+
/>
|
|
17
|
+
<section
|
|
18
|
+
v-else
|
|
19
|
+
class="border border-(--ui-border) rounded-xl overflow-hidden"
|
|
20
|
+
>
|
|
21
|
+
<header class="flex items-center justify-between px-4 sm:px-5 py-3 bg-elevated/60 border-b border-(--ui-border)">
|
|
22
|
+
<h2 class="text-sm font-semibold text-highlighted">
|
|
23
|
+
{{ t('account.dashboard.budgets') }}
|
|
24
|
+
</h2>
|
|
25
|
+
<ULink
|
|
26
|
+
class="text-xs font-medium text-primary hover:underline"
|
|
27
|
+
:to="localePath('/account/cost-centers')"
|
|
28
|
+
>
|
|
29
|
+
{{ t('account.dashboard.viewAll') }} →
|
|
30
|
+
</ULink>
|
|
31
|
+
</header>
|
|
32
|
+
<ul
|
|
33
|
+
v-if="budgetBars.length"
|
|
34
|
+
class="divide-y divide-(--ui-border)"
|
|
35
|
+
>
|
|
36
|
+
<li
|
|
37
|
+
v-for="bar in budgetBars"
|
|
38
|
+
:key="bar.id"
|
|
39
|
+
class="px-4 sm:px-5 py-3"
|
|
40
|
+
>
|
|
41
|
+
<div class="flex items-baseline justify-between gap-2">
|
|
42
|
+
<p class="text-sm font-medium text-highlighted truncate">
|
|
43
|
+
{{ bar.label }}
|
|
44
|
+
</p>
|
|
45
|
+
<p class="text-xs text-muted tabular-nums shrink-0">
|
|
46
|
+
{{ bar.used }} %
|
|
47
|
+
</p>
|
|
48
|
+
</div>
|
|
49
|
+
<div class="mt-2 h-1.5 rounded-full bg-elevated overflow-hidden">
|
|
50
|
+
<div
|
|
51
|
+
class="h-full rounded-full w-(--budget-used)"
|
|
52
|
+
:class="bar.used >= 90 ? 'bg-warning' : 'bg-primary'"
|
|
53
|
+
:style="{ '--budget-used': `${bar.used}%` }"
|
|
54
|
+
/>
|
|
55
|
+
</div>
|
|
56
|
+
<p class="mt-1.5 text-xs text-muted tabular-nums">
|
|
57
|
+
{{ t('account.dashboard.budgetAvailable', {
|
|
58
|
+
available: formatCurrency(bar.available),
|
|
59
|
+
total: formatCurrency(bar.total),
|
|
60
|
+
}) }}
|
|
61
|
+
</p>
|
|
62
|
+
</li>
|
|
63
|
+
</ul>
|
|
64
|
+
<p
|
|
65
|
+
v-else
|
|
66
|
+
class="px-4 sm:px-5 py-6 text-sm text-muted"
|
|
67
|
+
>
|
|
68
|
+
{{ t('account.dashboard.noBudgets') }}
|
|
69
|
+
</p>
|
|
70
|
+
</section>
|
|
71
|
+
</template>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/** Dashboard greeting: personalized welcome headline and subtitle. */
|
|
3
|
+
const { t, auth } = useAccountDashboard();
|
|
4
|
+
</script>
|
|
5
|
+
|
|
6
|
+
<template>
|
|
7
|
+
<div>
|
|
8
|
+
<h1 class="text-2xl font-semibold text-highlighted">
|
|
9
|
+
{{ auth.user?.name
|
|
10
|
+
? t('account.dashboard.greeting', { name: auth.user.name })
|
|
11
|
+
: t('account.dashboard.title') }}
|
|
12
|
+
</h1>
|
|
13
|
+
<p class="text-sm text-muted mt-1">
|
|
14
|
+
{{ t('account.dashboard.description') }}
|
|
15
|
+
</p>
|
|
16
|
+
</div>
|
|
17
|
+
</template>
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/** Dashboard KPI band: open orders, awaiting approval, 30-day spend, budget %. */
|
|
3
|
+
const {
|
|
4
|
+
t,
|
|
5
|
+
formatCurrency,
|
|
6
|
+
openOrdersCount,
|
|
7
|
+
awaitingApprovalCount,
|
|
8
|
+
spend30,
|
|
9
|
+
budgetUtilization,
|
|
10
|
+
ordersPending,
|
|
11
|
+
contextPending,
|
|
12
|
+
requisitionsPending,
|
|
13
|
+
} = useAccountDashboard();
|
|
14
|
+
|
|
15
|
+
const pending = computed(() =>
|
|
16
|
+
ordersPending.value || contextPending.value || requisitionsPending.value);
|
|
17
|
+
|
|
18
|
+
/** Divider-separated KPI cells: 2-col grid on mobile, 4-col from lg. */
|
|
19
|
+
const statCell = `p-4 sm:p-5 border-(--ui-border)
|
|
20
|
+
max-lg:nth-[n+3]:border-t max-lg:nth-[2n]:border-l lg:not-first:border-l`;
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<template>
|
|
24
|
+
<USkeleton
|
|
25
|
+
v-if="pending"
|
|
26
|
+
class="h-28 w-full rounded-xl"
|
|
27
|
+
/>
|
|
28
|
+
<dl
|
|
29
|
+
v-else
|
|
30
|
+
class="border border-(--ui-border) rounded-xl grid grid-cols-2 lg:grid-cols-4"
|
|
31
|
+
>
|
|
32
|
+
<div :class="statCell">
|
|
33
|
+
<dt class="text-sm text-muted truncate">
|
|
34
|
+
{{ t('account.dashboard.stats.openOrders') }}
|
|
35
|
+
</dt>
|
|
36
|
+
<dd class="mt-1 text-2xl font-semibold text-highlighted tabular-nums">
|
|
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">
|
|
60
|
+
<dt class="text-sm text-muted truncate">
|
|
61
|
+
{{ t('account.dashboard.stats.budgetUsed') }}
|
|
62
|
+
</dt>
|
|
63
|
+
<dd
|
|
64
|
+
class="mt-1 text-2xl font-semibold tabular-nums"
|
|
65
|
+
:class="(budgetUtilization ?? 0) >= 90 ? 'text-warning' : 'text-highlighted'"
|
|
66
|
+
>
|
|
67
|
+
{{ budgetUtilization !== null ? `${budgetUtilization} %` : '—' }}
|
|
68
|
+
</dd>
|
|
69
|
+
</div>
|
|
70
|
+
</dl>
|
|
71
|
+
</template>
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/** Dashboard widget: quick-access links into the most-used account areas. */
|
|
3
|
+
const { icon } = useIcons();
|
|
4
|
+
const localePath = useLocalePath();
|
|
5
|
+
const { t, quickActions } = useAccountDashboard();
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
<template>
|
|
9
|
+
<section class="border border-(--ui-border) rounded-xl overflow-hidden">
|
|
10
|
+
<h2 class="px-4 sm:px-5 py-3 text-sm font-semibold text-highlighted bg-elevated/60 border-b border-(--ui-border)">
|
|
11
|
+
{{ t('account.dashboard.quickAccess') }}
|
|
12
|
+
</h2>
|
|
13
|
+
<ul class="divide-y divide-(--ui-border)">
|
|
14
|
+
<li
|
|
15
|
+
v-for="action in quickActions"
|
|
16
|
+
:key="action.to"
|
|
17
|
+
>
|
|
18
|
+
<NuxtLink
|
|
19
|
+
:to="localePath(action.to)"
|
|
20
|
+
class="flex items-center gap-3 px-4 sm:px-5 py-3 text-sm text-highlighted
|
|
21
|
+
hover:bg-elevated/40 transition-colors"
|
|
22
|
+
>
|
|
23
|
+
<UIcon
|
|
24
|
+
:name="icon(action.token)"
|
|
25
|
+
class="size-4.5 text-primary shrink-0"
|
|
26
|
+
/>
|
|
27
|
+
<span class="truncate">{{ t(action.labelKey) }}</span>
|
|
28
|
+
<UIcon
|
|
29
|
+
:name="icon('chevron-right')"
|
|
30
|
+
class="size-4 text-dimmed ms-auto shrink-0"
|
|
31
|
+
/>
|
|
32
|
+
</NuxtLink>
|
|
33
|
+
</li>
|
|
34
|
+
</ul>
|
|
35
|
+
</section>
|
|
36
|
+
</template>
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/** Dashboard widget: the five most recent orders with status and total. */
|
|
3
|
+
const localePath = useLocalePath();
|
|
4
|
+
const {
|
|
5
|
+
t,
|
|
6
|
+
formatCurrency,
|
|
7
|
+
formatDate,
|
|
8
|
+
statusColors,
|
|
9
|
+
recentOrders,
|
|
10
|
+
ordersPending,
|
|
11
|
+
} = useAccountDashboard();
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<template>
|
|
15
|
+
<USkeleton
|
|
16
|
+
v-if="ordersPending"
|
|
17
|
+
class="h-72 w-full rounded-xl"
|
|
18
|
+
/>
|
|
19
|
+
<section
|
|
20
|
+
v-else
|
|
21
|
+
class="border border-(--ui-border) rounded-xl overflow-hidden"
|
|
22
|
+
>
|
|
23
|
+
<header class="flex items-center justify-between px-4 sm:px-5 py-3 bg-elevated/60 border-b border-(--ui-border)">
|
|
24
|
+
<h2 class="text-sm font-semibold text-highlighted">
|
|
25
|
+
{{ t('account.dashboard.recentOrders') }}
|
|
26
|
+
</h2>
|
|
27
|
+
<ULink
|
|
28
|
+
class="text-xs font-medium text-primary hover:underline"
|
|
29
|
+
:to="localePath('/account/orders')"
|
|
30
|
+
>
|
|
31
|
+
{{ t('account.dashboard.viewAll') }} →
|
|
32
|
+
</ULink>
|
|
33
|
+
</header>
|
|
34
|
+
<ul
|
|
35
|
+
v-if="recentOrders.length"
|
|
36
|
+
class="divide-y divide-(--ui-border)"
|
|
37
|
+
>
|
|
38
|
+
<li
|
|
39
|
+
v-for="order in recentOrders"
|
|
40
|
+
:key="order.id"
|
|
41
|
+
>
|
|
42
|
+
<NuxtLink
|
|
43
|
+
:to="localePath(`/account/orders/${order.id}`)"
|
|
44
|
+
class="flex flex-wrap items-center gap-x-4 gap-y-1 px-4 sm:px-5 py-3
|
|
45
|
+
hover:bg-elevated/40 transition-colors"
|
|
46
|
+
>
|
|
47
|
+
<span class="text-sm font-semibold text-highlighted">{{ order.id }}</span>
|
|
48
|
+
<span class="text-xs text-muted">{{ formatDate(order.date) }}</span>
|
|
49
|
+
<span class="flex items-center gap-3 ms-auto">
|
|
50
|
+
<UBadge
|
|
51
|
+
:color="statusColors[order.status]"
|
|
52
|
+
variant="subtle"
|
|
53
|
+
size="sm"
|
|
54
|
+
:label="t(`orders.status.${order.status}`)"
|
|
55
|
+
/>
|
|
56
|
+
<span class="text-sm tabular-nums text-highlighted min-w-20 text-right">
|
|
57
|
+
{{ formatCurrency(order.total) }}
|
|
58
|
+
</span>
|
|
59
|
+
</span>
|
|
60
|
+
</NuxtLink>
|
|
61
|
+
</li>
|
|
62
|
+
</ul>
|
|
63
|
+
<p
|
|
64
|
+
v-else
|
|
65
|
+
class="px-4 sm:px-5 py-6 text-sm text-muted"
|
|
66
|
+
>
|
|
67
|
+
{{ t('account.dashboard.noOrders') }}
|
|
68
|
+
</p>
|
|
69
|
+
</section>
|
|
70
|
+
</template>
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/** Dashboard widget: open requisitions awaiting action. */
|
|
3
|
+
const localePath = useLocalePath();
|
|
4
|
+
const {
|
|
5
|
+
t,
|
|
6
|
+
formatCurrency,
|
|
7
|
+
openRequisitions,
|
|
8
|
+
requisitionsPending,
|
|
9
|
+
} = useAccountDashboard();
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<template>
|
|
13
|
+
<USkeleton
|
|
14
|
+
v-if="requisitionsPending"
|
|
15
|
+
class="h-72 w-full rounded-xl"
|
|
16
|
+
/>
|
|
17
|
+
<section
|
|
18
|
+
v-else
|
|
19
|
+
class="border border-(--ui-border) rounded-xl overflow-hidden"
|
|
20
|
+
>
|
|
21
|
+
<header class="flex items-center justify-between px-4 sm:px-5 py-3 bg-elevated/60 border-b border-(--ui-border)">
|
|
22
|
+
<h2 class="text-sm font-semibold text-highlighted">
|
|
23
|
+
{{ t('account.dashboard.openRequisitions') }}
|
|
24
|
+
</h2>
|
|
25
|
+
<ULink
|
|
26
|
+
class="text-xs font-medium text-primary hover:underline"
|
|
27
|
+
:to="localePath('/account/requisitions')"
|
|
28
|
+
>
|
|
29
|
+
{{ t('account.dashboard.viewAll') }} →
|
|
30
|
+
</ULink>
|
|
31
|
+
</header>
|
|
32
|
+
<ul
|
|
33
|
+
v-if="openRequisitions.length"
|
|
34
|
+
class="divide-y divide-(--ui-border)"
|
|
35
|
+
>
|
|
36
|
+
<li
|
|
37
|
+
v-for="requisition in openRequisitions"
|
|
38
|
+
:key="requisition.id"
|
|
39
|
+
>
|
|
40
|
+
<NuxtLink
|
|
41
|
+
:to="localePath(`/account/requisitions/${requisition.id}`)"
|
|
42
|
+
class="flex flex-wrap items-center gap-x-4 gap-y-1 px-4 sm:px-5 py-3
|
|
43
|
+
hover:bg-elevated/40 transition-colors"
|
|
44
|
+
>
|
|
45
|
+
<span class="text-sm font-semibold text-highlighted">{{ requisition.id }}</span>
|
|
46
|
+
<span class="text-xs text-muted">{{ requisition.requestedBy.name }}</span>
|
|
47
|
+
<span class="text-sm tabular-nums text-highlighted ms-auto">
|
|
48
|
+
{{ formatCurrency(requisition.totalValue) }}
|
|
49
|
+
</span>
|
|
50
|
+
</NuxtLink>
|
|
51
|
+
</li>
|
|
52
|
+
</ul>
|
|
53
|
+
<p
|
|
54
|
+
v-else
|
|
55
|
+
class="px-4 sm:px-5 py-6 text-sm text-muted"
|
|
56
|
+
>
|
|
57
|
+
{{ t('account.dashboard.noRequisitions') }}
|
|
58
|
+
</p>
|
|
59
|
+
</section>
|
|
60
|
+
</template>
|