убрал ошибки, появляющиеся на странице пациентов в браузере
This commit is contained in:
parent
6c2a6e4c00
commit
f5f9cac37e
@ -9,15 +9,17 @@ const PatientModal = ({visible, onCancel, onSubmit, patient}) => {
|
||||
const [form] = Form.useForm();
|
||||
|
||||
useEffect(() => {
|
||||
if (patient) {
|
||||
form.setFieldsValue({
|
||||
...patient,
|
||||
birthday: patient.birthday ? moment(patient.birthday) : null,
|
||||
});
|
||||
} else {
|
||||
form.resetFields();
|
||||
if (visible) {
|
||||
if (patient) {
|
||||
form.setFieldsValue({
|
||||
...patient,
|
||||
birthday: patient.birthday ? moment(patient.birthday) : null,
|
||||
});
|
||||
} else {
|
||||
form.resetFields();
|
||||
}
|
||||
}
|
||||
}, [patient, form]);
|
||||
}, [visible, patient, form]);
|
||||
|
||||
const handleOk = async () => {
|
||||
try {
|
||||
@ -26,6 +28,7 @@ const PatientModal = ({visible, onCancel, onSubmit, patient}) => {
|
||||
values.birthday = values.birthday.format("YYYY-MM-DD");
|
||||
}
|
||||
onSubmit(values);
|
||||
form.resetFields();
|
||||
} catch (errorInfo) {
|
||||
console.log("Validation Failed:", errorInfo);
|
||||
}
|
||||
@ -35,13 +38,17 @@ const PatientModal = ({visible, onCancel, onSubmit, patient}) => {
|
||||
<Modal
|
||||
title={patient ? "Редактировать пациента" : "Добавить пациента"}
|
||||
open={visible}
|
||||
onCancel={onCancel}
|
||||
onCancel={() => {
|
||||
form.resetFields();
|
||||
onCancel();
|
||||
}}
|
||||
onOk={handleOk}
|
||||
okText="Сохранить"
|
||||
cancelText="Отмена"
|
||||
centered
|
||||
maskClosable={false}
|
||||
bodyStyle={{padding: 24}}
|
||||
forceRender={true}
|
||||
styles={{body: {padding: 24}}}
|
||||
style={{top: 20}}
|
||||
>
|
||||
<Form form={form} layout="vertical">
|
||||
|
||||
@ -6,7 +6,6 @@ import getAllPatients from "../api/GetAllPatients.jsx";
|
||||
import PatientListCard from "../components/PatientListCard.jsx";
|
||||
import PatientModal from "../components/PatientModal.jsx"; // Подключаем модальное окно
|
||||
|
||||
const { Search } = Input;
|
||||
const { Option } = Select;
|
||||
|
||||
const PatientsPage = () => {
|
||||
@ -83,7 +82,7 @@ const PatientsPage = () => {
|
||||
<div style={{ padding: 20 }}>
|
||||
<Row gutter={[16, 16]} style={{ marginBottom: 20 }}>
|
||||
<Col xs={24} sm={16}>
|
||||
<Search
|
||||
<Input
|
||||
placeholder="Поиск пациента"
|
||||
onChange={(e) => setSearchText(e.target.value)}
|
||||
style={{ width: "100%" }}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user