mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-09 00:08:18 +00:00
Production checklists, issue fixes
This commit is contained in:
@@ -13,10 +13,14 @@ export const dashboardApi = {
|
||||
const bookingsTotal = bookingsRes?.meta?.total || 0;
|
||||
const passengersTotal = passengersRes?.meta?.total || 0;
|
||||
|
||||
// Calculate revenue from bookings
|
||||
const allBookingsRes = await apiClient.get<any>('/bookings?pageSize=100');
|
||||
const allBookings = Array.isArray(allBookingsRes) ? allBookingsRes : allBookingsRes?.items || [];
|
||||
const totalRevenue = allBookings.reduce((sum: number, b: any) => sum + (b.totalMinor || 0), 0);
|
||||
// Calculate revenue from confirmed bookings only
|
||||
const confirmedRes = await apiClient.get<any>('/bookings?pageSize=1000&status=CONFIRMED');
|
||||
const boardedRes = await apiClient.get<any>('/bookings?pageSize=1000&status=BOARDED');
|
||||
const paidBookings = [
|
||||
...(Array.isArray(confirmedRes) ? confirmedRes : confirmedRes?.items || []),
|
||||
...(Array.isArray(boardedRes) ? boardedRes : boardedRes?.items || []),
|
||||
];
|
||||
const totalRevenue = paidBookings.reduce((sum: number, b: any) => sum + (b.totalMinor || 0), 0);
|
||||
|
||||
// Calculate average occupancy (placeholder - would need dedicated endpoint)
|
||||
const occupancyRate = Math.floor(Math.random() * 100); // Replace with actual data
|
||||
@@ -29,10 +33,9 @@ export const dashboardApi = {
|
||||
totalTripsToday: 0,
|
||||
activeTrips: 0,
|
||||
cancelledBookings: 0,
|
||||
averageTicketPrice: allBookings.length > 0 ? totalRevenue / allBookings.length : 0,
|
||||
averageTicketPrice: paidBookings.length > 0 ? Math.round(totalRevenue / paidBookings.length) : 0,
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch dashboard stats:', error);
|
||||
return {
|
||||
totalBookings: 0,
|
||||
totalRevenue: 0,
|
||||
@@ -51,7 +54,6 @@ export const dashboardApi = {
|
||||
const response = await apiClient.get<RevenueData[]>(`/dashboard/revenue?days=${days}`);
|
||||
return response;
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch revenue chart:', error);
|
||||
return [];
|
||||
}
|
||||
},
|
||||
@@ -82,7 +84,6 @@ export const dashboardApi = {
|
||||
paymentIntent: booking.paymentIntent,
|
||||
}));
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch recent bookings:', error);
|
||||
return [];
|
||||
}
|
||||
},
|
||||
@@ -92,7 +93,6 @@ export const dashboardApi = {
|
||||
const response = await apiClient.get<any[]>(`/agents/top?limit=${limit}`);
|
||||
return response || [];
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch top agents:', error);
|
||||
return [];
|
||||
}
|
||||
},
|
||||
@@ -102,7 +102,6 @@ export const dashboardApi = {
|
||||
const response = await apiClient.get<any[]>(`/dashboard/occupancy?days=${days}`);
|
||||
return response || [];
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch occupancy trend:', error);
|
||||
return [];
|
||||
}
|
||||
},
|
||||
@@ -112,7 +111,6 @@ export const dashboardApi = {
|
||||
const response = await apiClient.get<any[]>(`/schedules/upcoming?limit=${limit}`);
|
||||
return response || [];
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch upcoming trips:', error);
|
||||
return [];
|
||||
}
|
||||
},
|
||||
@@ -122,7 +120,6 @@ export const dashboardApi = {
|
||||
const response = await apiClient.get<any[]>('/dashboard/payment-methods');
|
||||
return response || [];
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch payment methods:', error);
|
||||
return [];
|
||||
}
|
||||
},
|
||||
@@ -137,7 +134,6 @@ export const dashboardApi = {
|
||||
loyaltyPoints: 0,
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch passenger stats:', error);
|
||||
return {
|
||||
totalPassengers: 0,
|
||||
newPassengersToday: 0,
|
||||
@@ -157,7 +153,6 @@ export const dashboardApi = {
|
||||
totalAmount: 0,
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch transaction summary:', error);
|
||||
return {
|
||||
totalTransactions: 0,
|
||||
successfulTransactions: 0,
|
||||
@@ -176,7 +171,6 @@ export const dashboardApi = {
|
||||
activePayments: 0,
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch live metrics:', error);
|
||||
return {
|
||||
onlineUsers: 0,
|
||||
activeBookings: 0,
|
||||
|
||||
@@ -5,7 +5,6 @@ import { PaginatedResponse } from '@edr/types';
|
||||
export const routesApi = {
|
||||
getAll: async () => {
|
||||
const response = await apiClient.get<any>('/routes');
|
||||
console.log('Routes API response:', response);
|
||||
// Handle both direct array and wrapped response
|
||||
if (Array.isArray(response)) {
|
||||
return { items: response };
|
||||
@@ -24,7 +23,6 @@ export const routesApi = {
|
||||
},
|
||||
|
||||
create: (data: any) => {
|
||||
console.log('Creating route with data:', JSON.stringify(data, null, 2));
|
||||
return apiClient.post<Route>('/routes', data);
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user