import React from "react"; import {connect} from "react-redux"; import moment from "moment"; import {CustomSelect} from "./select"; import { setAppointmentSpec, setAppointmentShedule, setAppointmentDoctor, clearAppointment, setAppointmentTime, setAppointmentComment, postOrders } from "../../actions/appointment"; import Calendar from "../Calendar"; export class Appoint extends React.Component { state = { pickedDate: null }; componentDidMount() { this.props.setAppointmentDoctor(this.props.match.params.doctorId) } componentWillUnmount() { this.props.clearAppointment() } setSpec = (e) => { this.props.setAppointmentSpec({data: e, services: this.props.services}) }; setShedule = (e) => { this.setState({pickedDate: e.target.id}); this.props.setAppointmentShedule({ data: e.target.id, services: this.props.services, doctors: this.props.doctors }) }; setTime = (e) => { this.props.setAppointmentTime(e.target.value) }; setComment = (e) => { this.props.setAppointmentComment(e.target.value) }; postOrder = () => { this.props.postOrders(this.props.appointment.appointment) }; render() { const {appointment, timeArray, doctors, services, match} = this.props; const doctor = doctors.find(el => el._id === match.params.doctorId); let spec; if (appointment.specId) { spec = services.find(el => el._id === appointment.specId) } console.log(appointment) return ( <>
{doctor &&
{doctor.name}/

{doctor.name}

{doctor.profession}

{appointment.specId && } {appointment.sheduleId && (
{timeArray.map((el, index) => (
))}
{appointment.time && (