-
Notifications
You must be signed in to change notification settings - Fork 0
/
Result.js
92 lines (80 loc) · 2.31 KB
/
Result.js
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import React, { Component } from 'react'
import { connect } from 'react-redux'
import throttle from 'react-throttle-render'
import Result_info from './Result_info'
import IconButton from 'material-ui/IconButton'
import KeyboardArrowLeft from 'material-ui/svg-icons/hardware/keyboard-arrow-left'
import KeyboardArrowRight from 'material-ui/svg-icons/hardware/keyboard-arrow-right'
const mapStateToProps = ({results,number,inputed,id,round}) => ({
results,number,inputed,id,round
})
class Result extends Component {
constructor(props) {
super(props)
this.state = {
page: 0
}
}
handleClickPrev(){
const { page } = this.state
const { round } = this.props
if(page < round-1) {
this.setState({
page: page+1
})
}
}
handleClickNext(){
const { page } = this.state
if(page > 0) {
this.setState({
page: page-1
})
}
}
render(){
const {results,number,inputed,id,round} = this.props
const {page} = this.state
console.log(page)
console.log(round)
console.log(!(page < round-1))
console.log(!(page > 0))
return (
<div>
<h2>実験結果</h2>
{(results.length > 0)
?
<span>
<IconButton
tooltip="Prev Result"
disabled = {!(page < round-1)}
onClick = {this.handleClickPrev.bind(this)}
>
<KeyboardArrowLeft />
</IconButton>
<IconButton
tooltip="Next Result"
style = {{
float:"right"
}}
disabled = {!(page > 0)}
onClick = {this.handleClickNext.bind(this)}
>
<KeyboardArrowRight />
</IconButton>
<p>第{results[page].round}ラウンドの結果</p>
{(results[page].inputs == 0)
? (<p>一人も投票していないので、結果を表示することができません</p>)
: <Result_info
results = {results[page]}
id = {id}
/>
}
</span>
: (<p>一回も実験を実施していないので、結果を表示することができません</p>)
}
</div>
)
}
}
export default connect(mapStateToProps)(throttle(Result, 200))