From e7bbfb133bf3104d68a87768dd22e65553170f48 Mon Sep 17 00:00:00 2001 From: Diptesh Choudhuri Date: Sun, 20 Oct 2024 07:58:09 +0530 Subject: [PATCH] chore(frontend): changes to exrrcise display --- .../app/routes/_dashboard.fitness.$action.tsx | 441 +++++++++--------- 1 file changed, 219 insertions(+), 222 deletions(-) diff --git a/apps/frontend/app/routes/_dashboard.fitness.$action.tsx b/apps/frontend/app/routes/_dashboard.fitness.$action.tsx index de956a5dc9..84d812e8c3 100644 --- a/apps/frontend/app/routes/_dashboard.fitness.$action.tsx +++ b/apps/frontend/app/routes/_dashboard.fitness.$action.tsx @@ -1114,53 +1114,43 @@ const ExerciseDisplay = (props: { > - - - + + {exercise.exerciseId} + + + { + setCurrentWorkout( + produce(currentWorkout, (draft) => { + draft.exercises[props.exerciseIdx].isCollapsed = + !exercise.isCollapsed; + }), + ); + }} > - {exercise.exerciseId} - - - { - setCurrentWorkout( - produce(currentWorkout, (draft) => { - draft.exercises[props.exerciseIdx].isCollapsed = - !exercise.isCollapsed; - }), - ); - }} - > - + + + + + - - - - - - + - {exercise.notes.map((note, idx) => ( - - ))} - + } @@ -1260,189 +1250,196 @@ const ExerciseDisplay = (props: { {exercise.isCollapsed ? null : ( - <> - - {exercise.isShowDetailsOpen ? ( - - {match(exercise.openedDetailsTab) - .with("images", undefined, () => ( - - - {exerciseDetails?.attributes.images.map((i) => ( - - ))} - - - )) - .with("history", () => ( - - {exerciseHistory?.map((history, idx) => ( - - {getSurroundingElements( - exerciseHistory, - activeHistoryIdx, - ).includes(idx) ? ( - { - if (!coreDetails.isPro) { - notifications.show({ - color: "red", - message: - "Ryot Pro required to copy sets from other workouts", - }); - return; - } - const workout = await getWorkoutDetails( - history.workoutId, - ); - const yes = await confirmWrapper({ - confirmation: `Are you sure you want to copy all sets from "${workout.details.name}"?`, - }); - if (yes) { - const sets = - workout.details.information.exercises[ - history.idx - ].sets; - const converted = sets.map((set) => - convertHistorySetToCurrentSet(set), - ); - setCurrentWorkout( - produce(currentWorkout, (draft) => { - draft.exercises[ - props.exerciseIdx - ].sets.push(...converted); - }), - ); - } - }} - /> - ) : null} - + + {exercise.notes.map((note, idx) => ( + + ))} + {exercise.isShowDetailsOpen ? ( + + {match(exercise.openedDetailsTab) + .with("images", undefined, () => ( + + + {exerciseDetails?.attributes.images.map((i) => ( + ))} - - )) - .exhaustive()} - {(userExerciseDetails?.history?.length || 0) > 0 ? ( - { - if (!coreDetails.isPro) { - notifications.show({ - color: "red", - message: PRO_REQUIRED_MESSAGE, - }); - return; - } - setCurrentWorkout( - produce(currentWorkout, (draft) => { - draft.exercises[ - props.exerciseIdx - ].openedDetailsTab = - exercise.openedDetailsTab === "images" - ? "history" - : "images"; - }), - ); - }} + + + )) + .with("history", () => ( + - {match(exercise.openedDetailsTab) - .with("images", undefined, () => ) - .with("history", () => ) - .exhaustive()} - - ) : null} - + {exerciseHistory?.map((history, idx) => ( + + {getSurroundingElements( + exerciseHistory, + activeHistoryIdx, + ).includes(idx) ? ( + { + if (!coreDetails.isPro) { + notifications.show({ + color: "red", + message: + "Ryot Pro required to copy sets from other workouts", + }); + return; + } + const workout = await getWorkoutDetails( + history.workoutId, + ); + const yes = await confirmWrapper({ + confirmation: `Are you sure you want to copy all sets from "${workout.details.name}"?`, + }); + if (yes) { + const sets = + workout.details.information.exercises[ + history.idx + ].sets; + const converted = sets.map((set) => + convertHistorySetToCurrentSet(set), + ); + setCurrentWorkout( + produce(currentWorkout, (draft) => { + draft.exercises[ + props.exerciseIdx + ].sets.push(...converted); + }), + ); + } + }} + /> + ) : null} + + ))} + + )) + .exhaustive()} + {(userExerciseDetails?.history?.length || 0) > 0 ? ( + { + if (!coreDetails.isPro) { + notifications.show({ + color: "red", + message: PRO_REQUIRED_MESSAGE, + }); + return; + } + setCurrentWorkout( + produce(currentWorkout, (draft) => { + draft.exercises[ + props.exerciseIdx + ].openedDetailsTab = + exercise.openedDetailsTab === "images" + ? "history" + : "images"; + }), + ); + }} + > + {match(exercise.openedDetailsTab) + .with("images", undefined, () => ) + .with("history", () => ) + .exhaustive()} + + ) : null} + + ) : null} + + + SET + + + PREVIOUS + + {durationCol ? ( + + DURATION (MIN) + ) : null} - - - SET + {distanceCol ? ( + + DISTANCE ( + {match(unitSystem) + .with(UserUnitSystem.Metric, () => "KM") + .with(UserUnitSystem.Imperial, () => "MI") + .exhaustive()} + ) - - PREVIOUS + ) : null} + {weightCol ? ( + + WEIGHT ( + {match(unitSystem) + .with(UserUnitSystem.Metric, () => "KG") + .with(UserUnitSystem.Imperial, () => "LB") + .exhaustive()} + ) - {durationCol ? ( - - DURATION (MIN) - - ) : null} - {distanceCol ? ( - - DISTANCE ( - {match(unitSystem) - .with(UserUnitSystem.Metric, () => "KM") - .with(UserUnitSystem.Imperial, () => "MI") - .exhaustive()} - ) - - ) : null} - {weightCol ? ( - - WEIGHT ( - {match(unitSystem) - .with(UserUnitSystem.Metric, () => "KG") - .with(UserUnitSystem.Imperial, () => "LB") - .exhaustive()} - ) - - ) : null} - {repsCol ? ( - - REPS - - ) : null} - - - {exercise.sets.map((_, idx) => ( - - ))} - + ) : null} + {repsCol ? ( + + REPS + + ) : null} + + + {exercise.sets.map((_, idx) => ( + + ))} - + )}