feat(hooks): add useOnlineStatus and offline banner that gates tx actions#460
Open
Nuel-ship-it wants to merge 1 commit into
Open
feat(hooks): add useOnlineStatus and offline banner that gates tx actions#460Nuel-ship-it wants to merge 1 commit into
Nuel-ship-it wants to merge 1 commit into
Conversation
…actions Subscribes to online/offline events, shows a warning banner in Layout, and disables Bond create/withdraw and Trust Score lookup buttons while disconnected. - src/hooks/useOnlineStatus.ts: hook with navigator.onLine init, event listeners, window/navigator guard for non-browser environments, cleanup on unmount - src/components/Layout.tsx: offline Banner (warning, aria-live via role=alert) shown only when offline, dismissed automatically on reconnect - src/pages/Bond.tsx: passes isOnline to BondRow; disables Withdraw, Create bond, and AmountInput when offline; shows inline offline banner with id for aria-describedby - src/pages/TrustScore.tsx: disables Look up score button when offline; shows inline offline banner with id for aria-describedby - src/hooks/useOnlineStatus.test.ts: Vitest unit tests (init, online/offline transitions, cleanup on unmount) - src/pages/offline.test.tsx: RTL integration tests for Layout banner, Bond disabled actions, and TrustScore disabled lookup Closes CredenceOrg#447
|
@Nuel-ship-it Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #447
Adds browser connectivity detection so the app proactively warns the user when offline and disables transaction actions instead of silently failing.
Changes
src/hooks/useOnlineStatus.ts(new)booleaninitialised fromnavigator.onLineonline/offlinewindow events with cleanup on unmountnavigator/window(defaults totrue)src/components/Layout.tsxBanner(warning severity,role="alert") inside<main>when offlinesrc/pages/Bond.tsxAmountInputwhen offlineisOnlinetoBondRowto disable each Withdraw buttonid="offline-banner"foraria-describedbysrc/pages/TrustScore.tsxid="ts-offline-banner"foraria-describedbyTests
src/hooks/useOnlineStatus.test.ts— 6 Vitest unit tests (init, transitions, cleanup)src/pages/offline.test.tsx— 10 RTL integration tests (Layout banner, Bond/TrustScore buttons)Test results
Baseline (main): 119 failed / 782 passed
This branch: 112 failed / 789 passed — +16 new passing tests, no regressions
Acceptance criteria
useOnlineStatuswith cleanup + no-window guardaria-describedbyon disabled buttons