fix: StudentReport Page 리포트카드 안나오는거 수정 시험 한번도 안 본 상태에서 접근 시 에러 안나게 변경

This commit is contained in:
minwucho 2024-08-09 16:35:08 +09:00
parent 8b82681089
commit 7b972cf4f8

View File

@ -9,11 +9,10 @@ export default function StudentReportPage() {
const { lectureId } = useParams();
const { data } = useStudentReports(lectureId);
const reports = data?.data;
console.log(reports);
const totalCounts = reports.reduce?.(
(acc, report) => {
if (acc.allCount > 0) {
if (report.allCount > 0) {
acc.correctCount += report.correctCount;
acc.allCount += report.allCount;
}
@ -27,6 +26,7 @@ export default function StudentReportPage() {
title="퀴즈 성적"
canCreate={false}
>
{totalCounts && (
<div className={styles.wrapper}>
<div className={styles.LinksContainer}>
{reports.map?.((report) => (
@ -45,6 +45,7 @@ export default function StudentReportPage() {
/>
</div>
</div>
)}
</ArticleBoard>
);
}