From 6c2ddd68f1680268deacf54d5aadb13041757e1d Mon Sep 17 00:00:00 2001 From: WhyAsh5114 Date: Sun, 23 Jun 2024 19:14:36 +0530 Subject: [PATCH] added overrides sheet --- .../ExerciseSplitDrawer.svelte | 234 +++++++++++++++--- 1 file changed, 204 insertions(+), 30 deletions(-) diff --git a/src/lib/components/mesocycleAndExerciseSplit/ExerciseSplitDrawer.svelte b/src/lib/components/mesocycleAndExerciseSplit/ExerciseSplitDrawer.svelte index 3662a1de..d9746932 100644 --- a/src/lib/components/mesocycleAndExerciseSplit/ExerciseSplitDrawer.svelte +++ b/src/lib/components/mesocycleAndExerciseSplit/ExerciseSplitDrawer.svelte @@ -2,14 +2,23 @@ import * as Sheet from '$lib/components/ui/sheet'; import { Button } from '$lib/components/ui/button'; import AddIcon from 'virtual:icons/lucide/plus'; + import ChevronRight from 'virtual:icons/lucide/chevron-right'; + import ChevronLeft from 'virtual:icons/lucide/chevron-left'; import { Label } from '$lib/components/ui/label'; import * as Select from '$lib/components/ui/select'; import * as Command from '$lib/components/ui/command'; + import { Checkbox } from '$lib/components/ui/checkbox'; import { Switch } from '$lib/components/ui/switch'; import { Textarea } from '$lib/components/ui/textarea'; - import Input from '$lib/components/ui/input/input.svelte'; + import { Input } from '$lib/components/ui/input'; import { toast } from 'svelte-sonner'; - import { ChangeType, MuscleGroup, SetType } from '@prisma/client'; + import { + ChangeType, + MuscleGroup, + ProgressionVariable, + SetType, + type Mesocycle + } from '@prisma/client'; import { convertCamelCaseToNormal } from '$lib/utils'; import { commonExercisePerMuscleGroup } from '$lib/common/commonExercises'; import type { @@ -27,25 +36,36 @@ type PropsType = | ({ context: 'exerciseSplit' } & CommonProps) - | ({ context: 'mesocycle' } & CommonProps); + | ({ + context: 'mesocycle'; + mesocycle: Mesocycle; + } & CommonProps); type NonUndefined = T extends undefined ? never : T; type FullExerciseTemplate = NonUndefined; let { ...props }: PropsType = $props(); + const extraMesocycleProps: Partial = { + sets: undefined, + overloadPercentage: null, + forceRIRMatching: null, + lastSetToFailure: null, + preferredProgressionVariable: null + }; + const defaultExercise: Partial = { name: '', setType: 'Straight', - involvesBodyweight: false + involvesBodyweight: false, + ...(props.context !== 'exerciseSplit' && structuredClone(extraMesocycleProps)) }; let open = $state(false); + let overridesSheetOpen = $state(false); let mode = $derived(props.editingExercise === undefined ? 'Add' : 'Edit'); let searching = $state(false); - let currentExercise: Partial = $state( - structuredClone(defaultExercise) - ); + let currentExercise: Partial = $state(structuredClone(defaultExercise)); $effect(() => { if (props.editingExercise) { @@ -55,7 +75,10 @@ }); function selectExercise(exercise: ExerciseTemplateWithoutIds) { - currentExercise = structuredClone(exercise); + currentExercise = structuredClone({ + ...exercise, + ...(props.context === 'mesocycle' && structuredClone(extraMesocycleProps)) + }); searching = false; } @@ -82,6 +105,10 @@ resetDrawerState(); open = false; } + + function submitOverrides() { + overridesSheetOpen = false; + } @@ -165,6 +192,26 @@ /> {/if} + {#if props.context === 'mesocycle' && 'sets' in currentExercise} +
+ + +
+
+ Progression + +
+ {/if}
@@ -197,28 +244,6 @@
-
- - -
-
- - -
{#if currentExercise.setType === 'Drop' || currentExercise.setType === 'Down' || currentExercise.setType === 'Top'}
{/if} +
+ + +
+
+ + +