feat(payment): refactor payment configuration retrieval into a custom hook
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { api } from '../lib/api';
|
||||
import type { ApiResponse } from '../lib/api';
|
||||
|
||||
export function usePaymentConfig() {
|
||||
const { data } = useQuery<ApiResponse<{ test_mode: boolean }>>({
|
||||
queryKey: ['payment-config'],
|
||||
queryFn: () => api.get('/api/v1/payment/config'),
|
||||
staleTime: 5 * 60 * 1000,
|
||||
});
|
||||
return { isTestMode: data?.data?.test_mode ?? false };
|
||||
}
|
||||
Reference in New Issue
Block a user