|
@@ -1,5 +1,6 @@
|
|
import React from 'react';
|
|
import React from 'react';
|
|
import {connect} from "react-redux";
|
|
import {connect} from "react-redux";
|
|
|
|
+import moment from "moment";
|
|
// import { CustomSelect } from "./select";
|
|
// import { CustomSelect } from "./select";
|
|
|
|
|
|
import {
|
|
import {
|
|
@@ -17,6 +18,9 @@ import {
|
|
import Calendar from "./Calendar";
|
|
import Calendar from "./Calendar";
|
|
|
|
|
|
export class Appoint extends React.Component {
|
|
export class Appoint extends React.Component {
|
|
|
|
+ state = {
|
|
|
|
+ pickedDate:null
|
|
|
|
+ };
|
|
|
|
|
|
componentDidMount() {
|
|
componentDidMount() {
|
|
this.props.setAppointmentDoctor(this.props.match.params.doctorId)
|
|
this.props.setAppointmentDoctor(this.props.match.params.doctorId)
|
|
@@ -30,6 +34,11 @@ export class Appoint extends React.Component {
|
|
this.props.setAppointmentSpec(e.target.value)
|
|
this.props.setAppointmentSpec(e.target.value)
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+ setShedule = (e) => {
|
|
|
|
+ this.setState({pickedDate:e.target.id});
|
|
|
|
+ this.props.setAppointmentShedule(e.target.id)
|
|
|
|
+ };
|
|
|
|
+
|
|
setTime = (e) => {
|
|
setTime = (e) => {
|
|
this.props.setAppointmentTime(e.target.value)
|
|
this.props.setAppointmentTime(e.target.value)
|
|
};
|
|
};
|
|
@@ -45,12 +54,13 @@ export class Appoint extends React.Component {
|
|
|
|
|
|
render() {
|
|
render() {
|
|
const {doctors, appointment, timeArray,services} = this.props.app;
|
|
const {doctors, appointment, timeArray,services} = this.props.app;
|
|
- const {match, setAppointmentShedule} = this.props;
|
|
|
|
|
|
+ const {match} = 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)
|
|
}
|
|
}
|
|
|
|
+ console.log(this.props.app.appointment)
|
|
return (
|
|
return (
|
|
<>
|
|
<>
|
|
<div className="main">
|
|
<div className="main">
|
|
@@ -71,6 +81,12 @@ export class Appoint extends React.Component {
|
|
<p>{spec.name}</p>
|
|
<p>{spec.name}</p>
|
|
<p>Длительность: {spec.duration} ч.</p>
|
|
<p>Длительность: {spec.duration} ч.</p>
|
|
<p>Цена от {spec.price} грн.</p>
|
|
<p>Цена от {spec.price} грн.</p>
|
|
|
|
+ {this.state.pickedDate &&
|
|
|
|
+ <p>{moment(this.state.pickedDate).format('DD-MMMM-YYYY')}</p>
|
|
|
|
+ }
|
|
|
|
+ {appointment.time &&
|
|
|
|
+ <p>{appointment.time}</p>
|
|
|
|
+ }
|
|
</div>
|
|
</div>
|
|
}
|
|
}
|
|
|
|
|
|
@@ -84,41 +100,44 @@ export class Appoint extends React.Component {
|
|
</select>
|
|
</select>
|
|
|
|
|
|
{appointment.spec &&
|
|
{appointment.spec &&
|
|
- <Calendar
|
|
|
|
- doctor={doctor}
|
|
|
|
- action={setAppointmentShedule}
|
|
|
|
- />
|
|
|
|
|
|
+ <Calendar
|
|
|
|
+ doctor={doctor}
|
|
|
|
+ action={this.setShedule}
|
|
|
|
+ />
|
|
}
|
|
}
|
|
|
|
|
|
- {appointment.shedule &&
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ {appointment.shedule &&
|
|
<div className = "appointment-time" >
|
|
<div className = "appointment-time" >
|
|
<div className="btn-box" >
|
|
<div className="btn-box" >
|
|
- { timeArray.map ( (el, index)=> (
|
|
|
|
-
|
|
|
|
- <label key={Object.keys(el)} >
|
|
|
|
- <input
|
|
|
|
- type ="radio"
|
|
|
|
- name = "choise-time"
|
|
|
|
- id = {index} onChange={this.setTime}
|
|
|
|
- value = {Object.keys(el)}
|
|
|
|
- />
|
|
|
|
- {Object.keys(el)}
|
|
|
|
- </label>
|
|
|
|
- ))
|
|
|
|
- }
|
|
|
|
- </div>
|
|
|
|
- </div>
|
|
|
|
|
|
+ {
|
|
|
|
+ timeArray.map ( (el, index) => (
|
|
|
|
+ <label key={Object.keys(el)} >
|
|
|
|
+ <input
|
|
|
|
+ type ="radio"
|
|
|
|
+ name = "choise-time"
|
|
|
|
+ id = {index} onChange={this.setTime}
|
|
|
|
+ value = {Object.keys(el)}
|
|
|
|
+ />
|
|
|
|
+ {Object.keys(el)}
|
|
|
|
+ </label>
|
|
|
|
+ ))
|
|
|
|
+ }
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
}
|
|
}
|
|
|
|
|
|
{appointment.time &&
|
|
{appointment.time &&
|
|
<div style={{display:"flex",flexDirection:"column"}}>
|
|
<div style={{display:"flex",flexDirection:"column"}}>
|
|
- <input className = "appointment comment" type='text' placeholder='Добавить комментарий' onChange={this.setComment}/>
|
|
|
|
|
|
+ <input
|
|
|
|
+ className = "appointment comment"
|
|
|
|
+ type='text'
|
|
|
|
+ placeholder='Добавить комментарий'
|
|
|
|
+ onChange={this.setComment}/>
|
|
<button className = "btn link" onClick={this.postOrder}>Подтвердите запись</button>
|
|
<button className = "btn link" onClick={this.postOrder}>Подтвердите запись</button>
|
|
</div>
|
|
</div>
|
|
}
|
|
}
|
|
-
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|