|
@@ -2,7 +2,6 @@ import React from 'react';
|
|
import {connect} from "react-redux";
|
|
import {connect} from "react-redux";
|
|
|
|
|
|
import {
|
|
import {
|
|
-
|
|
|
|
setAppointmentSpec,
|
|
setAppointmentSpec,
|
|
setAppointmentShedule,
|
|
setAppointmentShedule,
|
|
setAppointmentDoctor,
|
|
setAppointmentDoctor,
|
|
@@ -13,10 +12,11 @@ import {
|
|
|
|
|
|
} from "../actions/actions";
|
|
} from "../actions/actions";
|
|
|
|
|
|
|
|
+import Calendar from "../components/Calendar"
|
|
|
|
+
|
|
export class Appoint extends React.Component {
|
|
export class Appoint extends React.Component {
|
|
|
|
|
|
componentDidMount() {
|
|
componentDidMount() {
|
|
- console.log(this.props)
|
|
|
|
this.props.setAppointmentDoctor(this.props.match.params.doctorId)
|
|
this.props.setAppointmentDoctor(this.props.match.params.doctorId)
|
|
}
|
|
}
|
|
|
|
|
|
@@ -25,95 +25,76 @@ export class Appoint extends React.Component {
|
|
}
|
|
}
|
|
|
|
|
|
render() {
|
|
render() {
|
|
- const {doctors, appointment, timeArray, wrongDate,services} = this.props.app;
|
|
|
|
|
|
+ const {doctors, appointment, timeArray,services} = this.props.app;
|
|
const {match, setAppointmentSpec, setAppointmentShedule, setAppointmentTime, setAppointmentComment, postOrders} = this.props;
|
|
const {match, setAppointmentSpec, setAppointmentShedule, setAppointmentTime, setAppointmentComment, postOrders} = this.props;
|
|
const doctor = doctors.find(el => el._id === match.params.doctorId);
|
|
const doctor = doctors.find(el => el._id === match.params.doctorId);
|
|
let spec;
|
|
let spec;
|
|
if (appointment.spec){
|
|
if (appointment.spec){
|
|
spec = services.find(el => el._id === appointment.spec)
|
|
spec = services.find(el => el._id === appointment.spec)
|
|
}
|
|
}
|
|
- let currentDate;
|
|
|
|
- let choosedData;
|
|
|
|
- if (doctor) {
|
|
|
|
- if (doctor.shedule && appointment.shedule) {
|
|
|
|
- currentDate = new Date().toISOString().split('T')[0];
|
|
|
|
- choosedData = doctor.shedule.find(el => el._id === appointment.shedule).data.split('T')[0];
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
return (
|
|
return (
|
|
<>
|
|
<>
|
|
- <div className="main">
|
|
|
|
- {doctor &&
|
|
|
|
|
|
+ <div className="main">
|
|
|
|
+ {doctor &&
|
|
<div className = "info-wrap">
|
|
<div className = "info-wrap">
|
|
- <div className="card">
|
|
|
|
- <div className="card-item">
|
|
|
|
- <img src={`.${doctor.photo}`} alt={doctor.name}/>
|
|
|
|
|
|
+ <div className="card">
|
|
|
|
+ <div className="card-item">
|
|
|
|
+ <img src={`.${doctor.photo}`} alt={doctor.name}/>
|
|
|
|
+ </div>
|
|
|
|
+ <div className="card-item desc">
|
|
|
|
+ <h3>{doctor.name}</h3>
|
|
|
|
+ <p className = "highlights">{doctor.profession}</p>
|
|
|
|
+
|
|
|
|
+ {appointment.spec &&
|
|
|
|
+ <div>
|
|
|
|
+ <p>{spec.name}</p>
|
|
|
|
+ <p>Длительность: {spec.duration} ч.</p>
|
|
|
|
+ {/* <p>{spec.description}</p> */}
|
|
|
|
+ <p>Цена от {spec.price} грн.</p>
|
|
</div>
|
|
</div>
|
|
- <div className="card-item desc">
|
|
|
|
- <h3>{doctor.name}</h3>
|
|
|
|
- <p className = "highlights">{doctor.profession}</p>
|
|
|
|
- {appointment.spec &&
|
|
|
|
- <div>
|
|
|
|
- <p>{spec.name}</p>
|
|
|
|
- <p>Длительность: {spec.duration} ч.</p>
|
|
|
|
- {/* <p>{spec.description}</p> */}
|
|
|
|
- <p>Цена от {spec.price} грн.</p>
|
|
|
|
- </div>
|
|
|
|
- }
|
|
|
|
- <select onChange={(e)=>setAppointmentSpec(e.target.value)} defaultValue='Выбор услуги'>
|
|
|
|
- <option disabled >Выбор услуги</option>
|
|
|
|
- {
|
|
|
|
- doctor.speciality.map(el=> (
|
|
|
|
- <option key={el._id}>{el.name}</option>
|
|
|
|
- ))
|
|
|
|
- }
|
|
|
|
- </select>
|
|
|
|
- {appointment.spec &&
|
|
|
|
- <input
|
|
|
|
- type="date"
|
|
|
|
- onChange={(e) => setAppointmentShedule(doctor.shedule.find(el => new Date(el.data).toISOString().split('T')[0] === new Date(e.target.value).toISOString().split('T')[0])
|
|
|
|
- ? doctor.shedule.find(el => new Date(el.data).toISOString().split('T')[0] === new Date(e.target.value).toISOString().split('T')[0])._id
|
|
|
|
- : null
|
|
|
|
- )}
|
|
|
|
- />
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- {!appointment.shedule ?
|
|
|
|
- !wrongDate ?
|
|
|
|
- <p>На эту дату нет свободного времени для выбора</p>
|
|
|
|
- : null
|
|
|
|
- : <div>
|
|
|
|
- { choosedData >= currentDate ?
|
|
|
|
- <div>
|
|
|
|
- <select onChange={(e)=>setAppointmentTime(e.target.value)} defaultValue='choose time'>
|
|
|
|
- <option disabled >Выбор даты</option>
|
|
|
|
- {
|
|
|
|
- timeArray.map(el=> (
|
|
|
|
- Object.values(el)[0]
|
|
|
|
- ? <option key={Object.keys(el)[0]} style={{color:'green'}} > {Object.keys(el)[0]} </option>
|
|
|
|
- : <option key={Object.keys(el)[0]} style={{color:'red'}} disabled > {Object.keys(el)[0]} </option>
|
|
|
|
- ))
|
|
|
|
- }
|
|
|
|
- </select>
|
|
|
|
- </div>
|
|
|
|
- : <p>Выберите текущую или будущую дату</p>
|
|
|
|
- }
|
|
|
|
- </div>
|
|
|
|
|
|
+ <select onChange={(e)=>setAppointmentSpec(e.target.value)} defaultValue='Выбор услуги'>
|
|
|
|
+ <option disabled >Выбор услуги</option>
|
|
|
|
+ {
|
|
|
|
+ doctor.speciality.map(el=> (
|
|
|
|
+ <option key={el._id}>{el.name}</option>
|
|
|
|
+ ))
|
|
|
|
+ }
|
|
|
|
+ </select>
|
|
|
|
+
|
|
|
|
+ {appointment.spec &&
|
|
|
|
+ <Calendar doctor={doctor} setAppointmentShedule={setAppointmentShedule} />
|
|
}
|
|
}
|
|
|
|
|
|
- {appointment.time &&
|
|
|
|
- <div style={{display:"flex",flexDirection:"column"}}>
|
|
|
|
- <input type='text' placeholder='Добавить комментарий' onChange={(e)=>setAppointmentComment(e.target.value)}/>
|
|
|
|
- <button onClick={() => postOrders(appointment)}>Подтвердите запись</button>
|
|
|
|
|
|
+ {appointment.shedule &&
|
|
|
|
+ <div>
|
|
|
|
+ <div>
|
|
|
|
+ <select onChange={(e)=>setAppointmentTime(e.target.value)} defaultValue='choose time'>
|
|
|
|
+ <option disabled >Выбор даты</option>
|
|
|
|
+ {
|
|
|
|
+ timeArray.map(el=> (
|
|
|
|
+ <option key={Object.keys(el)[0]}> {Object.keys(el)[0]} </option>
|
|
|
|
+ ))
|
|
|
|
+ }
|
|
|
|
+ </select>
|
|
</div>
|
|
</div>
|
|
|
|
+ </div>
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ {appointment.time &&
|
|
|
|
+ <div style={{display:"flex",flexDirection:"column"}}>
|
|
|
|
+ <input type='text' placeholder='Добавить комментарий' onChange={(e)=>setAppointmentComment(e.target.value)}/>
|
|
|
|
+ <button onClick={() => postOrders(appointment)}>Подтвердите запись</button>
|
|
</div>
|
|
</div>
|
|
|
|
+ }
|
|
|
|
+
|
|
</div>
|
|
</div>
|
|
|
|
+ </div>
|
|
</div>
|
|
</div>
|
|
- }
|
|
|
|
- </div>
|
|
|
|
-
|
|
|
|
|
|
+ }
|
|
|
|
+ </div>
|
|
|
|
+
|
|
</>
|
|
</>
|
|
);
|
|
);
|
|
}
|
|
}
|
|
@@ -136,3 +117,4 @@ const mapDispatchToProps = {
|
|
};
|
|
};
|
|
|
|
|
|
export default connect (mapStateToProps,mapDispatchToProps)(Appoint)
|
|
export default connect (mapStateToProps,mapDispatchToProps)(Appoint)
|
|
|
|
+
|