feat: implement real Drift trading history using SDK methods
- Updated getTradingHistory to fetch actual Drift order records - Added fallback to local database for trade history - Enhanced executeTrade to store trades in database for history tracking - Fixed hydration issues in AutoTradingPanel and TradingHistory components - Improved error handling and logging for trading history retrieval
This commit is contained in:
@@ -199,120 +199,4 @@ export default function SessionStatus() {
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
} else if (sessionInfo.hasSavedCookies || sessionInfo.hasSavedStorage) {
|
||||
return `Session Available${dockerSuffix}`
|
||||
} else {
|
||||
return `Not Logged In${dockerSuffix}`
|
||||
}
|
||||
}
|
||||
|
||||
const getDetailedStatus = () => {
|
||||
if (!sessionInfo) return []
|
||||
|
||||
return [
|
||||
{ label: 'Authenticated', value: sessionInfo.isAuthenticated ? '✅' : '❌' },
|
||||
{ label: 'Connection', value: sessionInfo.connectionStatus === 'connected' ? '✅' :
|
||||
sessionInfo.connectionStatus === 'disconnected' ? '🔌' :
|
||||
sessionInfo.connectionStatus === 'error' ? '❌' : '❓' },
|
||||
{ label: 'Browser Active', value: sessionInfo.browserActive ? '✅' : '❌' },
|
||||
{ label: 'Saved Cookies', value: sessionInfo.hasSavedCookies ? `✅ (${sessionInfo.cookiesCount})` : '❌' },
|
||||
{ label: 'Saved Storage', value: sessionInfo.hasSavedStorage ? '✅' : '❌' },
|
||||
{ label: 'Environment', value: sessionInfo.dockerEnv ? '🐳 Docker' : '💻 Local' },
|
||||
]
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="bg-gray-900 rounded-lg shadow p-4">
|
||||
<div className="flex items-center justify-between mb-4">
|
||||
<h3 className="text-lg font-semibold text-white">TradingView Session</h3>
|
||||
<button
|
||||
onClick={() => fetchSessionStatus()}
|
||||
disabled={loading || refreshing}
|
||||
className="px-3 py-1 bg-blue-600 text-white rounded text-sm hover:bg-blue-700 disabled:opacity-50"
|
||||
>
|
||||
{loading || refreshing ? '⟳' : '🔄'}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Status Indicator */}
|
||||
<div className="flex items-center space-x-3 mb-4">
|
||||
<div className={`w-3 h-3 rounded-full ${getStatusColor()}`}></div>
|
||||
<span className="text-white font-medium">{getStatusText()}</span>
|
||||
</div>
|
||||
|
||||
{/* Detailed Status */}
|
||||
{sessionInfo && (
|
||||
<div className="space-y-2 mb-4">
|
||||
{getDetailedStatus().map((item, index) => (
|
||||
<div key={index} className="flex justify-between text-sm">
|
||||
<span className="text-gray-400">{item.label}:</span>
|
||||
<span className="text-white">{item.value}</span>
|
||||
</div>
|
||||
))}
|
||||
<div className="flex justify-between text-sm">
|
||||
<span className="text-gray-400">Last Checked:</span>
|
||||
<span className="text-white text-xs">
|
||||
{new Date(sessionInfo.lastChecked).toLocaleTimeString()}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Error Display */}
|
||||
{error && (
|
||||
<div className="bg-red-900 border border-red-700 rounded p-2 mb-4">
|
||||
<p className="text-red-300 text-sm">{error}</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Action Buttons */}
|
||||
<div className="flex flex-wrap gap-2">
|
||||
<button
|
||||
onClick={() => handleSessionAction('refresh')}
|
||||
disabled={refreshing}
|
||||
className="px-3 py-1 bg-green-600 text-white rounded text-sm hover:bg-green-700 disabled:opacity-50"
|
||||
>
|
||||
Refresh Session
|
||||
</button>
|
||||
<button
|
||||
onClick={() => handleSessionAction('test')}
|
||||
disabled={refreshing}
|
||||
className="px-3 py-1 bg-blue-600 text-white rounded text-sm hover:bg-blue-700 disabled:opacity-50"
|
||||
>
|
||||
Test Session
|
||||
</button>
|
||||
<button
|
||||
onClick={() => handleSessionAction('clear')}
|
||||
disabled={refreshing}
|
||||
className="px-3 py-1 bg-red-600 text-white rounded text-sm hover:bg-red-700 disabled:opacity-50"
|
||||
>
|
||||
Clear Session
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Usage Instructions */}
|
||||
{sessionInfo && !sessionInfo.isAuthenticated && (
|
||||
<div className="mt-4 p-3 bg-yellow-900 border border-yellow-700 rounded">
|
||||
<p className="text-yellow-300 text-sm">
|
||||
💡 <strong>To establish session:</strong> Run the analysis or screenshot capture once to trigger manual login,
|
||||
then future requests will use the saved session and avoid captchas.
|
||||
{sessionInfo.dockerEnv && (
|
||||
<><br/>🐳 <strong>Docker:</strong> Session data is persisted in the container volume for reuse across restarts.</>
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Docker Environment Info */}
|
||||
{sessionInfo?.dockerEnv && (
|
||||
<div className="mt-4 p-3 bg-blue-900 border border-blue-700 rounded">
|
||||
<p className="text-blue-300 text-sm">
|
||||
🐳 <strong>Docker Environment:</strong> Running in containerized mode. Session persistence is enabled
|
||||
via volume mount at <code className="bg-blue-800 px-1 rounded">/.tradingview-session</code>
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user