убрал редактирование приема
This commit is contained in:
parent
6add3821c7
commit
2a1f6a9989
@ -1,2 +1,9 @@
|
||||
import {ComponentPreviews, useInitial} from "../dev/index.js";
|
||||
import {DevSupport} from "@react-buddy/ide-toolbox";
|
||||
import {StrictMode} from 'react'
|
||||
import {createRoot} from 'react-dom/client'
|
||||
import App from './App.jsx'
|
||||
|
||||
createRoot(document.getElementById('root')).render(
|
||||
<StrictMode>
|
||||
<App/>
|
||||
</StrictMode>
|
||||
)
|
||||
|
||||
@ -89,19 +89,9 @@ const AppointmentFormModal = ({onCancel}) => {
|
||||
<Form
|
||||
form={appointmentFormModalUI.form}
|
||||
onFinish={appointmentFormModalUI.handleOk}
|
||||
initialValues={
|
||||
appointmentFormModalUI.selectedAppointment
|
||||
? {
|
||||
patient_id: appointmentFormModalUI.selectedAppointment.patient_id,
|
||||
type_id: appointmentFormModalUI.selectedAppointment.type_id,
|
||||
appointment_datetime: appointmentFormModalUI.appo,
|
||||
days_until_the_next_appointment: appointmentFormModalUI.selectedAppointment.days_until_the_next_appointment,
|
||||
results: appointmentFormModalUI.selectedAppointment.results,
|
||||
}
|
||||
: {
|
||||
initialValues={{
|
||||
patient_id: appointmentFormModalUI.selectedPatient?.id,
|
||||
}
|
||||
}
|
||||
}}
|
||||
layout="vertical"
|
||||
>
|
||||
<Form.Item
|
||||
@ -205,7 +195,7 @@ const AppointmentFormModal = ({onCancel}) => {
|
||||
<LoadingIndicator/>
|
||||
) : (
|
||||
<Modal
|
||||
title={appointmentFormModalUI.selectedAppointment ? "Редактировать прием" : "Создать прием"}
|
||||
title={"Создать прием"}
|
||||
open={appointmentFormModalUI.modalVisible}
|
||||
onCancel={appointmentFormModalUI.handleCancel}
|
||||
footer={null}
|
||||
|
||||
@ -10,7 +10,7 @@ const {useBreakpoint} = Grid;
|
||||
|
||||
const useAppointmentFormModalUI = (onCancel, createAppointment, updateAppointment, patients) => {
|
||||
const dispatch = useDispatch();
|
||||
const {modalVisible, selectedAppointment} = useSelector(state => state.appointmentsUI);
|
||||
const {modalVisible} = useSelector(state => state.appointmentsUI);
|
||||
const [form] = Form.useForm();
|
||||
const screens = useBreakpoint();
|
||||
|
||||
@ -52,26 +52,12 @@ const useAppointmentFormModalUI = (onCancel, createAppointment, updateAppointmen
|
||||
setCurrentStep(0);
|
||||
setSearchPatientString("");
|
||||
setFormValues({});
|
||||
if (selectedAppointment) {
|
||||
const patient = appointments.find(p => p.id === selectedAppointment.patient_id);
|
||||
setSelectedPatient(patient);
|
||||
setCurrentStep(1);
|
||||
form.setFieldsValue({
|
||||
patient_id: selectedAppointment.patient_id,
|
||||
type_id: selectedAppointment.type_id,
|
||||
appointment_datetime: selectedAppointment.appointment_datetime
|
||||
? dayjs(selectedAppointment.appointment_datetime)
|
||||
: dayjs(new Date()),
|
||||
days_until_the_next_appointment: selectedAppointment.days_until_the_next_appointment,
|
||||
results: selectedAppointment.results,
|
||||
});
|
||||
} else {
|
||||
|
||||
form.setFieldsValue({
|
||||
appointment_datetime: dayjs(new Date()),
|
||||
})
|
||||
}
|
||||
}
|
||||
}, [modalVisible, selectedAppointment, form, appointments]);
|
||||
}, [modalVisible, form, appointments]);
|
||||
|
||||
const handleResultsChange = (newContent) => {
|
||||
setResults(newContent);
|
||||
@ -114,10 +100,10 @@ const useAppointmentFormModalUI = (onCancel, createAppointment, updateAppointmen
|
||||
const values = await form.validateFields();
|
||||
setFormValues(values);
|
||||
setCurrentStep(2);
|
||||
} catch (_) {
|
||||
} catch (error) {
|
||||
notification.error({
|
||||
message: 'Ошибка валидации',
|
||||
description: 'Пожалуйста, заполните все обязательные поля.',
|
||||
description: error.message || 'Пожалуйста, заполните все обязательные поля.',
|
||||
placement: 'topRight',
|
||||
});
|
||||
}
|
||||
@ -138,7 +124,6 @@ const useAppointmentFormModalUI = (onCancel, createAppointment, updateAppointmen
|
||||
|
||||
const appointmentTime = values.appointment_datetime;
|
||||
const hasConflict = appointments.some(app =>
|
||||
app.id !== selectedAppointment?.id &&
|
||||
dayjs(app.appointment_datetime).isSame(appointmentTime, 'minute')
|
||||
);
|
||||
|
||||
@ -159,21 +144,13 @@ const useAppointmentFormModalUI = (onCancel, createAppointment, updateAppointmen
|
||||
results: results,
|
||||
};
|
||||
|
||||
if (selectedAppointment) {
|
||||
await updateAppointment({id: selectedAppointment.id, data}).unwrap();
|
||||
notification.success({
|
||||
message: 'Прием обновлен',
|
||||
description: 'Прием успешно обновлен.',
|
||||
placement: 'topRight',
|
||||
});
|
||||
} else {
|
||||
|
||||
await createAppointment(data).unwrap();
|
||||
notification.success({
|
||||
message: 'Прием создан',
|
||||
description: 'Прием успешно создан.',
|
||||
placement: 'topRight',
|
||||
});
|
||||
}
|
||||
|
||||
dispatch(closeModal());
|
||||
form.resetFields();
|
||||
@ -200,7 +177,7 @@ const useAppointmentFormModalUI = (onCancel, createAppointment, updateAppointmen
|
||||
|
||||
const disableBackButton = currentStep === 0;
|
||||
const disableNextButton = currentStep === 0 && !selectedPatient;
|
||||
const nextButtonText = currentStep === 2 ? (selectedAppointment ? 'Сохранить' : 'Создать') : 'Далее';
|
||||
const nextButtonText = currentStep === 2 ? 'Создать' : 'Далее';
|
||||
|
||||
return {
|
||||
form,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user