diff --git a/src/views/dashboards/superUserDashboard/InvoicingBillingPeriod/displays/layout/InvoicingBillingPeriodStatistics.vue b/src/views/dashboards/superUserDashboard/InvoicingBillingPeriod/displays/layout/InvoicingBillingPeriodStatistics.vue index debc5bfd..443289ae 100644 --- a/src/views/dashboards/superUserDashboard/InvoicingBillingPeriod/displays/layout/InvoicingBillingPeriodStatistics.vue +++ b/src/views/dashboards/superUserDashboard/InvoicingBillingPeriod/displays/layout/InvoicingBillingPeriodStatistics.vue @@ -35,7 +35,11 @@ const getResponsePayload = (response: any = {}) => { * Fixed pricing distribution data structure: */ const fixed_pricing_department_distribution = ref([]); +const fixedPricingDistributionLoaded = ref(false); +const fixedPricingDistributionFailed = ref(false); const fetchFixedPricingDistribution = async () => { + fixedPricingDistributionLoaded.value = false; + fixedPricingDistributionFailed.value = false; SessionUser.request( '/superuser/invoicing/period/distribution/fixed-pricing', 'GET', @@ -47,15 +51,20 @@ const fetchFixedPricingDistribution = async () => { if (response.data && response.data.includes.collective_fixed_pricing_results) { fixed_pricing_department_distribution.value = response.data.includes.collective_fixed_pricing_results; + fixedPricingDistributionLoaded.value = true; + fixedPricingDistributionFailed.value = false; /** * Fixed pricing distribution data structure: * { "total_fixed_price": 137962, "total_original_price": 72799, "total_department_totals": { "1": 11826, "2": 22687, "3": 17009, "4": 12457, "5": 1161, "6": 6611, "7": 1048 }, "total_department_totals_relative": { "1": 30962.876996916584, "2": 28790.813863868243, "3": 32997.60337384933, "4": 15442.430865260254, "5": 1407.808993176734, "6": 9521.78041528052, "7": 1010.6854916483431 }, "total_department_totals_parsed": { "Glostrup": 17009, "Taastrup": 22687, "Hvidovre": 11826, "Roskilde": 6611, "Køge": 12457, "Aarhus C": 1161, "Taulov": 1048 }, "total_department_totals_relative_parsed": { "Glostrup": 32997.60337384933, "Taastrup": 28790.813863868243, "Hvidovre": 30962.876996916584, "Roskilde": 9521.78041528052, "Køge": 15442.430865260254, "Aarhus C": 1407.808993176734, "Taulov": 1010.6854916483431 } } */ } else { console.error('Unexpected response structure:', response); + fixedPricingDistributionFailed.value = true; } }).catch((error) => { console.error('Error fetching fixed pricing distribution:', error); + fixedPricingDistributionLoaded.value = true; + fixedPricingDistributionFailed.value = true; }); } const clearFixedPricingDistribution = () => { @@ -134,7 +143,11 @@ watch( * Subscription display logic: */ const vehicleSubscriptionDistribution = ref(null); +const vehicleSubscriptionDistributionLoaded = ref(false); +const vehicleSubscriptionDistributionFailed = ref(false); const fetchVehicleSubscriptionDistribution = async () => { + vehicleSubscriptionDistributionLoaded.value = false; + vehicleSubscriptionDistributionFailed.value = false; SessionUser.request( '/superuser/invoicing/period/distribution/wash-subscriptions', 'GET', @@ -150,9 +163,12 @@ const fetchVehicleSubscriptionDistribution = async () => { vehicleSubscriptionDistribution.value = response.data.includes.collective_subscription_results; } else { console.error('Unexpected response structure:', response); + vehicleSubscriptionDistributionFailed.value = true; } }).catch((error) => { console.error('Error fetching vehicle subscription distribution:', error); + vehicleSubscriptionDistributionLoaded.value = true; + vehicleSubscriptionDistributionFailed.value = true; }); } const clearVehicleSubscriptionDistribution = () => {