|
@@ -1,6 +1,6 @@
|
|
|
import React, { Component } from 'react';
|
|
|
-import { Field, reduxForm } from 'redux-form';
|
|
|
-import { Link, Redirect } from "react-router-dom";
|
|
|
+import { reduxForm } from 'redux-form';
|
|
|
+
|
|
|
import FormData from 'form-data'
|
|
|
|
|
|
|
|
@@ -10,16 +10,8 @@ class FormRedactorStaff extends Component {
|
|
|
super(props)
|
|
|
this.state = { trig:false }
|
|
|
}
|
|
|
- // componentDidUpdate(prevProps){
|
|
|
- // const { match } = this.props
|
|
|
- // if(prevProps.InfoStaff[0].id !==this.props.InfoStaff[0].id ){
|
|
|
- // this.props.getStaffsDataById(this.props.InfoStaff[0].id)
|
|
|
- // }
|
|
|
- // console.log("prevProps.InfoStaff", prevProps.InfoStaff, "this.props.InfoStaff", this.props.InfoStaff)
|
|
|
- // }
|
|
|
onChange = e =>{
|
|
|
- const { pushPhoto,photo } = this.props
|
|
|
- //this.setState({image: e.target.files[0]})
|
|
|
+ const { pushPhoto } = this.props
|
|
|
this.setState({trig:true})
|
|
|
let data = new FormData();
|
|
|
data.append('image',e.target.files[0], e.target.files[0].name);
|
|
@@ -46,7 +38,7 @@ class FormRedactorStaff extends Component {
|
|
|
|
|
|
}
|
|
|
send = () =>{
|
|
|
- const { inputData, inputData1, inputData2, inputData3, match, photo, EditStaffAction, InfoStaff, getUser } = this.props
|
|
|
+ const { inputData, inputData1, inputData2, inputData3, photo, EditStaffAction, InfoStaff, getUser } = this.props
|
|
|
let values = {}
|
|
|
if(!this.state.trig){
|
|
|
values.img = "http://rs.img.com.ua/crop?v2=1&w=600&h=0&url=%2F%2Fbm.img.com.ua%2Fberlin%2Fstorage%2Forig%2Fd224d3bd9bfe8bcb6b561da523d87364.jpg";
|
|
@@ -77,26 +69,27 @@ class FormRedactorStaff extends Component {
|
|
|
}
|
|
|
EditStaffAction(values)
|
|
|
|
|
|
- //console.log(values)
|
|
|
+
|
|
|
}
|
|
|
render(){
|
|
|
|
|
|
|
|
|
- const { handleSubmit, pristine, reset, submitting, InfoStaff, photo, allCategory } = this.props
|
|
|
+ const { pristine, reset, submitting, InfoStaff, allCategory } = this.props
|
|
|
|
|
|
const category = allCategory.data.filter(el => el.parentId !== 0)
|
|
|
let data;
|
|
|
|
|
|
|
|
|
- data = InfoStaff.map(el => <form className="form">
|
|
|
+ data = InfoStaff.map((el,key) => <form className="form" key={key}>
|
|
|
<input type="text" name="title" defaultValue ={el.title} className="input" onChange={this.changeHandler}/>
|
|
|
- <textarea type="text" name="description" defaultValue ={el.description} className="input" onChange={this.changeHandler1}/>
|
|
|
+ <textarea type="text" name="description" defaultValue ={el.description} className="textarea" onChange={this.changeHandler1}/>
|
|
|
<input type="number" name="price" defaultValue ={el.price} className="input" onChange={this.changeHandler2}/>
|
|
|
<select type="number" name="categoryId" className="input" defaultValue ={el.categoryId} onChange={this.changeHandler3}>
|
|
|
|
|
|
<option >Выберите рубрику</option>
|
|
|
{category.map(el => <option value={el.id}> {el.title}</option>)}
|
|
|
</select>
|
|
|
+ <div className="file">
|
|
|
<label className='upload-zone'>
|
|
|
<i> </i>
|
|
|
<input type='file' className='files' onChange={this.onChange}/>
|
|
@@ -117,15 +110,15 @@ class FormRedactorStaff extends Component {
|
|
|
<input type='file' className='files' onChange={this.onChange}/>
|
|
|
|
|
|
</label>
|
|
|
-
|
|
|
+ </div>
|
|
|
|
|
|
|
|
|
<div className="buttonConteiner">
|
|
|
<button type="button" className="button" onClick={this.send}>
|
|
|
- Submit
|
|
|
+ Добавить
|
|
|
</button>
|
|
|
<button type="button" disabled={pristine || submitting} onClick={reset} className="button" >
|
|
|
- Clear Values
|
|
|
+ Очистить
|
|
|
</button>
|
|
|
|
|
|
</div>
|