|
@@ -3,67 +3,45 @@ import { Field, reduxForm } from 'redux-form';
|
|
|
|
|
|
import FormData from 'form-data'
|
|
|
|
|
|
-class SendingForm extends Component {
|
|
|
-
|
|
|
- constructor(props){
|
|
|
+class SendingForm extends Component {
|
|
|
+ constructor(props) {
|
|
|
super(props)
|
|
|
- this.state = { image: 'http://zabavnik.club/wp-content/uploads/vopros_2_14000037-939x1024.jpg' }
|
|
|
-
|
|
|
- }
|
|
|
- onChange3 = e =>{
|
|
|
- const { pushPhoto,photo } = this.props
|
|
|
- //this.setState({image: e.target.files[0]})
|
|
|
- let data = new FormData();
|
|
|
- data.append('image',e.target.files[0], e.target.files[0].name);
|
|
|
-
|
|
|
- pushPhoto(data)
|
|
|
- }
|
|
|
- onChange2 = e =>{
|
|
|
- const { pushPhoto,photo } = this.props
|
|
|
- //this.setState({image: e.target.files[0]})
|
|
|
- let data = new FormData();
|
|
|
- data.append('image',e.target.files[0], e.target.files[0].name);
|
|
|
-
|
|
|
- pushPhoto(data)
|
|
|
- }
|
|
|
- onChange1 = e =>{
|
|
|
- const { pushPhoto,photo } = this.props
|
|
|
- //this.setState({image: e.target.files[0]})
|
|
|
- let data = new FormData();
|
|
|
- data.append('image',e.target.files[0], e.target.files[0].name);
|
|
|
-
|
|
|
- pushPhoto(data)
|
|
|
+ this.state = { image: 'http://zabavnik.club/wp-content/uploads/vopros_2_14000037-939x1024.jpg' }
|
|
|
+
|
|
|
}
|
|
|
- onChange = e =>{
|
|
|
- const { pushPhoto,photo } = this.props
|
|
|
+
|
|
|
+ onChange = e => {
|
|
|
+ const { pushPhoto, photo } = this.props
|
|
|
//this.setState({image: e.target.files[0]})
|
|
|
let data = new FormData();
|
|
|
- data.append('image',e.target.files[0], e.target.files[0].name);
|
|
|
-
|
|
|
- pushPhoto(data)
|
|
|
+ data.append('image', e.target.files[0], e.target.files[0].name);
|
|
|
+
|
|
|
+ pushPhoto(data)
|
|
|
}
|
|
|
+
|
|
|
submit = values => {
|
|
|
- const { AddNewStaffAction, getUser, photo } = this.props
|
|
|
+ const { AddNewStaffAction, getUser, photo } = this.props
|
|
|
//const { image } = this.state
|
|
|
-
|
|
|
- let massive = []
|
|
|
- // massive = photo.map(el => el.data.fileName)
|
|
|
- // console.log(photo)
|
|
|
- values.img = `http://127.0.0.1:2000/static/${photo.map(el => el.data.fileName)}`
|
|
|
+
|
|
|
+ let massive = []
|
|
|
+ // massive = photo.map(el => el.data.fileName)
|
|
|
+ // console.log(photo)
|
|
|
+ values.img = `http://127.0.0.1:2000/static/${photo.map(el => el.data.fileName)}`
|
|
|
values.staff = "Машина"
|
|
|
values.state = 1
|
|
|
values.userId = getUser.id
|
|
|
console.log(values)
|
|
|
AddNewStaffAction(values)
|
|
|
- };
|
|
|
- render(){
|
|
|
-
|
|
|
- const { handleSubmit, pristine, reset, submitting, allCategory, photo } = this.props
|
|
|
- console.log(photo)
|
|
|
-
|
|
|
-
|
|
|
- return (
|
|
|
-
|
|
|
+ }
|
|
|
+
|
|
|
+ render() {
|
|
|
+
|
|
|
+ const { handleSubmit, pristine, reset, submitting, allCategory, photo } = this.props
|
|
|
+ console.log(photo)
|
|
|
+
|
|
|
+
|
|
|
+ return (
|
|
|
+
|
|
|
<div className="formdiv">
|
|
|
<form onSubmit={handleSubmit(this.submit)} className="form">
|
|
|
<Field
|
|
@@ -94,42 +72,36 @@ class SendingForm extends Component {
|
|
|
<Field
|
|
|
name="categoryId"
|
|
|
component="select"
|
|
|
-
|
|
|
+
|
|
|
className="input"
|
|
|
>
|
|
|
<option >Выберите рубрику</option>
|
|
|
{allCategory.map(el => <option value={el.id}> {el.title}</option>)}
|
|
|
</Field>
|
|
|
|
|
|
-
|
|
|
- <label className='upload-zone'>
|
|
|
- <i> </i>
|
|
|
- <input type='file' className='files' onChange={this.onChange}/>
|
|
|
-
|
|
|
- </label>
|
|
|
- <label className='upload-zone zone2'>
|
|
|
- <i> </i>
|
|
|
- <input type='file' className='files' onChange={this.onChange}/>
|
|
|
-
|
|
|
- </label>
|
|
|
- <label className='upload-zone zone3'>
|
|
|
- <i> </i>
|
|
|
- <input type='file' className='files' onChange={this.onChange}/>
|
|
|
-
|
|
|
- </label>
|
|
|
- <label className='upload-zone zone4'>
|
|
|
- <i> </i>
|
|
|
- <input type='file' className='files' onChange={this.onChange}/>
|
|
|
-
|
|
|
- </label>
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- {/* <input type="file" onChange={this.onChange}></input> */}
|
|
|
- {/* <input type="file" onChange={this.onChange1}></input>
|
|
|
- <input type="file" onChange={this.onChange2}></input>
|
|
|
- <input type="file" onChange={this.onChange3}></input> */}
|
|
|
-
|
|
|
+ <div className="file">
|
|
|
+ <label className='upload-zone'>
|
|
|
+ <i> </i>
|
|
|
+ <input type='file' className='files' onChange={this.onChange} />
|
|
|
+
|
|
|
+ </label>
|
|
|
+ <label className='upload-zone zone2'>
|
|
|
+ <i> </i>
|
|
|
+ <input type='file' className='files' onChange={this.onChange} />
|
|
|
+
|
|
|
+ </label>
|
|
|
+ <label className='upload-zone zone3'>
|
|
|
+ <i> </i>
|
|
|
+ <input type='file' className='files' onChange={this.onChange} />
|
|
|
+
|
|
|
+ </label>
|
|
|
+ <label className='upload-zone zone4'>
|
|
|
+ <i> </i>
|
|
|
+ <input type='file' className='files' onChange={this.onChange} />
|
|
|
+
|
|
|
+ </label>
|
|
|
+ </div>
|
|
|
+
|
|
|
<div className="buttonConteiner">
|
|
|
<button type="submit" disabled={pristine || submitting} className="button" >
|
|
|
Submit
|
|
@@ -138,14 +110,14 @@ class SendingForm extends Component {
|
|
|
Clear Values
|
|
|
</button>
|
|
|
</div>
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
</form>
|
|
|
|
|
|
</div>
|
|
|
-
|
|
|
- )
|
|
|
- }
|
|
|
+
|
|
|
+ )
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
export default reduxForm({
|