const { useState, useEffect } = React; function App() { const [currentPage, setCurrentPage] = useState('dashboard'); const [selectedContactId, setSelectedContactId] = useState(null); const [user, setUser] = useState(null); const [loading, setLoading] = useState(true); useEffect(() => { // Check if user is authenticated fetch('/api/auth/me') .then(res => { if (res.ok) return res.json(); throw new Error('Not authenticated'); }) .then(data => { setUser(data); setLoading(false); }) .catch(() => { // Not logged in - redirect to login window.location.href = '/login'; }); }, []); if (loading) return
Loading...
; if (!user) return null; return (
{/* Sidebar Navigation */}

CRM

{user.email}

{user.role.toUpperCase()}

{/* Main Content */}
{currentPage === 'dashboard' && } {currentPage === 'contacts' && { setSelectedContactId(id); setCurrentPage('contact-detail'); }} />} {currentPage === 'contact-detail' && } {currentPage === 'email-queue' && } {currentPage === 'new-contact' && { setCurrentPage('contacts'); }} />}
); }