import { type ReactNode, useEffect } from 'react';
import { NavLink } from 'react-router-dom';
import { useTranslation } from 'react-i18next';
import { useUIStore } from '../../store/uiStore';
import './AppShell.css';
interface Props {
children: ReactNode;
}
const NAV_ITEMS = [
{ path: '/', translationKey: 'appshell.nav.home', icon: },
{ path: '/data-collection', translationKey: 'appshell.nav.data_collection', icon: '📊' },
{ path: '/potential-analysis', translationKey: 'appshell.nav.potential_analysis', icon: '📈' },
];
export default function AppShell({ children }: Props) {
const { t, i18n } = useTranslation();
const theme = useUIStore((s) => s.theme);
const toggleTheme = useUIStore((s) => s.toggleTheme);
const toggleLanguage = () => {
const nextLang = i18n.language === 'en' ? 'de' : 'en';
i18n.changeLanguage(nextLang);
localStorage.setItem('i18nextLng', nextLang);
// Trigger Google Translate widget
try {
const selectField = document.querySelector('.goog-te-combo') as HTMLSelectElement;
if (selectField) {
selectField.value = nextLang;
selectField.dispatchEvent(new Event('change'));
}
} catch (e) {
console.error('Google Translate trigger failed:', e);
}
};
// Sync dark mode class to HTML element
useEffect(() => {
console.log('[HeatTransPlan] Current Theme:', theme);
if (theme === 'dark') {
document.documentElement.classList.add('dark');
} else {
document.documentElement.classList.remove('dark');
}
}, [theme]);
return (