Remove demo data fallbacks - use only real Drift account data
- Updated Dashboard.tsx to remove demo data fallbacks - Updated TradingHistory.tsx to use new Drift trading history endpoint - Added getTradingHistory method to DriftTradingService - Created new /api/drift/trading-history endpoint - Removed fallback demo positions from getPositions method - All UI components now show only real Drift account data or empty states - No more hardcoded mock trades or positions
This commit is contained in:
@@ -19,44 +19,26 @@ export default function TradingHistory() {
|
||||
useEffect(() => {
|
||||
async function fetchTrades() {
|
||||
try {
|
||||
const res = await fetch('/api/trading-history')
|
||||
if (res.ok) {
|
||||
const data = await res.json()
|
||||
setTrades(data)
|
||||
// Try Drift trading history first
|
||||
const driftRes = await fetch('/api/drift/trading-history')
|
||||
if (driftRes.ok) {
|
||||
const data = await driftRes.json()
|
||||
if (data.success && data.trades) {
|
||||
setTrades(data.trades)
|
||||
} else {
|
||||
// No trades available
|
||||
setTrades([])
|
||||
}
|
||||
} else {
|
||||
// Mock data for demonstration
|
||||
setTrades([
|
||||
{
|
||||
id: '1',
|
||||
symbol: 'BTCUSD',
|
||||
side: 'BUY',
|
||||
amount: 0.1,
|
||||
price: 45230.50,
|
||||
status: 'FILLED',
|
||||
executedAt: new Date().toISOString(),
|
||||
pnl: 125.50
|
||||
},
|
||||
{
|
||||
id: '2',
|
||||
symbol: 'ETHUSD',
|
||||
side: 'SELL',
|
||||
amount: 2.5,
|
||||
price: 2856.75,
|
||||
status: 'FILLED',
|
||||
executedAt: new Date(Date.now() - 3600000).toISOString(),
|
||||
pnl: -67.25
|
||||
},
|
||||
{
|
||||
id: '3',
|
||||
symbol: 'SOLUSD',
|
||||
side: 'BUY',
|
||||
amount: 10,
|
||||
price: 95.80,
|
||||
status: 'FILLED',
|
||||
executedAt: new Date(Date.now() - 7200000).toISOString(),
|
||||
pnl: 89.75
|
||||
}
|
||||
])
|
||||
// API failed - try fallback to local database
|
||||
const res = await fetch('/api/trading-history')
|
||||
if (res.ok) {
|
||||
const data = await res.json()
|
||||
setTrades(data || [])
|
||||
} else {
|
||||
// Both APIs failed - show empty state
|
||||
setTrades([])
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch trades:', error)
|
||||
|
||||
Reference in New Issue
Block a user