import React from 'react'; import {connect} from "react-redux"; import { setAppointmentSpec, setAppointmentShedule, setAppointmentDoctor, clearAppointment, setAppointmentTime, setAppointmentComment, postOrders } from "../actions/actions"; export class Appoint extends React.Component { componentDidMount() { console.log(this.props) this.props.setAppointmentDoctor(this.props.match.params.doctorId) } componentWillUnmount() { this.props.clearAppointment() } render() { const {doctors, appointment, timeArray, wrongDate,services} = this.props.app; const {match, setAppointmentSpec, setAppointmentShedule, setAppointmentTime, setAppointmentComment, postOrders} = this.props; const doctor = doctors.find(el => el._id === match.params.doctorId); let spec; if (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 ( <> {doctor &&
{doctor.name}
{doctor.profession}
Опыт работы {new Date().toISOString().split('T')[0].split('-')[0] - doctor.experience.split('T')[0].split('-')[0]} лет
{doctor.skillsDescription}
{appointment.spec &&{spec.name}
Duration:{spec.duration}h
{spec.description}
Price: {spec.price} грн.
There is no available time to choose on this date
: null :Choose current or future date
}