Restore improved layout and coin icons from development branch
- Restore clean homepage with only StatusOverview component - Restore improved StatusOverview with CoinGecko coin icons - Restore unified layout with gradient cards instead of fragmented sections
This commit is contained in:
102
app/page.js
102
app/page.js
@@ -4,109 +4,9 @@ import StatusOverview from '../components/StatusOverview.js'
|
||||
|
||||
export default function HomePage() {
|
||||
return (
|
||||
<div className="space-y-8">
|
||||
<div>
|
||||
{/* Status Overview */}
|
||||
<StatusOverview />
|
||||
|
||||
{/* Quick Actions */}
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6">
|
||||
<div className="card card-gradient text-center">
|
||||
<div className="w-16 h-16 bg-blue-500/20 rounded-full flex items-center justify-center mx-auto mb-4">
|
||||
<span className="text-blue-400 text-2xl">📊</span>
|
||||
</div>
|
||||
<h3 className="text-lg font-semibold text-white mb-2">AI Analysis</h3>
|
||||
<p className="text-gray-400 text-sm mb-4">Get market insights and TradingView analysis</p>
|
||||
<a href="/analysis" className="inline-flex items-center px-4 py-2 bg-blue-600/20 text-blue-400 rounded-lg hover:bg-blue-600/30 transition-colors text-sm">
|
||||
View Analysis
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div className="card card-gradient text-center">
|
||||
<div className="w-16 h-16 bg-green-500/20 rounded-full flex items-center justify-center mx-auto mb-4">
|
||||
<span className="text-green-400 text-2xl">💰</span>
|
||||
</div>
|
||||
<h3 className="text-lg font-semibold text-white mb-2">Manual Trading</h3>
|
||||
<p className="text-gray-400 text-sm mb-4">Execute trades and view history</p>
|
||||
<a href="/trading" className="inline-flex items-center px-4 py-2 bg-green-600/20 text-green-400 rounded-lg hover:bg-green-600/30 transition-colors text-sm">
|
||||
Trade Now
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div className="card card-gradient text-center">
|
||||
<div className="w-16 h-16 bg-purple-500/20 rounded-full flex items-center justify-center mx-auto mb-4">
|
||||
<span className="text-purple-400 text-2xl">🤖</span>
|
||||
</div>
|
||||
<h3 className="text-lg font-semibold text-white mb-2">Auto Trading</h3>
|
||||
<p className="text-gray-400 text-sm mb-4">Configure automation</p>
|
||||
<a href="/automation" className="inline-flex items-center px-4 py-2 bg-purple-600/20 text-purple-400 rounded-lg hover:bg-purple-600/30 transition-colors text-sm">
|
||||
Setup Bot
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div className="card card-gradient text-center">
|
||||
<div className="w-16 h-16 bg-orange-500/20 rounded-full flex items-center justify-center mx-auto mb-4">
|
||||
<span className="text-orange-400 text-2xl">⚙️</span>
|
||||
</div>
|
||||
<h3 className="text-lg font-semibold text-white mb-2">Settings</h3>
|
||||
<p className="text-gray-400 text-sm mb-4">Developer configuration</p>
|
||||
<a href="/settings" className="inline-flex items-center px-4 py-2 bg-orange-600/20 text-orange-400 rounded-lg hover:bg-orange-600/30 transition-colors text-sm">
|
||||
Configure
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Featured: Chart Trading Demo */}
|
||||
<div className="card card-gradient">
|
||||
<div className="flex items-center justify-between mb-6">
|
||||
<div>
|
||||
<h2 className="text-xl font-semibold text-white mb-2">🚀 Professional Chart Trading</h2>
|
||||
<p className="text-gray-400">Advanced trading interface with leverage, charting, and position management</p>
|
||||
</div>
|
||||
<div className="text-right">
|
||||
<span className="inline-block px-3 py-1 bg-yellow-600/20 text-yellow-400 rounded-full text-sm font-medium">NEW</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-1 md:grid-cols-3 gap-6 mb-6">
|
||||
<div className="flex items-center space-x-3">
|
||||
<div className="w-8 h-8 bg-green-500/20 rounded-full flex items-center justify-center">
|
||||
<span className="text-green-400 text-sm">📈</span>
|
||||
</div>
|
||||
<div>
|
||||
<div className="text-white font-medium">Real-time Charts</div>
|
||||
<div className="text-gray-400 text-sm">Professional candlestick visualization</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center space-x-3">
|
||||
<div className="w-8 h-8 bg-yellow-500/20 rounded-full flex items-center justify-center">
|
||||
<span className="text-yellow-400 text-sm">⚡</span>
|
||||
</div>
|
||||
<div>
|
||||
<div className="text-white font-medium">Leverage Trading</div>
|
||||
<div className="text-gray-400 text-sm">1x to 100x leverage options</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center space-x-3">
|
||||
<div className="w-8 h-8 bg-blue-500/20 rounded-full flex items-center justify-center">
|
||||
<span className="text-blue-400 text-sm">🎯</span>
|
||||
</div>
|
||||
<div>
|
||||
<div className="text-white font-medium">Position Management</div>
|
||||
<div className="text-gray-400 text-sm">Stop loss & take profit</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<a
|
||||
href="/chart-trading-demo"
|
||||
className="inline-flex items-center px-6 py-3 bg-gradient-to-r from-blue-600 to-purple-600 text-white rounded-lg hover:from-blue-700 hover:to-purple-700 transition-all transform hover:scale-105 font-medium"
|
||||
>
|
||||
<span className="mr-2">🚀</span>
|
||||
Launch Chart Trading Terminal
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -3,17 +3,24 @@ import React, { useEffect, useState } from 'react'
|
||||
|
||||
export default function StatusOverview() {
|
||||
const [status, setStatus] = useState({
|
||||
driftBalance: 0,
|
||||
portfolioValue: 0,
|
||||
activeTrades: 0,
|
||||
dailyPnL: 0,
|
||||
systemStatus: 'offline',
|
||||
bitqueryStatus: 'unknown',
|
||||
marketPrices: [],
|
||||
walletBalance: null, // Real wallet balance
|
||||
availableCoins: [] // Available coins in wallet
|
||||
walletBalance: null,
|
||||
availableCoins: []
|
||||
})
|
||||
const [loading, setLoading] = useState(true)
|
||||
|
||||
// Coin icons mapping - using CoinGecko images
|
||||
const coinIcons = {
|
||||
'BTC': 'https://assets.coingecko.com/coins/images/1/large/bitcoin.png',
|
||||
'ETH': 'https://assets.coingecko.com/coins/images/279/large/ethereum.png',
|
||||
'SOL': 'https://assets.coingecko.com/coins/images/4128/large/solana.png',
|
||||
'SOL-USD': 'https://assets.coingecko.com/coins/images/4128/large/solana.png'
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
async function fetchStatus() {
|
||||
try {
|
||||
@@ -36,18 +43,18 @@ export default function StatusOverview() {
|
||||
console.warn('Could not fetch wallet balance:', e)
|
||||
}
|
||||
|
||||
// Get market data from Bitquery
|
||||
let balance = walletBalance?.totalValue || 0 // Use real wallet balance
|
||||
let bitqueryStatus = 'error'
|
||||
// Get market data - only BTC, ETH, SOL
|
||||
let marketPrices = []
|
||||
|
||||
try {
|
||||
const marketRes = await fetch('/api/market')
|
||||
if (marketRes.ok) {
|
||||
const marketData = await marketRes.json()
|
||||
if (marketData.success) {
|
||||
marketPrices = marketData.data.prices || []
|
||||
bitqueryStatus = marketData.data.status?.connected ? 'online' : 'error'
|
||||
// Filter to only show BTC, ETH, SOL
|
||||
const targetCoins = ['BTC', 'ETH', 'SOL']
|
||||
marketPrices = (marketData.data.prices || [])
|
||||
.filter(price => targetCoins.includes(price.symbol))
|
||||
.sort((a, b) => targetCoins.indexOf(a.symbol) - targetCoins.indexOf(b.symbol))
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
@@ -66,11 +73,10 @@ export default function StatusOverview() {
|
||||
}
|
||||
|
||||
setStatus({
|
||||
driftBalance: balance,
|
||||
activeTrades: 0, // No fake trades - will show real ones when we have them
|
||||
dailyPnL: 0, // No fake P&L
|
||||
portfolioValue: walletBalance?.totalValue || 0,
|
||||
activeTrades: 0,
|
||||
dailyPnL: 0,
|
||||
systemStatus: systemStatus,
|
||||
bitqueryStatus: bitqueryStatus,
|
||||
marketPrices: marketPrices,
|
||||
walletBalance: walletBalance,
|
||||
availableCoins: availableCoins
|
||||
@@ -100,154 +106,165 @@ export default function StatusOverview() {
|
||||
error: '🔴'
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="card card-gradient">
|
||||
<div className="flex items-center justify-between mb-6">
|
||||
<h2 className="text-xl font-bold text-white">System Status</h2>
|
||||
<div className="flex items-center space-x-2">
|
||||
<span className="text-lg">{statusIcon[status.systemStatus]}</span>
|
||||
<span className={`text-sm font-medium ${statusColor[status.systemStatus]}`}>
|
||||
{status.systemStatus.toUpperCase()}
|
||||
</span>
|
||||
if (loading) {
|
||||
return (
|
||||
<div className="card card-gradient">
|
||||
<div className="flex items-center justify-center py-12">
|
||||
<div className="spinner"></div>
|
||||
<span className="ml-2 text-gray-400">Loading overview...</span>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
{loading ? (
|
||||
<div className="flex items-center justify-center py-8">
|
||||
<div className="spinner"></div>
|
||||
<span className="ml-2 text-gray-400">Loading status...</span>
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
{/* System Status Header */}
|
||||
<div className="card card-gradient">
|
||||
<div className="flex items-center justify-between mb-6">
|
||||
<h2 className="text-xl font-bold text-white">System Status</h2>
|
||||
<div className="flex items-center space-x-2">
|
||||
<span className="text-lg">{statusIcon[status.systemStatus]}</span>
|
||||
<span className={`text-sm font-medium ${statusColor[status.systemStatus]}`}>
|
||||
Trading Bot {status.systemStatus.toUpperCase()}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<div className="space-y-6">
|
||||
{/* Main Status Grid */}
|
||||
<div className="grid grid-cols-1 sm:grid-cols-3 gap-6">
|
||||
<div className="text-center">
|
||||
<div className="w-16 h-16 bg-blue-500/20 rounded-full flex items-center justify-center mx-auto mb-3">
|
||||
<span className="text-blue-400 text-2xl">💎</span>
|
||||
</div>
|
||||
<p className="text-2xl font-bold text-blue-400">
|
||||
${status.driftBalance.toFixed(2)}
|
||||
</p>
|
||||
<p className="text-gray-400 text-sm">Portfolio Value</p>
|
||||
</div>
|
||||
|
||||
{/* Wallet Balance */}
|
||||
{/* Portfolio Overview - Combined Section */}
|
||||
<div className="grid grid-cols-2 lg:grid-cols-4 gap-4 mb-6">
|
||||
<div className="bg-gradient-to-br from-blue-500/10 to-blue-600/10 border border-blue-500/20 rounded-lg p-4">
|
||||
<div className="flex items-center space-x-3 mb-2">
|
||||
<div className="w-10 h-10 bg-blue-500/20 rounded-full flex items-center justify-center">
|
||||
<span className="text-blue-400 text-lg">💎</span>
|
||||
</div>
|
||||
<div>
|
||||
<p className="text-blue-400 text-sm font-medium">Portfolio Value</p>
|
||||
<p className="text-xl font-bold text-white">${status.portfolioValue.toFixed(2)}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{status.walletBalance && (
|
||||
<div className="text-center">
|
||||
<div className="w-16 h-16 bg-emerald-500/20 rounded-full flex items-center justify-center mx-auto mb-3">
|
||||
<span className="text-emerald-400 text-2xl">🪙</span>
|
||||
<div className="bg-gradient-to-br from-emerald-500/10 to-emerald-600/10 border border-emerald-500/20 rounded-lg p-4">
|
||||
<div className="flex items-center space-x-3 mb-2">
|
||||
<div className="w-10 h-10 bg-emerald-500/20 rounded-full flex items-center justify-center p-1">
|
||||
<img
|
||||
src={coinIcons['SOL']}
|
||||
alt="SOL"
|
||||
className="w-6 h-6 rounded-full"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<p className="text-emerald-400 text-sm font-medium">Wallet Balance</p>
|
||||
<p className="text-xl font-bold text-white">
|
||||
{status.walletBalance.positions?.[0]?.amount?.toFixed(4) || '0.0000'} SOL
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<p className="text-2xl font-bold text-emerald-400">
|
||||
{status.walletBalance.positions?.[0]?.amount?.toFixed(4) || '0.0000'} SOL
|
||||
</p>
|
||||
<p className="text-gray-400 text-sm">Wallet Balance</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="text-center">
|
||||
<div className="w-16 h-16 bg-purple-500/20 rounded-full flex items-center justify-center mx-auto mb-3">
|
||||
<span className="text-purple-400 text-2xl">🔄</span>
|
||||
<div className="bg-gradient-to-br from-purple-500/10 to-purple-600/10 border border-purple-500/20 rounded-lg p-4">
|
||||
<div className="flex items-center space-x-3 mb-2">
|
||||
<div className="w-10 h-10 bg-purple-500/20 rounded-full flex items-center justify-center">
|
||||
<span className="text-purple-400 text-lg"><EFBFBD></span>
|
||||
</div>
|
||||
<p className="text-2xl font-bold text-purple-400">
|
||||
{status.activeTrades}
|
||||
</p>
|
||||
<p className="text-gray-400 text-sm">Active Trades</p>
|
||||
</div>
|
||||
|
||||
<div className="text-center">
|
||||
<div className="w-16 h-16 bg-green-500/20 rounded-full flex items-center justify-center mx-auto mb-3">
|
||||
<span className="text-green-400 text-2xl">📈</span>
|
||||
</div>
|
||||
<p className={`text-2xl font-bold ${status.dailyPnL >= 0 ? 'text-green-400' : 'text-red-400'}`}>
|
||||
{status.dailyPnL >= 0 ? '+' : ''}${status.dailyPnL.toFixed(2)}
|
||||
</p>
|
||||
<p className="text-gray-400 text-sm">Daily P&L</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Service Status */}
|
||||
<div className="border-t border-gray-700 pt-6">
|
||||
<div className="flex items-center justify-between mb-4">
|
||||
<h3 className="text-lg font-semibold text-white">Service Status</h3>
|
||||
</div>
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<div className="flex items-center justify-between p-3 bg-gray-800 rounded-lg">
|
||||
<span className="text-gray-300">Trading Bot</span>
|
||||
<div className="flex items-center space-x-2">
|
||||
<span className="text-sm">{statusIcon[status.systemStatus]}</span>
|
||||
<span className={`text-sm font-medium ${statusColor[status.systemStatus]}`}>
|
||||
{status.systemStatus.toUpperCase()}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex items-center justify-between p-3 bg-gray-800 rounded-lg">
|
||||
<span className="text-gray-300">Bitquery API</span>
|
||||
<div className="flex items-center space-x-2">
|
||||
<span className="text-sm">{statusIcon[status.bitqueryStatus]}</span>
|
||||
<span className={`text-sm font-medium ${statusColor[status.bitqueryStatus]}`}>
|
||||
{status.bitqueryStatus.toUpperCase()}
|
||||
</span>
|
||||
</div>
|
||||
<div>
|
||||
<p className="text-purple-400 text-sm font-medium">Active Trades</p>
|
||||
<p className="text-xl font-bold text-white">{status.activeTrades}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Market Prices */}
|
||||
{status.marketPrices.length > 0 && (
|
||||
<div className="border-t border-gray-700 pt-6">
|
||||
<div className="flex items-center justify-between mb-4">
|
||||
<h3 className="text-lg font-semibold text-white">Live Market Prices</h3>
|
||||
<span className="text-xs text-gray-400">Via Bitquery</span>
|
||||
<div className="bg-gradient-to-br from-green-500/10 to-green-600/10 border border-green-500/20 rounded-lg p-4">
|
||||
<div className="flex items-center space-x-3 mb-2">
|
||||
<div className="w-10 h-10 bg-green-500/20 rounded-full flex items-center justify-center">
|
||||
<span className="text-green-400 text-lg">📈</span>
|
||||
</div>
|
||||
<div className="grid grid-cols-1 sm:grid-cols-3 gap-4">
|
||||
{status.marketPrices.map((price, index) => (
|
||||
<div key={index} className="p-3 bg-gray-800 rounded-lg">
|
||||
<div className="flex items-center justify-between">
|
||||
<span className="text-white font-medium">{price.symbol}</span>
|
||||
<span className="text-white font-bold">${price.price?.toFixed(4)}</span>
|
||||
</div>
|
||||
<div className="flex items-center justify-between mt-1">
|
||||
<span className="text-xs text-gray-400">24h Change</span>
|
||||
<span className={`text-xs font-medium ${
|
||||
price.change24h >= 0 ? 'text-green-400' : 'text-red-400'
|
||||
}`}>
|
||||
{price.change24h >= 0 ? '+' : ''}{price.change24h?.toFixed(2)}%
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
<div>
|
||||
<p className="text-gray-400 text-sm font-medium">Daily P&L</p>
|
||||
<p className={`text-xl font-bold ${status.dailyPnL >= 0 ? 'text-green-400' : 'text-red-400'}`}>
|
||||
{status.dailyPnL >= 0 ? '+' : ''}${status.dailyPnL.toFixed(2)}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Available Coins in Wallet */}
|
||||
{status.availableCoins.length > 0 && (
|
||||
<div className="border-t border-gray-700 pt-6">
|
||||
<div className="flex items-center justify-between mb-4">
|
||||
<h3 className="text-lg font-semibold text-white">Available Wallet Coins</h3>
|
||||
<span className="text-xs text-gray-400">Ready for Trading</span>
|
||||
</div>
|
||||
<div className="grid grid-cols-1 gap-3">
|
||||
{status.availableCoins.map((coin, index) => (
|
||||
<div key={index} className="p-3 bg-gray-800 rounded-lg">
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="flex items-center space-x-3">
|
||||
<span className="text-lg">🪙</span>
|
||||
<div>
|
||||
<span className="text-white font-medium">{coin.symbol}</span>
|
||||
<div className="text-xs text-gray-400">${coin.price?.toFixed(2)}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="text-right">
|
||||
<div className="text-white font-bold">{coin.amount?.toFixed(4)}</div>
|
||||
<div className="text-sm text-gray-400">${coin.usdValue?.toFixed(2)}</div>
|
||||
{/* Available Wallet Coins */}
|
||||
{status.availableCoins.length > 0 && (
|
||||
<div className="border-t border-gray-700 pt-4">
|
||||
<h3 className="text-lg font-semibold text-white mb-3">Available Coins</h3>
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-3">
|
||||
{status.availableCoins.map((coin, index) => (
|
||||
<div key={index} className="bg-gray-800/50 rounded-lg p-3">
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="flex items-center space-x-3">
|
||||
{coinIcons[coin.symbol] ? (
|
||||
<img
|
||||
src={coinIcons[coin.symbol]}
|
||||
alt={coin.symbol}
|
||||
className="w-6 h-6 rounded-full"
|
||||
/>
|
||||
) : (
|
||||
<span className="text-xl">🪙</span>
|
||||
)}
|
||||
<div>
|
||||
<span className="text-white font-medium">{coin.symbol}</span>
|
||||
<div className="text-xs text-gray-400">${coin.price?.toFixed(2)}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="text-right">
|
||||
<div className="text-white font-medium">{coin.amount?.toFixed(4)}</div>
|
||||
<div className="text-sm text-gray-400">${coin.usdValue?.toFixed(2)}</div>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Live Market Prices - BTC, ETH, SOL only */}
|
||||
{status.marketPrices.length > 0 && (
|
||||
<div className="card card-gradient">
|
||||
<div className="flex items-center justify-between mb-4">
|
||||
<h3 className="text-lg font-semibold text-white">Live Market Prices</h3>
|
||||
<span className="text-xs text-gray-400">Real-time data</span>
|
||||
</div>
|
||||
<div className="grid grid-cols-1 md:grid-cols-3 gap-4">
|
||||
{status.marketPrices.map((price, index) => (
|
||||
<div key={index} className="bg-gradient-to-br from-gray-800/50 to-gray-700/50 border border-gray-600/30 rounded-lg p-4">
|
||||
<div className="flex items-center justify-between mb-2">
|
||||
<div className="flex items-center space-x-2">
|
||||
{coinIcons[price.symbol] ? (
|
||||
<img
|
||||
src={coinIcons[price.symbol]}
|
||||
alt={price.symbol}
|
||||
className="w-8 h-8 rounded-full"
|
||||
/>
|
||||
) : (
|
||||
<span className="text-2xl">🪙</span>
|
||||
)}
|
||||
<span className="text-white font-bold text-lg">{price.symbol}</span>
|
||||
</div>
|
||||
<span className="text-white font-bold text-xl">${price.price?.toFixed(2)}</span>
|
||||
</div>
|
||||
<div className="flex items-center justify-between">
|
||||
<span className="text-xs text-gray-400">24h Change</span>
|
||||
<span className={`text-sm font-medium px-2 py-1 rounded ${
|
||||
price.change24h >= 0
|
||||
? 'text-green-400 bg-green-400/10'
|
||||
: 'text-red-400 bg-red-400/10'
|
||||
}`}>
|
||||
{price.change24h >= 0 ? '+' : ''}{price.change24h?.toFixed(2)}%
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user