diff --git a/frontend/src/components/AppShell.tsx b/frontend/src/components/AppShell.tsx new file mode 100644 index 0000000..6536b7d --- /dev/null +++ b/frontend/src/components/AppShell.tsx @@ -0,0 +1,96 @@ +import { useState } from 'react' +import { Outlet, useNavigate } from 'react-router-dom' +import { useAppSelector, useAppDispatch } from '../store/hooks' +import { closeTab, activateTab } from '../store/slices/tabsSlice' +import NavOverlay from './NavOverlay' + +const ANTLER_PATHS = [ + 'M14 10c2 4 1 8-1 11 3-1 7 0 10 3 1-4 4-7 8-7-3 3-4 7-3 11l4 1c-1 3 0 6 3 8-3 0-6 1-8 4-1-3-4-5-8-5 2-3 2-7 0-10-3 1-7 0-10-3 3 0 5-2 6-5l-1-8z', + 'M48 14c-2 3-2 6-1 9-2-2-5-2-8-1 1 3 1 6-1 9 3 0 5 2 6 5 1-3 4-5 7-5-2-3-2-6 0-9 2 1 5 1 7-1-2 0-4-1-5-3-1-2-3-4-5-4z', + 'M28 38c2 3 5 5 9 5 1 4 4 7 8 8-3 2-5 5-5 9-3-2-7-3-11-2 1-3 1-7-1-10-3 0-6-1-8-4 3-1 6-3 8-6z', +] + +export default function AppShell() { + const dispatch = useAppDispatch() + const navigate = useNavigate() + const { tabs, activeId } = useAppSelector(s => s.tabs) + const userInfo = useAppSelector(s => s.auth.userInfo) + const [navOpen, setNavOpen] = useState(false) + + function handleTabClick(id: string, path: string) { + dispatch(activateTab(id)) + navigate(path) + } + + function handleTabClose(e: React.MouseEvent, id: string) { + e.stopPropagation() + const idx = tabs.findIndex(t => t.id === id) + dispatch(closeTab(id)) + const remaining = tabs.filter(t => t.id !== id) + const newIdx = Math.min(idx, remaining.length - 1) + if (remaining[newIdx]) navigate(remaining[newIdx].path) + } + + return ( +