diff --git a/src/app/(protected)/dashboard/student/dashboard/page.tsx b/src/app/(protected)/dashboard/student/dashboard/page.tsx index 2db7818..4c90a1a 100644 --- a/src/app/(protected)/dashboard/student/dashboard/page.tsx +++ b/src/app/(protected)/dashboard/student/dashboard/page.tsx @@ -94,6 +94,12 @@ export default function StudentDashboard() { errorPieChartData, } = data; const COLORS = ["#4CAF50", "#FFC107"]; + const EMPTY_CHART_COLOR = "#E5E7EB"; + const hasCompletionRecord = completionData.completed > 0; + const hasErrorChartData = errorPieChartData.some((item) => item.value > 0); + const normalizedErrorPieChartData = hasErrorChartData + ? errorPieChartData + : [{ name: "暂无数据", value: 1 }]; return (
@@ -144,6 +150,11 @@ export default function StudentDashboard() {
+ {!hasCompletionRecord && ( +
+ 暂无完成记录 +
+ )} @@ -166,7 +177,7 @@ export default function StudentDashboard() { - {errorPieChartData.map( + {normalizedErrorPieChartData.map( ( entry: { name: string; value: number }, index: number ) => ( ) )} @@ -190,6 +205,11 @@ export default function StudentDashboard() { + {!hasErrorChartData && ( +
+ 暂无作答数据 +
+ )}