-
Notifications
You must be signed in to change notification settings - Fork 0
Enhance workout session management and UI interactions #78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
ef55865
2555a63
10f910a
82c2578
5c4193e
8792fb0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -141,16 +141,49 @@ export default function SplitProgressTracker({ | |
| <div className="split-cards"> | ||
| {splitStatus.map((info) => { | ||
| const isNext = !allCompleted && info.splitDay.id === nextSplit?.id; | ||
| const isInProgress = | ||
| activeWorkout && | ||
| !activeWorkout.completed && | ||
| activeWorkout.splitDayId === info.splitDay.id; | ||
|
|
||
| const handleCardClick = () => { | ||
| if (isInProgress) { | ||
| if (onResumeWorkout) { | ||
| onResumeWorkout(); | ||
| } else { | ||
| console.warn( | ||
| 'Resume workout callback not provided - workout cannot be resumed' | ||
| ); | ||
| } | ||
| } else if (onStartWorkout) { | ||
| onStartWorkout(info.splitDay.id); | ||
| } else { | ||
| console.warn( | ||
| 'Start workout callback not provided - workout cannot be started' | ||
| ); | ||
| } | ||
| }; | ||
|
Comment on lines
+149
to
+165
|
||
|
|
||
| return ( | ||
| <div | ||
| <button | ||
| type="button" | ||
| key={info.splitDay.id} | ||
| className={`split-card ${info.completed ? 'completed' : ''} ${isNext ? 'next' : ''}`} | ||
| className={`split-card clickable ${info.completed ? 'completed' : ''} ${isNext ? 'next' : ''} ${isInProgress ? 'in-progress' : ''}`} | ||
| onClick={handleCardClick} | ||
| aria-label={`${ | ||
| isInProgress ? 'Resume' : info.completed ? 'Redo' : 'Start' | ||
| } ${info.splitDay.name}`} | ||
| > | ||
| <div className="split-card-header"> | ||
| <span className="split-name">{info.splitDay.name}</span> | ||
| <span className="split-status"> | ||
| {info.completed ? '✓' : isNext ? '★ Next' : ''} | ||
| {isInProgress | ||
| ? '🏋️ In Progress' | ||
| : info.completed | ||
| ? '✓' | ||
| : isNext | ||
| ? '★ Next' | ||
| : ''} | ||
| </span> | ||
| </div> | ||
| {info.completedDate && ( | ||
|
|
@@ -164,28 +197,26 @@ export default function SplitProgressTracker({ | |
| {info.splitDay.exercises.length !== 1 ? 's' : ''} | ||
| </div> | ||
| )} | ||
| </div> | ||
| <div className="split-card-action"> | ||
| {isInProgress | ||
| ? 'Tap to resume' | ||
| : info.completed | ||
| ? 'Tap to redo' | ||
| : 'Tap to start'} | ||
| </div> | ||
| </button> | ||
| ); | ||
| })} | ||
| </div> | ||
|
|
||
| {/* Action Button */} | ||
| {allCompleted ? ( | ||
| {/* Completion Message */} | ||
| {allCompleted && ( | ||
| <div className="completion-message"> | ||
| <span className="completion-icon">🎉</span> | ||
| <p className="completion-text">All done this week!</p> | ||
| <p className="completion-subtext"> | ||
| You can repeat splits or start next week's training | ||
| </p> | ||
| <p className="completion-subtext">Tap any split above to redo it</p> | ||
| </div> | ||
| ) : nextSplit && onStartWorkout ? ( | ||
| <button | ||
| className="btn btn-primary start-workout-btn" | ||
| onClick={() => onStartWorkout(nextSplit.id)} | ||
| > | ||
| Start Next Workout | ||
| </button> | ||
| ) : null} | ||
| )} | ||
| </div> | ||
|
|
||
| {/* Deload Week Message */} | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,7 +3,7 @@ | |
| * Handles active workout logging and tracking | ||
| */ | ||
|
|
||
| import { useState, useMemo, useEffect } from 'react'; | ||
| import { useState, useMemo, useEffect, useRef } from 'react'; | ||
| import { useWorkoutSession } from '../../hooks/useWorkoutSession'; | ||
| import { | ||
| useExercises, | ||
|
|
@@ -103,11 +103,25 @@ export default function WorkoutSession({ onNavigate }: WorkoutSessionProps) { | |
| }, [activeMesocycle, completedWorkouts]); | ||
|
|
||
| // Auto-start workout if coming from mesocycle dashboard with a selected split | ||
| const autoStartProcessedRef = useRef(false); | ||
| useEffect(() => { | ||
| const selectedSplitDayId = localStorage.getItem('selectedSplitDayId'); | ||
| if (selectedSplitDayId && activeMesocycle && !isActive) { | ||
| if ( | ||
| selectedSplitDayId && | ||
| activeMesocycle && | ||
| !autoStartProcessedRef.current | ||
| ) { | ||
| // Mark as processed to prevent re-execution | ||
| autoStartProcessedRef.current = true; | ||
| // Clear immediately to prevent re-triggering | ||
| localStorage.removeItem('selectedSplitDayId'); | ||
|
|
||
| // If there's already an active (but stale) workout, cancel it first | ||
| // so we start fresh with the user's explicitly chosen split | ||
| if (isActive) { | ||
| cancelWorkout(); | ||
| } | ||
|
|
||
| // Auto-start the workout with the selected split | ||
| startWorkoutFromSplit(activeMesocycle.id, selectedSplitDayId).catch( | ||
| (error) => { | ||
|
|
@@ -116,7 +130,13 @@ export default function WorkoutSession({ onNavigate }: WorkoutSessionProps) { | |
| } | ||
| ); | ||
| } | ||
| }, [activeMesocycle, isActive, startWorkoutFromSplit, showToast]); | ||
| }, [ | ||
| activeMesocycle, | ||
| isActive, | ||
| startWorkoutFromSplit, | ||
| cancelWorkout, | ||
| showToast, | ||
| ]); | ||
|
Comment on lines
107
to
+139
|
||
|
|
||
| // Get all unique muscle groups from workout exercises | ||
| const workoutMuscleGroups = useMemo(() => { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Button elements should have default styles reset to maintain the card appearance. The .split-card.clickable class should include properties to reset button defaults such as 'border: none;' and 'background: none;' to ensure the button inherits the .split-card styling properly. Currently, the button might display with default browser button styling that could interfere with the card appearance.