import JoditEditor from "jodit-react"; import dayjs from "dayjs"; import { Button, Collapse, DatePicker, Form, Input, InputNumber, Modal, Result, Row, Select, Spin, Steps, Typography, Drawer, Upload, List, } from "antd"; import {UploadOutlined} from '@ant-design/icons'; import useAppointmentFormModal from "./useAppointmentFormModal.js"; import useAppointmentFormModalUI from "./useAppointmentFormModalUI.js"; import LoadingIndicator from "../../Widgets/LoadingIndicator/LoadingIndicator.jsx"; import {useMemo, useCallback, useRef} from "react"; const AppointmentFormModal = () => { const appointmentFormModalData = useAppointmentFormModal(); const appointmentFormModalUI = useAppointmentFormModalUI( appointmentFormModalData.createAppointment, appointmentFormModalData.patients, appointmentFormModalData.cancelAppointment, appointmentFormModalData.useGetByPatientIdQuery ); const cursorPositionRef = useRef(null); const saveCursorPosition = useCallback(() => { if (appointmentFormModalUI.editor.current) { const editor = appointmentFormModalUI.editor.current.editor; const selection = editor.selection; if (selection) { cursorPositionRef.current = selection.getBookmark(); } } }, [appointmentFormModalUI.editor]); const restoreCursorPosition = useCallback(() => { if (appointmentFormModalUI.editor.current && cursorPositionRef.current) { const editor = appointmentFormModalUI.editor.current.editor; const selection = editor.selection; if (selection && cursorPositionRef.current) { selection.moveToBookmark(cursorPositionRef.current); } } }, [appointmentFormModalUI.editor]); const handleEditorBlur = useCallback( (newContent) => { saveCursorPosition(); appointmentFormModalUI.form.setFieldsValue({results: newContent}); setTimeout(restoreCursorPosition, 0); }, [appointmentFormModalUI.form, saveCursorPosition, restoreCursorPosition] ); const patientsItems = useMemo(() => appointmentFormModalUI.filteredPatients.map((patient) => ({ key: patient.id, label: `${patient.last_name} ${patient.first_name} (${appointmentFormModalUI.getDateString(patient.birthday)})`, children: (
Пациент: {patient.last_name} {patient.first_name}
Дата рождения: {appointmentFormModalUI.getDateString(patient.birthday)}
Диагноз: {patient.diagnosis || "Не указан"}
Email: {patient.email || "Не указан"}
Телефон: {patient.phone || ""}
Дата рождения: {appointmentFormModalUI.getSelectedPatientBirthdayString()}
Email: {appointmentFormModalUI.selectedPatient.email || "Не указан"}
Телефон: {appointmentFormModalUI.selectedPatient.phone || ""}
Пациент: {patient ? `${patient.last_name} ${patient.first_name}` : "Не указан"}
Тип приема: {appointmentType ? appointmentType.title : "Не указан"}
Время приема:{" "} {values.appointment_datetime ? dayjs(values.appointment_datetime).format("DD.MM.YYYY HH:mm") : "Не указано"}
Дней до следующего приема: {values.days_until_the_next_appointment || "Не указано"}
Результаты приема:
Прикрепленные файлы:
{appointmentFormModalUI.draftFiles.length > 0 ? (Файлы не прикреплены
)}