From f790ad065bd14c3d44bc345122cf812d653e82cc Mon Sep 17 00:00:00 2001 From: Hayden <64056131+hay-kot@users.noreply.github.com> Date: Thu, 22 Dec 2022 18:53:04 -0900 Subject: [PATCH] improve UI log --- frontend/components/global/Currency.vue | 2 +- frontend/components/global/StatCard.vue | 1 + frontend/pages/item/[id]/index/log.vue | 12 +++++++++--- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/frontend/components/global/Currency.vue b/frontend/components/global/Currency.vue index 38a2f6f..2538c1c 100644 --- a/frontend/components/global/Currency.vue +++ b/frontend/components/global/Currency.vue @@ -13,7 +13,7 @@ const value = computed(() => { if (!props.amount || props.amount === "0") { - return ""; + return fmt(0); } return fmt(props.amount); diff --git a/frontend/components/global/StatCard.vue b/frontend/components/global/StatCard.vue index 4027e02..6ce2429 100644 --- a/frontend/components/global/StatCard.vue +++ b/frontend/components/global/StatCard.vue @@ -23,5 +23,6 @@ withDefaults(defineProps(), { type: "number", + subtitle: undefined, }); diff --git a/frontend/pages/item/[id]/index/log.vue b/frontend/pages/item/[id]/index/log.vue index 0e76ad5..ff590d8 100644 --- a/frontend/pages/item/[id]/index/log.vue +++ b/frontend/pages/item/[id]/index/log.vue @@ -21,12 +21,12 @@ { id: "total", title: "Total Cost", - value: log.value.costTotal, + value: log.value.costTotal || 0, }, { id: "average", title: "Monthly Average", - value: log.value.costAverage, + value: log.value.costAverage || 0, }, ]; }); @@ -61,14 +61,20 @@ refreshLog(); } + const confirm = useConfirm(); + async function deleteEntry(id: string) { + const result = await confirm.open("Are you sure you want to delete this entry?"); + if (result.isCanceled) { + return; + } + const { error } = await api.items.maintenance.delete(props.item.id, id); if (error) { toast.error("Failed to delete entry"); return; } - refreshLog(); }