diff --git a/src/components/auth/LoginGuardDevPanel.tsx b/src/components/auth/LoginGuardDevPanel.tsx index e7112db..1ef1fbe 100644 --- a/src/components/auth/LoginGuardDevPanel.tsx +++ b/src/components/auth/LoginGuardDevPanel.tsx @@ -3,7 +3,8 @@ import React from "react"; import { DevModeHandlers, CacheInfo } from "./LoginGuardTypes"; import { AuthTokens } from "@/utils/nativeBridge"; -import { User } from "@/lib/api"; +import { User, Store, PagedResult } from "@/lib/api"; +import { Activity } from "@/hooks/useActivity"; interface LoginGuardDevPanelProps { cacheInfo: CacheInfo; @@ -15,9 +16,9 @@ interface LoginGuardDevPanelProps { userInfoError: Error | null; userInfo: User | undefined; clearTokens: () => void; - stores: any[]; - activities: any[] | undefined; - storesData: any; + stores: Store[]; + activities: Activity[] | undefined; + storesData: PagedResult | undefined; isAvailable: boolean; devHandlers: DevModeHandlers; } @@ -44,8 +45,7 @@ export function LoginGuardDevPanel({ {/* 캐시 정보 */}
- 캐시: {cacheInfo.count}개 | - {cacheInfo.isValid ? " 유효" : " 무효"} | + 캐시: {cacheInfo.count}개 |{cacheInfo.isValid ? " 유효" : " 무효"} | {cacheInfo.lastUpdate ? ` ${cacheInfo.lastUpdate.toLocaleTimeString()}` : " 없음"} @@ -154,9 +154,8 @@ export function LoginGuardDevPanel({ {/* 매장 및 활동 정보 */}
- 매장: {stores.length ? `${stores.length}개` : "로딩..."} | - 활동: {activities?.length || 0}개 | 총:{" "} - {storesData?.totalElements || 0}개 + 매장: {stores.length ? `${stores.length}개` : "로딩..."} | 활동:{" "} + {activities?.length || 0}개 | 총: {storesData?.totalElements || 0}개
@@ -165,9 +164,7 @@ export function LoginGuardDevPanel({ 브릿지 상태: {isAvailable ? "✅ 연결됨" : "❌ 미연결"} | NativeBridge:{" "} - {typeof window !== "undefined" && window.NativeBridge - ? "✅" - : "❌"}{" "} + {typeof window !== "undefined" && window.NativeBridge ? "✅" : "❌"}{" "} | iOS:{" "} {typeof window !== "undefined" && window.webkit?.messageHandlers?.chalpu @@ -178,4 +175,4 @@ export function LoginGuardDevPanel({
); -} \ No newline at end of file +} diff --git a/src/hooks/useAuth.ts b/src/hooks/useAuth.ts index df533eb..aecb4f7 100644 --- a/src/hooks/useAuth.ts +++ b/src/hooks/useAuth.ts @@ -14,7 +14,7 @@ export const useAuth = () => { setTokens, setLoading, clearTokens, - initializeFromLocalStorage, + initialize, } = useAuthStore(); // 토큰 초기화 @@ -23,21 +23,17 @@ export const useAuth = () => { try { // 로컬스토리지에서 accessToken 확인 및 자동 로그인 - initializeFromLocalStorage(); + initialize(); } catch (error) { console.error("토큰 초기화 실패:", error); clearTokens(); } - + // 초기화 실패 시 안전장치: 3초 후 강제로 로딩 해제 setTimeout(() => { setLoading(false); }, 3000); - }, [ - setLoading, - clearTokens, - initializeFromLocalStorage, - ]); + }, [setLoading, clearTokens, initialize]); // 토큰 갱신 (네이티브에서 처리하므로 단순히 로컬스토리지 재확인) const refreshTokens = useCallback(async (): Promise => { @@ -101,36 +97,35 @@ export const useAuth = () => { // 컴포넌트 마운트 시 토큰 초기화 useEffect(() => { - console.log('🔥 [useAuth] useEffect 시작, 현재 상태:', { - tokens: !!tokens, - isLoggedIn, - isLoading + console.log("🔥 [useAuth] useEffect 시작, 현재 상태:", { + tokens: !!tokens, + isLoggedIn, + isLoading, }); - + // 즉시 초기화 시도 initializeTokens(); - + // fallback: 2초 후에도 여전히 로딩 중이면 강제 초기화 const fallbackTimer = setTimeout(() => { const currentState = useAuthStore.getState(); - console.log('🔥 [useAuth] Fallback 타이머 실행, 현재 상태:', { + console.log("🔥 [useAuth] Fallback 타이머 실행, 현재 상태:", { tokens: !!currentState.tokens, isLoggedIn: currentState.isLoggedIn, - isLoading: currentState.isLoading + isLoading: currentState.isLoading, }); - + if (currentState.isLoading) { - console.log('🔥 [useAuth] 여전히 로딩 중 - 강제 초기화'); - currentState.initializeFromLocalStorage(); + console.log("🔥 [useAuth] 여전히 로딩 중 - 강제 초기화"); + currentState.initialize(); } }, 2000); - + return () => { clearTimeout(fallbackTimer); }; }, [initializeTokens]); - return { tokens, isLoading,