|
@@ -1,13 +1,19 @@
|
|
import React from 'react';
|
|
import React from 'react';
|
|
import Input from './Input'
|
|
import Input from './Input'
|
|
import CheckBoxWindow from "./CheckBoxWindow";
|
|
import CheckBoxWindow from "./CheckBoxWindow";
|
|
-import { CustomSelect } from "../hooks/select";
|
|
|
|
|
|
+import {CustomSelect} from "../hooks/select";
|
|
|
|
+import ConfirmButton from "../ConfirmButton";
|
|
|
|
|
|
export default class ChangeServicesDoctors extends React.Component {
|
|
export default class ChangeServicesDoctors extends React.Component {
|
|
state = {
|
|
state = {
|
|
|
|
+ showConfirm: false,
|
|
flag: false,
|
|
flag: false,
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+ changeConfirm = (action, text) => {
|
|
|
|
+ this.setState({showConfirm: !this.state.showConfirm})
|
|
|
|
+ };
|
|
|
|
+
|
|
componentDidUpdate(prevProps) {
|
|
componentDidUpdate(prevProps) {
|
|
if (this.props.data !== prevProps.data) this.setState({flag: false})
|
|
if (this.props.data !== prevProps.data) this.setState({flag: false})
|
|
};
|
|
};
|
|
@@ -24,9 +30,9 @@ export default class ChangeServicesDoctors extends React.Component {
|
|
this.props.form.map(el => {
|
|
this.props.form.map(el => {
|
|
obj[el.name] = el.value
|
|
obj[el.name] = el.value
|
|
});
|
|
});
|
|
- this.props.postItem(this.props.categories? {
|
|
|
|
|
|
+ this.props.postItem(this.props.categories ? {
|
|
...obj,
|
|
...obj,
|
|
- speciality:this.props.specialityArray
|
|
|
|
|
|
+ speciality: this.props.specialityArray
|
|
} : obj)
|
|
} : obj)
|
|
};
|
|
};
|
|
|
|
|
|
@@ -38,9 +44,9 @@ export default class ChangeServicesDoctors extends React.Component {
|
|
if (el.value !== '') obj[el.name] = el.value
|
|
if (el.value !== '') obj[el.name] = el.value
|
|
});
|
|
});
|
|
this.props.putItem({
|
|
this.props.putItem({
|
|
- data: this.props.categories? {
|
|
|
|
|
|
+ data: this.props.categories ? {
|
|
...obj,
|
|
...obj,
|
|
- speciality:this.props.specialityArray
|
|
|
|
|
|
+ speciality: this.props.specialityArray
|
|
} : obj,
|
|
} : obj,
|
|
id: this.props.itemId
|
|
id: this.props.itemId
|
|
})
|
|
})
|
|
@@ -48,7 +54,8 @@ export default class ChangeServicesDoctors extends React.Component {
|
|
};
|
|
};
|
|
|
|
|
|
deleteItem = () => {
|
|
deleteItem = () => {
|
|
- this.props.deleteItem(this.props.itemId)
|
|
|
|
|
|
+ this.props.deleteItem(this.props.itemId);
|
|
|
|
+ this.changeConfirm()
|
|
};
|
|
};
|
|
|
|
|
|
changeId = (e) => {
|
|
changeId = (e) => {
|
|
@@ -70,46 +77,53 @@ export default class ChangeServicesDoctors extends React.Component {
|
|
} = this.props;
|
|
} = this.props;
|
|
let doctor = data.find(el => el._id === itemId);
|
|
let doctor = data.find(el => el._id === itemId);
|
|
if (doctor) doctor = doctor.speciality;
|
|
if (doctor) doctor = doctor.speciality;
|
|
- console.log(data,specialityArray)
|
|
|
|
|
|
+ console.log(data, specialityArray);
|
|
return (
|
|
return (
|
|
<div className="change-services-doctors">
|
|
<div className="change-services-doctors">
|
|
{this.state.flag &&
|
|
{this.state.flag &&
|
|
- <CheckBoxWindow categories={categories} specialityArray={specialityArray} changeFlag={this.changeFlag} changeSpecialityArray={changeSpecialityArray}/>}
|
|
|
|
|
|
+ <CheckBoxWindow categories={categories} specialityArray={specialityArray} changeFlag={this.changeFlag}
|
|
|
|
+ changeSpecialityArray={changeSpecialityArray}/>}
|
|
<div className="admin-item">
|
|
<div className="admin-item">
|
|
<form className="form-doctors" onSubmit={itemId ? this.changeItem : this.postNewItem}>
|
|
<form className="form-doctors" onSubmit={itemId ? this.changeItem : this.postNewItem}>
|
|
{
|
|
{
|
|
form.map(el => {
|
|
form.map(el => {
|
|
el.required = !itemId;
|
|
el.required = !itemId;
|
|
- return (
|
|
|
|
- <Input
|
|
|
|
- key={el.id}
|
|
|
|
- id={el.id}
|
|
|
|
- el={el}
|
|
|
|
- className = {el.className}
|
|
|
|
- changeInputValues={changeInputValues}
|
|
|
|
- />
|
|
|
|
- )
|
|
|
|
|
|
+ return (
|
|
|
|
+ <Input
|
|
|
|
+ key={el.id}
|
|
|
|
+ id={el.id}
|
|
|
|
+ el={el}
|
|
|
|
+ className={el.className}
|
|
|
|
+ changeInputValues={changeInputValues}
|
|
|
|
+ />
|
|
|
|
+ )
|
|
})
|
|
})
|
|
}
|
|
}
|
|
- {categories && <button className = " btn servise-btn" onClick={this.changeFlag}>Выбрать сервисы</button>}
|
|
|
|
|
|
+ {categories &&
|
|
|
|
+ <button className=" btn servise-btn" onClick={this.changeFlag}>Выбрать сервисы</button>}
|
|
<input className="btn link"
|
|
<input className="btn link"
|
|
type='submit'
|
|
type='submit'
|
|
- value={itemId ? 'Изменить' : 'Добавить'}
|
|
|
|
|
|
+ value={itemId ? 'Изменить' : 'Добавить'}
|
|
/>
|
|
/>
|
|
</form>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
<div className="admin-item">
|
|
<div className="admin-item">
|
|
|
|
|
|
<CustomSelect
|
|
<CustomSelect
|
|
- label="Выбрать"
|
|
|
|
- options={data}
|
|
|
|
- clickOptionEvent={this.changeId}
|
|
|
|
|
|
+ label="Выбрать"
|
|
|
|
+ options={data}
|
|
|
|
+ clickOptionEvent={this.changeId}
|
|
/>
|
|
/>
|
|
{itemId &&
|
|
{itemId &&
|
|
- <button className="btn link" onClick={this.deleteItem} style={{backgroundColor: "#ff9774"}}>Удалить
|
|
|
|
|
|
+ <button className="btn link" onClick={this.changeConfirm}
|
|
|
|
+ style={{backgroundColor: "#ff9774"}}>Удалить
|
|
выбранный элемент</button>
|
|
выбранный элемент</button>
|
|
}
|
|
}
|
|
</div>
|
|
</div>
|
|
|
|
+ {this.state.showConfirm &&
|
|
|
|
+ <ConfirmButton yes={this.deleteItem} no={this.changeConfirm}
|
|
|
|
+ text={'Are you sure you want to Delete Item?'}/>
|
|
|
|
+ }
|
|
</div>
|
|
</div>
|
|
);
|
|
);
|
|
}
|
|
}
|