|
1 | 1 | import { Buffer } from "buffer";
|
2 | 2 | import { useAutoAnimate } from "@formkit/auto-animate/react";
|
3 | 3 | import { DragDropContext, Draggable, Droppable } from "@hello-pangea/dnd";
|
4 |
| -import { $path } from "@ignisda/remix-routes"; |
5 | 4 | import {
|
6 | 5 | ActionIcon,
|
7 | 6 | Anchor,
|
@@ -79,6 +78,7 @@ import { RESET } from "jotai/utils";
|
79 | 78 | import Cookies from "js-cookie";
|
80 | 79 | import { useRef } from "react";
|
81 | 80 | import Webcam from "react-webcam";
|
| 81 | +import { $path } from "remix-routes"; |
82 | 82 | import { ClientOnly } from "remix-utils/client-only";
|
83 | 83 | import { namedAction } from "remix-utils/named-action";
|
84 | 84 | import invariant from "tiny-invariant";
|
@@ -911,20 +911,7 @@ const ExerciseDisplay = (props: {
|
911 | 911 | </Menu.Target>
|
912 | 912 | {currentTimer?.triggeredBy?.exerciseIdentifier ===
|
913 | 913 | exercise.identifier ? (
|
914 |
| - <Progress |
915 |
| - pos="absolute" |
916 |
| - color="violet" |
917 |
| - bottom={-6} |
918 |
| - value={ |
919 |
| - (currentTimer.endAt.diff(dayjsLib(), "seconds") * 100) / |
920 |
| - currentTimer.totalTime |
921 |
| - } |
922 |
| - size="xs" |
923 |
| - radius="md" |
924 |
| - w="100%" |
925 |
| - onClick={props.openTimerDrawer} |
926 |
| - style={{ cursor: "pointer" }} |
927 |
| - /> |
| 914 | + <RestTimerProgress onClick={props.openTimerDrawer} /> |
928 | 915 | ) : null}
|
929 | 916 | </Group>
|
930 | 917 | {exercise.notes.map((note, idx) => (
|
@@ -1118,6 +1105,30 @@ const ExerciseDisplay = (props: {
|
1118 | 1105 | ) : null;
|
1119 | 1106 | };
|
1120 | 1107 |
|
| 1108 | +const RestTimerProgress = (props: { onClick: () => void }) => { |
| 1109 | + const [currentTimer] = useTimerAtom(); |
| 1110 | + forceUpdateEverySecond(); |
| 1111 | + |
| 1112 | + if (!currentTimer) return null; |
| 1113 | + |
| 1114 | + return ( |
| 1115 | + <Progress |
| 1116 | + pos="absolute" |
| 1117 | + color="violet" |
| 1118 | + bottom={-6} |
| 1119 | + value={ |
| 1120 | + (currentTimer.endAt.diff(dayjsLib(), "seconds") * 100) / |
| 1121 | + currentTimer.totalTime |
| 1122 | + } |
| 1123 | + size="xs" |
| 1124 | + radius="md" |
| 1125 | + w="100%" |
| 1126 | + onClick={props.onClick} |
| 1127 | + style={{ cursor: "pointer" }} |
| 1128 | + /> |
| 1129 | + ); |
| 1130 | +}; |
| 1131 | + |
1121 | 1132 | const SetDisplay = (props: {
|
1122 | 1133 | setIdx: number;
|
1123 | 1134 | repsCol: boolean;
|
@@ -1214,17 +1225,20 @@ const SetDisplay = (props: {
|
1214 | 1225 | {exercise.alreadyDoneSets[props.setIdx] ? (
|
1215 | 1226 | <Box
|
1216 | 1227 | onClick={() => {
|
1217 |
| - if (set.confirmedAt) return; |
1218 | 1228 | setCurrentWorkout(
|
1219 | 1229 | produce(currentWorkout, (draft) => {
|
1220 |
| - draft.exercises[props.exerciseIdx].sets[ |
1221 |
| - props.setIdx |
1222 |
| - ].statistic = |
1223 |
| - exercise.alreadyDoneSets[props.setIdx].statistic; |
| 1230 | + const idxToTarget = set.confirmedAt |
| 1231 | + ? props.setIdx + 1 |
| 1232 | + : props.setIdx; |
| 1233 | + const setToTarget = |
| 1234 | + draft.exercises[props.exerciseIdx].sets[idxToTarget]; |
| 1235 | + if (setToTarget) |
| 1236 | + setToTarget.statistic = |
| 1237 | + exercise.alreadyDoneSets[props.setIdx].statistic; |
1224 | 1238 | }),
|
1225 | 1239 | );
|
1226 | 1240 | }}
|
1227 |
| - style={!set.confirmedAt ? { cursor: "pointer" } : undefined} |
| 1241 | + style={{ cursor: "pointer" }} |
1228 | 1242 | >
|
1229 | 1243 | <DisplaySetStatistics
|
1230 | 1244 | statistic={exercise.alreadyDoneSets[props.setIdx].statistic}
|
|
0 commit comments