mirror of
https://github.com/hay-kot/homebox.git
synced 2024-11-28 19:45:41 +00:00
b77c9be36f
* bump prettier/eslint-plugin * bump nuxt pwa * use typed imports * set vue version to fix layout errors * disable import
39 lines
883 B
TypeScript
39 lines
883 B
TypeScript
import type { UserClient } from "~~/lib/api/user";
|
|
|
|
type StatCard = {
|
|
label: string;
|
|
value: number;
|
|
type: "currency" | "number";
|
|
};
|
|
|
|
export function statCardData(api: UserClient) {
|
|
const { data: statistics } = useAsyncData(async () => {
|
|
const { data } = await api.stats.group();
|
|
return data;
|
|
});
|
|
|
|
return computed(() => {
|
|
return [
|
|
{
|
|
label: "Total Value",
|
|
value: statistics.value?.totalItemPrice || 0,
|
|
type: "currency",
|
|
},
|
|
{
|
|
label: "Total Items",
|
|
value: statistics.value?.totalItems || 0,
|
|
type: "number",
|
|
},
|
|
{
|
|
label: "Total Locations",
|
|
value: statistics.value?.totalLocations || 0,
|
|
type: "number",
|
|
},
|
|
{
|
|
label: "Total Labels",
|
|
value: statistics.value?.totalLabels || 0,
|
|
type: "number",
|
|
},
|
|
] as StatCard[];
|
|
});
|
|
}
|