fix: frontend resilience in admin dashboard

This commit is contained in:
2026-04-23 11:00:02 -04:00
parent 137bf19a02
commit 1016fd397e
+8 -7
View File
@@ -30,11 +30,11 @@ import { useStore } from "@/lib/store";
import { formatNumber } from "@/lib/utils"; import { formatNumber } from "@/lib/utils";
interface Analytics { interface Analytics {
users: { total: number; with_wallet: number; active_30d: number }; users: { total: number; new_this_week: number };
transactions: { transactions: {
total_earned: number; total_earned: number;
total_spent: number; total_spent: number;
total_count: number; total_transactions: number;
}; };
requests: { requests: {
total: number; total: number;
@@ -90,7 +90,8 @@ export default function AdminPage() {
setAnalytics(analyticsRes.data); setAnalytics(analyticsRes.data);
setUsers(usersRes.data.users || []); setUsers(usersRes.data.users || []);
setSettings(settingsRes.data); setSettings(settingsRes.data);
} catch { } catch (err) {
console.error("Admin load error:", err);
toast.error("Failed to load coop secrets"); toast.error("Failed to load coop secrets");
} finally { } finally {
setIsLoading(false); setIsLoading(false);
@@ -433,7 +434,7 @@ export default function AdminPage() {
<Users className="h-3 w-3" /> Flock Size <Users className="h-3 w-3" /> Flock Size
</div> </div>
<div className="text-4xl font-black"> <div className="text-4xl font-black">
{analytics?.users.total || 0} {analytics?.users?.total ?? 0}
</div> </div>
</div> </div>
<div className="rounded-3xl border-4 border-foreground bg-card p-6 shadow-[6px_6px_0px_0px_rgba(0,0,0,1)]"> <div className="rounded-3xl border-4 border-foreground bg-card p-6 shadow-[6px_6px_0px_0px_rgba(0,0,0,1)]">
@@ -441,7 +442,7 @@ export default function AdminPage() {
<Database className="h-3 w-3" /> Total $COOP <Database className="h-3 w-3" /> Total $COOP
</div> </div>
<div className="text-4xl font-black"> <div className="text-4xl font-black">
{formatNumber(analytics?.transactions.total_earned || 0)} {formatNumber(analytics?.transactions?.total_earned ?? 0)}
</div> </div>
</div> </div>
<div className="rounded-3xl border-4 border-foreground bg-card p-6 shadow-[6px_6px_0px_0px_rgba(0,0,0,1)]"> <div className="rounded-3xl border-4 border-foreground bg-card p-6 shadow-[6px_6px_0px_0px_rgba(0,0,0,1)]">
@@ -449,7 +450,7 @@ export default function AdminPage() {
<TrendingUp className="h-3 w-3" /> Requests <TrendingUp className="h-3 w-3" /> Requests
</div> </div>
<div className="text-4xl font-black"> <div className="text-4xl font-black">
{analytics?.requests.total || 0} {analytics?.requests?.total ?? 0}
</div> </div>
</div> </div>
<div className="rounded-3xl border-4 border-foreground bg-card p-6 shadow-[6px_6px_0px_0px_rgba(0,0,0,1)]"> <div className="rounded-3xl border-4 border-foreground bg-card p-6 shadow-[6px_6px_0px_0px_rgba(0,0,0,1)]">
@@ -457,7 +458,7 @@ export default function AdminPage() {
<ShieldAlert className="h-3 w-3 text-destructive" /> Pending <ShieldAlert className="h-3 w-3 text-destructive" /> Pending
</div> </div>
<div className="text-4xl font-black text-destructive"> <div className="text-4xl font-black text-destructive">
{analytics?.requests.pending || 0} {analytics?.requests?.pending ?? 0}
</div> </div>
</div> </div>
</div> </div>