From 6ea81efd90e8517ba951b4f26c3552893884e0f1 Mon Sep 17 00:00:00 2001 From: minheon Date: Wed, 1 Apr 2026 11:18:54 +0900 Subject: [PATCH] =?UTF-8?q?[fix]=20=ED=95=98=EB=8B=A8=20nav=20=EB=B2=84?= =?UTF-8?q?=ED=8A=BC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/layouts/PageNavigator.tsx | 59 +++++++++++++++++++++++++++-------- 1 file changed, 46 insertions(+), 13 deletions(-) diff --git a/src/layouts/PageNavigator.tsx b/src/layouts/PageNavigator.tsx index 2bd929c..a28a217 100644 --- a/src/layouts/PageNavigator.tsx +++ b/src/layouts/PageNavigator.tsx @@ -2,21 +2,51 @@ 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"; -const PAGE_FLOW = [ - { path: "/", label: "홈" }, - { path: "/report", label: "마케팅 분석" }, - { path: "/plan", label: "콘텐츠 기획" }, - { path: "/studio", label: "콘텐츠 제작" }, - { path: "/channels", label: "채널 연결" }, - { path: "/distribute", label: "콘텐츠 배포" }, - { path: "/performance", label: "성과 관리" }, +/** 리포트 라우트가 `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 = PAGE_FLOW.findIndex((p) => p.path === location.pathname); + const currentIndex = flowIndexForPathname(location.pathname); if (currentIndex === -1) return null; const prev = currentIndex > 0 ? PAGE_FLOW[currentIndex - 1] : null; @@ -29,7 +59,8 @@ export function PageNavigator() { > {/* 이전 페이지 */}