feat(web): add React Query, dark mode toggle, and error retry UX
- Install @tanstack/react-query with exponential backoff retry config - Create QueryClientProvider and custom hooks for listings, analytics, payments, and subscription API calls - Migrate 5 dashboard pages from useState/useEffect to React Query hooks - Add dark mode CSS variables and ThemeProvider with localStorage persistence - Add theme toggle button in dashboard header (sun/moon icon) - Enhance error boundaries with auto-retry, retry count, and loading state Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
28
apps/web/lib/hooks/use-payments.ts
Normal file
28
apps/web/lib/hooks/use-payments.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { paymentApi } from '@/lib/payment-api';
|
||||
|
||||
export const paymentKeys = {
|
||||
all: ['payments'] as const,
|
||||
transactions: (params: { status?: string; limit?: number; offset?: number }) =>
|
||||
['payments', 'transactions', params] as const,
|
||||
status: (id: string) => ['payments', 'status', id] as const,
|
||||
};
|
||||
|
||||
export function useTransactions(params: {
|
||||
status?: string;
|
||||
limit?: number;
|
||||
offset?: number;
|
||||
} = {}) {
|
||||
return useQuery({
|
||||
queryKey: paymentKeys.transactions(params),
|
||||
queryFn: () => paymentApi.getTransactions(params),
|
||||
});
|
||||
}
|
||||
|
||||
export function usePaymentStatus(id: string) {
|
||||
return useQuery({
|
||||
queryKey: paymentKeys.status(id),
|
||||
queryFn: () => paymentApi.getPaymentStatus(id),
|
||||
enabled: !!id,
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user