// src/utils/usePageContext.js import { useEffect, useState } from "react"; import { useLocation } from "react-router-dom"; /* route → page-key map */ const routeMap = [ { test: p => p.startsWith("/career-explorer"), page: "CareerExplorer" }, { test: p => p.startsWith("/educational-programs"), page: "EducationalProgramsPage" }, { test: p => p.startsWith("/career-roadmap"), page: "CareerRoadmap" }, { test: p => p.startsWith("/retirement"), page: "RetirementPlanner" }, { test: p => p.startsWith("/resume-rewrite"), page: "ResumeRewrite" }, ]; export default function usePageContext() { const { pathname } = useLocation(); const [page, setPage] = useState("Home"); useEffect(() => { const found = routeMap.find(r => r.test(pathname)); setPage(found ? found.page : "Home"); }, [pathname]); return page; // ← hook now RETURNS the page string }