Commit 4467b3b7 authored by Adrià Labay's avatar Adrià Labay
Browse files

fix search navigation in student view

parent dffb81cd
......@@ -67,7 +67,7 @@ class SearchBox extends React.Component {
event.target.select()
}
onSuggestionSelected = (event, { suggestion }) => {
this.props.setSelected(suggestion.id)
this.props.setSelected(suggestion)
}
// Autosuggest will call this function every time you need to update suggestions.
......
......@@ -61,6 +61,7 @@ class Email extends React.Component {
examID={this.props.examID}
selectedStudent={this.state.selectedStudent}
setStudent={student => {
console.log(student)
this.setState({
selectedStudent: student
})
......
......@@ -78,6 +78,10 @@ class CheckStudents extends React.Component {
}
}
selectCopy = (copy) => {
this.setCopyIndex(this.state.copies.findIndex((c) => c.number === copy.number))
}
prev = () => {
this.setCopyIndex(this.state.index - 1)
}
......@@ -180,7 +184,7 @@ class CheckStudents extends React.Component {
'student.lastName',
'student.id'
]}
setSelected={this.setCopyIndex}
setSelected={this.selectCopy}
renderSelected={({number, student}) => {
if (student) {
return `#${number}: ${student.firstName} ${student.lastName} (${student.id})`
......
......@@ -67,9 +67,8 @@ class StudentControls extends React.Component {
'firstName',
'lastName'
]}
setSelected={studentID => {
const idx = this.state.students.findIndex(s => s.id === studentID)
this.props.setStudent(this.state.students[idx])
setSelected={student => {
this.props.setStudent(student)
}}
renderSelected={(student) => (
student !== null
......
......@@ -2,6 +2,10 @@ import React from 'react'
import SearchBox from '../../components/SearchBox.jsx'
class GradeNavigation extends React.Component {
setSubmission = (submission) => {
this.props.setSubmission(submission.id)
}
render () {
const submission = this.props.submission
const submissions = this.props.submissions
......@@ -26,7 +30,7 @@ class GradeNavigation extends React.Component {
data-tooltip='Press ctrl to hide shortcuts'>
<SearchBox
placeholder='Search for a submission'
setSelected={this.props.setSubmission}
setSelected={this.setSubmission}
selected={submission}
options={submissions}
suggestionKeys={(this.props.anonymous ? ['id'] : [
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment