money-rain commited on
Commit
eecb251
·
verified ·
1 Parent(s): 66c0988

Create web/src/App.jsx

Browse files
Files changed (1) hide show
  1. web/src/App.jsx +163 -0
web/src/App.jsx ADDED
@@ -0,0 +1,163 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { useState, useEffect } from 'react';
2
+ import { LineChart, Line, XAxis, YAxis, Tooltip, ResponsiveContainer, PieChart, Pie, Cell } from 'recharts';
3
+
4
+ const COLORS = ['#00f3ff', '#bc13fe']; // Cyan pour Gains, Magenta pour Pertes
5
+
6
+ export default function App() {
7
+ const [seuil, setSeuil] = useState(2.0);
8
+ const [data, setData] = useState(null);
9
+ const [loading, setLoading] = useState(true);
10
+
11
+ useEffect(() => {
12
+ setLoading(true);
13
+ // Appel de l'API sur le même domaine (port 7860)
14
+ fetch(`/api/stats?seuil=${seuil}`)
15
+ .then(res => res.json())
16
+ .then(result => {
17
+ setData(result);
18
+ setLoading(false);
19
+ })
20
+ .catch(err => {
21
+ console.error("Erreur API:", err);
22
+ setLoading(false);
23
+ });
24
+ }, [seuil]);
25
+
26
+ if (loading || !data) {
27
+ return (
28
+ <div className="flex items-center justify-center h-screen text-slate-500 text-xl">
29
+ Chargement des données...
30
+ </div>
31
+ );
32
+ }
33
+
34
+ if (data.error) {
35
+ return <div className="flex items-center justify-center h-screen text-red-500">{data.error}</div>;
36
+ }
37
+
38
+ // Formatage des données pour Recharts
39
+ const chartData = data.historique.map((r, i) => ({ name: i, cote: r.cote }));
40
+ const pieData = [
41
+ { name: `Gains (> ${seuil}x)`, value: data.distribution.gains },
42
+ { name: `Pertes (<= ${seuil}x)`, value: data.distribution.pertes }
43
+ ];
44
+
45
+ return (
46
+ <div className="min-h-screen p-6 bg-slate-100">
47
+ <div className="max-w-7xl mx-auto">
48
+
49
+ {/* Header */}
50
+ <div className="mb-8 text-center">
51
+ <h1 className="text-4xl font-extrabold text-transparent bg-clip-text bg-gradient-to-r from-neon-cyan to-neon-magenta drop-shadow-neon-cyan">
52
+ AVIATOR ANALYTICS V3
53
+ </h1>
54
+ <p className="text-slate-500 mt-2">Analyse dynamique en temps réel</p>
55
+ </div>
56
+
57
+ {/* LE SUPER SLIDER DE SEUIL */}
58
+ <div className="glass-card p-6 mb-8 flex flex-col md:flex-row items-center justify-between gap-4">
59
+ <div className="w-full md:w-1/3">
60
+ <span className="text-sm font-bold text-slate-600 uppercase tracking-wider">Seuil d'analyse</span>
61
+ </div>
62
+ <div className="w-full md:w-2/3 flex items-center gap-4">
63
+ <span className="text-slate-400 text-sm">1.0x</span>
64
+ <input
65
+ type="range"
66
+ min="1.1"
67
+ max="10"
68
+ step="0.1"
69
+ value={seuil}
70
+ onChange={(e) => setSeuil(parseFloat(e.target.value))}
71
+ className="neon-slider w-full"
72
+ />
73
+ <span className="text-slate-400 text-sm">10.0x</span>
74
+ </div>
75
+ <div className="text-3xl font-bold text-neon-cyan drop-shadow-[0_0_10px_rgba(0,243,255,0.7)]">
76
+ {seuil.toFixed(1)}x
77
+ </div>
78
+ </div>
79
+
80
+ {/* KPI Cards */}
81
+ <div className="grid grid-cols-1 md:grid-cols-4 gap-6 mb-8">
82
+ <KpiCard title="Total Rounds" value={data.totalRounds} color="text-slate-800" />
83
+ <KpiCard title="Cote Moyenne" value={`${data.coteMoyenne}x`} color="text-neon-cyan" shadow="neon-cyan" />
84
+ <KpiCard title="Avantage Maison" value={`${data.avantageMaison}%`} color="text-neon-magenta" shadow="neon-magenta" isNegative={data.avantageMaison > 0} />
85
+ <KpiCard title="Max Streak (Gains)" value={`${data.streaks.maxGains} coups`} color="text-green-500" />
86
+ </div>
87
+
88
+ {/* Graphiques */}
89
+ <div className="grid grid-cols-1 lg:grid-cols-3 gap-6 mb-8">
90
+ {/* Courbe des cotes */}
91
+ <div className="glass-card p-6 lg:col-span-2">
92
+ <h3 className="text-lg font-bold text-slate-700 mb-4">Historique des Cotes (100 derniers)</h3>
93
+ <div className="h-64">
94
+ <ResponsiveContainer width="100%" height="100%">
95
+ <LineChart data={chartData}>
96
+ <XAxis dataKey="name" hide />
97
+ <YAxis domain={[0, 'auto']} />
98
+ <Tooltip
99
+ contentStyle={{ background: 'rgba(255,255,255,0.8)', backdropFilter: 'blur(5px)', border: 'none', borderRadius: '10px' }}
100
+ formatter={(value) => [`${value}x`, "Cote"]}
101
+ />
102
+ <Line type="monotone" dataKey="cote" stroke="#00f3ff" strokeWidth={2} dot={false} activeDot={{r: 6, fill: '#bc13fe'}} />
103
+ </LineChart>
104
+ </ResponsiveContainer>
105
+ </div>
106
+ </div>
107
+
108
+ {/* Pie Chart Distribution */}
109
+ <div className="glass-card p-6 flex flex-col items-center justify-center">
110
+ <h3 className="text-lg font-bold text-slate-700 mb-4">Distribution</h3>
111
+ <div className="h-48 w-full">
112
+ <ResponsiveContainer width="100%" height="100%">
113
+ <PieChart>
114
+ <Pie data={pieData} cx="50%" cy="50%" innerRadius={40} outerRadius={70} paddingAngle={5} dataKey="value">
115
+ {pieData.map((entry, index) => (
116
+ <Cell key={`cell-${index}`} fill={COLORS[index % COLORS.length]} />
117
+ ))}
118
+ </Pie>
119
+ <Tooltip
120
+ contentStyle={{ background: 'rgba(255,255,255,0.8)', border: 'none', borderRadius: '10px' }}
121
+ formatter={(value, name) => [`${value} (${((value/data.totalRounds)*100).toFixed(1)}%)`, name]}
122
+ />
123
+ </PieChart>
124
+ </ResponsiveContainer>
125
+ </div>
126
+ <div className="flex gap-6 mt-4 text-sm font-semibold">
127
+ <div className="flex items-center gap-2"><span className="w-3 h-3 rounded-full bg-neon-cyan"></span> Gains ({data.distribution.pourcentageGains}%)</div>
128
+ <div className="flex items-center gap-2"><span className="w-3 h-3 rounded-full bg-neon-magenta"></span> Pertes ({data.distribution.pourcentagePertes}%)</div>
129
+ </div>
130
+ </div>
131
+ </div>
132
+
133
+ </div>
134
+
135
+ {/* Styles CSS Injectés pour le Glassmorphism (pour éviter un fichier tailwind trop complexe pour l'instant) */}
136
+ <style jsx global>{`
137
+ .glass-card {
138
+ background: rgba(255, 255, 255, 0.7);
139
+ backdrop-filter: blur(12px);
140
+ -webkit-backdrop-filter: blur(12px);
141
+ border: 1px solid rgba(255, 255, 255, 0.4);
142
+ border-radius: 1rem;
143
+ box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.1);
144
+ transition: all 0.3s ease;
145
+ }
146
+ .glass-card:hover {
147
+ border-color: rgba(0, 243, 255, 0.3);
148
+ box-shadow: 0 8px 32px 0 rgba(0, 243, 255, 0.1);
149
+ }
150
+ `}</style>
151
+ </div>
152
+ );
153
+ }
154
+
155
+ // Composant Card réutilisable
156
+ const KpiCard = ({ title, value, color, shadow, isNegative }) => (
157
+ <div className={`glass-card p-6 text-center ${shadow ? `shadow-${shadow}` : ''}`}>
158
+ <p className="text-sm font-medium text-slate-500 mb-1">{title}</p>
159
+ <p className={`text-3xl font-bold ${color} ${isNegative ? 'drop-shadow-[0_0_8px_rgba(188,19,254,0.6)]' : ''}`}>
160
+ {value}
161
+ </p>
162
+ </div>
163
+ );