Skip to content

fix(#65): add loading states to all async operations#520

Merged
Smartdevs17 merged 2 commits into
Smartdevs17:mainfrom
rindicomfort:fix/65-loading-states
Jun 1, 2026
Merged

fix(#65): add loading states to all async operations#520
Smartdevs17 merged 2 commits into
Smartdevs17:mainfrom
rindicomfort:fix/65-loading-states

Conversation

@rindicomfort
Copy link
Copy Markdown
Contributor

Summary

Closes #65

Standardizes loading state handling across the app with a shared LoadingState type and a single reusable AsyncStateView component.

Files

src/types/loadingState.ts (new)

  • 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()

src/components/common/AsyncStateView.tsx (new)

Wraps any async-driven content and renders the correct UI per state:

  • idleidleFallback (null by default)
  • loadingskeleton prop or centred ActivityIndicator
  • error → error card with message, recovery suggestions, retry button
  • success → children

Stores updated

  • settingsStoreloadingState on updateExchangeRates
  • fraudStoreloadingState on refreshFraudSignals
  • supportStoreloadingState on createTicket
  • invoiceStoreLoadingState import wired in

Acceptance Criteria

  • All async ops have loading state
  • Consistent loading UI (AsyncStateView)
  • Error messages shown with recovery suggestions
  • Retry available on error

- 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
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Jun 1, 2026

@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! 🚀

Learn more about application limits

@Smartdevs17 Smartdevs17 merged commit d80d784 into Smartdevs17:main Jun 1, 2026
3 of 24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🔧 Add loading states to all async operations

2 participants