diff --git a/components/History.tsx b/components/History.tsx index 847e25d..0d2715c 100644 --- a/components/History.tsx +++ b/components/History.tsx @@ -112,7 +112,7 @@ const History: React.FC = ({ sessions, sporadicSets, onUpdateSessi } }; - if (sessions.length === 0) { + if (sessions.length === 0 && (!sporadicSets || sporadicSets.length === 0)) { return (
@@ -197,66 +197,66 @@ const History: React.FC = ({ sessions, sporadicSets, onUpdateSessi
) })} - - {/* Sporadic Sets Section */} - {sporadicSets && sporadicSets.length > 0 && ( -
-

{t('sporadic_sets_title', lang)}

- {Object.entries( - sporadicSets.reduce((groups: Record, set) => { - const date = new Date(set.timestamp).toISOString().split('T')[0]; - if (!groups[date]) groups[date] = []; - groups[date].push(set); - return groups; - }, {}) - ) - .sort(([a], [b]) => b.localeCompare(a)) - .map(([date, sets]) => ( -
-
{date}
-
- {sets.map(set => ( -
-
-
{set.exerciseName}
-
- {set.type === ExerciseType.STRENGTH && `${set.weight || 0}kg x ${set.reps || 0}`} - {set.type === ExerciseType.BODYWEIGHT && `${set.weight ? `+${set.weight}kg` : 'BW'} x ${set.reps || 0}`} - {set.type === ExerciseType.CARDIO && `${set.durationSeconds || 0}s ${set.distanceMeters ? `/ ${set.distanceMeters}m` : ''}`} - {set.type === ExerciseType.STATIC && `${set.durationSeconds || 0}s`} - {set.type === ExerciseType.HIGH_JUMP && `${set.height || 0}cm`} - {set.type === ExerciseType.LONG_JUMP && `${set.distanceMeters || 0}m`} - {set.type === ExerciseType.PLYOMETRIC && `x ${set.reps || 0}`} + {/* Sporadic Sets Section */} + {sporadicSets && sporadicSets.length > 0 && ( +
+

{t('sporadic_sets_title', lang)}

+ {Object.entries( + sporadicSets.reduce((groups: Record, set) => { + const date = new Date(set.timestamp).toISOString().split('T')[0]; + if (!groups[date]) groups[date] = []; + groups[date].push(set); + return groups; + }, {}) + ) + .sort(([a], [b]) => b.localeCompare(a)) + .map(([date, sets]) => ( +
+
{date}
+
+ {(sets as SporadicSet[]).map(set => ( +
+
+
{set.exerciseName}
+
+ {set.type === ExerciseType.STRENGTH && `${set.weight || 0}kg x ${set.reps || 0}`} + {set.type === ExerciseType.BODYWEIGHT && `${set.weight ? `+${set.weight}kg` : 'BW'} x ${set.reps || 0}`} + {set.type === ExerciseType.CARDIO && `${set.durationSeconds || 0}s ${set.distanceMeters ? `/ ${set.distanceMeters}m` : ''}`} + {set.type === ExerciseType.STATIC && `${set.durationSeconds || 0}s`} + {set.type === ExerciseType.HIGH_JUMP && `${set.height || 0}cm`} + {set.type === ExerciseType.LONG_JUMP && `${set.distanceMeters || 0}m`} + {set.type === ExerciseType.PLYOMETRIC && `x ${set.reps || 0}`} +
+
+ {new Date(set.timestamp).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })} +
-
- {new Date(set.timestamp).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })} +
+ +
-
- - -
-
- ))} + ))} +
-
- ))} -
- )} + ))} +
+ )} +
{/* DELETE CONFIRMATION DIALOG (MD3) */} {deletingId && ( diff --git a/components/Tracker/ActiveSessionView.tsx b/components/Tracker/ActiveSessionView.tsx index 4f3aa73..40ce102 100644 --- a/components/Tracker/ActiveSessionView.tsx +++ b/components/Tracker/ActiveSessionView.tsx @@ -204,7 +204,8 @@ const ActiveSessionView: React.FC = ({ tracker, activeSe filteredExercises.map(ex => ( +

{t('quick_log', lang)}

@@ -67,13 +86,20 @@ const SporadicView: React.FC = ({ tracker, lang }) => { autoComplete="off" type="text" /> + {showSuggestions && (
{filteredExercises.length > 0 ? ( filteredExercises.map(ex => (
)}
+ + {isCreating && ( + setIsCreating(false)} + onSave={handleCreateExercise} + lang={lang} + existingExercises={exercises} + /> + )}
); }; diff --git a/components/Tracker/useTracker.ts b/components/Tracker/useTracker.ts index bbf981a..5e386da 100644 --- a/components/Tracker/useTracker.ts +++ b/components/Tracker/useTracker.ts @@ -308,7 +308,7 @@ export const useTracker = ({ } try { - const result = await logSporadicSet(userId, set); + const result = await logSporadicSet(set); if (result) { setSporadicSuccess(true); setTimeout(() => setSporadicSuccess(false), 2000); @@ -329,6 +329,7 @@ export const useTracker = ({ await saveExercise(userId, newEx); setExercises(prev => [...prev, newEx].sort((a, b) => a.name.localeCompare(b.name))); setSelectedExercise(newEx); + setSearchQuery(newEx.name); setIsCreating(false); }; @@ -364,6 +365,17 @@ export const useTracker = ({ setShowPlanList(false); }; + const resetForm = () => { + setWeight(''); + setReps(''); + setDuration(''); + setDistance(''); + setHeight(''); + setSelectedExercise(null); + setSearchQuery(''); + setSporadicSuccess(false); + }; + return { exercises, plans, @@ -426,5 +438,6 @@ export const useTracker = ({ handleSaveEdit, handleCancelEdit, jumpToStep, + resetForm, }; }; diff --git a/server/prisma/dev.db b/server/prisma/dev.db index bf88365..b1174a0 100644 Binary files a/server/prisma/dev.db and b/server/prisma/dev.db differ