We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 04671b0 commit 46a2f72Copy full SHA for 46a2f72
src/routes/api/workout/complete/+server.ts
@@ -34,7 +34,11 @@ export async function POST({ request }) {
34
const blockTemplate = blockTemplates[blockType as keyof typeof blockTemplates]
35
const maxWeeks = blockTemplate?.weeks?.length || 8
36
37
- if (newDay > 7) {
+ // 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) {
42
newDay = 1
43
newWeek++
44
if (newWeek > maxWeeks) {
0 commit comments