import React from 'react'; import { useNavigate, useLocation } from 'react-router-dom'; import { Node, Edge } from 'reactflow'; import styles from './SidePane.module.css'; import MindMapList from './MindMapList'; import axios from '../utils/axios'; import { MindMapData } from '../utils/jsonUtils'; // Icons with improved styling const HomeIcon = () => ( ); const MindMapIcon = () => ( ); const LogoutIcon = () => ( ); const ChevronIcon = ({ isCollapsed }: { isCollapsed: boolean }) => ( ); interface SidePaneProps { onSelectMindMap: (mindMap: MindMapData) => void; onNewMindMap: () => void; isCollapsed: boolean; setIsCollapsed: (collapsed: boolean) => void; onDeleteMindMap: (id: string) => void; } const SidePane: React.FC = ({ onSelectMindMap, onNewMindMap, isCollapsed, setIsCollapsed, onDeleteMindMap }) => { const navigate = useNavigate(); const location = useLocation(); const isEditor = location.pathname === '/editor'; const handleLogout = async () => { try { await axios.post('/logout'); } catch (error) { // Ignore error, proceed to clear token and redirect } localStorage.removeItem('token'); navigate('/'); }; const handleNavigation = (path: string) => (e: React.MouseEvent) => { e.preventDefault(); try { navigate(path); } catch (error) { console.error('Navigation error:', error); // Fallback to window.location if navigation fails window.location.href = path; } }; return (
Home Mind Map {isEditor && ( )}
); }; export default SidePane;