사용자 locale 변경 시 menus와 user-menus 재호출

This commit is contained in:
hyeonsu
2025-08-28 10:09:57 +09:00
parent 49f812f444
commit 404984a652
3 changed files with 13 additions and 4 deletions

View File

@@ -180,5 +180,6 @@ export const useMenu = (user: any, authLoading: boolean) => {
isMenuLoading: menuState.isLoading,
handleMenuClick,
toggleMenu,
refreshMenus: loadMenuData, // 메뉴 새로고침 함수 추가
};
};

View File

@@ -16,7 +16,7 @@ interface AlertModalState {
/**
* 프로필 관련 비즈니스 로직을 관리하는 커스텀 훅
*/
export const useProfile = (user: any, refreshUserData: () => Promise<void>) => {
export const useProfile = (user: any, refreshUserData: () => Promise<void>, refreshMenus?: () => Promise<void>) => {
// 상태 관리
const [modalState, setModalState] = useState<ProfileModalState>({
isOpen: false,
@@ -229,7 +229,8 @@ export const useProfile = (user: any, refreshUserData: () => Promise<void>) => {
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<void>) => {
// 성공: 사용자 정보 새로고침
await refreshUserData();
// locale이 변경된 경우 메뉴도 새로고침
if (localeChanged && refreshMenus) {
console.log("🔄 locale 변경으로 인한 메뉴 새로고침 시작");
await refreshMenus();
console.log("✅ 메뉴 새로고침 완료");
}
setModalState((prev) => ({
...prev,
selectedFile: null,