Refactor the application initialization and data fetching strategy to improve performance, reliability, and user experience, especially within the Flutter webview context.
Key changes:
- **Bootstrap & Initialization**: Implemented a `beforeInteractive` bootstrap script to handle locale correction and safe-area insets before the app becomes visible, reducing layout shift and flickering.
- **Locale Routing**: Enhanced the middleware proxy to prioritize authoritative cookie-based locales and improved `Accept-Language` header parsing to support complex device headers.
- **Assessment Progress**: Introduced a local assessment progress tracking mechanism that merges server-side completion data with local `localStorage` drafts, ensuring users don't lose progress during transitions.
- **Data Fetching**: Optimized React Query configurations by increasing `staleTime` and disabling aggressive refetching on window focus/mount to reduce unnecessary network overhead.
- **UI/UX Improvements**:
- Replaced `next/image` icon loading with an inline `UiIcon` component to eliminate per-icon network requests and ensure icons are available in the initial HTML.
- Implemented a Flutter-style skeleton shimmer animation using CSS transforms for smoother performance in the webview.
- Updated CSS variables to use `env(safe-area-inset-*)` for better mobile compatibility.
- **Refactoring**:
- Consolidated marriage-related data fetching into a unified `useFormSchemaQuery` pattern.
- Simplified component logic by removing redundant `silent-reloader` calls and manual cache-busting headers.
- Improved type safety for the Flutter bridge and window global objects.
Introduces `anonymousEntryVisible` prop to `EntryRouteResolver` to
conditionally prevent redirection to the intro page. Also removes
the legacy `bridgeWaitTimeout` logic and cleans up the effect
dependencies.
Introduces a mechanism to cache and resolve the user's entry route
based on their authentication status and profile progress. This
ensures users are redirected to their correct application state
(e.g., questions list, finding match, or intro) more reliably and
efficiently.
Key changes:
- Added `entry-route-cache` utility to manage `HABIB_MARRIAGE_ENTRY_PATH`
cookie with path validation.
- Implemented `EntryRouteResolver` component to handle initial
routing logic and bridge synchronization.
- Refactored `getSubmitPath` and `hasCompletedMarriageProfileBasics`
to distinguish between incomplete onboarding (terms) and
completed basics (questions list).
- Updated `authBridge` and `use-profile-main` to trigger cache
updates on token changes or profile fetches.
- Improved `SliderPage` navigation guards to prevent skipping
terms/rules.
- Added `NetworkImage` component for better handling of remote
image loading and fallbacks.
- Enhanced `LoadingSkeleton` with a new `white` shimmer variant.
- Updated `TokenSwitcher` to clear cached routes on logout/switch.
- Added comprehensive unit tests for new routing and auth logic.