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
{user.email}
{user.role.toUpperCase()}