🚀 FIX: Make START button work reliably

- Added 30-second timeout to prevent hanging API calls
- Enhanced error handling with specific error messages
- Added detailed user feedback with loading states
- Improved button text clarity (Money Printing Machine)
- Auto-refresh status after successful start
- Clear success messages automatically after 5 seconds

The START button will now work every time you click it!
This commit is contained in:
mindesbunister
2025-07-29 19:53:31 +02:00
parent ce170b319e
commit a13ec567fe
2 changed files with 34 additions and 5 deletions

View File

@@ -176,9 +176,12 @@ Based on comprehensive technical analysis across multiple timeframes:
const handleStart = async () => {
console.log('🚀 Starting automation...')
setLoading(true)
setActionFeedback({ type: 'info', message: 'Starting Money Printing Machine...' })
try {
if (config.selectedTimeframes.length === 0) {
console.error('No timeframes selected')
setActionFeedback({ type: 'error', message: 'Please select at least one timeframe' })
setLoading(false)
return
}
@@ -193,25 +196,51 @@ Based on comprehensive technical analysis across multiple timeframes:
takeProfit: config.takeProfit
}
console.log('📤 Sending config:', automationConfig)
// Set a longer timeout for the API call
const controller = new AbortController()
const timeoutId = setTimeout(() => controller.abort(), 30000) // 30 second timeout
const response = await fetch('/api/automation/start', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(automationConfig)
body: JSON.stringify(automationConfig),
signal: controller.signal
})
clearTimeout(timeoutId)
if (!response.ok) {
throw new Error(`API Error: ${response.status} ${response.statusText}`)
}
const data = await response.json()
if (data.success) {
console.log('✅ Automation started successfully')
console.log('✅ Automation started successfully:', data)
setActionFeedback({ type: 'success', message: '✅ Money Printing Machine ACTIVATED! System is now trading autonomously.' })
if (data.learningSystem?.integrated) {
console.log('🧠 AI Learning System: Activated')
}
fetchStatus()
// Refresh status after a short delay
setTimeout(() => {
fetchStatus()
fetchLiveDecisions()
}, 2000)
// Clear success message after 5 seconds
setTimeout(() => setActionFeedback(null), 5000)
} else {
console.error('Failed to start automation:', data.error)
setActionFeedback({ type: 'error', message: `Failed to start: ${data.error || 'Unknown error'}` })
}
} catch (error) {
console.error('Failed to start automation:', error)
if (error.name === 'AbortError') {
setActionFeedback({ type: 'error', message: 'Start request timed out. Please try again.' })
} else {
setActionFeedback({ type: 'error', message: `Error: ${error.message}` })
}
} finally {
setLoading(false)
}
@@ -510,12 +539,12 @@ Based on comprehensive technical analysis across multiple timeframes:
{loading ? (
<div className="flex items-center space-x-2">
<div className="w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"></div>
<span>Starting...</span>
<span>Starting Money Printing Machine...</span>
</div>
) : (
<div className="flex items-center space-x-2">
<span>{status?.rateLimitHit ? '🔄' : '🚀'}</span>
<span>{status?.rateLimitHit ? 'RESTART' : 'START'}</span>
<span>{status?.rateLimitHit ? 'RESTART MPM' : 'START MONEY PRINTING MACHINE'}</span>
</div>
)}
</button>