"use client" import type React from "react" import { useState, useEffect } from "react" import { useNavigate } from "react-router-dom" import { motion } from "framer-motion" import { Camera, Save, User, Mail, MapPin, Lock, Bell, Home } from "lucide-react" import { Link } from "react-router-dom" interface UserProfile { firstName: string lastName: string email: string jobTitle: string department: string bio: string avatar: string } export default function ProfileSettings() { const [isFirstLoad, setIsFirstLoad] = useState(true) const [isLoading, setIsLoading] = useState(false) const [activeTab, setActiveTab] = useState("profile") const [profile, setProfile] = useState({ firstName: "Admin", lastName: "User", email: "admin@example.com", jobTitle: "Database Administrator", department: "IT", bio: "Experienced database administrator with a focus on migration data management.", avatar: "", }) const navigate = useNavigate() // Add a handleLogout function that clears the adminNavigation flag const handleLogout = () => { localStorage.removeItem("adminToken") localStorage.removeItem("adminNavigation") // Clear navigation flag on logout navigate("/admin/login") } 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 profile data const timer = setTimeout(() => { setIsFirstLoad(false) }, 500) // Reduced loading time for better UX return () => clearTimeout(timer) } } }, [isFirstLoad, navigate]) const handleInputChange = (e: React.ChangeEvent) => { const { name, value } = e.target setProfile((prev) => ({ ...prev, [name]: value })) } const handleSave = () => { setIsLoading(true) // Simulate API call setTimeout(() => { setIsLoading(false) }, 500) // Reduced loading time for better UX } const handleAvatarChange = (e: React.ChangeEvent) => { const file = e.target.files?.[0] if (file) { const reader = new FileReader() reader.onload = (event) => { if (event.target?.result) { } } reader.readAsDataURL(file) } } // If it's the first load, show a loading state if (isFirstLoad) { return (

Loading profile...

) } return (
{/* Sidebar */}

Italian Migrants

Northern Territory DB

{/* Update the bottom user section in the sidebar */}
{/* Main content */}
{/* Header */}

Admin Portal

Northern Territory
{/* Settings content */}

Settings

Manage your account preferences

{/* Tabs */}
{/* Profile Tab Content */} {activeTab === "profile" && (

Profile Information

Update your personal information and how it appears on your profile.

{profile.avatar ? ( Profile ) : (
)}