import React, { useState, useEffect } from 'react'; import { X } from 'lucide-react'; import Navbar from './components/Navbar'; import Hero from './components/Hero'; import TrustedBy from './components/TrustedBy'; import ProductOverview from './components/ProductOverview'; import InteractiveDemo from './components/InteractiveDemo'; import UseCases from './components/UseCases'; import HowItWorks from './components/HowItWorks'; import Accuracy from './components/Accuracy'; import Documentation from './components/Documentation'; import FAQ from './components/FAQ'; import Footer from './components/Footer'; import SimulationPage from './components/SimulationPage'; import ChatPage from './components/ChatPage'; import ProductGuide from './components/ProductGuide'; function App() { const [currentView, setCurrentView] = useState<'landing' | 'simulation' | 'chat' | 'guide'>('simulation'); const [user, setUser] = useState(null); const [simulationResult, setSimulationResult] = useState(null); useEffect(() => { const fetchUser = async () => { try { const response = await fetch('/api/user'); if (response.ok) { const data = await response.json(); setUser(data); } } catch (error) { console.error("Failed to fetch user:", error); } }; fetchUser(); // Listen for storage changes in case of popup login const handleStorage = () => fetchUser(); window.addEventListener('storage', handleStorage); return () => window.removeEventListener('storage', handleStorage); }, []); const loginWithHF = () => { // Open in a new tab to pop out of iframe window.open('/login', '_blank'); }; const handleLogout = async () => { await fetch('/api/logout'); setUser(null); }; const startSimulation = () => { setCurrentView('simulation'); window.scrollTo(0,0); }; const goBackToLanding = () => { setCurrentView('landing'); }; const openChat = () => { setCurrentView('chat'); }; const openGuide = () => { setCurrentView('guide'); }; const goBackToSimulation = () => { setCurrentView('simulation'); }; if (currentView === 'guide') { return (
); } if (currentView === 'simulation') { return ( ); } if (currentView === 'conversation') { return ; } if (currentView === 'chat') { return ( ); } return (
); } export default App;