diff --git a/src/components/dashboard/chart-surat.tsx b/src/components/dashboard/chart-surat.tsx index 18b1535..e8c759c 100644 --- a/src/components/dashboard/chart-surat.tsx +++ b/src/components/dashboard/chart-surat.tsx @@ -36,19 +36,21 @@ export function ChartSurat() { async function fetchTrends() { try { const res = await apiClient.GET("/api/complaint/service-trends"); - console.log("Service trends response:", res); - if (res.data?.data) { + console.log("📊 Service trends response:", res); + + if (res.data?.data && res.data.data.length > 0) { const chartData = (res.data.data as { month: string; count: number }[]).map((d) => ({ month: d.month, value: Number(d.count), })); - console.log("Mapped chart data:", chartData); + console.log("📈 Mapped chart data:", chartData); setData(chartData); } else { - console.log("No data in response"); + console.log("⚠️ No data in response or empty data array"); + setData([]); } } catch (error) { - console.error("Failed to fetch service trends", error); + console.error("❌ Failed to fetch service trends", error); } finally { setLoading(false); } @@ -101,46 +103,55 @@ export function ChartSurat() { - + {loading ? ( + ) : data.length > 0 ? ( + + + + + + + + + ) : ( - - - - - - - + + + Tidak ada data pengajuan surat 6 bulan terakhir + + )} - + ); }