fix: frontend resilience in admin dashboard
This commit is contained in:
@@ -30,11 +30,11 @@ import { useStore } from "@/lib/store";
|
||||
import { formatNumber } from "@/lib/utils";
|
||||
|
||||
interface Analytics {
|
||||
users: { total: number; with_wallet: number; active_30d: number };
|
||||
users: { total: number; new_this_week: number };
|
||||
transactions: {
|
||||
total_earned: number;
|
||||
total_spent: number;
|
||||
total_count: number;
|
||||
total_transactions: number;
|
||||
};
|
||||
requests: {
|
||||
total: number;
|
||||
@@ -90,7 +90,8 @@ export default function AdminPage() {
|
||||
setAnalytics(analyticsRes.data);
|
||||
setUsers(usersRes.data.users || []);
|
||||
setSettings(settingsRes.data);
|
||||
} catch {
|
||||
} catch (err) {
|
||||
console.error("Admin load error:", err);
|
||||
toast.error("Failed to load coop secrets");
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
@@ -433,7 +434,7 @@ export default function AdminPage() {
|
||||
<Users className="h-3 w-3" /> Flock Size
|
||||
</div>
|
||||
<div className="text-4xl font-black">
|
||||
{analytics?.users.total || 0}
|
||||
{analytics?.users?.total ?? 0}
|
||||
</div>
|
||||
</div>
|
||||
<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
|
||||
</div>
|
||||
<div className="text-4xl font-black">
|
||||
{formatNumber(analytics?.transactions.total_earned || 0)}
|
||||
{formatNumber(analytics?.transactions?.total_earned ?? 0)}
|
||||
</div>
|
||||
</div>
|
||||
<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
|
||||
</div>
|
||||
<div className="text-4xl font-black">
|
||||
{analytics?.requests.total || 0}
|
||||
{analytics?.requests?.total ?? 0}
|
||||
</div>
|
||||
</div>
|
||||
<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
|
||||
</div>
|
||||
<div className="text-4xl font-black text-destructive">
|
||||
{analytics?.requests.pending || 0}
|
||||
{analytics?.requests?.pending ?? 0}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user