"use client" import { useEffect, useState } from "react" import { useNavigate } from "react-router-dom" import { motion } from "framer-motion" import { Users, Database, FileText, Settings, BarChart2, Calendar, Clock, PlusCircle, Search, User, Bell, Home, } from "lucide-react" import { Link } from "react-router-dom" export default function AdminDashboard() { const [isFirstLoad, setIsFirstLoad] = useState(true) const [isProfileDropdownOpen, setIsProfileDropdownOpen] = useState(false) const navigate = useNavigate() useEffect(() => { // Check if user is authenticated const token = localStorage.getItem("adminToken") if (!token) { navigate("/admin/login") return } // Check if we're navigating from another admin page const hasVisitedAdmin = localStorage.getItem("adminNavigation") // Skip loading if we're navigating from another admin page if (hasVisitedAdmin) { setIsFirstLoad(false) } else { // Set flag to indicate we've visited an admin page localStorage.setItem("adminNavigation", "true") // Only show loading state on first load if (isFirstLoad) { // Simulate loading dashboard data const timer = setTimeout(() => { setIsFirstLoad(false) // Show welcome toast }, 500) // Reduced loading time for better UX return () => clearTimeout(timer) } } }, [isFirstLoad, navigate]) const handleLogout = () => { localStorage.removeItem("adminToken") localStorage.removeItem("adminNavigation") // Clear navigation flag on logout navigate("/admin/login") } // If it's the first load, show a loading state if (isFirstLoad) { return (

Loading dashboard...

) } return (
{/* Sidebar */}

Italian Migrants

Northern Territory DB

Admin User
{/* Main content */}
{/* Header */}

Admin Portal

{/* Notifications */} {/* Profile dropdown */}
{isProfileDropdownOpen && ( setIsProfileDropdownOpen(false)} > Your Profile Settings )}
{/* Dashboard content */}
{/* Stats cards */}

Total Migrants

256

+12 this month

Total Records

1,248

+86 this month

Recent Updates

24

Last update: Today

Pending Tasks

8

3 require attention
{/* Quick actions */}

Quick Actions

Add New Migrant
{/* Recent activity */}

Recent Activity

{[ { action: "Added new migrant", user: "Admin", time: "10 minutes ago", type: "add" }, { action: "Updated record #1248", user: "Admin", time: "2 hours ago", type: "update" }, { action: "Generated monthly report", user: "System", time: "Yesterday", type: "report" }, { action: "Deleted duplicate record", user: "Admin", time: "2 days ago", type: "delete" }, { action: "Imported 15 new records", user: "Admin", time: "1 week ago", type: "import" }, ].map((activity, index) => (
{activity.type === "add" ? ( ) : activity.type === "update" ? ( ) : activity.type === "delete" ? ( ) : activity.type === "report" ? ( ) : ( )}

{activity.action}

By {activity.user} • {activity.time}

))}
) }