From 404984a652fa2b0329cf9fa5cfe088bd2cb26c29 Mon Sep 17 00:00:00 2001 From: hyeonsu Date: Thu, 28 Aug 2025 10:09:57 +0900 Subject: [PATCH] =?UTF-8?q?=EC=82=AC=EC=9A=A9=EC=9E=90=20locale=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=20=EC=8B=9C=20menus=EC=99=80=20user-menus=20?= =?UTF-8?q?=EC=9E=AC=ED=98=B8=EC=B6=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/components/layout/AppLayout.tsx | 4 ++-- frontend/hooks/useMenu.ts | 1 + frontend/hooks/useProfile.ts | 12 ++++++++++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/frontend/components/layout/AppLayout.tsx b/frontend/components/layout/AppLayout.tsx index 9a4d6207..079844c9 100644 --- a/frontend/components/layout/AppLayout.tsx +++ b/frontend/components/layout/AppLayout.tsx @@ -194,7 +194,7 @@ export function AppLayout({ children }: AppLayoutProps) { const router = useRouter(); const pathname = usePathname(); const { user, logout, refreshUserData } = useAuth(); - const { userMenus, adminMenus, loading } = useMenu(); + const { userMenus, adminMenus, loading, refreshMenus } = useMenu(); const [sidebarOpen, setSidebarOpen] = useState(false); const [expandedMenus, setExpandedMenus] = useState>(new Set()); @@ -213,7 +213,7 @@ export function AppLayout({ children }: AppLayoutProps) { selectImage, removeImage, saveProfile, - } = useProfile(user, refreshUserData); + } = useProfile(user, refreshUserData, refreshMenus); // 현재 경로에 따라 어드민 모드인지 판단 const isAdminMode = pathname.startsWith("/admin"); diff --git a/frontend/hooks/useMenu.ts b/frontend/hooks/useMenu.ts index 2e0f5992..c1bb1756 100644 --- a/frontend/hooks/useMenu.ts +++ b/frontend/hooks/useMenu.ts @@ -180,5 +180,6 @@ export const useMenu = (user: any, authLoading: boolean) => { isMenuLoading: menuState.isLoading, handleMenuClick, toggleMenu, + refreshMenus: loadMenuData, // 메뉴 새로고침 함수 추가 }; }; diff --git a/frontend/hooks/useProfile.ts b/frontend/hooks/useProfile.ts index d723b895..b4aaaf00 100644 --- a/frontend/hooks/useProfile.ts +++ b/frontend/hooks/useProfile.ts @@ -16,7 +16,7 @@ interface AlertModalState { /** * 프로필 관련 비즈니스 로직을 관리하는 커스텀 훅 */ -export const useProfile = (user: any, refreshUserData: () => Promise) => { +export const useProfile = (user: any, refreshUserData: () => Promise, refreshMenus?: () => Promise) => { // 상태 관리 const [modalState, setModalState] = useState({ isOpen: false, @@ -229,7 +229,8 @@ export const useProfile = (user: any, refreshUserData: () => Promise) => { if (response.result) { // locale이 변경된 경우 전역 변수와 localStorage 업데이트 - if (modalState.formData.locale && modalState.formData.locale !== user.locale) { + const localeChanged = modalState.formData.locale && modalState.formData.locale !== user.locale; + if (localeChanged) { if (typeof window !== "undefined") { // 전역 변수 업데이트 (window as any).__GLOBAL_USER_LANG = modalState.formData.locale; @@ -241,6 +242,13 @@ export const useProfile = (user: any, refreshUserData: () => Promise) => { // 성공: 사용자 정보 새로고침 await refreshUserData(); + + // locale이 변경된 경우 메뉴도 새로고침 + if (localeChanged && refreshMenus) { + console.log("🔄 locale 변경으로 인한 메뉴 새로고침 시작"); + await refreshMenus(); + console.log("✅ 메뉴 새로고침 완료"); + } setModalState((prev) => ({ ...prev, selectedFile: null,