feat(payment): refactor payment configuration retrieval into a custom hook
This commit is contained in:
@@ -10,6 +10,7 @@ import {
|
||||
import { api } from '../lib/api';
|
||||
import type { ApiResponse, PaginatedResponse } from '../lib/api';
|
||||
import type { SmsWalletBalance, SmsWalletLog, SmsSettings } from '../types';
|
||||
import { usePaymentConfig } from '../hooks/usePaymentConfig';
|
||||
import { formatRial, formatNumber, formatDateTime } from '../lib/utils';
|
||||
import Modal from '../components/ui/Modal';
|
||||
import Pagination from '../components/ui/Pagination';
|
||||
@@ -44,17 +45,12 @@ function SmsWalletPageInner() {
|
||||
queryFn: () => api.get('/api/v1/sms/settings'),
|
||||
});
|
||||
|
||||
const { data: paymentConfigData } = useQuery<ApiResponse<{ test_mode: boolean }>>({
|
||||
queryKey: ['payment-config'],
|
||||
queryFn: () => api.get('/api/v1/payment/config'),
|
||||
staleTime: 5 * 60 * 1000,
|
||||
});
|
||||
const { isTestMode } = usePaymentConfig();
|
||||
|
||||
const balance = balanceData?.data;
|
||||
const logs = logsData?.data ?? EMPTY_LOGS;
|
||||
const total = logsData?.meta?.totalRecords ?? 0;
|
||||
const settings = settingsData?.data;
|
||||
const isTestMode = paymentConfigData?.data?.test_mode ?? false;
|
||||
|
||||
const chargeForm = useForm<ChargeForm>({ resolver: zodResolver(chargeSchema) });
|
||||
const watchAmount = chargeForm.watch('amount_rials');
|
||||
|
||||
Reference in New Issue
Block a user