|
@@ -7,59 +7,90 @@ class SendingForm extends Component {
|
|
|
|
|
|
constructor(props){
|
|
|
super(props)
|
|
|
- this.state = { image: 'http://zabavnik.club/wp-content/uploads/vopros_2_14000037-939x1024.jpg' }
|
|
|
+ this.state = { trig:false }
|
|
|
|
|
|
}
|
|
|
- onChange3 = e =>{
|
|
|
- const { pushPhoto,photo } = this.props
|
|
|
- //this.setState({image: e.target.files[0]})
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ onChange = e =>{
|
|
|
+ const { pushPhoto, base64 } = this.props
|
|
|
+ this.setState({trig:true})
|
|
|
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)
|
|
|
+ var file = e.target.files[0];
|
|
|
+ var reader = new FileReader();
|
|
|
+ reader.onloadend = function() {
|
|
|
+ base64(reader.result)
|
|
|
+ }
|
|
|
+ reader.readAsDataURL(file);
|
|
|
}
|
|
|
- onChange2 = e =>{
|
|
|
- const { pushPhoto,photo } = this.props
|
|
|
- //this.setState({image: e.target.files[0]})
|
|
|
+ onChange1 = e =>{
|
|
|
+ const { pushPhoto, base641 } = this.props
|
|
|
+ this.setState({trig:true})
|
|
|
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)
|
|
|
+ var file = e.target.files[0];
|
|
|
+ var reader = new FileReader();
|
|
|
+ reader.onloadend = function() {
|
|
|
+ base641(reader.result)
|
|
|
+ }
|
|
|
+ reader.readAsDataURL(file);
|
|
|
}
|
|
|
- onChange1 = e =>{
|
|
|
- const { pushPhoto,photo } = this.props
|
|
|
- //this.setState({image: e.target.files[0]})
|
|
|
+ onChange2 = e =>{
|
|
|
+ const { pushPhoto, base642 } = this.props
|
|
|
+ this.setState({trig:true})
|
|
|
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)
|
|
|
+ var file = e.target.files[0];
|
|
|
+ var reader = new FileReader();
|
|
|
+ reader.onloadend = function() {
|
|
|
+ base642(reader.result)
|
|
|
+ }
|
|
|
+ reader.readAsDataURL(file);
|
|
|
}
|
|
|
- onChange = e =>{
|
|
|
- const { pushPhoto,photo } = this.props
|
|
|
- //this.setState({image: e.target.files[0]})
|
|
|
+ onChange3 = e =>{
|
|
|
+ const { pushPhoto, base643 } = this.props
|
|
|
+ this.setState({trig:true})
|
|
|
let data = new FormData();
|
|
|
- data.append('image',e.target.files[0], e.target.files[0].name);
|
|
|
-
|
|
|
- pushPhoto(data)
|
|
|
+ if( e.target.files[0] == undefined ) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ data.append('image',e.target.files[0], e.target.files[0].name);
|
|
|
+ pushPhoto(data)
|
|
|
+ var file = e.target.files[0];
|
|
|
+ var reader = new FileReader();
|
|
|
+ reader.onloadend = function() {
|
|
|
+ base643(reader.result)
|
|
|
+ }
|
|
|
+ reader.readAsDataURL(file);
|
|
|
}
|
|
|
submit = values => {
|
|
|
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)}`
|
|
|
+ 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";
|
|
|
+ values.state = 0
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ values.img = `http://127.0.0.1:2000/static/${photo.map(el => el.data.fileName)}`;
|
|
|
+ values.state = 1
|
|
|
+ }
|
|
|
+ //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)
|
|
|
+ const { handleSubmit, pristine, reset, submitting, allCategory, photo, base64Photo, addOrnot, base64Photo1, base64Photo2, base64Photo3, addOrnot1, addOrnot2, addOrnot3 } = this.props
|
|
|
+
|
|
|
|
|
|
|
|
|
return (
|
|
@@ -102,24 +133,24 @@ class SendingForm extends Component {
|
|
|
</Field>
|
|
|
|
|
|
|
|
|
- <label className='upload-zone'>
|
|
|
- <i> </i>
|
|
|
+ <label className='upload-zone zone1'>
|
|
|
+ {addOrnot ? <img src={base64Photo} style={{"width": "80px", "height": "80px"}}></img> : <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}/>
|
|
|
+ {addOrnot1 ? <img src={base64Photo1} style={{"width": "80px", "height": "80px"}}></img> : <i> </i>}
|
|
|
+ <input type='file' className='files' onChange={this.onChange1}/>
|
|
|
|
|
|
</label>
|
|
|
<label className='upload-zone zone3'>
|
|
|
- <i> </i>
|
|
|
- <input type='file' className='files' onChange={this.onChange}/>
|
|
|
+ {addOrnot2 ? <img src={base64Photo2} style={{"width": "80px", "height": "80px"}}></img> : <i> </i>}
|
|
|
+ <input type='file' className='files' onChange={this.onChange2}/>
|
|
|
|
|
|
</label>
|
|
|
<label className='upload-zone zone4'>
|
|
|
- <i> </i>
|
|
|
- <input type='file' className='files' onChange={this.onChange}/>
|
|
|
+ {addOrnot3 ? <img src={base64Photo3} style={{"width": "80px", "height": "80px"}}></img> : <i> </i>}
|
|
|
+ <input type='file' className='files' onChange={this.onChange3}/>
|
|
|
|
|
|
</label>
|
|
|
|
|
@@ -150,4 +181,11 @@ class SendingForm extends Component {
|
|
|
|
|
|
export default reduxForm({
|
|
|
form: 'SendingForm'
|
|
|
-})(SendingForm)
|
|
|
+})(SendingForm)
|
|
|
+// const mapStateToProps = (state, props) => ({
|
|
|
+// form: props.formId
|
|
|
+// });
|
|
|
+
|
|
|
+// const component = reduxForm({ enableReinitialize: true })(SendingForm);
|
|
|
+
|
|
|
+// export default connect(mapStateToProps)(component);
|