File size: 4,106 Bytes
8964497 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | import React, { useState, useEffect } from 'react';
const API_BASE = import.meta.env.VITE_API_URL || 'http://localhost:8000';
export default function CommandHeader() {
const [stats, setStats] = useState({
psiStatus: 'GREEN',
psiScore: 0.041,
wmapeLift: 24.3,
mcpTools: 35,
connected: true,
});
useEffect(() => {
const fetchStats = async () => {
try {
const res = await fetch(`${API_BASE}/api/analytics/summary`);
if (res.ok) {
const data = await res.json();
setStats(prev => ({
...prev,
connected: true,
}));
}
} catch {
// Keeps fallback
}
};
fetchStats();
const interval = setInterval(fetchStats, 30000);
return () => clearInterval(interval);
}, []);
return (
<header style={styles.header}>
{/* Brand Badge */}
<div style={styles.brandGroup}>
<div style={styles.logoPill}>
<span style={styles.logoDot} />
<span>HYPERFLOW OPERATING SYSTEM</span>
</div>
</div>
{/* Live Stat Badges */}
<div style={styles.statGroup}>
<div style={styles.statCard}>
<span style={styles.statLabel}>PSI DRIFT</span>
<div style={styles.valGroup}>
<span style={styles.dotGreen} />
<span style={{ color: 'var(--accent-emerald)', fontWeight: 700 }}>{stats.psiStatus}</span>
<span style={styles.statSub}>({stats.psiScore})</span>
</div>
</div>
<div style={styles.statCard}>
<span style={styles.statLabel}>WMAPE LIFT</span>
<span style={{ color: 'var(--accent-coral-pink)', fontWeight: 700 }}>+{stats.wmapeLift}%</span>
</div>
<div style={styles.statCard}>
<span style={styles.statLabel}>SWIGGY MCP</span>
<span style={{ color: '#FFF', fontWeight: 700 }}>{stats.mcpTools} Tools</span>
</div>
<div style={{ ...styles.statCard, borderColor: stats.connected ? 'rgba(0, 228, 117, 0.3)' : 'rgba(255, 51, 102, 0.3)' }}>
<span style={styles.statLabel}>STATUS</span>
<span style={{ color: stats.connected ? 'var(--accent-emerald)' : 'var(--accent-coral)', fontWeight: 700 }}>
{stats.connected ? 'Connected' : 'Offline'}
</span>
</div>
</div>
</header>
);
}
const styles = {
header: {
height: 60,
background: 'rgba(10, 9, 13, 0.8)',
backdropFilter: 'blur(16px)',
borderBottom: '1px solid var(--bg-border)',
display: 'flex',
alignItems: 'center',
justifyContent: 'space-between',
padding: '0 24px',
flexShrink: 0,
zIndex: 20,
},
brandGroup: {
display: 'flex',
alignItems: 'center',
gap: 12,
},
logoPill: {
display: 'flex',
alignItems: 'center',
gap: 8,
padding: '6px 14px',
background: 'rgba(255, 51, 102, 0.08)',
border: '1px solid rgba(255, 51, 102, 0.25)',
borderRadius: 'var(--radius-pill)',
fontFamily: 'var(--font-sans)',
fontSize: 11,
fontWeight: 700,
color: 'var(--accent-coral-pink)',
letterSpacing: '0.08em',
},
logoDot: {
width: 6,
height: 6,
borderRadius: '50%',
background: 'var(--accent-coral)',
boxShadow: '0 0 8px var(--accent-coral)',
},
statGroup: {
display: 'flex',
alignItems: 'center',
gap: 12,
},
statCard: {
display: 'flex',
alignItems: 'center',
gap: 8,
padding: '6px 14px',
background: 'rgba(18, 16, 23, 0.7)',
border: '1px solid var(--bg-border)',
borderRadius: 'var(--radius-pill)',
fontFamily: 'var(--font-sans)',
fontSize: 12,
},
statLabel: {
fontSize: 10,
fontWeight: 700,
color: 'var(--text-muted)',
letterSpacing: '0.06em',
},
valGroup: {
display: 'flex',
alignItems: 'center',
gap: 5,
},
dotGreen: {
width: 6,
height: 6,
borderRadius: '50%',
background: 'var(--accent-emerald)',
boxShadow: '0 0 6px var(--accent-emerald)',
},
statSub: {
fontSize: 11,
color: 'var(--text-secondary)',
},
};
|