사용자 프로필 수정 기능 및 스크립트, 도커 파일 정리 #7
|
|
@ -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<Set<string>>(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");
|
||||
|
|
|
|||
|
|
@ -180,5 +180,6 @@ export const useMenu = (user: any, authLoading: boolean) => {
|
|||
isMenuLoading: menuState.isLoading,
|
||||
handleMenuClick,
|
||||
toggleMenu,
|
||||
refreshMenus: loadMenuData, // 메뉴 새로고침 함수 추가
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in New Issue