import React, { useState } from 'react'; import { IconButton, Tooltip, Box, Menu, MenuItem, ListItemIcon, ListItemText, Chip, styled, } from '@mui/material'; import { ArrowBack as ArrowBackIcon, ArrowForward as ArrowForwardIcon, History as HistoryIcon, Home as HomeIcon, CalendarToday, DateRange, Event, WorkspacesOutlined, } from '@mui/icons-material'; import { useNavigationStore } from '../../stores/navigationStore'; const NavigationRoot = styled(Box)` display: flex; align-items: center; gap: 6px; height: 100%; `; function getNodeIcon(nodeType: string) { switch (nodeType) { case 'User': return ; case 'CalendarYear': return ; case 'CalendarMonth': return ; case 'CalendarDay': return ; default: return ; } } export const GraphNavigator: React.FC = () => { const { context, goBack, goForward, isLoading } = useNavigationStore(); const [historyMenuAnchor, setHistoryMenuAnchor] = useState(null); const { history } = context; const canGoBack = history.currentIndex > 0; const canGoForward = history.currentIndex < history.nodes.length - 1; const currentNode = context.node; const handleHistoryClick = (e: React.MouseEvent) => setHistoryMenuAnchor(e.currentTarget); const handleHistoryClose = () => setHistoryMenuAnchor(null); const handleHistoryItemClick = (index: number) => { const delta = index - history.currentIndex; if (delta < 0) for (let i = 0; i < -delta; i++) goBack(); else if (delta > 0) for (let i = 0; i < delta; i++) goForward(); handleHistoryClose(); }; return ( {currentNode && ( )} {history.nodes.map((node, index) => ( handleHistoryItemClick(index)} selected={index === history.currentIndex} dense > {getNodeIcon(node.type)} ))} ); };