Skip to content

Commit

Permalink
[Class statistics] Fix study track selection
Browse files Browse the repository at this point in the history
  • Loading branch information
rikurauhala committed May 2, 2024
1 parent b42f873 commit 6c86bf9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Dropdown, Form } from 'semantic-ui-react'
import { useLanguage } from '@/components/LanguagePicker/useLanguage'
import { createFilter } from './createFilter'

const StudyTrackFilterCard = ({ options, onOptionsChange, withoutSelf, activeAt, code }) => {
const StudyTrackFilterCard = ({ activeAt, code, onOptionsChange, options, withoutSelf }) => {
const { selected } = options
const { getTextIn } = useLanguage()

Expand Down Expand Up @@ -72,7 +72,7 @@ export const studyTrackFilter = createFilter({
defaultOptions: {
selected: [],
},
isActive: ({ selected }) => selected.length > 0,
isActive: ({ selected }) => (selected !== undefined ? selected.length > 0 : false),
filter: (student, { selected, args }) => {
const activeAt = _.get(args, 'activeAt', moment())

Expand Down
10 changes: 9 additions & 1 deletion services/frontend/src/components/PopulationStatistics/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,10 @@ export const PopulationStatistics = () => {
const noStudentsMessage = () => (
<div style={{ maxWidth: '80%' }}>
<Message
content="Choose “Advanced settings” below and make sure you have the correct student groups included in the class. For example, if you are looking for students of a specialist training in medicine or dentistry, you must choose “Students with non-degree study right”."
content={`
Choose “Advanced settings” below and make sure you have the correct student groups included
in the class. For example, if you are looking for students of a specialist training in
medicine or dentistry, you must choose “Students with non-degree study right”.`}
header="Not seeing any students?"
icon="question"
info
Expand All @@ -160,6 +163,8 @@ export const PopulationStatistics = () => {
</div>
)

const selected = query?.studyRights?.studyTrack ? [query?.studyRights?.studyTrack] : undefined

return (
<FilterView
displayTray={location.search !== ''}
Expand All @@ -171,6 +176,9 @@ export const PopulationStatistics = () => {
[hopsFilter.key]: {
studyStart: (students[0] || {}).studyrightStart,
},
[studyTrackFilter.key]: {
selected,
},
}}
name="PopulationStatistics"
students={students}
Expand Down

0 comments on commit 6c86bf9

Please sign in to comment.