Files
gymflow/components/Tracker/index.tsx
2025-11-29 19:03:42 +02:00

49 lines
1.5 KiB
TypeScript

import React from 'react';
import { WorkoutSession, WorkoutSet, WorkoutPlan, Language } from '../../types';
import { useTracker } from './useTracker';
import IdleView from './IdleView';
import SporadicView from './SporadicView';
import ActiveSessionView from './ActiveSessionView';
interface TrackerProps {
userId: string;
userWeight?: number;
activeSession: WorkoutSession | null;
activePlan: WorkoutPlan | null;
onSessionStart: (plan?: WorkoutPlan, startWeight?: number) => void;
onSessionEnd: () => void;
onSessionQuit: () => void;
onSetAdded: (set: WorkoutSet) => void;
onRemoveSet: (setId: string) => void;
onUpdateSet: (set: WorkoutSet) => void;
onSporadicSetAdded?: () => void;
lang: Language;
}
const Tracker: React.FC<TrackerProps> = (props) => {
const tracker = useTracker(props);
const { isSporadicMode } = tracker;
const { activeSession, lang, onSessionEnd, onSessionQuit, onRemoveSet } = props;
if (activeSession) {
return (
<ActiveSessionView
tracker={tracker}
activeSession={activeSession}
lang={lang}
onSessionEnd={onSessionEnd}
onSessionQuit={onSessionQuit}
onRemoveSet={onRemoveSet}
/>
);
}
if (isSporadicMode) {
return <SporadicView tracker={tracker} lang={lang} />;
}
return <IdleView tracker={tracker} lang={lang} />;
};
export default Tracker;