сделал добавление приемов
This commit is contained in:
parent
08c3bb5c7b
commit
1dbd83af2e
@ -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 (
|
||||
<Result
|
||||
status="error"
|
||||
title="Ошибка"
|
||||
subTitle="Произошла ошибка в работе страницы"
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
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: 'Выберите время'}]}
|
||||
>
|
||||
<DatePicker showTime format="DD.MM.YYYY HH:mm" style={{width: '100%'}}/>
|
||||
<DatePicker maxDate={dayjs(new Date()).add(1, 'day')} defaultValue={dayjs(new Date())} showTime format="DD.MM.YYYY HH:mm" style={{width: '100%'}}/>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
name="days_until_the_next_appointment"
|
||||
@ -168,7 +152,7 @@ const AppointmentFormModal = ({onCancel}) => {
|
||||
<p><b>Пациент:</b> {patient ? `${patient.last_name} ${patient.first_name}` : 'Не выбран'}</p>
|
||||
<p><b>Тип приема:</b> {appointmentType ? appointmentType.name : 'Не выбран'}</p>
|
||||
<p><b>Время
|
||||
приема:</b> {values.appointment_datetime ? dayjs(values.appointment_datetime).tz('Europe/Moscow').format('DD.MM.YYYY HH:mm') : 'Не указано'}
|
||||
приема:</b> {values.appointment_datetime ? dayjs(values.appointment_datetime).format('DD.MM.YYYY HH:mm') : 'Не указано'}
|
||||
</p>
|
||||
<p><b>Дней до следующего приема:</b> {values.days_until_the_next_appointment || 'Не указано'}</p>
|
||||
<p><b>Результаты приема:</b></p>
|
||||
@ -192,6 +176,16 @@ const AppointmentFormModal = ({onCancel}) => {
|
||||
},
|
||||
];
|
||||
|
||||
if (appointmentFormModalData.isError) {
|
||||
return (
|
||||
<Result
|
||||
status="error"
|
||||
title="Ошибка"
|
||||
subTitle="Произошла ошибка в работе страницы"
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
{appointmentFormModalData.isLoading ? (
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -5,7 +5,6 @@ const initialState = {
|
||||
collapsed: true,
|
||||
siderWidth: 250,
|
||||
hovered: false,
|
||||
selectedDate: dayjs().format('YYYY-MM-DD'),
|
||||
modalVisible: false,
|
||||
selectedAppointments: [],
|
||||
selectedAppointment: null,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user