feat(sprint-5): Phase 3 — Wire dashboard + members to React Query
- Dashboard: useClubStatsQuery + useRecentDistributionsQuery with fallback - Members list: useMembersQuery with debounced search + pagination - Member detail: useMemberQuery + useUpdateMemberMutation - Add member: useCreateMemberMutation with invalidation - All pages show loading skeletons during fetch - Graceful fallback to mock data when backend unavailable - New useDebounce hook for search input (300ms delay)
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
import { useEffect, useState } from "react"
|
||||
|
||||
/**
|
||||
* Debounce a value by a given delay.
|
||||
* Returns the debounced value that only updates after the delay.
|
||||
*/
|
||||
export function useDebounce<T>(value: T, delay: number): T {
|
||||
const [debouncedValue, setDebouncedValue] = useState<T>(value)
|
||||
|
||||
useEffect(() => {
|
||||
const timer = setTimeout(() => setDebouncedValue(value), delay)
|
||||
return () => clearTimeout(timer)
|
||||
}, [value, delay])
|
||||
|
||||
return debouncedValue
|
||||
}
|
||||
Reference in New Issue
Block a user