Skip to content

Commit 46a2f72

Browse files
CopilotBruno-366
andcommitted
Fix workout progression for blocks with varying days per week
Co-authored-by: Bruno-366 <81762173+Bruno-366@users.noreply.github.com>
1 parent 04671b0 commit 46a2f72

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/routes/api/workout/complete/+server.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@ export async function POST({ request }) {
3434
const blockTemplate = blockTemplates[blockType as keyof typeof blockTemplates]
3535
const maxWeeks = blockTemplate?.weeks?.length || 8
3636

37-
if (newDay > 7) {
37+
// Check if the next day exists in the current week
38+
const currentWeekTemplate = blockTemplate?.weeks?.[currentWeek - 1]
39+
const maxDaysInCurrentWeek = currentWeekTemplate?.days?.length || 7
40+
41+
if (newDay > maxDaysInCurrentWeek) {
3842
newDay = 1
3943
newWeek++
4044
if (newWeek > maxWeeks) {

0 commit comments

Comments
 (0)