import React from 'react'
import { useNavigate } from 'react-router-dom'
import { Shield, Users, BookOpen, AlertTriangle, Settings, ChevronRight } from 'lucide-react'
import { useAuthStore } from '../../store/authStore'
import { useStoryStore } from '../../store/storyStore'
import { useNotificationStore } from '../../store/notificationStore'
import { PlatformStats } from '../../components/admin/PlatformStats'
import { Button } from '../../components/ui/Button'
import { RoleBadge } from '../../components/ui/Badge'
import { Avatar } from '../../components/ui/Avatar'
function timeAgo(str: string): string {
const diff = Date.now() - new Date(str).getTime()
const m = Math.floor(diff / 60000)
if (m < 1) return 'just now'
if (m < 60) return `${m}m ago`
const h = Math.floor(m / 60)
if (h < 24) return `${h}h ago`
return `${Math.floor(h / 24)}d ago`
}
export const AdminDashboard: React.FC = () => {
const navigate = useNavigate()
const { allUsers } = useAuthStore()
const { stories } = useStoryStore()
const { notifications } = useNotificationStore()
const recentUsers = [...allUsers].sort((a, b) => new Date(b.created_at).getTime() - new Date(a.created_at).getTime()).slice(0, 5)
const recentStories = [...stories].sort((a, b) => new Date(b.created_at).getTime() - new Date(a.created_at).getTime()).slice(0, 5)
const adminLinks = [
{ to: '/admin/users', icon:
Platform management and moderation
{user.name} {user.surname}
@{user.username}
{story.title}
by @{story.author_username}