Skip to content

Commit c481b43

Browse files
committed
feat(frontend): general updates
1 parent 2ae467b commit c481b43

30 files changed

+128
-73
lines changed

apps/frontend/app/components/fitness.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { $path } from "@ignisda/remix-routes";
21
import {
32
ActionIcon,
43
Anchor,
@@ -24,6 +23,7 @@ import {
2423
import { startCase, truncate } from "@ryot/ts-utils";
2524
import { IconTrophy } from "@tabler/icons-react";
2625
import { useQuery } from "@tanstack/react-query";
26+
import { $path } from "remix-routes";
2727
import { match } from "ts-pattern";
2828
import { withFragment } from "ufo";
2929
import { dayjsLib, getSetColor } from "~/lib/generals";

apps/frontend/app/components/media.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { $path } from "@ignisda/remix-routes";
21
import {
32
ActionIcon,
43
Anchor,
@@ -24,6 +23,7 @@ import {
2423
ThemeIcon,
2524
Tooltip,
2625
} from "@mantine/core";
26+
import { $path } from "remix-routes";
2727
import "@mantine/dates/styles.css";
2828
import { useDisclosure } from "@mantine/hooks";
2929
import { Form, Link, useFetcher } from "@remix-run/react";

apps/frontend/app/lib/generals.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type Umami from "@bitprojects/umami-logger-typescript";
12
import {
23
createQueryKeys,
34
mergeQueryKeys,
@@ -48,6 +49,14 @@ export const queryClient = new QueryClient({
4849
defaultOptions: { queries: { staleTime: Number.POSITIVE_INFINITY } },
4950
});
5051

52+
declare global {
53+
interface Window {
54+
umami?: {
55+
track: typeof Umami.trackEvent;
56+
};
57+
}
58+
}
59+
5160
export const getSetColor = (l: SetLot) =>
5261
match(l)
5362
.with(SetLot.WarmUp, () => "yellow")

apps/frontend/app/lib/hooks.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import type Umami from "@bitprojects/umami-logger-typescript";
2-
import { $path } from "@ignisda/remix-routes";
31
import { useComputedColorScheme, useMantineTheme } from "@mantine/core";
42
import { useForceUpdate } from "@mantine/hooks";
53
import {
@@ -12,6 +10,7 @@ import type { EntityLot } from "@ryot/generated/graphql/backend/graphql";
1210
import { useQuery } from "@tanstack/react-query";
1311
import Cookies from "js-cookie";
1412
import type { FormEvent } from "react";
13+
import { $path } from "remix-routes";
1514
import { useInterval } from "usehooks-ts";
1615
import {
1716
CurrentWorkoutKey,
@@ -22,14 +21,6 @@ import {
2221
import { type InProgressWorkout, useCurrentWorkout } from "~/lib/state/fitness";
2322
import type { loader as dashboardLoader } from "~/routes/_dashboard";
2423

25-
declare global {
26-
interface Window {
27-
umami?: {
28-
track: typeof Umami.trackEvent;
29-
};
30-
}
31-
}
32-
3324
export const useGetMantineColor = () => {
3425
const theme = useMantineTheme();
3526
const colors = Object.keys(theme.colors);

apps/frontend/app/lib/state/fitness.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { $path } from "@ignisda/remix-routes";
21
import type { NavigateFunction } from "@remix-run/react";
32
import {
43
type CreateUserWorkoutMutationVariables,
@@ -18,6 +17,7 @@ import { createDraft, finishDraft } from "immer";
1817
import { atom, useAtom } from "jotai";
1918
import { atomWithReset, atomWithStorage } from "jotai/utils";
2019
import Cookies from "js-cookie";
20+
import { $path } from "remix-routes";
2121
import { withFragment } from "ufo";
2222
import { v4 as randomUUID } from "uuid";
2323
import {

apps/frontend/app/lib/utilities.server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import type { TypedDocumentNode } from "@graphql-typed-document-node/core";
2-
import { $path } from "@ignisda/remix-routes";
32
import {
43
createCookie,
54
createCookieSessionStorage,
@@ -25,6 +24,7 @@ import {
2524
type Variables,
2625
} from "graphql-request";
2726
import type { VariablesAndRequestHeadersArgs } from "node_modules/graphql-request/build/legacy/helpers/types";
27+
import { $path } from "remix-routes";
2828
import { match } from "ts-pattern";
2929
import { withoutHost } from "ufo";
3030
import { v4 as randomUUID } from "uuid";

apps/frontend/app/routes/_dashboard._index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { $path } from "@ignisda/remix-routes";
21
import {
32
Alert,
43
Box,
@@ -34,6 +33,7 @@ import {
3433
IconServer,
3534
} from "@tabler/icons-react";
3635
import { Fragment, type ReactNode } from "react";
36+
import { $path } from "remix-routes";
3737
import invariant from "tiny-invariant";
3838
import { match } from "ts-pattern";
3939
import { ApplicationGrid } from "~/components/common";

apps/frontend/app/routes/_dashboard.calendar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { $path } from "@ignisda/remix-routes";
21
import {
32
ActionIcon,
43
Anchor,
@@ -24,6 +23,7 @@ import {
2423
} from "@ryot/generated/graphql/backend/graphql";
2524
import { isNumber, snakeCase, startCase, sum, truncate } from "@ryot/ts-utils";
2625
import { IconChevronLeft, IconChevronRight } from "@tabler/icons-react";
26+
import { $path } from "remix-routes";
2727
import { z } from "zod";
2828
import { zx } from "zodix";
2929
import { dayjsLib } from "~/lib/generals";

apps/frontend/app/routes/_dashboard.collections.list.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { $path } from "@ignisda/remix-routes";
21
import {
32
ActionIcon,
43
Anchor,
@@ -37,6 +36,7 @@ import { IconEdit, IconPlus, IconTrashFilled } from "@tabler/icons-react";
3736
import { ClientError } from "graphql-request";
3837
import { useEffect, useState } from "react";
3938
import { Virtuoso } from "react-virtuoso";
39+
import { $path } from "remix-routes";
4040
import { namedAction } from "remix-utils/named-action";
4141
import { withQuery } from "ufo";
4242
import { z } from "zod";

apps/frontend/app/routes/_dashboard.fitness.$action.tsx

Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { Buffer } from "buffer";
22
import { useAutoAnimate } from "@formkit/auto-animate/react";
33
import { DragDropContext, Draggable, Droppable } from "@hello-pangea/dnd";
4-
import { $path } from "@ignisda/remix-routes";
54
import {
65
ActionIcon,
76
Anchor,
@@ -79,6 +78,7 @@ import { RESET } from "jotai/utils";
7978
import Cookies from "js-cookie";
8079
import { useRef } from "react";
8180
import Webcam from "react-webcam";
81+
import { $path } from "remix-routes";
8282
import { ClientOnly } from "remix-utils/client-only";
8383
import { namedAction } from "remix-utils/named-action";
8484
import invariant from "tiny-invariant";
@@ -911,20 +911,7 @@ const ExerciseDisplay = (props: {
911911
</Menu.Target>
912912
{currentTimer?.triggeredBy?.exerciseIdentifier ===
913913
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} />
928915
) : null}
929916
</Group>
930917
{exercise.notes.map((note, idx) => (
@@ -1118,6 +1105,30 @@ const ExerciseDisplay = (props: {
11181105
) : null;
11191106
};
11201107

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+
11211132
const SetDisplay = (props: {
11221133
setIdx: number;
11231134
repsCol: boolean;
@@ -1214,17 +1225,20 @@ const SetDisplay = (props: {
12141225
{exercise.alreadyDoneSets[props.setIdx] ? (
12151226
<Box
12161227
onClick={() => {
1217-
if (set.confirmedAt) return;
12181228
setCurrentWorkout(
12191229
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;
12241238
}),
12251239
);
12261240
}}
1227-
style={!set.confirmedAt ? { cursor: "pointer" } : undefined}
1241+
style={{ cursor: "pointer" }}
12281242
>
12291243
<DisplaySetStatistics
12301244
statistic={exercise.alreadyDoneSets[props.setIdx].statistic}

0 commit comments

Comments
 (0)