From d087e0a5a1aea6069451b27ed613c8cc240095bb Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 22 Jun 2026 00:03:43 +0000 Subject: [PATCH] Fix: restore App.jsx and properly add ChatCoach import, route, nav Previous commit wiped App.jsx due to emoji encoding error in the patch script. Restored from Stream A commit (c075eb9), then applied ChatCoach changes using a file-based Python script to handle unicode. - import ChatCoach from './pages/ChatCoach' (line 21) - NavLink /chat with brain emoji + 'Coach' label (line 95) - Route /chat -> ProtectedRoute -> ChatCoach (line 125) --- frontend/src/App.jsx | 130 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 130 insertions(+) diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx index e69de29..5ca3fe2 100644 --- a/frontend/src/App.jsx +++ b/frontend/src/App.jsx @@ -0,0 +1,130 @@ +import { Routes, Route, Navigate, NavLink, useNavigate, useLocation } from 'react-router-dom' +import { useState, useEffect } from 'react' +import { hasToken, clearToken, api } from './api' +import Login from './pages/Login' +import Dashboard from './pages/Dashboard' +import LogActivity from './pages/LogActivity' +import LogFood from './pages/LogFood' +import Nutrition from './pages/Nutrition' +import Rewards from './pages/Rewards' +import Settings from './pages/Settings' +import Onboarding from './pages/Onboarding' +import WeekView from './pages/WeekView' +import Welcome from './pages/Welcome' +import SettingsIntegrations from './pages/SettingsIntegrations' +import MealPlan from './pages/MealPlan' +import ProgramSearch from './pages/ProgramSearch' +import ProgramDetail from './pages/ProgramDetail' +import CatalogDetail from './pages/CatalogDetail' +import Support from './pages/Support' +import SupportAdmin from './pages/SupportAdmin' +import ChatCoach from './pages/ChatCoach' + +function ProtectedRoute({ children }) { + if (!hasToken()) return + return children +} + +function HelpButton() { + const [unread, setUnread] = useState(0) + const navigate = useNavigate() + const location = useLocation() + + // Don't show on login/onboarding/support pages + const hidden = ['/login', '/onboarding', '/support'].some(p => location.pathname.startsWith(p)) + + useEffect(() => { + if (hidden || !hasToken()) return + api.getUnreadCount() + .then(d => setUnread(d.unread || 0)) + .catch(() => {}) + // Poll every 60s for new replies + const interval = setInterval(() => { + api.getUnreadCount() + .then(d => setUnread(d.unread || 0)) + .catch(() => {}) + }, 60000) + return () => clearInterval(interval) + }, [location.pathname, hidden]) + + if (hidden) return null + + return ( + + ) +} + +function NavBar() { + return ( + + ) +} + +export default function App() { + return ( + <> + {hasToken() && } + + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + + {hasToken() && } + + ) +}