feat: enhance admin page and testing functionality

- Updated admin page to include navigation buttons for month selection, improving user experience.
- Refactored `AdminDutyList` to group duties by date, enhancing the display and organization of duties.
- Improved error handling in `ReassignSheet` by using i18n keys for error messages, ensuring better localization support.
- Enhanced tests for admin page and components to reflect recent changes, ensuring accuracy in functionality and accessibility.
- Added event dispatch for configuration loading in the app configuration, improving integration with the Telegram Mini App.
This commit is contained in:
2026-03-06 12:04:16 +03:00
parent 53a899ea26
commit 02a586a1c5
11 changed files with 324 additions and 113 deletions

View File

@@ -7,7 +7,6 @@
import { useEffect } from "react";
import { useAppStore } from "@/store/app-store";
import { getLang } from "@/i18n/messages";
import { useTranslation } from "@/i18n/use-translation";
import { RETRY_DELAY_MS } from "@/lib/constants";
@@ -19,24 +18,18 @@ export interface UseAppInitParams {
}
/**
* Syncs language from backend config, applies document lang/title, handles access denied
* when not allowed, and routes to current duty view when opened via startParam=duty.
* Applies document lang/title from store (when this hook runs, e.g. main page).
* Handles access denied when not allowed and routes to current duty view when opened via startParam=duty.
* Language is synced from window.__DT_LANG in TelegramProvider (all routes).
*/
export function useAppInit({ isAllowed, startParam }: UseAppInitParams): void {
const setLang = useAppStore((s) => s.setLang);
const lang = useAppStore((s) => s.lang);
const setAccessDenied = useAppStore((s) => s.setAccessDenied);
const setLoading = useAppStore((s) => s.setLoading);
const setCurrentView = useAppStore((s) => s.setCurrentView);
const { t } = useTranslation();
// Sync lang from backend config (window.__DT_LANG).
useEffect(() => {
if (typeof window === "undefined") return;
setLang(getLang());
}, [setLang]);
// Apply lang to document (title and html lang) for accessibility and i18n.
// Apply lang to document (title and html lang) when main page is mounted (tests render Page without TelegramProvider).
useEffect(() => {
if (typeof document === "undefined") return;
document.documentElement.lang = lang;