-
Notifications
You must be signed in to change notification settings - Fork 1
/
Training.js
128 lines (122 loc) · 3.63 KB
/
Training.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
import React from "react";
import {
Button,
CssBaseline,
Paper,
Grid,
Box,
Typography
} from "@material-ui/core";
import { withStyles } from "@material-ui/core/styles";
import styles from "./styles";
import Container from "@material-ui/core/Container";
import logo from "../../images/logo.png";
import { ArrowRight, ArrowLeft } from "@material-ui/icons";
import { Link } from "react-router-dom";
import Trophy from "../trophy/Trophy";
import { connect } from "react-redux";
class Training extends React.Component {
state = { trophy: false, achievement: "" };
componentDidMount() {
if (this.props.match.params.trainingId)
this.props.dispatch({
type: "WORKOUT",
payload: {
workoutList: this.props.workoutList,
trainingId: this.props.match.params.trainingId
}
});
}
finishWorkout = () => {
this.setState({
trophy: true,
achievement: "workout"
});
};
render() {
const { classes } = this.props;
if (this.state.trophy) {
return <Trophy achievement={this.state.achievement} />;
} else {
return (
<Container component="main" maxWidth="xs">
<CssBaseline />
<div className={classes.paper}>
<div className={classes.logo}>
<img src={logo} alt="IMP Trainer" />
</div>
{/* <Typography
className={classes.title}
component="h1"
variant="h5"
color="primary"
>
{this.props.workout.title}
</Typography> */}
<video
className={classes.video}
controls
autoPlay
src={this.props.workout.videoUrl}
/>
<Typography className={classes.title} component="p">
{this.props.workout.description}
</Typography>
<Grid container spacing={3}>
<Grid item xs={4}>
<Paper className={classes.grid}>
<p>Kcal</p>
<p>{this.props.workout.calories}</p>
</Paper>
</Grid>
<Grid item xs={4}>
<Paper className={classes.grid}>
<p>Time</p>
<p>{this.props.workout.totalTime * 0.0001}</p>
</Paper>
</Grid>
<Grid item xs={4}>
<Paper className={classes.grid}>
<p>Level</p>
<p>{this.props.workout.difficulty}</p>
</Paper>
</Grid>
</Grid>
{/* <Button
onClick={() => this.finishWorkout()}
fullWidth
variant="contained"
color="primary"
className={classes.submit}
>
<Done />
Done!
</Button>{" "}
*/}
<Grid style={{ height: "20px", width: "100%" }}></Grid>
<Grid container>
<Grid item xs>
<Link to="/dashboard" variant="body2">
<ArrowLeft className={classes.arrow} /> Dashboard
</Link>
</Grid>
<Grid item xs>
<Link to="/calendar" variant="body2">
My calendar <ArrowRight className={classes.arrow} />
</Link>
</Grid>
</Grid>
</div>
<Box mt={8}></Box>
</Container>
);
}
}
}
const mapStateToProps = state => {
return {
workout: state.workout,
workoutList: state.workoutList
};
};
export default withStyles(styles)(connect(mapStateToProps)(Training));