-
-
Notifications
You must be signed in to change notification settings - Fork 126
/
Copy pathstatistics.ts
42 lines (38 loc) · 979 Bytes
/
statistics.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { useI18n } from "vue-i18n";
import type { UserClient } from "~~/lib/api/user";
type StatCard = {
label: string;
value: number;
type: "currency" | "number";
};
export function statCardData(api: UserClient) {
const { t } = useI18n();
const { data: statistics } = useAsyncData(async () => {
const { data } = await api.stats.group();
return data;
});
return computed(() => {
return [
{
label: t("home.total_value"),
value: statistics.value?.totalItemPrice || 0,
type: "currency",
},
{
label: t("home.total_items"),
value: statistics.value?.totalItems || 0,
type: "number",
},
{
label: t("home.total_locations"),
value: statistics.value?.totalLocations || 0,
type: "number",
},
{
label: t("home.total_labels"),
value: statistics.value?.totalLabels || 0,
type: "number",
},
] as StatCard[];
});
}