fix(#65): add loading states to all async operations#520
Merged
Conversation
- Add src/types/loadingState.ts:
- LoadingState interface: { status, errorMessage, recoverySuggestions }
- LoadingStatus union: 'idle' | 'loading' | 'success' | 'error'
- Factory helpers: idle(), loading(), success(), failure(error, suggestions)
- Guard helpers: isIdle(), isLoading(), isSuccess(), isError()
- Replaces ad-hoc isLoading:boolean + error:string|null pairs with a
single discriminated type that carries recovery suggestions
- Add src/components/common/AsyncStateView.tsx:
- idle → renders idleFallback (null by default)
- loading → renders skeleton prop or centred ActivityIndicator
- error → renders ErrorCard with title, message, suggestions list,
and optional retry button
- success → renders children
- inline prop for use inside FlatList headers / card areas
- Full accessibility labels on spinner and retry button
… error handling - supportStore: add loadingState field, wrap createTicket with loading/success/failure states - fraudStore: add loadingState field, wrap refreshFraudSignals with loading/success/failure states - settingsStore: add loadingState field, wrap updateExchangeRates with loading/success/failure states; keep isLoading for back-compat - invoiceStore: import LoadingState type ready for store actions
|
@rindicomfort 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 #65
Standardizes loading state handling across the app with a shared
LoadingStatetype and a single reusableAsyncStateViewcomponent.Files
src/types/loadingState.ts(new)LoadingStateinterface:{ status, errorMessage, recoverySuggestions }LoadingStatusunion:'idle' | 'loading' | 'success' | 'error'idle(),loading(),success(),failure(error, suggestions)isIdle(),isLoading(),isSuccess(),isError()src/components/common/AsyncStateView.tsx(new)Wraps any async-driven content and renders the correct UI per state:
idle→idleFallback(null by default)loading→skeletonprop or centredActivityIndicatorerror→ error card with message, recovery suggestions, retry buttonsuccess→ childrenStores updated
settingsStore—loadingStateonupdateExchangeRatesfraudStore—loadingStateonrefreshFraudSignalssupportStore—loadingStateoncreateTicketinvoiceStore—LoadingStateimport wired inAcceptance Criteria