setHovered(true)}
+ onMouseLeave={() => setHovered(false)}
+ >
+ : }
+ style={{
+ width: hovered ? 250 : 50,
+ padding: hovered ? "0 20px" : "0",
+ overflow: "hidden",
+ textAlign: "left",
+ transition: "width 0.3s ease, padding 0.3s ease",
+ borderRadius: "4px 0 0 4px",
+ }}
+ >
+ {hovered ? (collapsed ? "Показать предстоящие события" : "Скрыть предстоящие события") : ""}
+
+
+ >
);
};
-export default AppointmentsLayout;
\ No newline at end of file
+export default AppointmentsLayout;
diff --git a/web-app/src/pages/IssuesPage.jsx b/web-app/src/pages/IssuesPage.jsx
index 9c5e3ae..22ff090 100644
--- a/web-app/src/pages/IssuesPage.jsx
+++ b/web-app/src/pages/IssuesPage.jsx
@@ -1,6 +1,5 @@
import {
notification,
- Spin,
Table,
Input,
Row,
@@ -12,21 +11,23 @@ import {
Typography,
Timeline, Grid, Pagination
} from "antd";
-import getAllLensIssues from "../api/lens_issues/GetAllLensIssues.jsx";
+import getAllLensIssues from "../api/lens_issues/getAllLensIssues.jsx";
import {useEffect, useState} from "react";
import {useAuth} from "../AuthContext.jsx";
-import {DatabaseOutlined, LoadingOutlined, PlusOutlined, UnorderedListOutlined} from "@ant-design/icons";
+import {DatabaseOutlined, PlusOutlined, UnorderedListOutlined} from "@ant-design/icons";
import LensIssueViewModal from "../components/lens_issues/LensIssueViewModal.jsx";
import dayjs from "dayjs";
import LensIssueFormModal from "../components/lens_issues/LensIssueFormModal.jsx";
-import addLensIssue from "../api/lens_issues/AddLensIssue.jsx";
+import addLensIssue from "../api/lens_issues/addLensIssue.jsx";
import SelectViewMode from "../components/SelectViewMode.jsx";
+import LoadingIndicator from "../components/LoadingIndicator.jsx";
+import {getCachedInfo, getCacheTimestamp} from "../utils/cachedInfoUtils.jsx";
const {Title} = Typography;
const {useBreakpoint} = Grid;
const IssuesPage = () => {
- const {user} = useAuth();
+ const {api} = useAuth();
const screens = useBreakpoint();
const [loading, setLoading] = useState(true);
@@ -56,13 +57,13 @@ const IssuesPage = () => {
const intervalId = setInterval(fetchLensIssues, 5000);
return () => clearInterval(intervalId);
}
- }, [user, isModalVisible]);
+ }, [isModalVisible]);
const fetchLensIssuesWithCache = async () => {
- const cachedData = localStorage.getItem("lensIssuesData");
- const cacheTimestamp = localStorage.getItem("lensIssuesTimestamp");
+ const cachedData = getCachedInfo("lensIssuesData");
+ const cacheTimestamp = getCacheTimestamp("lensIssuesData");
- if (cachedData && cacheTimestamp && (Date.now() - parseInt(cacheTimestamp)) < 60 * 1000) {
+ if (cachedData && cacheTimestamp && (Date.now() - cacheTimestamp) < 60 * 1000) {
setLensIssues(JSON.parse(cachedData));
setLoading(false);
} else {
@@ -71,7 +72,7 @@ const IssuesPage = () => {
};
const fetchViewModeFromCache = () => {
- const cachedViewMode = localStorage.getItem("viewModeIssues");
+ const cachedViewMode = getCachedInfo("viewModeIssues");
if (cachedViewMode) {
setViewMode(cachedViewMode);
}
@@ -92,7 +93,7 @@ const IssuesPage = () => {
const handleSubmitFormModal = async (issue_date, patient_id, lens_id) => {
try {
- await addLensIssue(user.token, {issue_date, patient_id, lens_id});
+ await addLensIssue(api, {issue_date, patient_id, lens_id});
setIsModalVisible(false);
notification.success({
message: "Линза выдана",
@@ -112,7 +113,7 @@ const IssuesPage = () => {
const fetchLensIssues = async () => {
try {
- const data = await getAllLensIssues(user.token);
+ const data = await getAllLensIssues(api);
setLensIssues(data);
setLoading(false);
} catch (error) {
@@ -345,9 +346,7 @@ const IssuesPage = () => {
{loading ? (
-
diff --git a/web-app/src/pages/lenses_layout/LensesPage.jsx b/web-app/src/pages/lenses_layout/LensesPage.jsx
index 8f9d235..bcec68d 100644
--- a/web-app/src/pages/lenses_layout/LensesPage.jsx
+++ b/web-app/src/pages/lenses_layout/LensesPage.jsx
@@ -6,7 +6,6 @@ import {
FloatButton,
Row,
Col,
- Spin,
Button,
Form,
InputNumber,
@@ -18,7 +17,6 @@ import {
Typography
} from "antd";
import {
- LoadingOutlined,
PlusOutlined,
DownOutlined,
UpOutlined,
@@ -27,20 +25,22 @@ import {
BuildOutlined
} from "@ant-design/icons";
import LensCard from "../../components/lenses/LensListCard.jsx";
-import getAllLenses from "../../api/lenses/GetAllLenses.jsx";
-import addLens from "../../api/lenses/AddLens.jsx";
-import updateLens from "../../api/lenses/UpdateLens.jsx";
-import deleteLens from "../../api/lenses/DeleteLens.jsx";
+import getAllLenses from "../../api/lenses/getAllLenses.jsx";
+import addLens from "../../api/lenses/addLens.jsx";
+import updateLens from "../../api/lenses/updateLens.jsx";
+import deleteLens from "../../api/lenses/deleteLens.jsx";
import {useAuth} from "../../AuthContext.jsx";
import LensFormModal from "../../components/lenses/LensFormModal.jsx";
import SelectViewMode from "../../components/SelectViewMode.jsx";
+import LoadingIndicator from "../../components/LoadingIndicator.jsx";
+import {getCachedInfo, getCacheTimestamp} from "../../utils/cachedInfoUtils.jsx";
const {Option} = Select;
const {useBreakpoint} = Grid;
const {Title} = Typography;
const LensesPage = () => {
- const {user} = useAuth();
+ const {api} = useAuth();
const screens = useBreakpoint();
const [current, setCurrent] = useState(1);
@@ -76,11 +76,11 @@ const LensesPage = () => {
const intervalId = setInterval(fetchLenses, 5000);
return () => clearInterval(intervalId);
}
- }, [user, isModalVisible, selectedLens]);
+ }, [isModalVisible, selectedLens]);
const fetchLensWithCache = async () => {
- const cachedData = localStorage.getItem("lensData");
- const cacheTimestamp = localStorage.getItem("lensTimestamp");
+ const cachedData = getCachedInfo("lensData");
+ const cacheTimestamp = getCacheTimestamp("lensData");
if (cachedData && cacheTimestamp && (Date.now() - parseInt(cacheTimestamp)) < 60 * 1000) {
setLenses(JSON.parse(cachedData));
@@ -93,7 +93,7 @@ const LensesPage = () => {
const fetchLenses = async () => {
try {
- const data = await getAllLenses(user.token);
+ const data = await getAllLenses(api);
setLenses(data);
setLoading(false);
} catch (error) {
@@ -108,7 +108,7 @@ const LensesPage = () => {
};
const fetchViewModeFromCache = () => {
- const cachedViewMode = localStorage.getItem("viewModeLenses");
+ const cachedViewMode = getCachedInfo("viewModeLenses");
if (cachedViewMode) {
setViewMode(cachedViewMode);
}
@@ -148,8 +148,8 @@ const LensesPage = () => {
const handleDeleteLens = async (lensId) => {
try {
- await deleteLens(user.token, lensId);
- await fetchLenses(user.token);
+ await deleteLens(api, lensId);
+ await fetchLenses(api);
notification.success({
message: "Линза удалена",
description: "Линза успешно удалена.",
@@ -168,14 +168,14 @@ const LensesPage = () => {
const handleModalSubmit = async (lensData) => {
try {
if (selectedLens) {
- await updateLens(user.token, selectedLens.id, lensData);
+ await updateLens(api, selectedLens.id, lensData);
notification.success({
message: "Линза обновлена",
description: "Линза успешно обновлена.",
placement: "topRight",
});
} else {
- await addLens(user.token, lensData);
+ await addLens(api, lensData);
notification.success({
message: "Линза добавлена",
description: "Линза успешно добавлена.",
@@ -345,7 +345,6 @@ const LensesPage = () => {
/>
);
-
return (
Линзы
@@ -497,9 +496,7 @@ const LensesPage = () => {
)}
{loading ? (
-
- }/>
-
+
) : viewMode === "tile" ? (
) : (
diff --git a/web-app/src/pages/lenses_layout/SetLensesPage.jsx b/web-app/src/pages/lenses_layout/SetLensesPage.jsx
index 7b9f59d..f569d3a 100644
--- a/web-app/src/pages/lenses_layout/SetLensesPage.jsx
+++ b/web-app/src/pages/lenses_layout/SetLensesPage.jsx
@@ -1,22 +1,24 @@
import {useAuth} from "../../AuthContext.jsx";
import {useEffect, useState} from "react";
-import {FloatButton, Input, List, notification, Row, Spin, Typography} from "antd";
-import getAllSets from "../../api/sets/GetAllSets.jsx";
-import {LoadingOutlined, PlusOutlined, SwitcherOutlined} from "@ant-design/icons";
+import {FloatButton, Input, List, notification, Row, Typography} from "antd";
+import getAllSets from "../../api/sets/getAllSets.jsx";
+import {PlusOutlined, SwitcherOutlined} from "@ant-design/icons";
import SetListCard from "../../components/sets/SetListCard.jsx";
import SetFormModal from "../../components/sets/SetFormModal.jsx";
-import updateSet from "../../api/sets/UpdateSet.jsx";
-import addSet from "../../api/sets/AddSet.jsx";
-import deleteSet from "../../api/sets/DeleteSet.jsx";
-import addSetContent from "../../api/set_content/AddSetContent.jsx";
-import updateSetContent from "../../api/set_content/UpdateSetContent.jsx";
-import appendLensesFromSet from "../../api/sets/AppendLensesFromSet.jsx";
+import updateSet from "../../api/sets/updateSet.jsx";
+import addSet from "../../api/sets/addSet.jsx";
+import deleteSet from "../../api/sets/deleteSet.jsx";
+import addSetContent from "../../api/set_content/addSetContent.jsx";
+import updateSetContent from "../../api/set_content/updateSetContent.jsx";
+import appendLensesFromSet from "../../api/sets/appendLensesFromSet.jsx";
+import LoadingIndicator from "../../components/LoadingIndicator.jsx";
+import {cacheInfo, getCachedInfo, getCacheTimestamp} from "../../utils/cachedInfoUtils.jsx";
const {Title} = Typography;
const SetLensesPage = () => {
- const {user} = useAuth();
+ const {api} = useAuth();
const [current, setCurrent] = useState(1);
const [pageSize, setPageSize] = useState(10);
@@ -36,14 +38,14 @@ const SetLensesPage = () => {
const intervalId = setInterval(fetchSets, 5000);
return () => clearInterval(intervalId);
}
- }, [user, isModalVisible]);
+ }, [isModalVisible]);
const fetchSetsWithCache = async () => {
- const cachedData = localStorage.getItem("setsData");
- const cacheTimestamp = localStorage.getItem("setsTimestamp");
+ const cachedData = getCachedInfo("setsData");
+ const cacheTimestamp = getCacheTimestamp("setsData");
- if (cachedData && cacheTimestamp && (Date.now() - parseInt(cacheTimestamp)) < 60 * 1000) {
- setSets(JSON.parse(cachedData));
+ if (cachedData && cacheTimestamp && (Date.now() - cacheTimestamp) < 60 * 1000) {
+ setSets(cachedData);
setLoading(false);
} else {
await fetchSets();
@@ -51,14 +53,11 @@ const SetLensesPage = () => {
};
const fetchSets = async () => {
- if (!user || !user.token) return;
-
try {
- const data = await getAllSets(user.token);
+ const data = await getAllSets(api);
setSets(data);
- localStorage.setItem("setsData", JSON.stringify(data));
- localStorage.setItem("setsTimestamp", Date.now().toString());
+ cacheInfo("setsData", data);
} catch (error) {
console.log(error);
notification.error({
@@ -87,7 +86,7 @@ const SetLensesPage = () => {
const handleDeleteSet = async (set_id) => {
try {
- await deleteSet(user.token, set_id);
+ await deleteSet(api, set_id);
notification.success({
message: "Набор удален",
description: "Набор успешно удален.",
@@ -110,7 +109,7 @@ const SetLensesPage = () => {
const handleAppendSet = async (set) => {
try {
- await appendLensesFromSet(user.token, set.id);
+ await appendLensesFromSet(api, set.id);
notification.success({
message: "Линзы добавлены",
description: "Линзы успешно добавлены.",
@@ -157,7 +156,7 @@ const SetLensesPage = () => {
const setContent = async (content, set_id) => {
try {
console.log(content);
- await addSetContent(user.token, content, set_id);
+ await addSetContent(api, content, set_id);
} catch (error) {
console.error("Ошибка сохранения набора:", error);
notification.error({
@@ -170,7 +169,7 @@ const SetLensesPage = () => {
const updateContent = async (content, set_id) => {
try {
- await updateSetContent(user.token, content, set_id);
+ await updateSetContent(api, content, set_id);
} catch (error) {
console.error("Ошибка сохранения набора:", error);
notification.error({
@@ -182,7 +181,7 @@ const SetLensesPage = () => {
};
const editCurrentSet = async (set) => {
- const refreshed_set = await updateSet(user.token, selectedSet.id, set);
+ const refreshed_set = await updateSet(api, selectedSet.id, set);
notification.success({
message: "Набор обновлен",
description: "Набор успешно обновлен.",
@@ -192,7 +191,7 @@ const SetLensesPage = () => {
};
const addNewSet = async (set) => {
- const refreshed_set = await addSet(user.token, set);
+ const refreshed_set = await addSet(api, set);
notification.success({
message: "Набор добавлен",
description: "Набор успешно добавлен.",
@@ -214,14 +213,7 @@ const SetLensesPage = () => {
{loading ? (
-
- }/>
-
+
) : (
{
+ localStorage.setItem(key, JSON.stringify(value));
+ localStorage.setItem(`${key}Timestamp`, Date.now().toString());
+};
+
+const getCachedInfo = (key) => {
+ const data = localStorage.getItem(key);
+ if (!data) return null;
+ return JSON.parse(data);
+};
+
+const getCacheTimestamp = (key) => {
+ const timestamp = localStorage.getItem(`${key}Timestamp`);
+ if (!timestamp) return null;
+ return parseInt(timestamp);
+};
+
+export {cacheInfo, getCachedInfo, getCacheTimestamp};
\ No newline at end of file