import { useState, useEffect } from 'react' import { GoogleOAuthProvider } from '@react-oauth/google' import type { MainTab } from '@common/types/navigation' import { MainLayout } from '@common/components/layout/MainLayout' import { LoginPage } from '@common/components/auth/LoginPage' import { registerMainTabSwitcher } from '@common/hooks/useSubMenu' import { useAuthStore } from '@common/store/authStore' import { useMenuStore } from '@common/store/menuStore' import { API_BASE_URL } from '@common/services/api' import { OilSpillView } from '@tabs/prediction' import { ReportsView } from '@tabs/reports' import { HNSView } from '@tabs/hns' import { AerialView } from '@tabs/aerial' import { AssetsView } from '@tabs/assets' import { BoardView } from '@tabs/board' import { WeatherView } from '@tabs/weather' import { IncidentsView } from '@tabs/incidents' import { AdminView } from '@tabs/admin' import { PreScatView } from '@tabs/scat' import { RescueView } from '@tabs/rescue' const GOOGLE_CLIENT_ID = import.meta.env.VITE_GOOGLE_CLIENT_ID || '' function App() { const [activeMainTab, setActiveMainTab] = useState('prediction') const { isAuthenticated, isLoading, checkSession } = useAuthStore() const { loadMenuConfig } = useMenuStore() useEffect(() => { checkSession() }, [checkSession]) useEffect(() => { if (isAuthenticated) { loadMenuConfig() } }, [isAuthenticated, loadMenuConfig]) useEffect(() => { registerMainTabSwitcher(setActiveMainTab) }, []) // 감사 로그: 탭 이동 기록 useEffect(() => { if (!isAuthenticated) return const blob = new Blob( [JSON.stringify({ action: 'TAB_VIEW', detail: activeMainTab })], { type: 'text/plain' } ) navigator.sendBeacon(`${API_BASE_URL}/audit/log`, blob) }, [activeMainTab, isAuthenticated]) // 세션 확인 중 스플래시 if (isLoading) { return (
WING
) } // 미인증 → 로그인 페이지 if (!isAuthenticated) { return } const renderView = () => { switch (activeMainTab) { case 'prediction': return case 'reports': return case 'hns': return case 'aerial': return case 'assets': return case 'board': return case 'weather': return case 'incidents': return case 'scat': return case 'admin': return case 'rescue': return default: return
준비 중입니다...
} } return ( {renderView()} ) } function AppWithProviders() { if (!GOOGLE_CLIENT_ID) { return } return ( ) } export default AppWithProviders