From 69d2a650b7ae923184f3cff20fd9310ccedb6d8e Mon Sep 17 00:00:00 2001 From: Diptesh Choudhuri Date: Sun, 8 Dec 2024 15:35:18 +0530 Subject: [PATCH] feat(frontend): adapt to new gql schema --- apps/frontend/app/components/fitness.tsx | 4 ++-- apps/frontend/app/lib/state/fitness.ts | 4 ++-- .../routes/_dashboard.fitness.$entity.$id._index.tsx | 2 +- .../app/routes/_dashboard.fitness.$entity.list.tsx | 12 +++++++++--- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/apps/frontend/app/components/fitness.tsx b/apps/frontend/app/components/fitness.tsx index 00626664b1..1c7ada6ddf 100644 --- a/apps/frontend/app/components/fitness.tsx +++ b/apps/frontend/app/components/fitness.tsx @@ -242,7 +242,7 @@ export const ExerciseHistory = (props: { const exercise = workoutDetails?.details.information.exercises[props.exerciseIdx]; const { data: exerciseDetails } = useQuery( - getExerciseDetailsQuery(exercise?.name || ""), + getExerciseDetailsQuery(exercise?.id || ""), ); const isInSuperset = props.supersetInformation?.find((s) => s.exercises.includes(props.exerciseIdx), @@ -276,7 +276,7 @@ export const ExerciseHistory = (props: { }), props.exerciseIdx.toString(), ) - : getExerciseDetailsPath(exercise.name) + : getExerciseDetailsPath(exercise.id) } fw="bold" lineClamp={1} diff --git a/apps/frontend/app/lib/state/fitness.ts b/apps/frontend/app/lib/state/fitness.ts index 1b98b2f837..75d3ac7930 100644 --- a/apps/frontend/app/lib/state/fitness.ts +++ b/apps/frontend/app/lib/state/fitness.ts @@ -294,7 +294,7 @@ export const duplicateOldWorkout = async ( params.updateWorkoutId ? v.confirmedAt : undefined, ), ); - const exerciseDetails = await getExerciseDetails(ex.name); + const exerciseDetails = await getExerciseDetails(ex.id); inProgress.exercises.push({ identifier: randomUUID(), name: exerciseDetails.details.name, @@ -304,7 +304,7 @@ export const duplicateOldWorkout = async ( images: [], videos: [], alreadyDoneSets: sets.map((s) => ({ statistic: s.statistic })), - exerciseId: ex.name, + exerciseId: ex.id, lot: ex.lot, notes: ex.notes, sets: sets, diff --git a/apps/frontend/app/routes/_dashboard.fitness.$entity.$id._index.tsx b/apps/frontend/app/routes/_dashboard.fitness.$entity.$id._index.tsx index e7c8d34824..b1c3d04f10 100644 --- a/apps/frontend/app/routes/_dashboard.fitness.$entity.$id._index.tsx +++ b/apps/frontend/app/routes/_dashboard.fitness.$entity.$id._index.tsx @@ -560,9 +560,9 @@ export default function Page() { {loaderData.information.exercises.map((exercise, idx) => ( ))} diff --git a/apps/frontend/app/routes/_dashboard.fitness.$entity.list.tsx b/apps/frontend/app/routes/_dashboard.fitness.$entity.list.tsx index bc751783e3..7eeae8dce0 100644 --- a/apps/frontend/app/routes/_dashboard.fitness.$entity.list.tsx +++ b/apps/frontend/app/routes/_dashboard.fitness.$entity.list.tsx @@ -63,7 +63,10 @@ import { useGetWorkoutStarter, useUserUnitSystem, } from "~/lib/hooks"; -import { getDefaultWorkout } from "~/lib/state/fitness"; +import { + getDefaultWorkout, + getExerciseDetailsQuery, +} from "~/lib/state/fitness"; import { getEnhancedCookieName, redirectToFirstPageIfOnInvalidPage, @@ -339,7 +342,7 @@ const DisplayWorkoutListItem = ({ {data.summary.exercises.map((exercise, idx) => ( ))} @@ -364,6 +367,9 @@ const ExerciseDisplay = (props: { exercise: WorkoutSummary["exercises"][number]; }) => { const unitSystem = useUserUnitSystem(); + const { data: exerciseDetails } = useQuery( + getExerciseDetailsQuery(props.exercise.id), + ); const stat = match(props.exercise.bestSet) .with(undefined, null, () => {}) .otherwise((value) => { @@ -382,7 +388,7 @@ const ExerciseDisplay = (props: { {props.exercise.numSets} × - {props.exercise.name} + {exerciseDetails?.name} {stat ? {stat} : null}