Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor fixes #1073

Merged
merged 8 commits into from
Oct 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 56 additions & 40 deletions apps/frontend/app/components/fitness.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,20 @@ import {
type WorkoutSetStatistic,
type WorkoutSupersetsInformation,
} from "@ryot/generated/graphql/backend/graphql";
import { isNumber, startCase } from "@ryot/ts-utils";
import { changeCase, isNumber, startCase } from "@ryot/ts-utils";
import {
IconArrowLeftToArc,
IconClock,
IconInfoCircle,
type IconProps,
IconRotateClockwise,
IconRun,
IconTrophy,
IconWeight,
IconZzz,
} from "@tabler/icons-react";
import { useQuery } from "@tanstack/react-query";
import type { ReactNode } from "react";
import type { ComponentType, ReactNode } from "react";
import { $path } from "remix-routes";
import { match } from "ts-pattern";
import { withFragment } from "ufo";
Expand Down Expand Up @@ -303,44 +305,42 @@ export const ExerciseHistory = (props: {
<SimpleGrid cols={{ base: 2, md: 3 }} spacing={4}>
{exercise.total ? (
<>
{Number(exercise.total.reps) > 0 ? (
<Flex align="center" gap="xs">
<IconRotateClockwise size={14} />
<Text fz="xs">Reps: {exercise.total.reps}</Text>
</Flex>
) : null}
{Number(exercise.total.duration) > 0 ? (
<Flex align="center" gap="xs">
<IconClock size={14} />
<Text fz="xs">
Duration: {exercise.total.duration} min
</Text>
</Flex>
) : null}
{Number(exercise.total.weight) > 0 ? (
<Flex align="center" gap="xs">
<IconWeight size={14} />
<Text fz="xs">
Weight:{" "}
{displayWeightWithUnit(
unitSystem,
exercise.total.weight,
)}
</Text>
</Flex>
) : null}
{Number(exercise.total.distance) > 0 ? (
<Flex align="center" gap="xs">
<IconRun size={14} />
<Text fz="xs">
Distance:{" "}
{displayDistanceWithUnit(
unitSystem,
exercise.total.distance,
)}
</Text>
</Flex>
) : null}
<DisplayExerciseAttributes
label="reps"
icon={IconRotateClockwise}
value={exercise.total.reps}
quantity={exercise.total.reps}
/>
<DisplayExerciseAttributes
label="duration"
icon={IconClock}
quantity={exercise.total.duration}
value={`${exercise.total.duration} min`}
/>
<DisplayExerciseAttributes
label="weight"
icon={IconWeight}
quantity={exercise.total.weight}
value={displayWeightWithUnit(
unitSystem,
exercise.total.weight,
)}
/>
<DisplayExerciseAttributes
icon={IconRun}
label="distance"
quantity={exercise.total.distance}
value={displayDistanceWithUnit(
unitSystem,
exercise.total.distance,
)}
/>
<DisplayExerciseAttributes
icon={IconZzz}
label="rest time"
quantity={exercise.total.restTime}
value={`${exercise.total.restTime}s`}
/>
</>
) : null}
</SimpleGrid>
Expand Down Expand Up @@ -386,6 +386,22 @@ export const ExerciseHistory = (props: {
);
};

const DisplayExerciseAttributes = (props: {
label: string;
value: number | string;
quantity: number | string;
icon: ComponentType<IconProps>;
}) => {
return Number(props.quantity) > 0 ? (
<Flex align="center" gap="xs">
<props.icon size={14} />
<Text fz="xs">
{changeCase(props.label)}: {props.value}
</Text>
</Flex>
) : null;
};

export const ExerciseDisplayItem = (props: {
exerciseId: string;
topRight?: ReactNode;
Expand Down
7 changes: 5 additions & 2 deletions apps/frontend/app/routes/_dashboard.fitness.$action.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,7 @@ const CreateSupersetModal = (props: {

return (
<Stack gap="lg">
<Group>
<Group wrap="nowrap">
<Text>Select color</Text>
<Select
size="xs"
Expand Down Expand Up @@ -909,7 +909,10 @@ const EditSupersetModal = (props: {
</Button>
<Button
fullWidth
disabled={exercises.length <= 1}
disabled={
exercises.length <= 1 ||
props.superset[1].exercises.length === exercises.length
}
onClick={() => {
setCurrentWorkout(
produce(cw, (draft) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,10 @@ export default function Page() {
{" "}
•{" "}
<Anchor
href={loaderData.personDetails.details.website}
target="_blank"
referrerPolicy="no-referrer"
fz={{ base: "xs", md: "sm" }}
href={loaderData.personDetails.details.website}
>
Website
</Anchor>
Expand Down
1 change: 0 additions & 1 deletion crates/migrations/src/m20241013_changes_for_issue_1052.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ DECLARE
superset_array jsonb := '[]'::jsonb;
superset jsonb;
color_options text[] := ARRAY['red', 'pink', 'yellow', 'gray', 'teal', 'green'];
color_index int := 1;
BEGIN
FOR workout_record IN SELECT id, information FROM "{x}" LOOP
workout_json := workout_record.information;
Expand Down
7 changes: 6 additions & 1 deletion crates/services/fitness/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,12 @@ impl ExerciseService {
association.update(&self.0.db).await?;
}
wkt.delete(&self.0.db).await?;
self.re_evaluate_user_workouts(user_id).await?;
self.0
.perform_application_job
.clone()
.enqueue(ApplicationJob::ReEvaluateUserWorkouts(user_id))
.await
.ok();
Ok(true)
}

Expand Down