diff --git a/web-app/src/Components/Pages/AppointmentsPage/Components/AppointmentCalendarTab/AppointmentsCalendarTab.jsx b/web-app/src/Components/Pages/AppointmentsPage/Components/AppointmentCalendarTab/AppointmentsCalendarTab.jsx
index f423a4d..e2e3615 100644
--- a/web-app/src/Components/Pages/AppointmentsPage/Components/AppointmentCalendarTab/AppointmentsCalendarTab.jsx
+++ b/web-app/src/Components/Pages/AppointmentsPage/Components/AppointmentCalendarTab/AppointmentsCalendarTab.jsx
@@ -1,25 +1,21 @@
-import { Calendar } from "antd";
+import {Calendar} from "antd";
import "dayjs/locale/ru";
import CalendarCell from "../CalendarCell/CalendarCell.jsx";
-import useAppointments from "../../useAppointments.js";
import useAppointmentCalendarUI from "./useAppointmentCalendarUI.js";
import AppointmentsListModal from "../AppointmentsListModal/AppointmentsListModal.jsx";
import dayjs from "dayjs";
+import PropTypes from "prop-types";
-const AppointmentsCalendarTab = () => {
- const appointmentsData = useAppointments();
- const appointmentsCalendarUI = useAppointmentCalendarUI(
- appointmentsData.appointments,
- appointmentsData.scheduledAppointments
- );
+const AppointmentsCalendarTab = ({currentMonth, onMonthChange, appointments, scheduledAppointments}) => {
+ const appointmentsCalendarUI = useAppointmentCalendarUI(appointments, scheduledAppointments);
const dateCellRender = (value) => {
const appointmentsForDate = appointmentsCalendarUI.getAppointmentsByListAndDate(
- appointmentsData.appointments,
+ appointments,
value
);
const scheduledForDate = appointmentsCalendarUI.getAppointmentsByListAndDate(
- appointmentsData.scheduledAppointments,
+ scheduledAppointments,
value,
true
);
@@ -43,14 +39,26 @@ const AppointmentsCalendarTab = () => {
{
+ appointmentsCalendarUI.onPanelChange(value, mode);
+ if (mode === "month") {
+ onMonthChange(value); // Вызываем onMonthChange при смене месяца
+ }
+ }}
cellRender={dateCellRender}
/>
-
+
);
};
+AppointmentsCalendarTab.propTypes = {
+ currentMonth: PropTypes.object.isRequired,
+ onMonthChange: PropTypes.func.isRequired,
+ appointments: PropTypes.array.isRequired,
+ scheduledAppointments: PropTypes.array.isRequired,
+};
+
export default AppointmentsCalendarTab;
\ No newline at end of file
diff --git a/web-app/src/Components/Pages/HomePage/useHomePage.js b/web-app/src/Components/Pages/HomePage/useHomePage.js
index 72d2d75..478b141 100644
--- a/web-app/src/Components/Pages/HomePage/useHomePage.js
+++ b/web-app/src/Components/Pages/HomePage/useHomePage.js
@@ -1,5 +1,8 @@
-import {useGetAppointmentsQuery} from "../../../Api/appointmentsApi.js";
-import {useGetScheduledAppointmentsQuery} from "../../../Api/scheduledAppointmentsApi.js";
+import {useGetAppointmentsQuery, useGetUpcomingAppointmentsQuery} from "../../../Api/appointmentsApi.js";
+import {
+ useGetScheduledAppointmentsQuery,
+ useGetUpcomingScheduledAppointmentsQuery
+} from "../../../Api/scheduledAppointmentsApi.js";
import {useGetAllPatientsQuery} from "../../../Api/patientsApi.js";
import {notification} from "antd";
import {useEffect} from "react";
@@ -14,32 +17,56 @@ import {
openModal as openPatientModal,
} from "../../../Redux/Slices/patientsSlice.js";
import dayjs from "dayjs";
+import utc from "dayjs/plugin/utc";
+import timezone from "dayjs/plugin/timezone";
import isBetween from "dayjs/plugin/isBetween";
import {useGetAppointmentTypesQuery} from "../../../Api/appointmentTypesApi.js";
+dayjs.extend(utc);
+dayjs.extend(timezone);
dayjs.extend(isBetween);
const useHomePage = () => {
const dispatch = useDispatch();
+ const {userData} = useSelector((state) => state.auth);
- const {
- userData
- } = useSelector((state) => state.auth);
+ const startDate = dayjs().startOf('month').format('YYYY-MM-DD');
+ const endDate = dayjs().endOf('month').format('YYYY-MM-DD');
const {
data: appointments = [],
isLoading: isLoadingAppointments,
isError: isErrorAppointments,
- } = useGetAppointmentsQuery((userData.id), {
- pollingInterval: 20000,
+ } = useGetAppointmentsQuery({doctor_id: userData.id, start_date: startDate, end_date: endDate}, {
+ pollingInterval: 60000,
+ skip: !userData.id,
});
const {
data: scheduledAppointments = [],
isLoading: isLoadingScheduledAppointments,
isError: isErrorScheduledAppointments,
- } = useGetScheduledAppointmentsQuery((userData.id), {
- pollingInterval: 20000,
+ } = useGetScheduledAppointmentsQuery({doctor_id: userData.id, start_date: startDate, end_date: endDate}, {
+ pollingInterval: 60000,
+ skip: !userData.id,
+ });
+
+ const {
+ data: upcomingAppointments = [],
+ isLoading: isLoadingUpcomingAppointments,
+ isError: isErrorUpcomingAppointments,
+ } = useGetUpcomingAppointmentsQuery(userData.id, {
+ pollingInterval: 60000,
+ skip: !userData.id,
+ });
+
+ const {
+ data: upcomingScheduledAppointments = [],
+ isLoading: isLoadingUpcomingScheduledAppointments,
+ isError: isErrorUpcomingScheduledAppointments,
+ } = useGetUpcomingScheduledAppointmentsQuery(userData.id, {
+ pollingInterval: 60000,
+ skip: !userData.id,
});
const {
@@ -47,7 +74,8 @@ const useHomePage = () => {
isLoading: isLoadingPatients,
isError: isErrorPatients,
} = useGetAllPatientsQuery(undefined, {
- pollingInterval: 20000,
+ pollingInterval: 60000,
+ skip: !userData.id,
});
const {
@@ -55,7 +83,8 @@ const useHomePage = () => {
isLoading: isLoadingAppointmentTypes,
isError: isErrorAppointmentTypes,
} = useGetAppointmentTypesQuery(undefined, {
- pollingInterval: 20000,
+ pollingInterval: 60000,
+ skip: !userData.id,
});
useEffect(() => {
@@ -73,6 +102,20 @@ const useHomePage = () => {
placement: "topRight",
});
}
+ if (isErrorUpcomingAppointments) {
+ notification.error({
+ message: "Ошибка",
+ description: "Ошибка загрузки предстоящих приемов.",
+ placement: "topRight",
+ });
+ }
+ if (isErrorUpcomingScheduledAppointments) {
+ notification.error({
+ message: "Ошибка",
+ description: "Ошибка загрузки предстоящих запланированных приемов.",
+ placement: "topRight",
+ });
+ }
if (isErrorPatients) {
notification.error({
message: "Ошибка",
@@ -87,7 +130,14 @@ const useHomePage = () => {
placement: "topRight",
});
}
- }, [isErrorAppointments, isErrorScheduledAppointments, isErrorPatients, isErrorAppointmentTypes]);
+ }, [
+ isErrorAppointments,
+ isErrorScheduledAppointments,
+ isErrorUpcomingAppointments,
+ isErrorUpcomingScheduledAppointments,
+ isErrorPatients,
+ isErrorAppointmentTypes
+ ]);
const handleEventClick = (event) => {
if (event.appointment_datetime) {
@@ -113,15 +163,21 @@ const useHomePage = () => {
patients,
appointments,
scheduledAppointments,
+ upcomingAppointments,
+ upcomingScheduledAppointments,
appointmentTypes,
isLoading:
isLoadingAppointments ||
isLoadingScheduledAppointments ||
+ isLoadingUpcomingAppointments ||
+ isLoadingUpcomingScheduledAppointments ||
isLoadingPatients ||
isLoadingAppointmentTypes,
isError:
isErrorAppointments ||
isErrorScheduledAppointments ||
+ isErrorUpcomingAppointments ||
+ isErrorUpcomingScheduledAppointments ||
isErrorPatients ||
isErrorAppointmentTypes,
handleEventClick,