Skip to content

Commit

Permalink
Merge pull request #130 from WhyAsh5114/WhyAsh5114/issue129
Browse files Browse the repository at this point in the history
fix: update migration function to fix the deleted template bug
  • Loading branch information
WhyAsh5114 authored Oct 18, 2024
2 parents 9b5251e + 08f133c commit 83292cf
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 27 deletions.
3 changes: 2 additions & 1 deletion src/lib/trpc/routes/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,8 @@ export const users = t.router({
startOverloadPercentage: 0,
userId: ctx.userId,
exerciseSplitId: templateIdx ? mesocycleTemplateIds[templateIdx] : null,
RIRProgression: mesocycleTemplates[templateIdx].RIRProgression.map(({ cycles }) => cycles)
RIRProgression:
templateIdx === -1 ? [1] : mesocycleTemplates[templateIdx].RIRProgression.map(({ cycles }) => cycles)
};

if (firstWorkout) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,33 @@
}
</script>

<Card.Root class="mb-2 flex items-center justify-between gap-2 p-2">
<span class="text-sm font-medium text-muted-foreground">The current split of the mesocycle</span>
<Button class="gap-2" onclick={editMesocycleExerciseSplit} size="sm">
Edit <EditIcon />
</Button>
</Card.Root>
<Tabs.Root
class="w-full"
onValueChange={(v) => {
selectedSplitDay = mesocycle.mesocycleExerciseSplitDays.find((splitDay) => splitDay.name === v)!;
}}
value={selectedSplitDay.name}
>
<Tabs.List class="flex justify-start overflow-x-auto">
{#each mesocycle.mesocycleExerciseSplitDays as splitDay}
<Tabs.Trigger disabled={splitDay.isRestDay} value={splitDay.name}>
{splitDay.isRestDay ? 'Rest' : splitDay.name}
</Tabs.Trigger>
{/each}
</Tabs.List>
<Tabs.Content class="flex flex-col gap-1" value={selectedSplitDay.name}>
{#each selectedSplitDay.mesocycleSplitDayExercises as exercise}
<ExerciseTemplateCard context="mesocycle" exerciseTemplate={exercise} readOnly />
{/each}
</Tabs.Content>
</Tabs.Root>
{#if mesocycle.mesocycleExerciseSplitDays.length > 0}
<Card.Root class="mb-2 flex items-center justify-between gap-2 p-2">
<span class="text-sm font-medium text-muted-foreground">The current split of the mesocycle</span>
<Button class="gap-2" onclick={editMesocycleExerciseSplit} size="sm">
Edit <EditIcon />
</Button>
</Card.Root>
<Tabs.Root
class="w-full"
onValueChange={(v) => {
selectedSplitDay = mesocycle.mesocycleExerciseSplitDays.find((splitDay) => splitDay.name === v)!;
}}
value={selectedSplitDay.name}
>
<Tabs.List class="flex justify-start overflow-x-auto">
{#each mesocycle.mesocycleExerciseSplitDays as splitDay}
<Tabs.Trigger disabled={splitDay.isRestDay} value={splitDay.name}>
{splitDay.isRestDay ? 'Rest' : splitDay.name}
</Tabs.Trigger>
{/each}
</Tabs.List>
<Tabs.Content class="flex flex-col gap-1" value={selectedSplitDay.name}>
{#each selectedSplitDay.mesocycleSplitDayExercises as exercise}
<ExerciseTemplateCard context="mesocycle" exerciseTemplate={exercise} readOnly />
{/each}
</Tabs.Content>
</Tabs.Root>
{:else}
<div class="muted-text-box">Mesocycle template for this mesocycle in V2 seems to have been deleted</div>
{/if}

0 comments on commit 83292cf

Please sign in to comment.