From 204fbfb126daf057a4567f64cfb7ab03a5679e82 Mon Sep 17 00:00:00 2001
From: joonhoekim <26rote@gmail.com>
Date: Fri, 21 Nov 2025 16:37:24 +0900
Subject: (김준회) 오픈 전, 헤더에서 특정 메뉴 가리기 처리
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 components/layout/Header.tsx | 53 +++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 47 insertions(+), 6 deletions(-)

(limited to 'components/layout/Header.tsx')

diff --git a/components/layout/Header.tsx b/components/layout/Header.tsx
index b3d9ee6a..b12c673c 100644
--- a/components/layout/Header.tsx
+++ b/components/layout/Header.tsx
@@ -33,6 +33,7 @@ import {
     salesNav,
     engineeringNav,
     MenuSection, 
+    MenuItem,
     mainNavVendor, 
     additionalNavVendor,
     domainBrandingKeys
@@ -46,6 +47,42 @@ import { useActiveMenus, filterActiveMenus, filterActiveAdditionalMenus } from "
 import { NotificationDropdown } from "./NotificationDropdown";
 import { useTranslation } from '@/i18n/client'
 
+// 환경변수에 따라 숨길 메뉴 키 목록 (수정 및 제거가 용이하도록 상수로 분리)
+const HIDDEN_MENU_SECTION_KEYS = [
+    "menu.vendor.sales.title",
+    "menu.vendor.procurement.title",
+];
+
+const HIDDEN_ADDITIONAL_MENU_KEYS = [
+    "menu.additional.system_settings",
+];
+
+/**
+ * 환경변수에 따라 메뉴 섹션을 필터링하는 함수
+ */
+const filterMenusByEnvironment = (sections: MenuSection[]): MenuSection[] => {
+    const shouldHideMenus = process.env.NEXT_PUBLIC_HIDE_PARTNERS_MENU_BEFORE_OPEN === 'true';
+    
+    if (!shouldHideMenus) {
+        return sections;
+    }
+    
+    return sections.filter(section => !HIDDEN_MENU_SECTION_KEYS.includes(section.titleKey));
+};
+
+/**
+ * 환경변수에 따라 추가 메뉴 항목을 필터링하는 함수
+ */
+const filterAdditionalMenusByEnvironment = (items: MenuItem[]): MenuItem[] => {
+    const shouldHideMenus = process.env.NEXT_PUBLIC_HIDE_PARTNERS_MENU_BEFORE_OPEN === 'true';
+    
+    if (!shouldHideMenus) {
+        return items;
+    }
+    
+    return items.filter(item => !HIDDEN_ADDITIONAL_MENU_KEYS.includes(item.titleKey));
+};
+
 export function Header() {
     const params = useParams();
     const lng = params?.lng as string;
@@ -131,9 +168,13 @@ export function Header() {
 
     const { main: originalMain, additional: originalAdditional, logoHref, brandNameKey, basePath } = getDomainConfig(pathname);
 
-    // 활성 메뉴만 필터링 (로딩 중이거나 에러 시에는 모든 메뉴 표시)
-    const main = isLoading ? originalMain : filterActiveMenus(originalMain, activeMenus);
-    const additional = isLoading ? originalAdditional : filterActiveAdditionalMenus(originalAdditional, activeMenus);
+    // 1단계: 환경변수에 따른 메뉴 필터링
+    const envFilteredMain = filterMenusByEnvironment(originalMain);
+    const envFilteredAdditional = filterAdditionalMenusByEnvironment(originalAdditional);
+
+    // 2단계: 활성 메뉴만 필터링 (로딩 중이거나 에러 시에는 환경변수 필터링만 적용)
+    const main = isLoading ? envFilteredMain : filterActiveMenus(envFilteredMain, activeMenus);
+    const additional = isLoading ? envFilteredAdditional : filterActiveAdditionalMenus(envFilteredAdditional, activeMenus);
 
 
     return (
@@ -300,14 +341,14 @@ export function Header() {
                     </div>
                 </div>
 
-                {/* 모바일 메뉴 - 도메인별 활성화된 메뉴만 전달 */}
+                {/* 모바일 메뉴 - 도메인별 활성화된 메뉴만 전달 (환경변수 필터링 적용) */}
                 {isMobileMenuOpen && (
                     <MobileMenu 
                         lng={lng} 
                         onClose={toggleMobileMenu}
                         activeMenus={activeMenus}
-                        domainMain={originalMain}
-                        domainAdditional={originalAdditional}
+                        domainMain={envFilteredMain}
+                        domainAdditional={envFilteredAdditional}
                         t={t}
                     />
                 )}
-- 
cgit v1.2.3

