Added totals to delivery

This commit is contained in:
2026-01-05 09:14:13 -05:00
parent 65cfd0c463
commit 68f5b6eafc
3 changed files with 97 additions and 4 deletions

View File

@@ -19,6 +19,18 @@
<div class="divider"></div>
<!-- Total Gallons -->
<div v-if="grand_total > 0 || totals.length > 0" class="mb-4">
<div v-if="grand_total > 0" class="mb-2">
<span class="badge badge-accent">Total: {{ grand_total }}</span>
</div>
<div class="flex flex-wrap gap-2">
<span v-for="total in totals" :key="total.town" class="badge badge-primary">
{{ total.town }}: {{ total.gallons }}
</span>
</div>
</div>
<!-- DESKTOP VIEW: Table -->
<div class="overflow-x-auto hidden xl:block">
<table class="table w-full">
@@ -168,7 +180,9 @@ export default defineComponent({
return {
token: null,
user: null,
deliveries: [] as any[],
deliveries: [] as any[],
totals: [] as any[],
grand_total: 0,
page: 1,
perPage: 50,
recordsLength: 0,
@@ -184,6 +198,7 @@ export default defineComponent({
},
mounted() {
this.getPage(this.page)
this.get_totals()
},
methods: {
getPage: function (page: any) {
@@ -219,6 +234,22 @@ export default defineComponent({
})
},
get_totals() {
let path = import.meta.env.VITE_BASE_URL + '/deliverystatus/tomorrow-totals';
axios({
method: 'get',
url: path,
headers: authHeader(),
}).then((response: any) => {
this.totals = response.data.totals || []
this.grand_total = response.data.grand_total || 0
}).catch((error: any) => {
console.error('Error fetching totals:', error);
this.totals = []
this.grand_total = 0
})
},
deleteCall(delivery_id: any) {
let path = import.meta.env.VITE_BASE_URL + '/delivery/delete/' + delivery_id;
axios({