|
@@ -1,7 +1,7 @@
|
|
|
import React, { Component } from "react";
|
|
|
import { connect } from "react-redux";
|
|
|
-import {getEvents, getEventByTitle} from "../../actions/adminMainPageActions";
|
|
|
-import {getRegistredUsers, resultsPromiseAll} from "../../actions/adminResultsActions";
|
|
|
+import { getEvents, getEventByTitle } from "../../actions/adminMainPageActions";
|
|
|
+import { getRegistredUsers, resultsPromiseAll } from "../../actions/adminResultsActions";
|
|
|
import AdminHeader from "../../components/adminHeader/adminHeader";
|
|
|
import ResultsForm from "../../components/adminResults/adminResultsForm";
|
|
|
import ConfirmationMessage from "../../components/confirmationMessage/confirmationMessage";
|
|
@@ -9,15 +9,16 @@ import ConfirmationMessage from "../../components/confirmationMessage/confirmati
|
|
|
class AdminResultstPage extends Component {
|
|
|
state = {
|
|
|
confirmationMessageFlag: false
|
|
|
- };
|
|
|
+ };
|
|
|
|
|
|
- componentDidMount() {
|
|
|
+ componentDidMount() {
|
|
|
this.props.getEvents();
|
|
|
}
|
|
|
|
|
|
showConfirmationMessage = () => {
|
|
|
- this.setState({confirmationMessageFlag: true })
|
|
|
+ this.setState({ confirmationMessageFlag: true })
|
|
|
};
|
|
|
+
|
|
|
closeConfirmationMessage = () => {
|
|
|
this.setState({ confirmationMessageFlag: false })
|
|
|
};
|
|
@@ -25,11 +26,11 @@ class AdminResultstPage extends Component {
|
|
|
submitHandler = values => {
|
|
|
const results = Object.keys(values).slice(2)
|
|
|
.map(elem => elem = {
|
|
|
- eventUser: elem,
|
|
|
- event: this.props.eventusers.find( user => user._id === elem).event[0],
|
|
|
+ eventUser: elem,
|
|
|
+ event: this.props.eventusers.find(user => user._id === elem).event[0],
|
|
|
time: values[elem]
|
|
|
})
|
|
|
-
|
|
|
+
|
|
|
this.props.resultsPromiseAll(results)
|
|
|
this.showConfirmationMessage()
|
|
|
}
|
|
@@ -41,9 +42,8 @@ class AdminResultstPage extends Component {
|
|
|
|
|
|
onChangeTitleHandler = e => {
|
|
|
const { value } = e.target;
|
|
|
- this.props.getEventByTitle(value).then((res) => {
|
|
|
- this.props.getRegistredUsers(res.payload.data.events[0]._id)
|
|
|
- })
|
|
|
+ const eventId = this.props.eventList.find(elem => elem.title === value)._id
|
|
|
+ this.props.getRegistredUsers(eventId)
|
|
|
};
|
|
|
|
|
|
render() {
|
|
@@ -53,31 +53,31 @@ class AdminResultstPage extends Component {
|
|
|
eventusers,
|
|
|
} = this.props
|
|
|
|
|
|
- return (
|
|
|
+ return (
|
|
|
<>
|
|
|
<AdminHeader />
|
|
|
<div className="results-form">
|
|
|
<div className="results-form__content">
|
|
|
<h2 className="results-form__form-title">RESULTS</h2>
|
|
|
- <ResultsForm
|
|
|
+ <ResultsForm
|
|
|
eventTypes={eventTypes}
|
|
|
eventList={eventList}
|
|
|
- submitHandler = {this.submitHandler}
|
|
|
- onChangeInputTimeHandler = {this.onChangeInputTimeHandler}
|
|
|
+ submitHandler={this.submitHandler}
|
|
|
+ onChangeInputTimeHandler={this.onChangeInputTimeHandler}
|
|
|
eventusers={eventusers}
|
|
|
- onChangeTypeHandler = {this.onChangeTypeHandler}
|
|
|
- onChangeTitleHandler = {this.onChangeTitleHandler}
|
|
|
+ onChangeTypeHandler={this.onChangeTypeHandler}
|
|
|
+ onChangeTitleHandler={this.onChangeTitleHandler}
|
|
|
/>
|
|
|
</div>
|
|
|
-
|
|
|
- {this.state.confirmationMessageFlag &&
|
|
|
- <ConfirmationMessage closeMessage = {this.closeConfirmationMessage}>
|
|
|
- <div className = "text">Results have beed added.</div>
|
|
|
+
|
|
|
+ {this.state.confirmationMessageFlag &&
|
|
|
+ <ConfirmationMessage closeMessage={this.closeConfirmationMessage}>
|
|
|
+ <div className="text">Results have beed added.</div>
|
|
|
</ConfirmationMessage >}
|
|
|
</div>
|
|
|
</>
|
|
|
- );
|
|
|
- }
|
|
|
+ );
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
const mapStateToProps = state => ({
|
|
@@ -90,5 +90,5 @@ const mapStateToProps = state => ({
|
|
|
|
|
|
export default connect(
|
|
|
mapStateToProps,
|
|
|
- {getEvents, getEventByTitle, getRegistredUsers, resultsPromiseAll}
|
|
|
+ { getEvents, getEventByTitle, getRegistredUsers, resultsPromiseAll }
|
|
|
)(AdminResultstPage);
|