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:
@@ -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,
|
||||
|
||||
@@ -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 }) {
|
||||
|
||||
Reference in New Issue
Block a user