diff --git a/src/pages/Index.vue b/src/pages/Index.vue index 481971c..5e06308 100755 --- a/src/pages/Index.vue +++ b/src/pages/Index.vue @@ -74,18 +74,18 @@
this week
- +
- Revenue + Tomorrow
- +
-
${{ formatNumber(total_profit_past_week) }}
-
this week
+
{{ countsStore.tomorrow }}
+
deliveries scheduled
@@ -251,6 +251,7 @@ import { useRouter } from 'vue-router' import axios from 'axios' import authHeader from '../services/auth.header' import { deliveryService } from '../services/deliveryService' +import { useCountsStore } from '../stores/counts' import { DeliveryMapItem } from '../types/models' import "leaflet/dist/leaflet.css" import { LMap, LTileLayer, LMarker, LPopup } from "@vue-leaflet/vue-leaflet" @@ -282,11 +283,13 @@ ChartJS.register( // Router const router = useRouter() +// Stores +const countsStore = useCountsStore() + // Reactive data const delivery_count = ref(0) const delivery_count_delivered = ref(0) const total_gallons_past_week = ref(0) -const total_profit_past_week = ref(0) const total_deliveries = ref(0) const user = ref({ user_id: 0, @@ -423,7 +426,8 @@ onMounted(() => { today_delivery_count() today_delivery_delivered() totalgallonsweek() - totalprofitweek() + totaldeliveriesweek() + countsStore.fetchSidebarCounts() fetchMapDeliveries() fetchWeeklyChartData() }) @@ -500,8 +504,8 @@ const totalgallonsweek = () => { }) } -const totalprofitweek = () => { - const path = import.meta.env.VITE_BASE_URL + '/money/profit/week' +const totaldeliveriesweek = () => { + const path = import.meta.env.VITE_BASE_URL + '/stats/delivery/count/week' axios({ method: "get", url: path, @@ -509,8 +513,20 @@ const totalprofitweek = () => { headers: authHeader(), }) .then((response: any) => { - total_profit_past_week.value = response.data.total_profit - total_deliveries.value = response.data.total_deliveries + total_deliveries.value = response.data.data || response.data.total || 0 + }) + .catch(() => { + // Fallback: use the money endpoint but only extract deliveries count + const fallbackPath = import.meta.env.VITE_BASE_URL + '/money/profit/week' + axios({ + method: "get", + url: fallbackPath, + withCredentials: true, + headers: authHeader(), + }) + .then((response: any) => { + total_deliveries.value = response.data.total_deliveries || 0 + }) }) }