const handleUpdate = async (e) => { e.preventDefault(); setIsLoading(true); setError(null); try { const token = localStorage.getItem('token'); if (!token) { throw new Error('No authentication token found'); } // Create a new object with properly formatted data const updateData = { bankName: formData.bankName || null, accountName: formData.accountName || null, accountNumber: formData.accountNumber ? String(formData.accountNumber) : null, // Keep as string accountExplanation: formData.accountExplanation || null, isActive: Boolean(formData.isActive), isBlocked: Boolean(formData.isBlocked), isInvest: Boolean(formData.isInvest), isPull: Boolean(formData.isPull), maxInvest: formData.maxInvest ? Number(formData.maxInvest) : null, minInvest: formData.minInvest ? Number(formData.minInvest) : null, maxPull: formData.maxPull ? Number(formData.maxPull) : null, minPull: formData.minPull ? Number(formData.minPull) : null, maxTransfer: formData.maxTransfer ? Number(formData.maxTransfer) : null, maxAmount: formData.maxAmount ? Number(formData.maxAmount) : null }; // Remove null values const cleanedData = Object.fromEntries( Object.entries(updateData).filter(([_, value]) => value !== null) ); const updateAccount = await axios.patch( `${BASE_URL}/bank/${accountId}`, cleanedData, { headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${token}`, 'Accept': 'application/json', } } ); console.log('Update response:', updateAccount); setShowModal(true); } catch (error) { console.error('Error updating account:', error); if (error.response) { // Log more detailed error information console.error('Error response:', error.response.data); setError(error.response.data.detail || 'Failed to update account'); } else { setError(error.message || 'Failed to update account'); } } finally { setIsLoading(false); } };