fk
This commit is contained in:
@@ -114,7 +114,7 @@ export const getCustomerDetailsServer = async (userId: string): Promise<Customer
|
||||
};
|
||||
|
||||
// Server-side platform stats function
|
||||
export async function getPlatformStatsServer(): Promise<any> {
|
||||
export async function getPlatformStatsServer() {
|
||||
try {
|
||||
// Try to fetch from server first
|
||||
const serverData = await fetchServer('/stats/platform')
|
||||
@@ -131,21 +131,31 @@ export async function getPlatformStatsServer(): Promise<any> {
|
||||
// If API call failed or returned empty data, use sample data
|
||||
console.info('Using sample stats data for demo');
|
||||
return {
|
||||
totalProducts: 243,
|
||||
totalVendors: 15,
|
||||
totalOrders: 1289,
|
||||
totalCustomers: 756,
|
||||
gmv: 38450
|
||||
orders: {
|
||||
completed: 1289
|
||||
},
|
||||
vendors: {
|
||||
total: 15
|
||||
},
|
||||
transactions: {
|
||||
volume: 38450,
|
||||
averageOrderValue: 29.83
|
||||
}
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('Error fetching platform stats (server):', error);
|
||||
// Return default stats to prevent UI breakage
|
||||
return {
|
||||
totalProducts: 0,
|
||||
totalVendors: 0,
|
||||
totalOrders: 0,
|
||||
totalCustomers: 0,
|
||||
gmv: 0
|
||||
orders: {
|
||||
completed: 0
|
||||
},
|
||||
vendors: {
|
||||
total: 0
|
||||
},
|
||||
transactions: {
|
||||
volume: 0,
|
||||
averageOrderValue: 0
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user