/* ============================================================ APP · router + shell ============================================================ */ function App() { const pageFromLocation = () => { if (window.location.pathname.replace(/\/$/, '') === '/docs') return 'docs'; return (window.location.hash || '#home').replace('#', '') || 'home'; }; const [page, setPage] = useState(pageFromLocation); const [showMentorFloat, setShowMentorFloat] = useState(false); const [showMentorModal, setShowMentorModal] = useState(false); useEffect(() => { const timer = window.setTimeout(() => setShowMentorFloat(true), 5000); return () => window.clearTimeout(timer); }, []); const go = (p) => { setPage(p); if (p === 'docs') { window.history.pushState(null, '', '/docs'); } else { window.history.pushState(null, '', `/#${p}`); } window.scrollTo({ top: 0, behavior: 'auto' }); }; useEffect(() => { const onLocation = () => setPage(pageFromLocation()); window.addEventListener('hashchange', onLocation); window.addEventListener('popstate', onLocation); return () => { window.removeEventListener('hashchange', onLocation); window.removeEventListener('popstate', onLocation); }; }, []); const PAGES = { home: Home, about: AboutPage, mentorship: MentorshipPage, business: BusinessPage, team: TeamPage, contacts: ContactsPage, donate: DonatePage, privacy: PrivacyPage, politika: PolicyPage, reports: ReportsPage, docs: DocsPage, }; const Current = PAGES[page] || NotFoundPage; return ( {showMentorFloat && !showMentorModal && ( setShowMentorModal(true)}> Стать наставником )} {showMentorModal && ( setShowMentorModal(false)}> e.stopPropagation()}> setShowMentorModal(false)} aria-label="Закрыть"> setShowMentorModal(false)} /> )} ); } ReactDOM.createRoot(document.getElementById('root')).render();