/
StudentSelector.jsx
42 lines (39 loc) · 1.12 KB
/
StudentSelector.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import React, { Component, PropTypes } from 'react';
import { dropdownStyles } from '@cdo/apps/templates/sectionProgress/ScriptSelector';
import { ALL_STUDENT_FILTER } from './sectionAssessmentsRedux';
import i18n from '@cdo/locale';
export default class StudentSelector extends Component {
static propTypes = {
studentList: PropTypes.array.isRequired,
studentId: PropTypes.number,
onChange: PropTypes.func.isRequired,
};
render() {
const { studentList, studentId, onChange } = this.props;
return (
<div>
<select
value={studentId}
onChange={event => onChange(parseInt(event.target.value))}
style={dropdownStyles.dropdown}
>
<option
key={ALL_STUDENT_FILTER}
value={ALL_STUDENT_FILTER}
>
{i18n.allStudents()}
</option>
{Object.values(studentList).map((student, index) => (
<option
key={student.id}
value={student.id}
>
{student.name}
</option>
))
}
</select>
</div>
);
}
}