import { useLocation, useNavigate } from "react-router-dom"; import ChevronLeftIcon from "@/assets/home/chevron-left.svg?react"; import ChevronRightIcon from "@/assets/home/chevron-right.svg?react"; /** 리포트 라우트가 `report/:id`일 때 점/플로우에서 이동할 기본 경로 */ const DEFAULT_REPORT_NAV_PATH = "/report/demo"; type FlowStep = { id: string; label: string; /** 이전·다음·점 클릭 시 `navigate`에 넣을 경로 */ navigatePath: string; isActive: (pathname: string) => boolean; }; const PAGE_FLOW: FlowStep[] = [ { id: "home", label: "홈", navigatePath: "/", isActive: (p) => p === "/" }, { id: "report", label: "마케팅 분석", navigatePath: DEFAULT_REPORT_NAV_PATH, isActive: (p) => p === "/report" || p.startsWith("/report/"), }, { id: "plan", label: "콘텐츠 기획", navigatePath: "/plan", isActive: (p) => p === "/plan" }, { id: "studio", label: "콘텐츠 제작", navigatePath: "/studio", isActive: (p) => p === "/studio" }, { id: "channels", label: "채널 연결", navigatePath: "/channels", isActive: (p) => p === "/channels" }, { id: "distribute", label: "콘텐츠 배포", navigatePath: "/distribute", isActive: (p) => p === "/distribute", }, { id: "performance", label: "성과 관리", navigatePath: "/performance", isActive: (p) => p === "/performance", }, ]; function flowIndexForPathname(pathname: string): number { return PAGE_FLOW.findIndex((step) => step.isActive(pathname)); } export function PageNavigator() { const location = useLocation(); const navigate = useNavigate(); const currentIndex = flowIndexForPathname(location.pathname); if (currentIndex === -1) return null; const prev = currentIndex > 0 ? PAGE_FLOW[currentIndex - 1] : null; const next = currentIndex < PAGE_FLOW.length - 1 ? PAGE_FLOW[currentIndex + 1] : null; return (