import PropTypes from 'prop-types'; import { useEffect, useRef, useState } from 'react'; import { useNavigate } from 'react-router-dom'; import { useDispatch } from 'react-redux'; import { useQueryClient } from '@tanstack/react-query'; import { TopNav } from '@astryxdesign/core/TopNav'; import { TopNavHeading } from '@astryxdesign/core/TopNav'; import { DropdownMenu } from '@astryxdesign/core/DropdownMenu'; import { Popover } from '@astryxdesign/core/Popover'; import { IconButton } from '@astryxdesign/core/IconButton'; import { Avatar } from '@astryxdesign/core/Avatar'; import { HStack } from '@astryxdesign/core/HStack'; import { VStack } from '@astryxdesign/core/VStack'; import { Text } from '@astryxdesign/core/Text'; import { Heading } from '@astryxdesign/core/Heading'; import { Divider } from '@astryxdesign/core/Divider'; import { TbBoxMultiple1 } from 'react-icons/tb'; import { GrMultiple } from 'react-icons/gr'; import { BellOutlined, WindowsOutlined, EditOutlined, CommentOutlined, LogoutOutlined, GiftOutlined, MessageOutlined, SettingOutlined } from '@ant-design/icons'; import avatar1 from 'assets/images/users/avatar-1.png'; import logo from 'assets/images/doormile-logo.png'; import navbarMark from 'assets/images/doormile-mark.png'; import { clearFcmToken } from 'store/reducers/fcmSlice'; import { logoutUser } from 'store/reducers/loginUserSlice'; import { performSessionLogout } from 'utils/session'; import { DT } from 'themes/dt/tokens'; // doormile-logo.png is a white asset; recolour to brand red for this // light TopNav surface (same trick login.js uses for its white-card logo). const logoStyle = { height: 24, width: 'auto', filter: 'brightness(0) saturate(100%) invert(15%) sepia(93%) saturate(5437%) hue-rotate(346deg) brightness(81%) contrast(92%)' }; // Collapsed rail: doormile-mark.png (red-on-white disc) needs a white // backing + scale(1.4) crop to fill its circle cleanly — same composition // the old DrawerHeader used, just sized for the nav-bar row instead of the // full-height sidebar rail. const markWrapperStyle = { width: 32, height: 32, borderRadius: '50%', background: '#fff', display: 'flex', alignItems: 'center', justifyContent: 'center', overflow: 'hidden', flexShrink: 0 }; const markStyle = { width: '100%', height: '100%', objectFit: 'cover', transform: 'scale(1.4)', display: 'block' }; const NotificationPanel = () => ( Notifications {[ { icon: , text: "It's Cristina danny's birthday today.", time: '2 min ago' }, { icon: , text: 'Aida Burg commented your post.', time: '5 August' }, { icon: , text: 'Your profile is 60% complete.', time: '7 hours ago' } ].map((n) => ( {n.text} {n.time} ))} View all ); // ==============================|| MAIN LAYOUT - TOP NAV ||============================== // const AppTopNav = ({ isSidebarCollapsed }) => { const navigate = useNavigate(); const dispatch = useDispatch(); const queryClient = useQueryClient(); const topNavRef = useRef(null); const [headerHeight, setHeaderHeight] = useState(null); const firstname = localStorage.getItem('firstname') || ''; const handleLogout = () => { performSessionLogout({ queryClient, dispatch, clearFcmToken, logoutUser }); }; // AppShell (height="auto") pins the sticky side nav below the header using // a --appshell-header-height CSS var it measures itself via ResizeObserver // (AppShell.tsx). On some routes that measurement lags/settles wrong, so // the side nav's sticky offset is off and its bottom-anchored collapse // button visibly jumps on scroll. Re-measure the header independently here // and force the same variable with !important on the shell root — an // author-stylesheet !important rule beats AppShell's own non-important // inline style.setProperty() call on that same element, so this always // wins regardless of what the internal measurement produced. useEffect(() => { const el = topNavRef.current; if (!el) return undefined; const updateHeight = () => setHeaderHeight(el.getBoundingClientRect().height); updateHeight(); const observer = new ResizeObserver(updateHeight); observer.observe(el); return () => observer.disconnect(); }, []); return ( <> Doormile Express ) : ( Doormile Express ) } headingHref="/doormile/dispatch" /> } endContent={ , isIconOnly: true, variant: 'ghost' }} items={[ { label: 'Create Order', icon: , onClick: () => navigate('/doormile/orders/create') }, { label: 'Create Multiple Order', icon: , onClick: () => navigate('/doormile/orders/createorders') } ]} /> } label="Notifications"> } /> , variant: 'ghost' }} items={[ { label: 'View Profile', icon: , onClick: () => navigate('/viewprofile') }, { label: 'Support Ticket', icon: }, { type: 'divider' }, { label: 'Logout', icon: , onClick: handleLogout } ]} /> } /> {headerHeight != null && ( )} ); }; AppTopNav.propTypes = { isSidebarCollapsed: PropTypes.bool }; export default AppTopNav;