Set logging is now a united. Sporadic set table removed.

This commit is contained in:
AG
2025-12-05 08:55:59 +02:00
parent a632de65ea
commit 41d1d0f16a
19 changed files with 1129 additions and 1232 deletions

34
App.tsx
View File

@@ -8,9 +8,8 @@ import AICoach from './components/AICoach';
import Plans from './components/Plans';
import Login from './components/Login';
import Profile from './components/Profile';
import { TabView, WorkoutSession, WorkoutSet, WorkoutPlan, User, Language, SporadicSet } from './types';
import { TabView, WorkoutSession, WorkoutSet, WorkoutPlan, User, Language } from './types';
import { getSessions, saveSession, deleteSession, getPlans, getActiveSession, updateActiveSession, deleteActiveSession, updateSetInActiveSession, deleteSetFromActiveSession } from './services/storage';
import { getSporadicSets, updateSporadicSet, deleteSporadicSet } from './services/sporadicSets';
import { getCurrentUserProfile, getMe } from './services/auth';
import { getSystemLanguage } from './services/i18n';
import { logWeight } from './services/weight';
@@ -25,7 +24,7 @@ function App() {
const [plans, setPlans] = useState<WorkoutPlan[]>([]);
const [activeSession, setActiveSession] = useState<WorkoutSession | null>(null);
const [activePlan, setActivePlan] = useState<WorkoutPlan | null>(null);
const [sporadicSets, setSporadicSets] = useState<SporadicSet[]>([]);
useEffect(() => {
// Set initial language
@@ -68,13 +67,11 @@ function App() {
// Load plans
const p = await getPlans(currentUser.id);
setPlans(p);
// Load sporadic sets
const sporadicSets = await getSporadicSets();
setSporadicSets(sporadicSets);
} else {
setSessions([]);
setPlans([]);
setSporadicSets([]);
}
};
loadSessions();
@@ -112,6 +109,7 @@ function App() {
const newSession: WorkoutSession = {
id: generateId(),
startTime: Date.now(),
type: 'STANDARD',
userBodyWeight: currentWeight,
sets: [],
planId: plan?.id,
@@ -198,24 +196,7 @@ function App() {
setSessions(prev => prev.filter(s => s.id !== sessionId));
};
const handleSporadicSetAdded = async () => {
const sets = await getSporadicSets();
setSporadicSets(sets);
};
const handleUpdateSporadicSet = async (set: SporadicSet) => {
const updated = await updateSporadicSet(set.id, set);
if (updated) {
setSporadicSets(prev => prev.map(s => s.id === set.id ? updated : s));
}
};
const handleDeleteSporadicSet = async (id: string) => {
const success = await deleteSporadicSet(id);
if (success) {
setSporadicSets(prev => prev.filter(s => s.id !== id));
}
};
if (!currentUser) {
return <Login onLogin={handleLogin} language={language} onLanguageChange={handleLanguageChange} />;
@@ -236,14 +217,12 @@ function App() {
userWeight={currentUser.profile?.weight}
activeSession={activeSession}
activePlan={activePlan}
sporadicSets={sporadicSets}
onSessionStart={handleStartSession}
onSessionEnd={handleEndSession}
onSessionQuit={handleQuitSession}
onSetAdded={handleAddSet}
onRemoveSet={handleRemoveSetFromActive}
onUpdateSet={handleUpdateSetInActive}
onSporadicSetAdded={handleSporadicSetAdded}
lang={language}
/>
)}
@@ -253,11 +232,8 @@ function App() {
{currentTab === 'HISTORY' && (
<History
sessions={sessions}
sporadicSets={sporadicSets}
onUpdateSession={handleUpdateSession}
onDeleteSession={handleDeleteSession}
onUpdateSporadicSet={handleUpdateSporadicSet}
onDeleteSporadicSet={handleDeleteSporadicSet}
lang={language}
/>
)}