AI coach fixed: acquired access to context data

This commit is contained in:
aodulov
2025-11-27 07:51:36 +02:00
parent 4f3a889410
commit 1ef85d7a58
4 changed files with 186 additions and 46 deletions

10
App.tsx
View File

@@ -9,7 +9,7 @@ import Plans from './components/Plans';
import Login from './components/Login';
import Profile from './components/Profile';
import { TabView, WorkoutSession, WorkoutSet, WorkoutPlan, User, Language } from './types';
import { getSessions, saveSession, deleteSession } from './services/storage';
import { getSessions, saveSession, deleteSession, getPlans } from './services/storage';
import { getCurrentUserProfile, getMe } from './services/auth';
import { getSystemLanguage } from './services/i18n';
@@ -19,6 +19,7 @@ function App() {
const [language, setLanguage] = useState<Language>('en');
const [sessions, setSessions] = useState<WorkoutSession[]>([]);
const [plans, setPlans] = useState<WorkoutPlan[]>([]);
const [activeSession, setActiveSession] = useState<WorkoutSession | null>(null);
const [activePlan, setActivePlan] = useState<WorkoutPlan | null>(null);
@@ -46,9 +47,12 @@ function App() {
if (currentUser) {
const s = await getSessions(currentUser.id);
setSessions(s);
// Profile fetch is skipped for now as it returns undefined
// Load plans
const p = await getPlans(currentUser.id);
setPlans(p);
} else {
setSessions([]);
setPlans([]);
}
};
loadSessions();
@@ -197,7 +201,7 @@ function App() {
/>
)}
{currentTab === 'STATS' && <Stats sessions={sessions} lang={language} />}
{currentTab === 'AI_COACH' && <AICoach history={sessions} lang={language} />}
{currentTab === 'AI_COACH' && <AICoach history={sessions} userProfile={currentUser.profile} plans={plans} lang={language} />}
{currentTab === 'PROFILE' && (
<Profile
user={currentUser}