Skip to content

Commit

Permalink
[Class statistics] Fix page crashing if no correct study right is found
Browse files Browse the repository at this point in the history
  • Loading branch information
valtterikantanen committed Aug 23, 2024
1 parent 54728c3 commit c4a9f49
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c4a9f49

Please sign in to comment.