|
@@ -13,24 +13,14 @@ class PhotogalaryReduxForm extends Component {
|
|
}
|
|
}
|
|
|
|
|
|
submit = values => {
|
|
submit = values => {
|
|
- // console.log('submit props', this.props)
|
|
|
|
- // console.log('submit state', this.state)
|
|
|
|
const pictures = this.state.addPhotogalaryInitialValue.pictures.reduce((prev, elem) => {
|
|
const pictures = this.state.addPhotogalaryInitialValue.pictures.reduce((prev, elem) => {
|
|
return prev.concat(elem.value);
|
|
return prev.concat(elem.value);
|
|
}, []);
|
|
}, []);
|
|
|
|
|
|
- // const eventId = this.props.eventList.find(
|
|
|
|
- // event => event.title === this.state.addPhotogalaryInitialValue.eventTitle
|
|
|
|
- // )._id
|
|
|
|
-
|
|
|
|
const submitValues = {
|
|
const submitValues = {
|
|
...this.state.addPhotogalaryInitialValue,
|
|
...this.state.addPhotogalaryInitialValue,
|
|
pictures: pictures,
|
|
pictures: pictures,
|
|
- // _id: eventId
|
|
|
|
}
|
|
}
|
|
- // console.log('submit eventId', eventId)
|
|
|
|
- console.log('submit values', submitValues)
|
|
|
|
- // console.log('pictures', pictures)
|
|
|
|
|
|
|
|
this.props.submitHandler(submitValues);
|
|
this.props.submitHandler(submitValues);
|
|
this.props.reset()
|
|
this.props.reset()
|
|
@@ -38,16 +28,15 @@ class PhotogalaryReduxForm extends Component {
|
|
|
|
|
|
onChangeTypeHandler = e => {
|
|
onChangeTypeHandler = e => {
|
|
const { name, value } = e.target;
|
|
const { name, value } = e.target;
|
|
- // console.log('eventInput', value)
|
|
|
|
|
|
+
|
|
this.setState(prevState => {
|
|
this.setState(prevState => {
|
|
- console.log('prevStateInput', prevState)
|
|
|
|
return {
|
|
return {
|
|
...prevState,
|
|
...prevState,
|
|
addPhotogalaryInitialValue: {
|
|
addPhotogalaryInitialValue: {
|
|
...prevState.addPhotogalaryInitialValue,
|
|
...prevState.addPhotogalaryInitialValue,
|
|
[name]: value
|
|
[name]: value
|
|
},
|
|
},
|
|
- filteredEventList: [{_id: 1, title: "Choose event"}].concat(
|
|
|
|
|
|
+ filteredEventList: [{_id: 1, title: "Select event"}].concat(
|
|
this.props.eventList.filter(el => el.eventType === value)
|
|
this.props.eventList.filter(el => el.eventType === value)
|
|
)
|
|
)
|
|
};
|
|
};
|
|
@@ -56,9 +45,8 @@ class PhotogalaryReduxForm extends Component {
|
|
|
|
|
|
onChangeTitleHandler = e => {
|
|
onChangeTitleHandler = e => {
|
|
const { name, value } = e.target;
|
|
const { name, value } = e.target;
|
|
- console.log('eventInput', value)
|
|
|
|
|
|
+
|
|
this.setState(prevState => {
|
|
this.setState(prevState => {
|
|
- console.log('prevStateInput', prevState)
|
|
|
|
return {
|
|
return {
|
|
...prevState,
|
|
...prevState,
|
|
addPhotogalaryInitialValue: {
|
|
addPhotogalaryInitialValue: {
|
|
@@ -71,14 +59,15 @@ class PhotogalaryReduxForm extends Component {
|
|
|
|
|
|
onChangePicturesHandler = e => {
|
|
onChangePicturesHandler = e => {
|
|
const { value, id } = e.target;
|
|
const { value, id } = e.target;
|
|
- console.log('eventPicture', e)
|
|
|
|
|
|
+
|
|
this.setState(prevState => {
|
|
this.setState(prevState => {
|
|
- console.log('prevStatePicture', prevState)
|
|
|
|
return {
|
|
return {
|
|
...prevState,
|
|
...prevState,
|
|
addPhotogalaryInitialValue: {
|
|
addPhotogalaryInitialValue: {
|
|
...prevState.addPhotogalaryInitialValue,
|
|
...prevState.addPhotogalaryInitialValue,
|
|
- pictures: prevState.addPhotogalaryInitialValue.pictures.map(el => (el.id === id ? { ...el, value } : el))
|
|
|
|
|
|
+ pictures: prevState.addPhotogalaryInitialValue.pictures.map(
|
|
|
|
+ el => (el.id === id ? { ...el, value } : el)
|
|
|
|
+ )
|
|
}
|
|
}
|
|
};
|
|
};
|
|
});
|
|
});
|
|
@@ -86,7 +75,6 @@ class PhotogalaryReduxForm extends Component {
|
|
|
|
|
|
addPicture = (e) => {
|
|
addPicture = (e) => {
|
|
this.setState(prevState => {
|
|
this.setState(prevState => {
|
|
- console.log('prevStatePicture-add', prevState)
|
|
|
|
return {
|
|
return {
|
|
...prevState,
|
|
...prevState,
|
|
addPhotogalaryInitialValue: {
|
|
addPhotogalaryInitialValue: {
|
|
@@ -107,7 +95,6 @@ class PhotogalaryReduxForm extends Component {
|
|
|
|
|
|
render() {
|
|
render() {
|
|
const { filteredEventList, addPhotogalaryInitialValue } = this.state;
|
|
const { filteredEventList, addPhotogalaryInitialValue } = this.state;
|
|
- // console.log(this.state )
|
|
|
|
|
|
|
|
const {
|
|
const {
|
|
handleSubmit,
|
|
handleSubmit,
|