diff --git a/web-app/src/Components/Pages/AppointmentsPage/Components/AppointmentCalendarTab/Components/AppointmentFormModal/AppointmentFormModal.jsx b/web-app/src/Components/Pages/AppointmentsPage/Components/AppointmentCalendarTab/Components/AppointmentFormModal/AppointmentFormModal.jsx index 794ebb4..4af887e 100644 --- a/web-app/src/Components/Pages/AppointmentsPage/Components/AppointmentCalendarTab/Components/AppointmentFormModal/AppointmentFormModal.jsx +++ b/web-app/src/Components/Pages/AppointmentsPage/Components/AppointmentCalendarTab/Components/AppointmentFormModal/AppointmentFormModal.jsx @@ -1,8 +1,6 @@ import ReactQuill from 'react-quill'; import 'react-quill/dist/quill.snow.css'; import dayjs from "dayjs"; -import utc from "dayjs/plugin/utc"; -import timezone from "dayjs/plugin/timezone"; import { Button, Collapse, @@ -24,10 +22,6 @@ import LoadingIndicator from "../../../../../../Widgets/LoadingIndicator.jsx"; import {useMemo} from "react"; import PropTypes from "prop-types"; -dayjs.extend(utc); -dayjs.extend(timezone); -dayjs.tz.setDefault('Europe/Moscow'); - const AppointmentFormModal = ({onCancel}) => { const appointmentFormModalData = useAppointmentFormModal(); const appointmentFormModalUI = useAppointmentFormModalUI( @@ -37,16 +31,6 @@ const AppointmentFormModal = ({onCancel}) => { appointmentFormModalData.patients, ); - if (appointmentFormModalData.isError) { - return ( - - ); - } - const patientsItems = appointmentFormModalUI.filteredPatients.map((patient) => ({ key: patient.id, label: `${patient.last_name} ${patient.first_name} (${appointmentFormModalUI.getDateString(patient.birthday)})`, @@ -107,7 +91,7 @@ const AppointmentFormModal = ({onCancel}) => { ? { patient_id: appointmentFormModalUI.selectedAppointment.patient_id, type_id: appointmentFormModalUI.selectedAppointment.type_id, - appointment_datetime: dayjs(appointmentFormModalUI.selectedAppointment.appointment_datetime).tz('Europe/Moscow'), + appointment_datetime: appointmentFormModalUI.appo, days_until_the_next_appointment: appointmentFormModalUI.selectedAppointment.days_until_the_next_appointment, results: appointmentFormModalUI.selectedAppointment.results, } @@ -135,7 +119,7 @@ const AppointmentFormModal = ({onCancel}) => { label="Время приема" rules={[{required: true, message: 'Выберите время'}]} > - + {

Пациент: {patient ? `${patient.last_name} ${patient.first_name}` : 'Не выбран'}

Тип приема: {appointmentType ? appointmentType.name : 'Не выбран'}

Время - приема: {values.appointment_datetime ? dayjs(values.appointment_datetime).tz('Europe/Moscow').format('DD.MM.YYYY HH:mm') : 'Не указано'} + приема: {values.appointment_datetime ? dayjs(values.appointment_datetime).format('DD.MM.YYYY HH:mm') : 'Не указано'}

Дней до следующего приема: {values.days_until_the_next_appointment || 'Не указано'}

Результаты приема:

@@ -192,6 +176,16 @@ const AppointmentFormModal = ({onCancel}) => { }, ]; + if (appointmentFormModalData.isError) { + return ( + + ); + } + return ( <> {appointmentFormModalData.isLoading ? ( diff --git a/web-app/src/Components/Pages/AppointmentsPage/Components/AppointmentCalendarTab/Components/AppointmentFormModal/useAppointmentFormModalUI.js b/web-app/src/Components/Pages/AppointmentsPage/Components/AppointmentCalendarTab/Components/AppointmentFormModal/useAppointmentFormModalUI.js index e19e5c3..adbd33f 100644 --- a/web-app/src/Components/Pages/AppointmentsPage/Components/AppointmentCalendarTab/Components/AppointmentFormModal/useAppointmentFormModalUI.js +++ b/web-app/src/Components/Pages/AppointmentsPage/Components/AppointmentCalendarTab/Components/AppointmentFormModal/useAppointmentFormModalUI.js @@ -16,6 +16,7 @@ const useAppointmentFormModalUI = (onCancel, createAppointment, updateAppointmen const [selectedPatient, setSelectedPatient] = useState(null); const [currentStep, setCurrentStep] = useState(0); + const [appointmentDate, setAppointmentDate] = useState(dayjs(new Date())); const [searchPatientString, setSearchPatientString] = useState(""); const [formValues, setFormValues] = useState({}); @@ -30,7 +31,7 @@ const useAppointmentFormModalUI = (onCancel, createAppointment, updateAppointmen const stepsContentStyle = {marginBottom: 16}; const stepsIndicatorStyle = {marginBottom: 16}; const footerRowStyle = {marginTop: 16}; - const footerButtonStyle = {marginLeft: 8}; + const footerButtonStyle = {marginRight: 8}; const screenXS = !screens.sm; const direction = screenXS ? "vertical" : "horizontal"; @@ -58,7 +59,7 @@ const useAppointmentFormModalUI = (onCancel, createAppointment, updateAppointmen patient_id: selectedAppointment.patient_id, type_id: selectedAppointment.type_id, appointment_datetime: selectedAppointment.appointment_datetime - ? dayjs(selectedAppointment.appointment_datetime).tz('Europe/Moscow') + ? dayjs(selectedAppointment.appointment_datetime) : null, days_until_the_next_appointment: selectedAppointment.days_until_the_next_appointment, results: selectedAppointment.results, @@ -84,6 +85,7 @@ const useAppointmentFormModalUI = (onCancel, createAppointment, updateAppointmen form.setFieldsValue({patient_id: undefined}); }; + const handleSetAppointmentDate = (date) => setAppointmentDate(date); const modalWidth = useMemo(() => screenXS ? 700 : "90%", [screenXS]); const handleClickNextButton = async () => { @@ -125,11 +127,10 @@ const useAppointmentFormModalUI = (onCancel, createAppointment, updateAppointmen try { const values = formValues; - // Проверка пересечения времени const appointmentTime = values.appointment_datetime; const hasConflict = appointments.some(app => app.id !== selectedAppointment?.id && - dayjs(app.appointment_datetime).tz('Europe/Moscow').isSame(appointmentTime, 'minute') + dayjs(app.appointment_datetime).isSame(appointmentTime, 'minute') ); if (hasConflict) { @@ -142,23 +143,13 @@ const useAppointmentFormModalUI = (onCancel, createAppointment, updateAppointmen } const data = { - patient_id: values.patient_id, + patient_id: selectedPatient.id, type_id: values.type_id, - appointment_datetime: appointmentTime.toISOString(), + appointment_datetime: appointmentTime.format("YYYY-MM-DD HH:mm:ss"), days_until_the_next_appointment: values.days_until_the_next_appointment, results: values.results, - doctor_id: localStorage.getItem('doctor_id'), }; - if (!data.doctor_id) { - notification.error({ - message: 'Ошибка', - description: 'ID доктора не найден. Пожалуйста, войдите в систему.', - placement: 'topRight', - }); - return; - } - if (selectedAppointment) { await updateAppointment({id: selectedAppointment.id, data}).unwrap(); notification.success({ @@ -209,6 +200,7 @@ const useAppointmentFormModalUI = (onCancel, createAppointment, updateAppointmen setSelectedPatient, currentStep, searchPatientString, + appointmentDate, handleSetSearchPatientString, filteredPatients, handleOk, @@ -218,6 +210,7 @@ const useAppointmentFormModalUI = (onCancel, createAppointment, updateAppointmen getSelectedPatientBirthdayString, handleClickNextButton, handleClickBackButton, + handleSetAppointmentDate, modalWidth, disableBackButton, disableNextButton, diff --git a/web-app/src/Redux/Slices/appointmentsSlice.js b/web-app/src/Redux/Slices/appointmentsSlice.js index 4f28ae1..4ac6f8f 100644 --- a/web-app/src/Redux/Slices/appointmentsSlice.js +++ b/web-app/src/Redux/Slices/appointmentsSlice.js @@ -5,7 +5,6 @@ const initialState = { collapsed: true, siderWidth: 250, hovered: false, - selectedDate: dayjs().format('YYYY-MM-DD'), modalVisible: false, selectedAppointments: [], selectedAppointment: null,