import { createContext, useContext, useMemo, useState, type ReactNode } from "react"; export type NavSection = "peers" | "networks" | "files"; type NavSectionContextValue = { section: NavSection; setSection: (s: NavSection) => void; }; const NavSectionContext = createContext(null); export const useNavSection = (): NavSectionContextValue => { const ctx = useContext(NavSectionContext); if (!ctx) { throw new Error("useNavSection must be used inside NavSectionProvider"); } return ctx; }; export const NavSectionProvider = ({ children }: { children: ReactNode }) => { const [section, setSection] = useState("peers"); const value = useMemo(() => ({ section, setSection }), [section]); return {children}; };