Skip to content

Commit

Permalink
implemented edit and clone of mesocycle
Browse files Browse the repository at this point in the history
  • Loading branch information
WhyAsh5114 committed Jun 20, 2024
1 parent ba598ec commit 0fb8b96
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions src/routes/mesocycles/manage/volume/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,30 @@
const id = mesocycleRunes.editingMesocycleId;
savingMesocycle = true;
mesocycleRunes.distributeStartVolumes();
const exerciseSplit = mesocycleRunes.selectedExerciseSplit as FullExerciseSplit;
const exerciseSplitWithoutExercises = {
...exerciseSplit,
exerciseSplitDays: exerciseSplit.exerciseSplitDays.map((splitDay) => {
const { exercises, id, exerciseSplitId, ...rest } = splitDay;
return rest;
})
};
const mesocycleCyclicSetChanges = mesocycleRunes.mesocycleCyclicSetChanges.map((setChange) => {
const { startVolume, inSplit, ...rest } = setChange;
return rest;
});
if (id) {
const { message } = await trpc().mesocycles.editById.mutate({
id,
mesocycleData: {
mesocycle: mesocycleRunes.mesocycle,
mesocycleCyclicSetChanges
}
});
toast.success(message);
} else {
mesocycleRunes.distributeStartVolumes();
const exerciseSplit = mesocycleRunes.selectedExerciseSplit as FullExerciseSplit;
const exerciseSplitWithoutExercises = {
...exerciseSplit,
exerciseSplitDays: exerciseSplit.exerciseSplitDays.map((splitDay) => {
const { exercises, id, exerciseSplitId, ...rest } = splitDay;
return rest;
})
};
const { message } = await trpc().mesocycles.create.mutate({
mesocycle: {
...mesocycleRunes.mesocycle,
Expand All @@ -57,8 +65,8 @@
exerciseSplit: exerciseSplitWithoutExercises
});
toast.success(message);
await invalidate('mesocycles:all');
}
await invalidate('mesocycles:all');
await goto('/mesocycles');
savingMesocycle = false;
mesocycleRunes.resetStores();
Expand All @@ -71,7 +79,7 @@
<MesocycleStartVolumesSetupTable />
</ScrollArea>
<div class="grid grid-cols-2 gap-1">
<Button variant="secondary" href="./exercise-split">Previous</Button>
<Button variant="secondary" href="./progression">Previous</Button>
<Button disabled={savingMesocycle} onclick={createOrEditMesocycle}>
{#if savingMesocycle}
<LoaderCircle class="animate-spin" />
Expand Down

0 comments on commit 0fb8b96

Please sign in to comment.