improve UI log

This commit is contained in:
Hayden 2022-12-22 18:53:04 -09:00
parent b9a2abd281
commit f790ad065b
No known key found for this signature in database
GPG key ID: 17CF79474E257545
3 changed files with 11 additions and 4 deletions

View file

@ -13,7 +13,7 @@
const value = computed(() => { const value = computed(() => {
if (!props.amount || props.amount === "0") { if (!props.amount || props.amount === "0") {
return ""; return fmt(0);
} }
return fmt(props.amount); return fmt(props.amount);

View file

@ -23,5 +23,6 @@
withDefaults(defineProps<Props>(), { withDefaults(defineProps<Props>(), {
type: "number", type: "number",
subtitle: undefined,
}); });
</script> </script>

View file

@ -21,12 +21,12 @@
{ {
id: "total", id: "total",
title: "Total Cost", title: "Total Cost",
value: log.value.costTotal, value: log.value.costTotal || 0,
}, },
{ {
id: "average", id: "average",
title: "Monthly Average", title: "Monthly Average",
value: log.value.costAverage, value: log.value.costAverage || 0,
}, },
]; ];
}); });
@ -61,14 +61,20 @@
refreshLog(); refreshLog();
} }
const confirm = useConfirm();
async function deleteEntry(id: string) { 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); const { error } = await api.items.maintenance.delete(props.item.id, id);
if (error) { if (error) {
toast.error("Failed to delete entry"); toast.error("Failed to delete entry");
return; return;
} }
refreshLog(); refreshLog();
} }
</script> </script>