Skip to content

Commit

Permalink
placeholder progression stuff for now
Browse files Browse the repository at this point in the history
  • Loading branch information
WhyAsh5114 committed Apr 30, 2024
1 parent 2befdbd commit a776c4f
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 10 deletions.
5 changes: 5 additions & 0 deletions src/lib/utils/mesocycles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,8 @@ export function exerciseTemplateSetToWorkoutExerciseSetData(
};
}
}

export function progressiveOverloadWorkout(referenceWorkout: Workout) {
// TODO: LMAO
return referenceWorkout;
}
9 changes: 8 additions & 1 deletion src/routes/workouts/[mode]/exercises/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
import Badge from '$lib/components/ui/badge/badge.svelte';
import { Progress } from '$lib/components/ui/progress';
import { getCycleNumber, getDayNumber, splitDayToWorkout } from '$lib/utils/mesocycles';
import {
getCycleNumber,
getDayNumber,
progressiveOverloadWorkout,
splitDayToWorkout
} from '$lib/utils/mesocycles';
import { onMount } from 'svelte';
import { toast } from 'svelte-sonner';
import DndComponent from './(components)/DndComponent.svelte';
Expand All @@ -29,6 +34,8 @@
exerciseSplit,
userData
) as PerformingWorkout;
} else if (referenceWorkout && $workoutStore === undefined) {
$workoutStore = progressiveOverloadWorkout(referenceWorkout);
}
} else {
toast.error(`Error ${response.status}`, {
Expand Down
32 changes: 23 additions & 9 deletions src/routes/workouts/[mode]/start/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import LoaderCircle from 'virtual:icons/lucide/loader-circle';
import SkipIcon from 'virtual:icons/lucide/skip-forward';
import { getCycleNumber, getDayNumber, splitDayToWorkout } from '$lib/utils/mesocycles';
import { getCycleNumber, getDayNumber, progressiveOverloadWorkout, splitDayToWorkout } from '$lib/utils/mesocycles';
import {
doesWorkoutInvolveBodyweight,
getMuscleGroupsAndSets,
Expand All @@ -27,7 +27,7 @@
let userData: UserData;
let callingEndpoint = false;
let skippingWorkout = false;
let advancingMesocycle = false;
let todaysWorkout: PerformingWorkout | 'rest';
let userBodyweightInput: number | null;
let overwriteWarningDialogOpen = false;
Expand All @@ -45,6 +45,8 @@
exerciseSplit as WithSID<ExerciseSplit>,
userData
);
} else {
todaysWorkout = progressiveOverloadWorkout(referenceWorkout);
}
} else {
toast.error(`Error ${response.status}`, {
Expand Down Expand Up @@ -77,9 +79,9 @@
goto('./exercises');
}
async function skipWorkout() {
skippingWorkout = true;
const response = await fetch('/api/mesocycles/active/skip-workout', {
async function advanceMesocycle() {
advancingMesocycle = true;
const response = await fetch('/api/mesocycles/active/advance', {
method: 'PATCH'
});
if (response.ok) {
Expand All @@ -88,7 +90,7 @@
} else {
toast.error(`Error ${response.status}`, { description: await response.text() });
}
skippingWorkout = false;
advancingMesocycle = false;
}
</script>

Expand Down Expand Up @@ -145,11 +147,11 @@
<Button
variant="destructive"
class="ml-auto gap-2"
on:click={skipWorkout}
disabled={skippingWorkout}
on:click={advanceMesocycle}
disabled={advancingMesocycle}
>
Skip
{#if skippingWorkout}
{#if advancingMesocycle}
<LoaderCircle class="mr-2 h-4 w-4 animate-spin" />
{:else}
<SkipIcon />
Expand All @@ -169,6 +171,18 @@
{:else if todaysWorkout === 'rest'}
<!-- TODO: rest day UI and completion -->
Rest day!
<Button
class="mt-auto gap-2"
on:click={advanceMesocycle}
disabled={advancingMesocycle}
>
Complete rest day
{#if advancingMesocycle}
<LoaderCircle class="mr-2 h-4 w-4 animate-spin" />
{:else}
<SkipIcon />
{/if}
</Button>
{:else}
<!-- TODO: without active mesocycle workouts -->
<span class="rounded-md border p-2 text-muted-foreground"> No active mesocycle found </span>
Expand Down

0 comments on commit a776c4f

Please sign in to comment.