Skip to content

Commit e34f4c1

Browse files
committed
fix: tenders table
1 parent c07217f commit e34f4c1

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

frontend/src/api/tenders.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,11 @@ export interface TenderStatistics {
9090
export const getTenderStatistics = async (): Promise<TenderStatistics[]> => {
9191
try {
9292
const response = await apiClient.get("/tenders/statistics");
93-
return response.data;
93+
return Array.isArray(response.data) ? response.data : [];
9494
} catch (error) {
95-
return handleApiError(error, "Fetch tender statistics");
95+
console.error("Failed to fetch tender statistics:", error);
96+
// Return empty array instead of throwing
97+
return [];
9698
}
9799
};
98100

frontend/src/components/dashboard/TableStatsGrid.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ export default function TableStatsGrid({ stats, loading = false }: TableStatsGri
4141
);
4242
}
4343

44+
// Guard against invalid stats data
45+
if (!Array.isArray(stats)) {
46+
console.error("TableStatsGrid: stats is not an array", stats);
47+
return null;
48+
}
49+
4450
// Create a map of stats for easy lookup
4551
const statsMap = new Map(stats.map(stat => [stat.source, stat]));
4652

0 commit comments

Comments
 (0)