import React from 'react'; import {CustomSelect} from "../../hooks/select"; import Calendar from "../../Calendar"; import ConfirmButton from "../../ConfirmButton"; class ChangeOrder extends React.Component { state = { order: { spec: '', doctor: '', time: '', comment: '', orderNumber: null, user: '', }, flag: false, showConfirm: false, }; changeConfirm = () => { this.setState({showConfirm: !this.state.showConfirm}) }; componentDidMount() { this.setState({ order: { spec: this.props.order.spec, doctor: this.props.order.doctor, time: this.props.order.time, comment: this.props.order.comment, orderNumber: this.props.order.orderNumber, date: this.props.order.date.split('T')[0], user: this.props.order.user, } }); } componentWillUnmount() { this.props.clearAppointment() } changeOrder = () => { this.setState({flag: !this.state.flag}) }; setDoctor = (e) => { this.props.setAppointmentDoctor(this.props.doctors.find(el => el.name === e)._id) }; setSpec = (e) => { this.props.setAppointmentSpec({services: this.props.services, data: e}) }; setShedule = (e) => { 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) }; deleteAndPostNewOrder = () => { this.props.deleteOrder({ id: this.props.order._id, newOrder: { spec: this.props.appointment.specId, doctor: this.props.appointment.doctorId, shedule: this.props.appointment.sheduleId, time: this.props.appointment.time, comment: this.props.appointment.comment, orderNumber: this.state.order.orderNumber, user:this.state.order.user._id } }); this.changeConfirm() }; render() { const { doctors, appointment, timeArray } = this.props; return ( <> {this.state.showConfirm && }
{this.state.flag &&
{appointment.doctorId && el._id === appointment.doctorId).speciality : []} clickOptionEvent={this.setSpec} /> } {appointment.specId && el._id === appointment.doctorId)} action={this.setShedule} /> } {appointment.sheduleId && (
{timeArray.map((el, index) => (
))}
{appointment.time && (