|
@@ -2,7 +2,7 @@ import React, { Component } from 'react';
|
|
|
import { reduxForm } from 'redux-form';
|
|
|
|
|
|
import FormData from 'form-data'
|
|
|
-
|
|
|
+import LinkHome from "../../Btn/linkHome"
|
|
|
|
|
|
class FormRedactorStaff extends Component {
|
|
|
|
|
@@ -18,7 +18,62 @@ class FormRedactorStaff extends Component {
|
|
|
|
|
|
pushPhoto(data)
|
|
|
}
|
|
|
-
|
|
|
+ onChange0 = 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)
|
|
|
+ var file = e.target.files[0];
|
|
|
+ var reader = new FileReader();
|
|
|
+ reader.onloadend = function () {
|
|
|
+ base64(reader.result)
|
|
|
+ }
|
|
|
+ reader.readAsDataURL(file);
|
|
|
+ }
|
|
|
+ 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)
|
|
|
+ var file = e.target.files[0];
|
|
|
+ var reader = new FileReader();
|
|
|
+ reader.onloadend = function () {
|
|
|
+ base641(reader.result)
|
|
|
+ }
|
|
|
+ reader.readAsDataURL(file);
|
|
|
+ }
|
|
|
+ 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)
|
|
|
+ var file = e.target.files[0];
|
|
|
+ var reader = new FileReader();
|
|
|
+ reader.onloadend = function () {
|
|
|
+ base642(reader.result)
|
|
|
+ }
|
|
|
+ reader.readAsDataURL(file);
|
|
|
+ }
|
|
|
+ onChange3 = e => {
|
|
|
+ const { pushPhoto, base643 } = this.props
|
|
|
+ this.setState({ trig: true })
|
|
|
+ let data = new FormData();
|
|
|
+ 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);
|
|
|
+
|
|
|
+ }
|
|
|
changeHandler = (e) =>{
|
|
|
const { inputchangeHandler } = this.props
|
|
|
inputchangeHandler(e.target.value)
|
|
@@ -38,10 +93,11 @@ class FormRedactorStaff extends Component {
|
|
|
|
|
|
}
|
|
|
send = () =>{
|
|
|
- const { inputData, inputData1, inputData2, inputData3, 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";
|
|
|
+ //http://rs.img.com.ua/crop?v2=1&w=600&h=0&url=%2F%2Fbm.img.com.ua%2Fberlin%2Fstorage%2Forig%2Fd224d3bd9bfe8bcb6b561da523d87364.jpg
|
|
|
+ values.img = "https://icoconvert.com/images/noimage2.png";
|
|
|
values.state = 0
|
|
|
}
|
|
|
else{
|
|
@@ -74,7 +130,7 @@ class FormRedactorStaff extends Component {
|
|
|
render(){
|
|
|
|
|
|
|
|
|
- const { pristine, reset, submitting, InfoStaff, allCategory } = this.props
|
|
|
+ const { pristine, reset, submitting, InfoStaff, allCategory, base64Photo, addOrnot, base64Photo1, base64Photo2, base64Photo3, addOrnot1, addOrnot2, addOrnot3 } = this.props
|
|
|
|
|
|
const category = allCategory.data.filter(el => el.parentId !== 0)
|
|
|
let data;
|
|
@@ -87,30 +143,30 @@ class FormRedactorStaff extends Component {
|
|
|
<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>)}
|
|
|
+ {category.map((el,key) => <option value={el.id} key={key} > {el.title}</option>)}
|
|
|
</select>
|
|
|
- <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="file">
|
|
|
+ <label className='upload-zone zone1'>
|
|
|
+ {addOrnot ? <img src={base64Photo} style={{ "width": "80px", "height": "80px" }} alt=""></img> : <i> </i>}
|
|
|
+ <input type='file' className='files' onChange={this.onChange0} />
|
|
|
+
|
|
|
+ </label>
|
|
|
+ <label className='upload-zone zone2'>
|
|
|
+ {addOrnot1 ? <img src={base64Photo1} style={{ "width": "80px", "height": "80px" }} alt=""></img> : <i> </i>}
|
|
|
+ <input type='file' className='files' onChange={this.onChange1} />
|
|
|
+
|
|
|
+ </label>
|
|
|
+ <label className='upload-zone zone3'>
|
|
|
+ {addOrnot2 ? <img src={base64Photo2} style={{ "width": "80px", "height": "80px" }} alt=""></img> : <i> </i>}
|
|
|
+ <input type='file' className='files' onChange={this.onChange2} />
|
|
|
+
|
|
|
+ </label>
|
|
|
+ <label className='upload-zone zone4'>
|
|
|
+ {addOrnot3 ? <img src={base64Photo3} style={{ "width": "80px", "height": "80px" }} alt=""></img> : <i> </i>}
|
|
|
+ <input type='file' className='files' onChange={this.onChange3} />
|
|
|
+
|
|
|
+ </label>
|
|
|
+ </div>
|
|
|
|
|
|
|
|
|
<div className="buttonConteiner">
|
|
@@ -130,6 +186,7 @@ class FormRedactorStaff extends Component {
|
|
|
return (
|
|
|
|
|
|
<div className="formdiv">
|
|
|
+ <LinkHome />
|
|
|
{data}
|
|
|
</div>
|
|
|
|