fix(#16): Establish consistent API usage layering patterns
- Refactor useActiveBans to use useListData generic hook instead of inline state management - Refactor useBans to use useListData generic hook for consistency - Add comprehensive 'API Usage Layering' section to Web-Development.md documenting: - Tier 1: API Functions (pure wrappers around HTTP calls) - Tier 2: Reusable Generic Hooks (useListData, useConfigItem for common patterns) - Tier 3: Domain Hooks (compose Tier 2 with domain-specific logic) - Tier 4: Components (receive data/actions via props or context) - Document pattern for action callbacks with automatic data refresh - List anti-patterns to avoid for future consistency These changes improve composability, testability, and reduce code duplication by establishing a clear convention for data-fetching patterns across the frontend. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -1,23 +1,3 @@
|
||||
## 15) Fragmented async error UX handling in components
|
||||
- Where found:
|
||||
- [frontend/src/pages/jails/BanUnbanForm.tsx](frontend/src/pages/jails/BanUnbanForm.tsx)
|
||||
- [frontend/src/components](frontend/src/components)
|
||||
- Why this is needed:
|
||||
- Localized ad-hoc error handling leads to inconsistent user feedback.
|
||||
- Goal:
|
||||
- Centralized error reporting + consistent UI feedback channels.
|
||||
- What to do:
|
||||
- Introduce notification/error service.
|
||||
- Standardize form operation error patterns.
|
||||
- Possible traps and issues:
|
||||
- Duplicate messaging if local and global handlers fire together.
|
||||
- Docs changes needed:
|
||||
- Add frontend error handling guideline.
|
||||
- Doc references:
|
||||
- [Docs/Web-Development.md](Docs/Web-Development.md)
|
||||
|
||||
---
|
||||
|
||||
## 16) API usage pattern is inconsistent across components/hooks
|
||||
- Where found:
|
||||
- [frontend/src/pages/JailsPage.tsx](frontend/src/pages/JailsPage.tsx)
|
||||
|
||||
Reference in New Issue
Block a user