From b3f242671eee7c6a6362bf50a9b7b99309bed212 Mon Sep 17 00:00:00 2001 From: dwindown Date: Mon, 10 Nov 2025 13:57:57 +0700 Subject: [PATCH] debug(tax): Add console logging for tax rate creation Added detailed console logging to debug why tax rates are not being saved: - Log request data before sending - Log API response - Log success/error callbacks - Invalidate both tax-settings and tax-suggested queries on success This will help identify if: 1. API request is being sent correctly 2. API response is successful 3. Query invalidation is working 4. Frontend state is updating Please test and check browser console for logs. --- admin-spa/src/routes/Settings/Tax.tsx | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/admin-spa/src/routes/Settings/Tax.tsx b/admin-spa/src/routes/Settings/Tax.tsx index e7e0122..79e419f 100644 --- a/admin-spa/src/routes/Settings/Tax.tsx +++ b/admin-spa/src/routes/Settings/Tax.tsx @@ -54,14 +54,20 @@ export default function TaxSettings() { // Create tax rate const createMutation = useMutation({ mutationFn: async (data: any) => { - return api.post('/settings/tax/rates', data); + console.log('[Tax] Creating rate:', data); + const response = await api.post('/settings/tax/rates', data); + console.log('[Tax] Create response:', response); + return response; }, - onSuccess: () => { + onSuccess: (data) => { + console.log('[Tax] Create success:', data); queryClient.invalidateQueries({ queryKey: ['tax-settings'] }); + queryClient.invalidateQueries({ queryKey: ['tax-suggested'] }); setShowAddRate(false); toast.success(__('Tax rate created')); }, onError: (error: any) => { + console.error('[Tax] Create error:', error); toast.error(error?.message || __('Failed to create tax rate')); }, }); @@ -99,7 +105,8 @@ export default function TaxSettings() { // Quick add suggested rate const quickAddMutation = useMutation({ mutationFn: async (suggestedRate: any) => { - return api.post('/settings/tax/rates', { + console.log('[Tax] Quick adding rate:', suggestedRate); + const response = await api.post('/settings/tax/rates', { country: suggestedRate.code, state: '', rate: suggestedRate.rate, @@ -109,12 +116,17 @@ export default function TaxSettings() { compound: 0, shipping: 1, }); + console.log('[Tax] Quick add response:', response); + return response; }, - onSuccess: () => { + onSuccess: (data) => { + console.log('[Tax] Quick add success:', data); queryClient.invalidateQueries({ queryKey: ['tax-settings'] }); + queryClient.invalidateQueries({ queryKey: ['tax-suggested'] }); toast.success(__('Tax rate added')); }, onError: (error: any) => { + console.error('[Tax] Quick add error:', error); toast.error(error?.message || __('Failed to add tax rate')); }, });