From 5bf25ca3eebe87427433844a6d997be2eecba2a0 Mon Sep 17 00:00:00 2001 From: mindesbunister Date: Sat, 26 Jul 2025 11:32:24 +0200 Subject: [PATCH] Fix Overview page runtime errors - Replace complex page.js with simple version that delegates to StatusOverview - Eliminates hydration errors from Date.now() usage - Prevents undefined property access errors (aiAnalytics.overview.totalLearningRecords) - Overview page now loads correctly without 'Something went wrong!' error - All data fetching and error handling properly managed by StatusOverview component --- app/page.js | 293 +--------------------------------------------------- 1 file changed, 4 insertions(+), 289 deletions(-) diff --git a/app/page.js b/app/page.js index 42a00f7..145b4ee 100644 --- a/app/page.js +++ b/app/page.js @@ -1,297 +1,12 @@ 'use client' -import React, { useState, useEffect } from 'react' +import StatusOverview from '../components/StatusOverview.js' export default function HomePage() { - const [positions, setPositions] = useState({ hasPosition: false }) - const [loading, setLoading] = useState(true) - const [aiAnalytics, setAiAnalytics] = useState(null) - const [analyticsLoading, setAnalyticsLoading] = useState(true) - - const fetchData = async () => { - try { - // Try to fetch position data from our real API (might not exist) - try { - const positionResponse = await fetch('/api/check-position') - if (positionResponse.ok) { - const positionData = await positionResponse.json() - setPositions(positionData) - } - } catch (e) { - console.log('Position API not available, using default') - } - - // Fetch REAL AI analytics - setAnalyticsLoading(true) - const analyticsResponse = await fetch('/api/ai-analytics') - if (analyticsResponse.ok) { - const analyticsData = await analyticsResponse.json() - setAiAnalytics(analyticsData) - } - setAnalyticsLoading(false) - } catch (error) { - console.error('Error fetching data:', error) - setAnalyticsLoading(false) - } finally { - setLoading(false) - } - } - - useEffect(() => { - fetchData() - // Refresh every 30 seconds - const interval = setInterval(fetchData, 30000) - return () => clearInterval(interval) - }, []) - return ( -
- {/* Quick Overview Cards */} -
- {/* Position Monitor */} -
-
-

- 🔍Position Monitor -

- - Last update: {new Date().toLocaleTimeString()} - -
-
- - {/* Position Status - REAL DATA */} -
- {positions.hasPosition ? ( -
-

- 📈Active Position -

-
-
-

Symbol

-

{positions.symbol}

-
-
-

Unrealized PnL

-

= 0 ? 'text-green-400' : 'text-red-400' - }`}> - ${(positions.unrealizedPnl || 0).toFixed(2)} -

-
-
-

Risk Level

-

- {positions.riskLevel} -

-
-
-

Status

-
-
- Active -
-
-
-
- ) : ( -
-

- 📊No Open Positions -

-

Scanning for opportunities...

-
- )} -
- - {/* Automation Status */} -
-

- 🤖Automation Status -

-
-

- STOPPED -

-

-
-
-
- - {/* REAL AI Learning Analytics */} -
- {analyticsLoading ? ( -
-
- Loading REAL AI learning analytics... -
- ) : aiAnalytics ? ( -
-

- 🧠REAL AI Learning Analytics & Performance -

- - {/* REAL Overview Stats */} -
-
-
{aiAnalytics.overview.totalLearningRecords}
-
REAL Learning Records
-
-
-
{aiAnalytics.overview.totalTrades}
-
REAL AI Trades Executed
-
-
-
{aiAnalytics.realTimeMetrics.daysSinceAIStarted}
-
Days Active
-
-
-
- {aiAnalytics.learningProof.isStatisticallySignificant ? '✓' : '⚠'} -
-
Statistical Significance
-
-
- - {/* REAL Learning Improvements */} -
-
-

REAL Learning Progress

-
-
- Confidence Change: - = 0 ? 'text-green-400' : 'text-red-400'}`}> - {aiAnalytics.improvements.confidenceImprovement > 0 ? '+' : ''}{aiAnalytics.improvements.confidenceImprovement.toFixed(2)}% - -
-
- Trend Direction: - - {aiAnalytics.improvements.trend} - -
-
- Sample Size: - {aiAnalytics.learningProof.sampleSize} -
-
-
- -
-

REAL Trading Performance

-
-
- Total PnL: - = 0 ? 'text-green-400' : 'text-red-400'}`}> - ${aiAnalytics.pnl.totalPnL.toFixed(2)} - -
-
- PnL Percentage: - = 0 ? 'text-green-400' : 'text-red-400'}`}> - {aiAnalytics.pnl.totalPnLPercent > 0 ? '+' : ''}{aiAnalytics.pnl.totalPnLPercent.toFixed(2)}% - -
-
- Win Rate: - {(aiAnalytics.pnl.winRate * 100).toFixed(1)}% -
-
- Avg Trade Size: - ${aiAnalytics.pnl.avgTradeSize.toFixed(2)} -
-
-
-
- - {/* REAL Proof of Learning */} -
-

- 📈PROVEN AI Learning Effectiveness (NOT FAKE!) -

-
-
-
{aiAnalytics.overview.totalLearningRecords}
-
REAL Learning Samples
-
-
-
{aiAnalytics.overview.totalTrades}
-
REAL AI Decisions
-
-
-
- {aiAnalytics.learningProof.isStatisticallySignificant ? 'PROVEN' : 'LEARNING'} -
-
Statistical Confidence
-
-
-
- 🧠 REAL AI learning system has collected {aiAnalytics.overview.totalLearningRecords} samples - and executed {aiAnalytics.overview.totalTrades} trades with - {aiAnalytics.learningProof.isStatisticallySignificant ? 'statistically significant' : 'emerging'} learning patterns. -
- ⚠️ These are ACTUAL numbers, not fake demo data! -
-
- - {/* Real-time Metrics */} -
- Last updated: {new Date(aiAnalytics.realTimeMetrics.lastUpdate).toLocaleString()} - • Learning Active: {aiAnalytics.realTimeMetrics.isLearningActive ? '✅' : '❌'} - • {aiAnalytics.realTimeMetrics.learningRecordsPerDay.toFixed(1)} records/day - • {aiAnalytics.realTimeMetrics.tradesPerDay.toFixed(1)} trades/day -
-
- ) : ( -
-
- ⚠️ -

Unable to load REAL AI analytics

- -
-
- )} -
- - {/* Overview Section */} -
- {loading ? ( -
-
- Loading REAL overview... -
- ) : ( -
-

REAL Trading Overview

-
-
-
🎯
-
Strategy Performance
-
AI-powered analysis with REAL continuous learning
-
-
-
🔄
-
Automated Execution
-
24/7 market monitoring and ACTUAL trade execution
-
-
-
📊
-
Risk Management
-
Advanced stop-loss and position sizing
-
-
-
- )} -
+
+ {/* Status Overview */} +
) }