page loading

This commit is contained in:
2026-08-28 11:15:47 +05:30
parent 9f64b42f8a
commit dd6a4771ed
5 changed files with 251 additions and 10 deletions

View File

@@ -3,6 +3,7 @@ import { Navigate, Route, Routes } from 'react-router-dom';
import { Spinner } from '@astryxdesign/core/Spinner';
import { RequireRole, useAuth } from '@/auth/AuthContext';
import { HOME_ROUTE } from '@/auth/roles';
import { withStaleChunkRecovery } from '@/lib/staleChunk';
import { LoginPage } from '@/features/auth/LoginPage';
import { NearleAdminShell } from '@/features/nearle-admin/NearleAdminShell';
import { StoreAdminShell } from '@/features/store-admin/StoreAdminShell';
@@ -15,8 +16,17 @@ import { StoreUserShell } from '@/features/store-user/StoreUserShell';
* means every visitor downloads the spreadsheet importer to look at a dashboard.
* That is the one thing from it worth deliberately not copying.
*/
/**
* Split pages recover from a deploy that lands mid-session.
*
* `withStaleChunkRecovery` is the difference between "Inventory is broken" and
* a reload nobody notices: the hashed filename this tab remembers stops
* existing the moment a new build ships, and the import 404s. See
* `lib/staleChunk.ts` — real errors still surface, only the missing chunk is
* retried.
*/
const named = <T extends string>(key: T, loader: () => Promise<Record<T, ComponentType>>) =>
lazy(() => loader().then((module) => ({ default: module[key] })));
lazy(withStaleChunkRecovery(() => loader().then((module) => ({ default: module[key] }))));
const StoresPage = named('StoresPage', () => import('@/features/nearle-admin/pages/StoresPage'));
const StoreDetailPage = named('StoreDetailPage', () => import('@/features/nearle-admin/pages/StoreDetailPage'));