diff --git a/web-app/src/App/main.jsx b/web-app/src/App/main.jsx index e80349e..74ce178 100644 --- a/web-app/src/App/main.jsx +++ b/web-app/src/App/main.jsx @@ -1,2 +1,9 @@ -import {ComponentPreviews, useInitial} from "../dev/index.js"; -import {DevSupport} from "@react-buddy/ide-toolbox"; \ No newline at end of file +import {StrictMode} from 'react' +import {createRoot} from 'react-dom/client' +import App from './App.jsx' + +createRoot(document.getElementById('root')).render( + + + +) 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 a431f2e..3d0851c 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 @@ -89,19 +89,9 @@ const AppointmentFormModal = ({onCancel}) => {
{ ) : ( { 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()), - }) - } + + 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', - }); - } + + 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,