Files
homebox/frontend/pages/home/statistics.ts
Tonya d4e28e6f3b Upgrade frontend deps, including nuxt (#982)
* feat: begin upgrading deps, still very buggy

* feat: progress

* feat: sort all type issues

* fix: sort type issues

* fix: import sonner styles

* fix: nuxt is the enemy

* fix: try sorting issue with workflows

* fix: update vitest config for dynamic import of path and defineConfig

* fix: add missing import

* fix: add time out to try and fix issues

* fix: add ui:ci:preview task for frontend build in CI mode

* fix: i was silly

* feat: add go:ci:with-frontend task for CI mode and remove ui:ci:preview from e2e workflow

* fix: update baseURL in Playwright config for local testing to use port 7745

* fix: update E2E_BASE_URL and remove wait for timeout in login test for smoother execution
2025-09-04 09:00:25 +01:00

49 lines
1.0 KiB
TypeScript

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(
"statistics",
async () => {
const { data } = await api.stats.group();
return data;
},
{
deep: true,
}
);
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[];
});
}