arbret/frontend/app/hooks
counterweight b86b506d72
Refactor frontend: Add reusable hooks and components
- Created useAsyncData hook: Eliminates repetitive data fetching boilerplate
  - Handles loading, error, and data state automatically
  - Supports enabled/disabled fetching
  - Provides refetch function

- Created PageLayout component: Standardizes page structure
  - Handles loading state, authorization checks, header, error display
  - Reduces ~10 lines of boilerplate per page

- Created useMutation hook: Simplifies action handling
  - Manages loading state and errors for mutations
  - Supports success/error callbacks
  - Used for cancel, create, revoke actions

- Created ErrorDisplay component: Standardizes error UI
  - Consistent error banner styling across app
  - Integrated into PageLayout

- Created useForm hook: Foundation for form state management
  - Handles form data, validation, dirty checking
  - Ready for future form migrations

- Migrated pages to use new patterns:
  - invites/page.tsx: useAsyncData + PageLayout
  - trades/page.tsx: useAsyncData + PageLayout + useMutation
  - trades/[id]/page.tsx: useAsyncData
  - admin/price-history/page.tsx: useAsyncData + PageLayout
  - admin/invites/page.tsx: useMutation for create/revoke

Benefits:
- ~40% reduction in boilerplate code
- Consistent patterns across pages
- Easier to maintain and extend
- Better type safety

All tests passing (32 frontend, 33 e2e)
2025-12-25 21:30:35 +01:00
..
useAsyncData.ts Refactor frontend: Add reusable hooks and components 2025-12-25 21:30:35 +01:00
useDebouncedValidation.ts Refactor API layer into structured domain-specific modules 2025-12-25 20:32:11 +01:00
useForm.ts Refactor frontend: Add reusable hooks and components 2025-12-25 21:30:35 +01:00
useMutation.ts Refactor frontend: Add reusable hooks and components 2025-12-25 21:30:35 +01:00
useRequireAuth.ts refactor(frontend): improve code quality and maintainability 2025-12-25 19:04:45 +01:00