|
@@ -3,67 +3,45 @@ import { Field, reduxForm } from 'redux-form';
|
|
|
|
|
|
import FormData from 'form-data'
|
|
import FormData from 'form-data'
|
|
|
|
|
|
-class SendingForm extends Component {
|
|
|
|
-
|
|
|
|
- constructor(props){
|
|
|
|
|
|
+class SendingForm extends Component {
|
|
|
|
+ constructor(props) {
|
|
super(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]})
|
|
//this.setState({image: e.target.files[0]})
|
|
let data = new FormData();
|
|
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 => {
|
|
submit = values => {
|
|
- const { AddNewStaffAction, getUser, photo } = this.props
|
|
|
|
|
|
+ const { AddNewStaffAction, getUser, photo } = this.props
|
|
//const { image } = this.state
|
|
//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.staff = "Машина"
|
|
values.state = 1
|
|
values.state = 1
|
|
values.userId = getUser.id
|
|
values.userId = getUser.id
|
|
console.log(values)
|
|
console.log(values)
|
|
AddNewStaffAction(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">
|
|
<div className="formdiv">
|
|
<form onSubmit={handleSubmit(this.submit)} className="form">
|
|
<form onSubmit={handleSubmit(this.submit)} className="form">
|
|
<Field
|
|
<Field
|
|
@@ -94,42 +72,36 @@ class SendingForm extends Component {
|
|
<Field
|
|
<Field
|
|
name="categoryId"
|
|
name="categoryId"
|
|
component="select"
|
|
component="select"
|
|
-
|
|
|
|
|
|
+
|
|
className="input"
|
|
className="input"
|
|
>
|
|
>
|
|
<option >Выберите рубрику</option>
|
|
<option >Выберите рубрику</option>
|
|
{allCategory.map(el => <option value={el.id}> {el.title}</option>)}
|
|
{allCategory.map(el => <option value={el.id}> {el.title}</option>)}
|
|
</Field>
|
|
</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">
|
|
<div className="buttonConteiner">
|
|
<button type="submit" disabled={pristine || submitting} className="button" >
|
|
<button type="submit" disabled={pristine || submitting} className="button" >
|
|
Submit
|
|
Submit
|
|
@@ -138,14 +110,14 @@ class SendingForm extends Component {
|
|
Clear Values
|
|
Clear Values
|
|
</button>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+
|
|
</form>
|
|
</form>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
-
|
|
|
|
- )
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
|
|
+ )
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
export default reduxForm({
|
|
export default reduxForm({
|