celo-poll/app/admin/page.tsx
2025-12-08 16:31:30 +03:00

109 lines
4.3 KiB
TypeScript
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

'use client'
import { useState, useEffect } from 'react'
import { Users, Vote, DollarSign, Activity, AlertCircle } from 'lucide-react'
import Link from 'next/link'
interface PlatformStats {
totalUsers: number
totalPolls: number
totalVotes: number
totalVolume: number
activeUsers24h: number
activePolls: number
}
export default function AdminDashboard() {
const [stats, setStats] = useState<PlatformStats | null>(null)
const [loading, setLoading] = useState(true)
useEffect(() => {
fetch('/api/admin/stats')
.then(r => r.json())
.then(data => {
setStats(data)
setLoading(false)
})
.catch(() => setLoading(false))
}, [])
if (loading) return <div className="min-h-screen bg-gradient-to-b from-celo-dark to-black text-white p-4 flex items-center justify-center">Loading...</div>
return (
<div className="min-h-screen bg-gradient-to-b from-celo-dark to-black text-white p-4">
<div className="max-w-6xl mx-auto space-y-6">
<h1 className="text-3xl font-bold">⚙️ Admin Dashboard</h1>
<div className="grid grid-cols-2 md:grid-cols-4 gap-4">
<div className="bg-white/10 rounded-xl p-4">
<div className="flex items-center gap-2 text-gray-400 mb-2">
<Users size={16} />
<span className="text-sm">Total Users</span>
</div>
<div className="text-2xl font-bold">{stats?.totalUsers || 0}</div>
</div>
<div className="bg-white/10 rounded-xl p-4">
<div className="flex items-center gap-2 text-gray-400 mb-2">
<Vote size={16} />
<span className="text-sm">Total Polls</span>
</div>
<div className="text-2xl font-bold">{stats?.totalPolls || 0}</div>
</div>
<div className="bg-white/10 rounded-xl p-4">
<div className="flex items-center gap-2 text-gray-400 mb-2">
<Activity size={16} />
<span className="text-sm">Total Votes</span>
</div>
<div className="text-2xl font-bold">{stats?.totalVotes || 0}</div>
</div>
<div className="bg-white/10 rounded-xl p-4">
<div className="flex items-center gap-2 text-gray-400 mb-2">
<DollarSign size={16} />
<span className="text-sm">Total Volume</span>
</div>
<div className="text-2xl font-bold">{stats?.totalVolume.toFixed(2) || 0} cUSD</div>
</div>
</div>
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
<div className="bg-white/10 rounded-xl p-6">
<h2 className="text-xl font-semibold mb-4">Quick Actions</h2>
<div className="space-y-2">
<Link href="/admin/polls" className="block bg-celo-green text-black px-4 py-2 rounded-lg hover:bg-celo-green/90 transition text-center font-semibold">
Manage Polls
</Link>
<Link href="/admin/moderation" className="block bg-white/10 px-4 py-2 rounded-lg hover:bg-white/20 transition text-center">
Moderation Queue
</Link>
<Link href="/create" className="block bg-white/10 px-4 py-2 rounded-lg hover:bg-white/20 transition text-center">
Create Poll
</Link>
</div>
</div>
<div className="bg-white/10 rounded-xl p-6">
<h2 className="text-xl font-semibold mb-4">System Health</h2>
<div className="space-y-3">
<div className="flex items-center justify-between">
<span className="text-gray-400">Active Users (24h)</span>
<span className="font-semibold">{stats?.activeUsers24h || 0}</span>
</div>
<div className="flex items-center justify-between">
<span className="text-gray-400">Active Polls</span>
<span className="font-semibold">{stats?.activePolls || 0}</span>
</div>
<div className="flex items-center gap-2 text-celo-green">
<div className="w-2 h-2 bg-celo-green rounded-full animate-pulse" />
<span className="text-sm">All systems operational</span>
</div>
</div>
</div>
</div>
</div>
</div>
)
}