import AppBar from "@mui/material/AppBar";
import Box from "@mui/material/Box";
import Toolbar from "@mui/material/Toolbar";
import IconButton from "@mui/material/IconButton";
import Typography from "@mui/material/Typography";
import SwipeableDrawer from "@mui/material/SwipeableDrawer";
import List from "@mui/material/List";
import ListItem from "@mui/material/ListItem";
import ListItemButton from "@mui/material/ListItemButton";
import ListItemText from "@mui/material/ListItemText";
import Avatar from "@mui/material/Avatar";
import Container from "@mui/material/Container";
import Tooltip from "@mui/material/Tooltip";
import MenuIcon from "@mui/icons-material/Menu";
import CloseIcon from "@mui/icons-material/Close";
import Divider from "@mui/material/Divider";
import Modal from "@mui/material/Modal";
import Button from "@mui/material/Button";
import LazyImage from "./LazyImage";
import Logo from "../../assets/images/logo.png";
import { useNavigate } from "react-router-dom";
import { useState, useRef, useEffect } from "react";
import { useTheme, useMediaQuery, ListItemIcon } from "@mui/material";
import { Home, Users, Heart, MessageCircle, Search, Bell } from "lucide-react";
const NAV_LINKS = [
{ label: "Home", path: "/" },
{ label: "Matches", path: "/matches" },
{ label: "Interest", path: "/interest" },
{ label: "Messages", path: "/chat" },
{ label: "Search", path: "/matches" },
{ label: "Notifications", path: "/notifications" }
];
const PROFILE_MENU = [
{ label: "Dashboard", path: "/dashboard-home" },
{ label: "Profile", path: "/profile" },
{ label: "Subscription", path: "/subscription-plan" },
{ label: "Subscription History", path: "/subscription-history" },
{ label: "Change Password", path: "/change-password" },
{ label: "View Reports", path: "/block-report-profilelist" },
{ label: "Blocked Users", path: "/block-report-profilelist" }
];
const ACCOUNT_SETTINGS = [
{ label: "Privacy Settings", path: "/account-settings" },
{ label: "Privacy Policy", path: "/privacy-policy" },
{ label: "Terms & Conditions", path: "/terms" },
{ label: "Contact Us", path: "/contact" },
{ label: "Be Safe Online", path: "/safe-online" },
{ label: "Delete Account", action: "delete" },
{ label: "Logout", action: "logout" }
];
const SparkleNavbar = ({ items, color = "#0fec1eff", onItemClick }) => {
const [activeIndex, setActiveIndex] = useState(0);
const [indicatorStyle, setIndicatorStyle] = useState({});
const [isAnimating, setIsAnimating] = useState(false);
const navRef = useRef(null);
const buttonRefs = useRef([]);
useEffect(() => {
updateIndicator(activeIndex);
}, []);
const updateIndicator = (index) => {
const button = buttonRefs.current[index];
if (button && navRef.current) {
const navRect = navRef.current.getBoundingClientRect();
const btnRect = button.getBoundingClientRect();
setIndicatorStyle({
left: btnRect.left - navRect.left + btnRect.width / 2 - 18,
opacity: 1
});
}
};
const handleClick = (index) => {
if (index === activeIndex || isAnimating) return;
setIsAnimating(true);
const newButton = buttonRefs.current[index];
if (newButton && navRef.current) {
const navRect = navRef.current.getBoundingClientRect();
const newRect = newButton.getBoundingClientRect();
setIndicatorStyle(prev => ({
...prev,
left: newRect.left - navRect.left + newRect.width / 2 - 18,
}));
setTimeout(() => {
setActiveIndex(index);
setIsAnimating(false);
if (onItemClick) onItemClick(items[index], index);
}, 300);
}
};
return (
);
};
const ProfileHeader = () => {
const navigate = useNavigate();
const [mobileDrawerOpen, setMobileDrawerOpen] = useState(false);
const [profileDrawerOpen, setProfileDrawerOpen] = useState(false);
const [deleteModalOpen, setDeleteModalOpen] = useState(false);
const [logoutModalOpen, setLogoutModalOpen] = useState(false);
const theme = useTheme();
const isDesktop = useMediaQuery(theme.breakpoints.up("md"));
const toggleMobileDrawer = (open) => () => setMobileDrawerOpen(open);
const toggleProfileDrawer = (open) => () => setProfileDrawerOpen(open);
const [selectedItem, setSelectedItem] = useState("Home");
const handleMenuClick = (item) => {
if (item.action === "delete") {
setDeleteModalOpen(true);
setProfileDrawerOpen(false);
} else if (item.action === "logout") {
setLogoutModalOpen(true);
setProfileDrawerOpen(false);
} else if (item.path) {
navigate(item.path);
setProfileDrawerOpen(false);
}
};
const handleDeleteAccount = () => {
// Add your delete account logic here
console.log("Account deleted");
setDeleteModalOpen(false);
navigate("/");
};
const handleLogout = () => {
// Add your logout logic here
console.log("Logged out");
setLogoutModalOpen(false);
navigate("/login");
};
const modalStyle = {
position: 'absolute',
top: '50%',
left: '50%',
transform: 'translate(-50%, -50%)',
width: isDesktop ? 400 : '90%',
bgcolor: 'background.paper',
borderRadius: 2,
boxShadow: 24,
p: 4,
};
const getNavIcon = (index) => {
const icons = [Home, Users, Heart, MessageCircle, Search, Bell];
const IconComponent = icons[index % icons.length];
return ;
};
const ProfileDrawerContent = (
Account
{!isDesktop && (
)}
{PROFILE_MENU.map((item) => (
handleMenuClick(item)}>
))}
Account Settings
{ACCOUNT_SETTINGS.map((item) => (
handleMenuClick(item)}>
))}
);
const MobileDrawerMenu = (
Menu
{NAV_LINKS.map(({ label, path }, index) => (
{
navigate(path);
toggleMobileDrawer(false)();
}}
>
{getNavIcon(index)}
))}
);
return (
<>
navigate("/")}
/>
navigate("/")}
>
link.label)}
color="#034E08"
onItemClick={(item) => {
setSelectedItem(item);
const link = NAV_LINKS.find(l => l.label === item);
if (link) navigate(link.path);
}}
/>
{MobileDrawerMenu}
{ProfileDrawerContent}
{/* Delete Account Modal */}
setDeleteModalOpen(false)}
aria-labelledby="delete-modal-title"
>
Delete Account
setDeleteModalOpen(false)} size="small">
Are you sure you want to delete your account? This action cannot be undone.
{/* Logout Modal */}
setLogoutModalOpen(false)}
aria-labelledby="logout-modal-title"
>
Logout
setLogoutModalOpen(false)} size="small">
Are you sure you want to logout?
>
);
};
export default ProfileHeader;