From c4a9f49c477d2c795a43ad310b9e3dc8f5fe212b Mon Sep 17 00:00:00 2001 From: Valtteri Kantanen Date: Fri, 23 Aug 2024 16:18:08 +0300 Subject: [PATCH] [Class statistics] Fix page crashing if no correct study right is found --- .../StudentTable/GeneralTab/GeneralTab.jsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/services/frontend/src/components/PopulationStudents/StudentTable/GeneralTab/GeneralTab.jsx b/services/frontend/src/components/PopulationStudents/StudentTable/GeneralTab/GeneralTab.jsx index 2d654f0d82..72a5e2108f 100644 --- a/services/frontend/src/components/PopulationStudents/StudentTable/GeneralTab/GeneralTab.jsx +++ b/services/frontend/src/components/PopulationStudents/StudentTable/GeneralTab/GeneralTab.jsx @@ -113,12 +113,15 @@ export const GeneralTab = ({ const transferFrom = student => getTextIn(populationStatistics.elementdetails.data[student.transferSource].name) const getCorrectStudyRight = studyRights => - studyRights.find(studyRight => + studyRights?.find(studyRight => cleanedQueryStudyrights.some(code => studyRight.studyRightElements.some(element => element.code === code)) ) const getStudyTracks = studyRights => { const correctStudyRight = getCorrectStudyRight(studyRights) + if (!correctStudyRight) { + return [] + } return cleanedQueryStudyrights.reduce((acc, code) => { const element = correctStudyRight.studyRightElements.find(element => element.code === code) const studyTrack = element?.studyTrack ? getTextIn(element.studyTrack.name) : null