feat: Restructure UI with navigation and separate pages

- Add Navigation component with clean tab-based navigation
- Create StatusOverview component for main dashboard indicators
- Split functionality into separate pages:
  * Overview page with status and quick actions
  * Analysis page for AI analysis
  * Trading page for manual trading and history
  * Automation page for auto-trading settings
  * Settings page for developer configuration
- Add React dependencies to package.json
- Maintain clean separation of concerns
This commit is contained in:
mindesbunister
2025-07-14 00:21:44 +02:00
parent 4b9e52278a
commit 3c988b47f2
10 changed files with 366 additions and 12 deletions

16
app/analysis/page.tsx Normal file
View File

@@ -0,0 +1,16 @@
import AIAnalysisPanel from '../../components/AIAnalysisPanel'
export default function AnalysisPage() {
return (
<div className="space-y-8">
<div className="flex items-center justify-between">
<div>
<h1 className="text-3xl font-bold text-white">AI Analysis</h1>
<p className="text-gray-400 mt-2">Get market insights and AI-powered analysis</p>
</div>
</div>
<AIAnalysisPanel />
</div>
)
}

25
app/automation/page.tsx Normal file
View File

@@ -0,0 +1,25 @@
import AutoTradingPanel from '../../components/AutoTradingPanel'
import SessionStatus from '../../components/SessionStatus'
export default function AutomationPage() {
return (
<div className="space-y-8">
<div className="flex items-center justify-between">
<div>
<h1 className="text-3xl font-bold text-white">Automation</h1>
<p className="text-gray-400 mt-2">Configure automated trading settings and monitor session status</p>
</div>
</div>
<div className="grid grid-cols-1 xl:grid-cols-2 gap-8">
<div className="space-y-6">
<AutoTradingPanel />
</div>
<div className="space-y-6">
<SessionStatus />
</div>
</div>
</div>
)
}

View File

@@ -1,5 +1,6 @@
import './globals.css'
import type { Metadata } from 'next'
import Navigation from '../components/Navigation'
export const metadata: Metadata = {
title: 'Trading Bot Dashboard',
@@ -44,6 +45,9 @@ export default function RootLayout({ children }: { children: React.ReactNode })
</div>
</header>
{/* Navigation */}
<Navigation />
{/* Main Content */}
<main className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
{children}

View File

@@ -1,4 +1,4 @@
import Dashboard from '../components/Dashboard'
import StatusOverview from '../components/StatusOverview'
export default function HomePage() {
return (
@@ -13,8 +13,55 @@ export default function HomePage() {
</p>
</div>
{/* Main Dashboard */}
<Dashboard />
{/* 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 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 manual trades</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>
</div>
)
}

25
app/settings/page.tsx Normal file
View File

@@ -0,0 +1,25 @@
import DeveloperSettings from '../../components/DeveloperSettings'
import DriftAccountStatus from '../../components/DriftAccountStatus'
export default function SettingsPage() {
return (
<div className="space-y-8">
<div className="flex items-center justify-between">
<div>
<h1 className="text-3xl font-bold text-white">Settings</h1>
<p className="text-gray-400 mt-2">Developer configuration and account status</p>
</div>
</div>
<div className="grid grid-cols-1 xl:grid-cols-2 gap-8">
<div className="space-y-6">
<DriftAccountStatus />
</div>
<div className="space-y-6">
<DeveloperSettings />
</div>
</div>
</div>
)
}

25
app/trading/page.tsx Normal file
View File

@@ -0,0 +1,25 @@
import AdvancedTradingPanel from '../../components/AdvancedTradingPanel'
import TradingHistory from '../../components/TradingHistory'
export default function TradingPage() {
return (
<div className="space-y-8">
<div className="flex items-center justify-between">
<div>
<h1 className="text-3xl font-bold text-white">Manual Trading</h1>
<p className="text-gray-400 mt-2">Execute trades and view trading history</p>
</div>
</div>
<div className="grid grid-cols-1 xl:grid-cols-2 gap-8">
<div className="space-y-6">
<AdvancedTradingPanel />
</div>
<div className="space-y-6">
<TradingHistory />
</div>
</div>
</div>
)
}

72
components/Navigation.tsx Normal file
View File

@@ -0,0 +1,72 @@
"use client"
import React from 'react'
import Link from 'next/link'
import { usePathname } from 'next/navigation'
const navItems = [
{
name: 'Overview',
href: '/',
icon: '🏠',
description: 'Dashboard overview'
},
{
name: 'Analysis',
href: '/analysis',
icon: '📊',
description: 'AI analysis & insights'
},
{
name: 'Trading',
href: '/trading',
icon: '💰',
description: 'Execute trades'
},
{
name: 'Automation',
href: '/automation',
icon: '🤖',
description: 'Auto-trading settings'
},
{
name: 'Settings',
href: '/settings',
icon: '⚙️',
description: 'Developer settings'
}
]
export default function Navigation() {
const pathname = usePathname()
return (
<nav className="bg-gray-900/50 backdrop-blur-sm border-b border-gray-800">
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div className="flex items-center justify-between h-14">
<div className="flex items-center space-x-8">
{navItems.map((item) => {
const isActive = pathname === item.href
return (
<Link
key={item.name}
href={item.href}
className={`flex items-center space-x-2 px-3 py-2 rounded-lg text-sm font-medium transition-all duration-200 group ${
isActive
? 'bg-blue-600/20 text-blue-400 border border-blue-500/30'
: 'text-gray-400 hover:text-gray-200 hover:bg-gray-800/50'
}`}
>
<span className={`text-lg ${isActive ? 'text-blue-400' : 'text-gray-500 group-hover:text-gray-300'}`}>
{item.icon}
</span>
<span>{item.name}</span>
</Link>
)
})}
</div>
</div>
</div>
</nav>
)
}

View File

@@ -0,0 +1,128 @@
"use client"
import React, { useEffect, useState } from 'react'
interface StatusData {
driftBalance: number
activeTrades: number
dailyPnL: number
systemStatus: 'online' | 'offline' | 'error'
}
export default function StatusOverview() {
const [status, setStatus] = useState<StatusData>({
driftBalance: 0,
activeTrades: 0,
dailyPnL: 0,
systemStatus: 'offline'
})
const [loading, setLoading] = useState(true)
useEffect(() => {
async function fetchStatus() {
try {
setLoading(true)
// Get Drift positions for active trades
const driftRes = await fetch('/api/drift/positions')
let activeTrades = 0
if (driftRes.ok) {
const driftData = await driftRes.json()
activeTrades = driftData.positions?.length || 0
}
// Get Drift balance
let driftBalance = 0
try {
const balanceRes = await fetch('/api/drift/balance')
if (balanceRes.ok) {
const balanceData = await balanceRes.json()
driftBalance = balanceData.netUsdValue || 0
}
} catch (e) {
console.warn('Could not fetch balance:', e)
}
setStatus({
driftBalance,
activeTrades,
dailyPnL: driftBalance * 0.1, // Approximate daily as 10% for demo
systemStatus: driftRes.ok ? 'online' : 'error'
})
} catch (error) {
console.error('Error fetching status:', error)
setStatus(prev => ({ ...prev, systemStatus: 'error' }))
}
setLoading(false)
}
fetchStatus()
// Refresh every 30 seconds
const interval = setInterval(fetchStatus, 30000)
return () => clearInterval(interval)
}, [])
const statusColor = {
online: 'text-green-400',
offline: 'text-yellow-400',
error: 'text-red-400'
}
const statusIcon = {
online: '🟢',
offline: '🟡',
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>
</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>
</div>
) : (
<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">Drift 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>
<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>
)}
</div>
)
}

25
package-lock.json generated
View File

@@ -11,6 +11,7 @@
"@drift-labs/sdk": "^2.126.0-beta.14",
"@prisma/client": "^6.11.1",
"@solana/web3.js": "^1.98.2",
"@types/react-dom": "^19.1.6",
"bs58": "^6.0.0",
"dotenv": "^17.2.0",
"next": "15.3.5",
@@ -18,7 +19,9 @@
"openai": "^5.8.3",
"playwright": "^1.54.1",
"prisma": "^6.11.1",
"puppeteer": "^24.12.0"
"puppeteer": "^24.12.0",
"react": "^19.1.0",
"react-dom": "^19.1.0"
},
"devDependencies": {
"@eslint/eslintrc": "^3",
@@ -2719,11 +2722,19 @@
"version": "19.1.8",
"resolved": "https://registry.npmjs.org/@types/react/-/react-19.1.8.tgz",
"integrity": "sha512-AwAfQ2Wa5bCx9WP8nZL2uMZWod7J7/JSplxbTmBQ5ms6QpqNYm672H0Vu9ZVKVngQ+ii4R/byguVEUZQyeg44g==",
"dev": true,
"dependencies": {
"csstype": "^3.0.2"
}
},
"node_modules/@types/react-dom": {
"version": "19.1.6",
"resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-19.1.6.tgz",
"integrity": "sha512-4hOiT/dwO8Ko0gV1m/TJZYk3y0KBnY9vzDh7W+DH17b2HFSOGgdj33dhihPeuy3l0q23+4e+hoXHV6hCC4dCXw==",
"license": "MIT",
"peerDependencies": {
"@types/react": "^19.0.0"
}
},
"node_modules/@types/uuid": {
"version": "8.3.4",
"resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.4.tgz",
@@ -4352,8 +4363,7 @@
"node_modules/csstype": {
"version": "3.1.3",
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.3.tgz",
"integrity": "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==",
"dev": true
"integrity": "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw=="
},
"node_modules/damerau-levenshtein": {
"version": "1.0.8",
@@ -7920,7 +7930,7 @@
"version": "19.1.0",
"resolved": "https://registry.npmjs.org/react/-/react-19.1.0.tgz",
"integrity": "sha512-FS+XFBNvn3GTAWq26joslQgWNoFu08F4kl0J4CgdNKADkdSGXQyTCnKteIAJy96Br6YbpEU1LSzV5dYtjMkMDg==",
"peer": true,
"license": "MIT",
"engines": {
"node": ">=0.10.0"
}
@@ -7929,7 +7939,7 @@
"version": "19.1.0",
"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.1.0.tgz",
"integrity": "sha512-Xs1hdnE+DyKgeHJeJznQmYMIBG3TKIHJJT95Q58nHLSrElKlGQqDTR2HQ9fx5CN/Gk6Vh/kupBTDLU11/nDk/g==",
"peer": true,
"license": "MIT",
"dependencies": {
"scheduler": "^0.26.0"
},
@@ -8176,8 +8186,7 @@
"node_modules/scheduler": {
"version": "0.26.0",
"resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.26.0.tgz",
"integrity": "sha512-NlHwttCI/l5gCPR3D1nNXtWABUmBwvZpEQiD4IXSbIDq8BzLIK/7Ir5gTFSGZDUu37K5cMNp0hFtzO38sC7gWA==",
"peer": true
"integrity": "sha512-NlHwttCI/l5gCPR3D1nNXtWABUmBwvZpEQiD4IXSbIDq8BzLIK/7Ir5gTFSGZDUu37K5cMNp0hFtzO38sC7gWA=="
},
"node_modules/semver": {
"version": "7.7.2",

View File

@@ -40,6 +40,7 @@
"@drift-labs/sdk": "^2.126.0-beta.14",
"@prisma/client": "^6.11.1",
"@solana/web3.js": "^1.98.2",
"@types/react-dom": "^19.1.6",
"bs58": "^6.0.0",
"dotenv": "^17.2.0",
"next": "15.3.5",
@@ -47,7 +48,9 @@
"openai": "^5.8.3",
"playwright": "^1.54.1",
"prisma": "^6.11.1",
"puppeteer": "^24.12.0"
"puppeteer": "^24.12.0",
"react": "^19.1.0",
"react-dom": "^19.1.0"
},
"devDependencies": {
"@eslint/eslintrc": "^3",