18098707d1
Fixed image loading with said api
36 lines
1.3 KiB
JavaScript
36 lines
1.3 KiB
JavaScript
import {Component} from "react";
|
|
|
|
export default class ScoreStats extends Component {
|
|
|
|
constructor(params) {
|
|
super(params);
|
|
}
|
|
|
|
getAverage(values) {
|
|
return values.reduce((p, c) => p + c, 0) / values.length;
|
|
}
|
|
|
|
render() {
|
|
const data = this.props.data;
|
|
|
|
return <div className={'score-stats'}>
|
|
<div className={'score-stats-info'}>
|
|
<p>{data.percentage}</p>
|
|
<p>{data.currentScore.toLocaleString()}</p>
|
|
</div>
|
|
<p className={'score-stats-average-cut'}>Average Cut</p>
|
|
<div className={'score-stats-hands'}>
|
|
<div className={'score-stats-left'}>
|
|
<p>{this.getAverage(data.leftHand.averagePreSwing).toFixed(2)}</p>
|
|
<p>{this.getAverage(data.leftHand.averagePostSwing).toFixed(2)}</p>
|
|
<p>{this.getAverage(data.leftHand.averageCut).toFixed(2)}</p>
|
|
</div>
|
|
<div className={'score-stats-right'}>
|
|
<p>{this.getAverage(data.rightHand.averagePreSwing).toFixed(2)}</p>
|
|
<p>{this.getAverage(data.rightHand.averagePostSwing).toFixed(2)}</p>
|
|
<p>{this.getAverage(data.rightHand.averageCut).toFixed(2)}</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
}
|
|
} |