Files
softclick-landing/src/App.tsx
Zotov Ivan Yuryevich 05d6e7f6d5 add prettier, pretify
2026-04-03 22:47:24 +03:00

131 lines
5.2 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { useState, useEffect } from 'react'
import { Header } from './components/Header'
import { Footer } from './components/Footer'
import { ContactModal } from './components/ContactModal'
import { HomePage } from './pages/HomePage'
import { CloudPage } from './pages/CloudPage'
import { RussianSoftwarePage } from './pages/RussianSoftwarePage'
import { CybersecurityPage } from './pages/CybersecurityPage'
import { AISolutionsPage } from './pages/AISolutionsPage'
import { RussianHardwarePage } from './pages/RussianHardwarePage'
import { HardwareSolutionsPage } from './pages/HardwareSolutionsPage'
import { CADandGISPage } from './pages/CADandGISPage'
import { IndustrialSolutionsPage } from './pages/IndustrialSolutionsPage'
import { GovernmentPage } from './pages/GovernmentPage'
import { BusinessPage } from './pages/BusinessPage'
import { ConsultingPage } from './pages/ConsultingPage'
import { ImplementationPage } from './pages/ImplementationPage'
import { ManagedServicesPage } from './pages/ManagedServicesPage'
import { IntegrationPage } from './pages/IntegrationPage'
import { SpecializedServicesPage } from './pages/SpecializedServicesPage'
import { SupportPage } from './pages/SupportPage'
import { SubscriptionPage } from './pages/SubscriptionPage'
export default function App() {
const [currentPage, setCurrentPage] = useState('home')
const [pendingScroll, setPendingScroll] = useState<string | null>(null)
const [isContactModalOpen, setIsContactModalOpen] = useState(false)
const scrollToSection = (sectionId: string) => {
// Даем странице время отрендериться
setTimeout(() => {
const section = document.getElementById(sectionId)
console.log('Trying to scroll to:', sectionId, 'Found element:', section)
if (section) {
const headerHeight = 85 // Header высота + минимальный отступ
const targetPosition = section.offsetTop - headerHeight
console.log('Scrolling to position:', targetPosition)
window.scrollTo({
top: targetPosition,
behavior: 'smooth',
})
} else {
console.error('Section not found:', sectionId)
}
}, 100)
}
const handleNavigate = (page: string, section?: string) => {
if (section) {
// Клик на Кейсы/О компании/Контакты
if (currentPage !== 'home') {
// Если не на главной - переходим туда
setCurrentPage('home')
setPendingScroll(section)
} else {
// Уже на главной - скроллим сразу
scrollToSection(section)
}
} else {
// Обычная навигация на другие страницы
setCurrentPage(page)
setPendingScroll(null)
window.scrollTo({ top: 0, behavior: 'smooth' })
}
}
useEffect(() => {
// Когда вернулись на главную с отложенным скроллом
if (currentPage === 'home' && pendingScroll) {
scrollToSection(pendingScroll)
setPendingScroll(null)
}
}, [currentPage, pendingScroll])
const handleBackToHome = () => {
setCurrentPage('home')
setPendingScroll(null)
window.scrollTo({ top: 0, behavior: 'smooth' })
}
const renderPage = () => {
switch (currentPage) {
case 'cloud':
return <CloudPage onBack={handleBackToHome} />
case 'russian-software':
return <RussianSoftwarePage onBack={handleBackToHome} />
case 'cybersecurity':
return <CybersecurityPage onBack={handleBackToHome} />
case 'ai-solutions':
return <AISolutionsPage onBack={handleBackToHome} />
case 'russian-hardware':
return <RussianHardwarePage onBack={handleBackToHome} />
case 'hardware-solutions':
return <HardwareSolutionsPage onBack={handleBackToHome} />
case 'cad-gis':
return <CADandGISPage onBack={handleBackToHome} />
case 'industrial-solutions':
return <IndustrialSolutionsPage onBack={handleBackToHome} />
case 'government':
return <GovernmentPage onBack={handleBackToHome} />
case 'business':
return <BusinessPage onBack={handleBackToHome} />
case 'consulting':
return <ConsultingPage onBack={handleBackToHome} />
case 'implementation':
return <ImplementationPage onBack={handleBackToHome} />
case 'managed-services':
return <ManagedServicesPage onBack={handleBackToHome} />
case 'integration':
return <IntegrationPage onBack={handleBackToHome} />
case 'specialized-services':
return <SpecializedServicesPage onBack={handleBackToHome} />
case 'support':
return <SupportPage onBack={handleBackToHome} />
case 'subscription':
return <SubscriptionPage onBack={handleBackToHome} />
default:
return <HomePage onOpenContactModal={() => setIsContactModalOpen(true)} />
}
}
return (
<div className="min-h-screen bg-white w-full overflow-x-hidden">
<Header onNavigate={handleNavigate} />
{renderPage()}
<Footer />
<ContactModal isOpen={isContactModalOpen} onClose={() => setIsContactModalOpen(false)} />
</div>
)
}