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: , label: 'Manage Users', desc: `${allUsers.length} registered users`, color: 'bg-blue-500/10 border-blue-500/20' }, { to: '/admin/content', icon: , label: 'Content Moderation', desc: `${stories.length} total stories`, color: 'bg-violet-500/10 border-violet-500/20' }, { to: '/admin/genres', icon: , label: 'Manage Genres', desc: 'Add or remove genres', color: 'bg-amber-500/10 border-amber-500/20' }, ] return (
{/* Header */}

Admin Dashboard

Platform management and moderation

{/* Platform stats */}

Platform Overview

{/* Quick links */}
{adminLinks.map(link => ( ))}
{/* Recent users */}

Recent Users

{recentUsers.map(user => (

{user.name} {user.surname}

@{user.username}

))}
{/* Recent stories */}

Recent Stories

{recentStories.map(story => (

{story.title}

by @{story.author_username}

{story.status}
))}
) }