|
@@ -2,6 +2,7 @@ import React from 'react';
|
|
import { connect } from "react-redux";
|
|
import { connect } from "react-redux";
|
|
|
|
|
|
import { getUserInfo } from "../../actions/getUserInfo";
|
|
import { getUserInfo } from "../../actions/getUserInfo";
|
|
|
|
+import { getResults } from "../../actions/getResults";
|
|
|
|
|
|
import './profile.scss';
|
|
import './profile.scss';
|
|
|
|
|
|
@@ -13,13 +14,12 @@ import Sidebar from '../../components/sidebar/Sidebar';
|
|
export class Profile extends React.Component {
|
|
export class Profile extends React.Component {
|
|
componentDidMount() {
|
|
componentDidMount() {
|
|
this.props.getUserInfo(JSON.parse(localStorage.user).user._id)
|
|
this.props.getUserInfo(JSON.parse(localStorage.user).user._id)
|
|
|
|
+ this.props.getResults();
|
|
}
|
|
}
|
|
|
|
|
|
render() {
|
|
render() {
|
|
- //console.log('profileUser',JSON.parse(localStorage.user).user._id);
|
|
|
|
- //const user = JSON.parse(localStorage.user).user;
|
|
|
|
- const { user } = this.props;
|
|
|
|
- //console.log('user',user);
|
|
|
|
|
|
+ const { user, results } = this.props;
|
|
|
|
+ const userResult = results.filter(result => result.eventUser.email === user.email);
|
|
|
|
|
|
return (
|
|
return (
|
|
<>
|
|
<>
|
|
@@ -62,43 +62,31 @@ export class Profile extends React.Component {
|
|
<input id="tab1" type="radio" name="tabs" checked readOnly hidden/>
|
|
<input id="tab1" type="radio" name="tabs" checked readOnly hidden/>
|
|
<label htmlFor="tab1" className="tab-label">History</label>
|
|
<label htmlFor="tab1" className="tab-label">History</label>
|
|
|
|
|
|
- {/*<input id="tab2" type="radio" name="tabs" readOnly hidden/>
|
|
|
|
- <label htmlFor="tab2" className="tab-label">Settings</label>*/}
|
|
|
|
-
|
|
|
|
<div className="tab-item" id="content1">
|
|
<div className="tab-item" id="content1">
|
|
<div className="history">
|
|
<div className="history">
|
|
- {/* название ивента, дистанция, время, место */}
|
|
|
|
<table>
|
|
<table>
|
|
<thead>
|
|
<thead>
|
|
<tr>
|
|
<tr>
|
|
<th>Event</th>
|
|
<th>Event</th>
|
|
<th>Distance</th>
|
|
<th>Distance</th>
|
|
<th>Time</th>
|
|
<th>Time</th>
|
|
- <th>Rating</th>
|
|
|
|
|
|
+ <th>Event type</th>
|
|
</tr>
|
|
</tr>
|
|
</thead>
|
|
</thead>
|
|
<tbody>
|
|
<tbody>
|
|
- <tr>
|
|
|
|
- <td>ULTRA MARATHON OF THE ATLANTIC 2019</td>
|
|
|
|
- <td>marathone</td>
|
|
|
|
- <td>3h40</td>
|
|
|
|
- <td>39</td>
|
|
|
|
- </tr>
|
|
|
|
- <tr>
|
|
|
|
- <td>CORFU HALF MARATHON</td>
|
|
|
|
- <td>Half marathone</td>
|
|
|
|
- <td>2h30</td>
|
|
|
|
- <td>30</td>
|
|
|
|
- </tr>
|
|
|
|
|
|
+ {
|
|
|
|
+ userResult.length !== 0 ? userResult.map(result => <tr key={result._id}>
|
|
|
|
+ <td>{result.event.title}</td>
|
|
|
|
+ <td>{result.eventUser.distance}</td>
|
|
|
|
+ <td>{result.time}</td>
|
|
|
|
+ <td>{result.event.eventType}</td>
|
|
|
|
+ </tr>
|
|
|
|
+ ) : <tr><td colSpan="5"><p className="not-found">Not found results</p></td></tr>
|
|
|
|
+ }
|
|
</tbody>
|
|
</tbody>
|
|
</table>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
-
|
|
|
|
- {/*<div className="tab-item" id="content2">
|
|
|
|
- <div className="settings">
|
|
|
|
- </div>
|
|
|
|
- </div>*/}
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@@ -109,11 +97,12 @@ export class Profile extends React.Component {
|
|
|
|
|
|
const mapStateToProps = state => {
|
|
const mapStateToProps = state => {
|
|
return {
|
|
return {
|
|
- user: state.userInfo.userProfile
|
|
|
|
|
|
+ user: state.userInfo.userProfile,
|
|
|
|
+ results: state.results.results
|
|
};
|
|
};
|
|
};
|
|
};
|
|
|
|
|
|
export default connect(
|
|
export default connect(
|
|
mapStateToProps,
|
|
mapStateToProps,
|
|
- { getUserInfo }
|
|
|
|
|
|
+ { getUserInfo, getResults }
|
|
)(Profile);
|
|
)(Profile);
|