|
@@ -1,54 +1,42 @@
|
|
|
import React, { Component } from "react";
|
|
|
import { connect } from "react-redux";
|
|
|
-// import * as actions from "../../actions/photogalaryActions";
|
|
|
import {getEvents, getEventByTitle} from "../../actions/adminMainPageActions";
|
|
|
-import {getRegistredUsers} from "../../actions/adminResultsActions";
|
|
|
+import {getRegistredUsers, resultsPromiseAll} from "../../actions/adminResultsActions";
|
|
|
import AdminHeader from "../../components/adminHeader/adminHeader";
|
|
|
import ResultsForm from "../../components/adminResults/adminResultsForm";
|
|
|
import ConfirmationMessage from "../../components/confirmationMessage/confirmationMessage";
|
|
|
|
|
|
class AdminResultstPage extends Component {
|
|
|
state = {
|
|
|
- // resultState: [
|
|
|
- // {
|
|
|
- // eventUser: {},
|
|
|
- // time: ''
|
|
|
- // }
|
|
|
- // ],
|
|
|
confirmationMessageFlag: false
|
|
|
};
|
|
|
|
|
|
componentDidMount() {
|
|
|
this.props.getEvents();
|
|
|
- // this.props.getRegistredUsers()
|
|
|
}
|
|
|
|
|
|
showConfirmationMessage = () => {
|
|
|
this.setState({confirmationMessageFlag: true })
|
|
|
- document.location.reload(true);
|
|
|
};
|
|
|
closeConfirmationMessage = () => {
|
|
|
this.setState({ confirmationMessageFlag: false })
|
|
|
};
|
|
|
|
|
|
submitHandler = values => {
|
|
|
- console.log('this.props.eventusers', this.props.eventusers)
|
|
|
- console.log('submit values', values)
|
|
|
- const results = Object.keys(values)
|
|
|
- .filter(elem => elem !== 'eventType')
|
|
|
+ const results = Object.keys(values).slice(2)
|
|
|
.map(elem => elem = {
|
|
|
- eventUser: this.props.eventusers.find(
|
|
|
- user => user._id === elem), time: values[elem]
|
|
|
- }
|
|
|
- )
|
|
|
-
|
|
|
- console.log('submit results', results)
|
|
|
+ eventUser: elem,
|
|
|
+ event: this.props.eventusers.find( user => user._id === elem).event[0],
|
|
|
+ time: values[elem]
|
|
|
+ })
|
|
|
+
|
|
|
+ this.props.resultsPromiseAll(results)
|
|
|
+ this.showConfirmationMessage()
|
|
|
}
|
|
|
|
|
|
onChangeTypeHandler = e => {
|
|
|
const { value } = e.target;
|
|
|
this.props.getEvents(value)
|
|
|
- // console.log('onChangeTypeHandler', value)
|
|
|
};
|
|
|
|
|
|
onChangeTitleHandler = e => {
|
|
@@ -56,30 +44,8 @@ class AdminResultstPage extends Component {
|
|
|
this.props.getEventByTitle(value).then((res) => {
|
|
|
this.props.getRegistredUsers(res.payload.data.events[0]._id)
|
|
|
})
|
|
|
- // console.log('titile eventList', this.props.eventList)
|
|
|
- // this.props.getRegistredUsers(this.props.eventList_)
|
|
|
- // console.log('onChangeTitleHandler', value)
|
|
|
};
|
|
|
|
|
|
- // onChangeInputTimeHandler = e => {
|
|
|
- // const { value, id, name } = e.target;
|
|
|
- // console.log('onChangeInputTimeHandler value', value, id)
|
|
|
- // this.setState(prevState => {
|
|
|
- // console.log('prevState resultState', prevState)
|
|
|
- // return {
|
|
|
- // ...prevState,
|
|
|
- // resultState: [
|
|
|
- // ...prevState.resultState,
|
|
|
- // {
|
|
|
- // eventuser: this.props.eventusers.find( elem => elem._id === id),
|
|
|
- // time: value,
|
|
|
- // id: id
|
|
|
- // }
|
|
|
- // ]
|
|
|
- // };
|
|
|
- // });
|
|
|
- // }
|
|
|
-
|
|
|
render() {
|
|
|
const {
|
|
|
eventTypes,
|
|
@@ -87,11 +53,6 @@ class AdminResultstPage extends Component {
|
|
|
eventusers,
|
|
|
} = this.props
|
|
|
|
|
|
- console.log('page props', this.props)
|
|
|
- // console.log('eventList', eventList)
|
|
|
- // console.log('gallery', this.props.gallery)
|
|
|
-
|
|
|
- // console.log("eventTypes", this.state.eventTypes );
|
|
|
return (
|
|
|
<>
|
|
|
<AdminHeader />
|
|
@@ -103,7 +64,6 @@ class AdminResultstPage extends Component {
|
|
|
eventList={eventList}
|
|
|
submitHandler = {this.submitHandler}
|
|
|
onChangeInputTimeHandler = {this.onChangeInputTimeHandler}
|
|
|
- // eventByTitle ={eventByTitle}
|
|
|
eventusers={eventusers}
|
|
|
onChangeTypeHandler = {this.onChangeTypeHandler}
|
|
|
onChangeTitleHandler = {this.onChangeTitleHandler}
|
|
@@ -125,12 +85,10 @@ const mapStateToProps = state => ({
|
|
|
eventByTitle: state.adminMainPageReducer.eventByTitle,
|
|
|
eventTypes: state.adminMainPageReducer.eventTypes,
|
|
|
eventusers: state.adminResultsReduser.eventusers,
|
|
|
- // eventFormInitialValue: state.adminMainPageReducer.eventFormInitialValue,
|
|
|
addPhotogalaryInitialValue: state.photogalaryReducer.addPhotogalaryInitialValue,
|
|
|
- // gallery: state.photogalaryReducer.gallery
|
|
|
});
|
|
|
|
|
|
export default connect(
|
|
|
mapStateToProps,
|
|
|
- {getEvents, getEventByTitle, getRegistredUsers}
|
|
|
+ {getEvents, getEventByTitle, getRegistredUsers, resultsPromiseAll}
|
|
|
)(AdminResultstPage);
|