feat: enhance CalendarPage and DutyList components for improved loading state handling

- Removed the loading state placeholder from CalendarPage, directly rendering the CalendarGrid component.
- Updated DutyList to display a loading message when data is being fetched, enhancing user experience during data loading.
- Introduced a new dataForMonthKey in the app store to manage month-specific data more effectively.
- Refactored useMonthData hook to reset duties and calendarEvents when a new month is detected, ensuring accurate data representation.
- Added tests to verify the new loading state behavior in both components.
This commit is contained in:
2026-03-03 16:17:24 +03:00
parent 16bf1a1043
commit 3b68e29d7b
6 changed files with 46 additions and 30 deletions

View File

@@ -1,6 +1,13 @@
import "@testing-library/jest-dom/vitest";
import { vi } from "vitest";
// jsdom does not provide ResizeObserver (used by CalendarPage for sticky block height).
global.ResizeObserver = vi.fn().mockImplementation(() => ({
observe: vi.fn(),
unobserve: vi.fn(),
disconnect: vi.fn(),
}));
// jsdom does not provide window.matchMedia (used by use-media-query and use-telegram-theme).
Object.defineProperty(window, "matchMedia", {
writable: true,

View File

@@ -18,6 +18,7 @@ export function resetAppStore() {
state.setAccessDenied(false);
state.setCurrentView("calendar");
state.setSelectedDay(null);
state.batchUpdate({ dataForMonthKey: null });
}
function AllTheProviders({ children }: { children: React.ReactNode }) {