Skip to content

Commit 8092778

Browse files
committed
feat: display groq billing badge in react dashboard
1 parent 0da6a81 commit 8092778

2 files changed

Lines changed: 29 additions & 2 deletions

File tree

web/src/App.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ h1 {
4545
.header-stats {
4646
display: flex;
4747
align-items: center;
48+
gap: 1rem;
4849
}
4950

5051
.balance-badge {
@@ -56,6 +57,14 @@ h1 {
5657
white-space: nowrap;
5758
}
5859

60+
.groq-badge.pos strong {
61+
color: #4caf50;
62+
}
63+
64+
.groq-badge.neg strong {
65+
color: #f44336;
66+
}
67+
5968
.balance-badge strong {
6069
color: #4caf50;
6170
margin-left: 0.5rem;

web/src/App.tsx

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,18 @@ interface HistoryData {
4545
generated_at: string;
4646
}
4747

48+
interface GroqData {
49+
todayTotal: number;
50+
thisMonthTotal: number;
51+
lastMonthTotal: number;
52+
generated_at?: string;
53+
}
54+
4855
function App() {
4956
const [currentData, setCurrentData] = useState<TrackerData | null>(null);
5057
const [sixData, setSixData] = useState<TrackerData | null>(null);
5158
const [historyData, setHistoryData] = useState<HistoryData | null>(null);
59+
const [groqData, setGroqData] = useState<GroqData | null>(null);
5260
const [loading, setLoading] = useState(true);
5361
const [error, setError] = useState<string | null>(null);
5462
const [activeModal, setActiveModal] = useState<{ type: 'pacing' | 'bank' | 'energy' | 'history', data?: any } | null>(null);
@@ -86,12 +94,14 @@ function App() {
8694
Promise.all([
8795
fetchData('/api/data', '/data.json'),
8896
fetchData('/api/six', '/six.json'),
89-
fetchData('/api/history', '/history_summary.json')
97+
fetchData('/api/history', '/history_summary.json'),
98+
fetchData('/api/groq', '/groq_summary.json')
9099
])
91-
.then(([current, six, history]) => {
100+
.then(([current, six, history, groq]) => {
92101
setCurrentData(current);
93102
setSixData(six);
94103
setHistoryData(history);
104+
setGroqData(groq);
95105
})
96106
.catch(err => setError(err.message))
97107
.finally(() => setLoading(false));
@@ -136,6 +146,14 @@ function App() {
136146
<div className="header-main">
137147
<h1>Time Carburetor</h1>
138148
<div className="header-stats">
149+
{groqData && (
150+
<span
151+
className={`balance-badge groq-badge ${groqData.todayTotal >= 0.03 ? 'pos' : 'neg'}`}
152+
title={`Groq Spend:\nToday: $${groqData.todayTotal.toFixed(2)}\nThis Month: $${groqData.thisMonthTotal.toFixed(2)}\nLast Month: $${groqData.lastMonthTotal.toFixed(2)}`}
153+
>
154+
Groq: <strong>${groqData.todayTotal.toFixed(2)}</strong>
155+
</span>
156+
)}
139157
<span className="balance-badge">
140158
Monthly: <strong>{currentBillableDiff >= 0 ? '+' : ''}{currentBillableDiff.toFixed(1)}h</strong>
141159
</span>

0 commit comments

Comments
 (0)