-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathResult_info.js
65 lines (60 loc) · 1.59 KB
/
Result_info.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
import React, { Component } from 'react'
import { connect } from 'react-redux'
import { Card, CardHeader, CardText } from 'material-ui/Card'
import Chart from '../components/Chart'
import Reward from './Reward'
class Result_info extends Component {
constructor(props) {
super(props)
this.state = {
expanded: true
}
}
changeExpanded(expanded){
this.setState({expanded: expanded})
}
render(){
const {results , id} = this.props
const { expanded } = this.state
const sum = results.sum
const inputs = results.inputs
const participants = results.participants
const round = results.round
const number = (id in participants)?participants[id].number:0
const inputed = (id in participants)?participants[id].inputed:false
return (
<div>
<p>全員の投票の平均値は{Math.round(sum/inputs*10)/10}でした。<br/>
報酬の基準値は{Math.round(sum*2/inputs/3)}({Math.round(sum*2/inputs/3*10)/10}を四捨五入)です。</p>
{
inputed
? <span><p>あなたが入力した値は{number}でした。</p></span>
: <span></span>
}
<Card
expanded = {expanded}
onExpandChange = {this.changeExpanded.bind(this)}
>
<CardHeader
title={"グラフ"}
actAsExpander={true}
showExpandableButton={true}
/>
<CardText expandable={true}>
<Chart
participants = {participants}
/>
</CardText>
</Card>
<br/>
<Reward
results = {results}
number = {number}
inputed = {inputed}
id = {id}
/>
</div>
)
}
}
export default Result_info