|
@@ -9,7 +9,8 @@ export default class Shedule extends React.Component {
|
|
|
endDate:null,
|
|
|
};
|
|
|
|
|
|
- post = () => {
|
|
|
+ post = (e) => {
|
|
|
+ e.preventDefault()
|
|
|
let current = new Date(this.state.startDate);
|
|
|
let end = new Date (this.state.endDate);
|
|
|
while (current.toISOString().split('T')[0] <= end.toISOString().split('T')[0]){
|
|
@@ -19,20 +20,28 @@ export default class Shedule extends React.Component {
|
|
|
data:current.toISOString().split('T')[0],
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
current = new Date(+current + 86400000)
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+ changeStart = (e) => {
|
|
|
+ this.setState({startDate:e.target.value } )
|
|
|
+ };
|
|
|
+ changeEnd = (e) => {
|
|
|
+ this.setState ( { endDate:e.target.value } )
|
|
|
+ };
|
|
|
+ setDoctor = (e) => {
|
|
|
+ this.props.setSheduleDoctor(e.target.value)
|
|
|
+ };
|
|
|
+
|
|
|
render() {
|
|
|
- console.log ( this.props )
|
|
|
- const { doctors, postNewShedule, sheduleMonthArray, setSheduleDoctor } = this.props;
|
|
|
+ const {doctors, postNewShedule} = this.props;
|
|
|
+ const doctor = doctors.find(el => el._id === postNewShedule.doctor)
|
|
|
return (
|
|
|
<div className = "shedule-container" >
|
|
|
-
|
|
|
<div className = "option" >
|
|
|
- <select className = "appointment admin-appointment" onChange={(e) => setSheduleDoctor(e.target.value)} defaultValue='Выберите доктора'>
|
|
|
- <option disabled >Выберите доктора</option>
|
|
|
+ <select className = "appointment admin-appointment" onChange={this.setDoctor} defaultValue={doctor ? doctor.name : 'Выберите доктора'}>
|
|
|
+ <option disabled >Выберите доктора</option>
|
|
|
{
|
|
|
doctors.map ( el=> (
|
|
|
<option key={el._id} id={el._id}> {el.name} </option>
|
|
@@ -42,22 +51,21 @@ export default class Shedule extends React.Component {
|
|
|
|
|
|
{postNewShedule.doctor &&
|
|
|
<div className = "input-box">
|
|
|
- <input className = "shedule-input " type="date" onChange = { ( e ) => this.setState({startDate:e.target.value } ) }/>
|
|
|
- <input className = "shedule-input right" type="date" onChange = { ( e ) => this.setState ( { endDate:e.target.value } ) } />
|
|
|
+ <input className = "shedule-input " type="date" onChange = {this.changeStart}/>
|
|
|
+ <input className = "shedule-input right" type="date" onChange = {this.changeEnd}/>
|
|
|
</div>
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- { ( this.state.startDate && this.state.endDate ) && <button className = "btn admin" onClick = { this.post }> Отправить </button>}
|
|
|
-
|
|
|
+ {(this.state.startDate && this.state.endDate) &&
|
|
|
+ <button className = "btn admin" onClick = {this.post}> Отправить </button>
|
|
|
+ }
|
|
|
</div>
|
|
|
-
|
|
|
|
|
|
{postNewShedule.doctor &&
|
|
|
- <Calendar
|
|
|
- doctor={doctors.find (el => el._id === postNewShedule.doctor)}
|
|
|
- action = {console.log}
|
|
|
- />
|
|
|
+ <Calendar
|
|
|
+ doctor={doctor}
|
|
|
+ action = {console.log}
|
|
|
+ />
|
|
|
}
|
|
|
</div>
|
|
|
);
|