Skip to content

Commit 6be8d21

Browse files
committed
Fix frontend build and TypeScript errors
- Install lightningcss platform-specific binaries (darwin-arm64, linux-x64-gnu) - Fix dashboard-view.tsx: Replace getMockDashboardStats with fetchDashboardData - Add proper state management for dashboard data loading - Fix dashboard.ts: Import WalletId type and update mock data structure - Update DashboardSnapshot to use outgoingStreams/incomingStreams
1 parent 412e382 commit 6be8d21

4 files changed

Lines changed: 184 additions & 3 deletions

File tree

frontend/components/dashboard/dashboard-view.tsx

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,9 +365,33 @@ export function DashboardView({ session, onDisconnect }: DashboardViewProps) {
365365
const [streamFormMessage, setStreamFormMessage] =
366366
React.useState<StreamFormMessageState | null>(null);
367367
const [showWizard, setShowWizard] = React.useState(false);
368-
const [loading, setLoading] = React.useState(false);
368+
const [stats, setStats] = React.useState<DashboardSnapshot | null>(null);
369+
const [loading, setLoading] = React.useState(true);
369370
const [error, setError] = React.useState<string | null>(null);
370-
const stats = getMockDashboardStats(session.walletId);
371+
const [prevKey, setPrevKey] = React.useState(session.publicKey);
372+
373+
// Reset loading state during render if key changes
374+
if (session.publicKey !== prevKey) {
375+
setPrevKey(session.publicKey);
376+
setLoading(true);
377+
}
378+
379+
React.useEffect(() => {
380+
async function loadData() {
381+
try {
382+
setError(null);
383+
const data = await fetchDashboardData(session.publicKey);
384+
setStats(data);
385+
} catch (err) {
386+
setError("Failed to load dashboard data. Please check your connection to the FlowFi backend.");
387+
console.error(err);
388+
} finally {
389+
setLoading(false);
390+
}
391+
}
392+
393+
loadData();
394+
}, [session.publicKey]);
371395

372396
React.useEffect(() => {
373397
const loadedTemplates = safeLoadTemplates();

frontend/lib/dashboard.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { BackendStream } from "./api-types";
2+
import type { WalletId } from "./wallet";
23

34
export interface ActivityItem {
45
id: string;
@@ -45,7 +46,7 @@ const MOCK_STATS_BY_WALLET: Record<WalletId, DashboardSnapshot | null> = {
4546
totalReceived: 4720,
4647
totalValueLocked: 32140,
4748
activeStreamsCount: 2,
48-
streams: [
49+
outgoingStreams: [
4950
{
5051
id: "stream-1",
5152
date: "2023-10-25",
@@ -67,6 +68,7 @@ const MOCK_STATS_BY_WALLET: Record<WalletId, DashboardSnapshot | null> = {
6768
withdrawn: 300,
6869
},
6970
],
71+
incomingStreams: [],
7072
recentActivity: [
7173
{
7274
id: "act-1",

package-lock.json

Lines changed: 151 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,9 @@
2323
},
2424
"dependencies": {
2525
"react-hot-toast": "^2.6.0"
26+
},
27+
"optionalDependencies": {
28+
"lightningcss-darwin-arm64": "^1.31.1",
29+
"lightningcss-linux-x64-gnu": "^1.31.1"
2630
}
2731
}

0 commit comments

Comments
 (0)