diff --git a/web-app/package-lock.json b/web-app/package-lock.json
index 8906d2b..0504126 100644
--- a/web-app/package-lock.json
+++ b/web-app/package-lock.json
@@ -19,6 +19,7 @@
"chart.js": "^4.4.9",
"dayjs": "^1.11.13",
"jodit-react": "^5.2.19",
+ "lodash": "^4.17.21",
"prop-types": "^15.8.1",
"react": "^18.3.1",
"react-chartjs-2": "^5.3.0",
@@ -3729,6 +3730,12 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
+ "node_modules/lodash": {
+ "version": "4.17.21",
+ "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
+ "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==",
+ "license": "MIT"
+ },
"node_modules/lodash.merge": {
"version": "4.6.2",
"resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz",
diff --git a/web-app/package.json b/web-app/package.json
index 809c6f6..9820eef 100644
--- a/web-app/package.json
+++ b/web-app/package.json
@@ -21,6 +21,7 @@
"chart.js": "^4.4.9",
"dayjs": "^1.11.13",
"jodit-react": "^5.2.19",
+ "lodash": "^4.17.21",
"prop-types": "^15.8.1",
"react": "^18.3.1",
"react-chartjs-2": "^5.3.0",
diff --git a/web-app/src/Components/Dummies/AppointmentFormModal/AppointmentFormModal.jsx b/web-app/src/Components/Dummies/AppointmentFormModal/AppointmentFormModal.jsx
index 67f952a..71d4634 100644
--- a/web-app/src/Components/Dummies/AppointmentFormModal/AppointmentFormModal.jsx
+++ b/web-app/src/Components/Dummies/AppointmentFormModal/AppointmentFormModal.jsx
@@ -19,7 +19,7 @@ import {
import useAppointmentFormModal from "./useAppointmentFormModal.js";
import useAppointmentFormModalUI from "./useAppointmentFormModalUI.js";
import LoadingIndicator from "../../Widgets/LoadingIndicator/LoadingIndicator.jsx";
-import {useMemo} from "react";
+import {useMemo, useCallback, useRef} from "react";
const AppointmentFormModal = () => {
const appointmentFormModalData = useAppointmentFormModal();
@@ -30,32 +30,66 @@ const AppointmentFormModal = () => {
appointmentFormModalData.useGetByPatientIdQuery
);
- const patientsItems = appointmentFormModalUI.filteredPatients.map((patient) => ({
- key: patient.id,
- label: `${patient.last_name} ${patient.first_name} (${appointmentFormModalUI.getDateString(patient.birthday)})`,
- children: (
-
-
- Пациент: {patient.last_name} {patient.first_name}
-
-
- Дата рождения: {appointmentFormModalUI.getDateString(patient.birthday)}
-
-
- Диагноз: {patient.diagnosis || "Не указан"}
-
-
- Email: {patient.email || "Не указан"}
-
-
- Телефон: {patient.phone || "Не указан"}
-
-
-
- ),
- }));
+ const cursorPositionRef = useRef(null);
+
+ const saveCursorPosition = useCallback(() => {
+ if (appointmentFormModalUI.editor.current) {
+ const editor = appointmentFormModalUI.editor.current.editor;
+ const selection = editor.selection;
+ if (selection) {
+ cursorPositionRef.current = selection.getBookmark();
+ }
+ }
+ }, [appointmentFormModalUI.editor]);
+
+ const restoreCursorPosition = useCallback(() => {
+ if (appointmentFormModalUI.editor.current && cursorPositionRef.current) {
+ const editor = appointmentFormModalUI.editor.current.editor;
+ const selection = editor.selection;
+ if (selection && cursorPositionRef.current) {
+ selection.moveToBookmark(cursorPositionRef.current);
+ }
+ }
+ }, [appointmentFormModalUI.editor]);
+
+ const handleEditorBlur = useCallback(
+ (newContent) => {
+ saveCursorPosition();
+ appointmentFormModalUI.form.setFieldsValue({results: newContent});
+ setTimeout(restoreCursorPosition, 0);
+ },
+ [appointmentFormModalUI.form, saveCursorPosition, restoreCursorPosition]
+ );
+
+ const patientsItems = useMemo(() =>
+ appointmentFormModalUI.filteredPatients.map((patient) => ({
+ key: patient.id,
+ label: `${patient.last_name} ${patient.first_name} (${appointmentFormModalUI.getDateString(patient.birthday)})`,
+ children: (
+
+
+ Пациент: {patient.last_name} {patient.first_name}
+
+
+ Дата рождения: {appointmentFormModalUI.getDateString(patient.birthday)}
+
+
+ Диагноз: {patient.diagnosis || "Не указан"}
+
+
+ Email: {patient.email || "Не указан"}
+
+
+ Телефон: {patient.phone || ""}
+
+
+
+ ),
+ })),
+ [appointmentFormModalUI.filteredPatients, appointmentFormModalUI.getDateString, appointmentFormModalUI.setSelectedPatient]
+ );
const SelectPatientStep = useMemo(() => {
return appointmentFormModalUI.selectedPatient ? (
@@ -70,7 +104,7 @@ const AppointmentFormModal = () => {
Email: {appointmentFormModalUI.selectedPatient.email || "Не указан"}
- Телефон: {appointmentFormModalUI.selectedPatient.phone || "Не указан"}
+ Телефон: {appointmentFormModalUI.selectedPatient.phone || ""}