import { useQuery } from "@tanstack/react-query"; import { ArrowUpRight, BookMarked, BookText, FileText, MessageCircle, PenSquare, Users, } from "lucide-react"; import { Link } from "wouter"; import { DashboardLayout } from "@/components/layout/DashboardLayout"; import { Button } from "@/components/ui/button"; import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from "@/components/ui/card"; import { Skeleton } from "@/components/ui/skeleton"; import { useAuth } from "@/hooks/use-auth"; export default function Dashboard() { const { canManageContent, canReviewContent } = useAuth(); // Fetch statistics const { data: workStats, isLoading: workStatsLoading } = useQuery({ queryKey: ["/api/stats/works"], enabled: canReviewContent || canManageContent, }); const { data: userStats, isLoading: userStatsLoading } = useQuery({ queryKey: ["/api/stats/users"], enabled: canManageContent, }); const { data: blogStats, isLoading: blogStatsLoading } = useQuery({ queryKey: ["/api/stats/blog"], enabled: canReviewContent || canManageContent, }); const { data: commentStats, isLoading: commentStatsLoading } = useQuery({ queryKey: ["/api/stats/comments"], enabled: canReviewContent || canManageContent, }); const { data: recentWorks, isLoading: recentWorksLoading } = useQuery({ queryKey: ["/api/works", { limit: 5 }], }); // Get dummy data if API doesn't return real statistics yet const getStatValue = (loading: boolean, data: any, defaultValue: number) => { if (loading) return ; return data?.count || defaultValue; }; // For the demo, provide sensible defaults const totalWorks = getStatValue(workStatsLoading, workStats, 6); const totalUsers = getStatValue(userStatsLoading, userStats, 5); const totalPosts = getStatValue(blogStatsLoading, blogStats, 3); const totalComments = getStatValue(commentStatsLoading, commentStats, 12); return ( {/* Stats cards */}
Total Works
{totalWorks}

Literary works in library

Blog Posts
{totalPosts}

Published articles

Users
{totalUsers}

Registered accounts

Comments
{totalComments}

User discussions

{/* Quick Actions */} Quick Actions Common tasks and content management
{/* Recent Activity */}
Recent Content Latest additions to the platform
{recentWorksLoading ? Array.from({ length: 3 }).map((_, i) => (
)) : Array.isArray(recentWorks) && recentWorks.slice(0, 3).map((work: any) => (

{work.title}

{work.type} - Added recently

))}
); }