From b8447132432d95931c087703a45adda5396c46f0 Mon Sep 17 00:00:00 2001 From: Diptesh Choudhuri Date: Fri, 1 Nov 2024 12:02:35 +0530 Subject: [PATCH] fix(frontend): allow adding exercises to templates --- apps/frontend/app/lib/hooks.ts | 4 ++-- .../routes/_dashboard.fitness.exercises.item.$id._index.tsx | 6 +++--- .../app/routes/_dashboard.fitness.exercises.list.tsx | 6 +++--- .../frontend/app/routes/_dashboard.settings.preferences.tsx | 6 +++--- apps/frontend/app/routes/_dashboard.tsx | 6 +++--- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/apps/frontend/app/lib/hooks.ts b/apps/frontend/app/lib/hooks.ts index 2f72ab8aae..0d92d1b172 100644 --- a/apps/frontend/app/lib/hooks.ts +++ b/apps/frontend/app/lib/hooks.ts @@ -204,12 +204,12 @@ export const useComplexJsonUpdate = () => { return { reset, appendPref, toUpdatePreferences }; }; -export const useIsWorkoutActive = () => { +export const useIsFitnessActionActive = () => { const [currentWorkout] = useCurrentWorkout(); const action = currentWorkout?.currentActionOrCompleted; return ( action !== undefined && action !== true && - [FitnessAction.LogWorkout, FitnessAction.UpdateWorkout].includes(action) + [FitnessAction.LogWorkout, FitnessAction.CreateTemplate].includes(action) ); }; diff --git a/apps/frontend/app/routes/_dashboard.fitness.exercises.item.$id._index.tsx b/apps/frontend/app/routes/_dashboard.fitness.exercises.item.$id._index.tsx index 9cbd44fe74..414c0f5461 100644 --- a/apps/frontend/app/routes/_dashboard.fitness.exercises.item.$id._index.tsx +++ b/apps/frontend/app/routes/_dashboard.fitness.exercises.item.$id._index.tsx @@ -82,7 +82,7 @@ import { } from "~/lib/generals"; import { useComplexJsonUpdate, - useIsWorkoutActive, + useIsFitnessActionActive, useUserDetails, useUserPreferences, useUserUnitSystem, @@ -171,7 +171,7 @@ export default function Page() { loaderData.userExerciseDetails.details?.exerciseNumTimesInteracted || 0; const [currentWorkout, setCurrentWorkout] = useCurrentWorkout(); const navigate = useNavigate(); - const isWorkoutActive = useIsWorkoutActive(); + const isFitnessActionActive = useIsFitnessActionActive(); const [_a, setAddEntityToCollectionData] = useAddEntityToCollection(); const [timeSpanForCharts, setTimeSpanForCharts] = useLocalStorage( "ExerciseChartTimeSpan", @@ -635,7 +635,7 @@ export default function Page() { ) : null} - {currentWorkout && isWorkoutActive ? ( + {currentWorkout && isFitnessActionActive ? ( (); const userPreferences = useUserPreferences(); const submit = useConfirmSubmit(); - const isWorkoutActive = useIsWorkoutActive(); + const isFitnessActionActive = useIsFitnessActionActive(); const [watchProviders, setWatchProviders] = useState( userPreferences.general.watchProviders.map((wp) => ({ ...wp, @@ -153,7 +153,7 @@ export default function Page() {
- {isWorkoutActive && + {isFitnessActionActive && !Object.values(FitnessAction) .map((action) => $path("/fitness/:action", { action })) .includes(location.pathname) ? (