Skip to content

Commit

Permalink
Merge pull request #166 from WhyAsh5114/165-session-bug
Browse files Browse the repository at this point in the history
165 session bug
  • Loading branch information
WhyAsh5114 authored Jan 3, 2025
2 parents 829c0a6 + 42b4b2b commit b8b78e9
Show file tree
Hide file tree
Showing 12 changed files with 988 additions and 1,357 deletions.
1,730 changes: 646 additions & 1,084 deletions package-lock.json

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
},
"devDependencies": {
"@iconify/json": "^2.2.227",
"@internationalized/date": "^3.6.0",
"@paralleldrive/cuid2": "^2.2.2",
"@playwright/test": "^1.45.1",
"@release-it/conventional-changelog": "^9.0.4",
Expand All @@ -28,27 +29,34 @@
"@typescript-eslint/parser": "^8.0.0",
"@vite-pwa/sveltekit": "^0.6.0",
"autoprefixer": "^10.4.19",
"bits-ui": "^0.22.0",
"cmdk-sv": "^0.0.18",
"dotenv": "^16.4.5",
"embla-carousel-svelte": "^8.5.1",
"eslint": "^9.7.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-svelte": "^2.42.0",
"globals": "^15.8.0",
"mode-watcher": "^0.5.0",
"mongodb": "^6.9.0",
"paneforge": "^0.0.6",
"postcss": "^8.4.39",
"postcss-load-config": "^6.0.1",
"prettier": "^3.3.3",
"prettier-plugin-svelte": "^3.2.5",
"prettier-plugin-tailwindcss": "^0.6.5",
"prisma": "^6.0.0",
"release-it": "^17.11.0",
"svelte": "^5.0.0-next.184",
"svelte": "5.15.*",
"svelte-check": "^4.0.0",
"svelte-dnd-action": "^0.9.49",
"svelte-sonner": "^0.3.28",
"tailwindcss": "^3.4.4",
"tslib": "^2.6.3",
"typescript": "^5.5.3",
"typescript-eslint": "^8.0.0",
"unplugin-icons": "^0.22.0",
"vaul-svelte": "^0.3.2",
"vite": "^6.0.0",
"yaml": "^2.5.1",
"zod": "^3.23.8",
Expand All @@ -58,28 +66,20 @@
"dependencies": {
"@auth/prisma-adapter": "^2.4.1",
"@auth/sveltekit": "^1.4.1",
"@internationalized/date": "^3.5.4",
"@prisma/client": "^6.0.0",
"@trpc/client": "^10.45.2",
"@trpc/server": "^10.45.2",
"bits-ui": "^0.22.0",
"chart.js": "^4.4.3",
"chartjs-adapter-date-fns": "^3.0.0",
"clsx": "^2.1.1",
"cmdk-sv": "^0.0.18",
"date-fns": "^4.1.0",
"dompurify": "^3.2.3",
"embla-carousel-svelte": "^8.3.0",
"marked": "^15.0.4",
"mode-watcher": "^0.5.0",
"paneforge": "^0.0.6",
"posthog-js": "^1.160.3",
"svelte-infinite-loading": "^1.4.0",
"svelte-sonner": "^0.3.26",
"tailwind-merge": "^2.4.0",
"tailwind-merge": "^2.5.0",
"tailwind-variants": "^0.3.0",
"trpc-sveltekit": "^3.6.2",
"trpc-transformer": "^3.2.2",
"vaul-svelte": "^0.3.2"
"trpc-transformer": "^3.2.2"
}
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
<script lang="ts">
import * as Sheet from '$lib/components/ui/sheet';
import { commonExercisePerMuscleGroup } from '$lib/common/commonExercises';
import { Button } from '$lib/components/ui/button';
import AddIcon from 'virtual:icons/lucide/plus';
import ChevronRight from 'virtual:icons/lucide/chevron-right';
import ChevronLeft from 'virtual:icons/lucide/chevron-left';
import { Checkbox } from '$lib/components/ui/checkbox';
import * as Command from '$lib/components/ui/command';
import { Input } from '$lib/components/ui/input';
import { Label } from '$lib/components/ui/label';
import * as Select from '$lib/components/ui/select';
import * as Command from '$lib/components/ui/command';
import { Checkbox } from '$lib/components/ui/checkbox';
import * as Sheet from '$lib/components/ui/sheet';
import { Switch } from '$lib/components/ui/switch';
import { Textarea } from '$lib/components/ui/textarea';
import { Input } from '$lib/components/ui/input';
import { toast } from 'svelte-sonner';
import { ChangeType, MuscleGroup, SetType, type Mesocycle } from '@prisma/client';
import { trpc } from '$lib/trpc/client';
import { convertCamelCaseToNormal } from '$lib/utils';
import { commonExercisePerMuscleGroup } from '$lib/common/commonExercises';
import { ChangeType, MuscleGroup, SetType, type Mesocycle } from '@prisma/client';
import { onMount } from 'svelte';
import { toast } from 'svelte-sonner';
import ChevronLeft from 'virtual:icons/lucide/chevron-left';
import ChevronRight from 'virtual:icons/lucide/chevron-right';
import AddIcon from 'virtual:icons/lucide/plus';
import type {
ExerciseTemplateWithoutIdsOrIndex,
MesocycleExerciseTemplateWithoutIdsOrIndex,
Expand Down Expand Up @@ -43,6 +45,19 @@
type FullExerciseTemplate = NonUndefined<typeof props.editingExercise>;
let { ...props }: PropsType = $props();
let allGroupedExercises = $state(commonExercisePerMuscleGroup);
onMount(async () => {
const userExercises = await trpc().workouts.getUserExercises.query('minimal');
const groupedUserExercises = Object.entries(
Object.groupBy(userExercises, (exercise) => exercise.customMuscleGroup ?? exercise.targetMuscleGroup)
).map(([muscleGroup, exercises]) => ({
muscleGroup: muscleGroup as MuscleGroup,
exercises: exercises!.map(({ workoutId, ...rest }) => ({ ...rest })) ?? []
}));
allGroupedExercises = [...allGroupedExercises, ...groupedUserExercises];
});
const extraMesocycleProps: Partial<MesocycleExerciseTemplateWithoutIdsOrIndex> = {
sets: undefined,
Expand Down
14 changes: 13 additions & 1 deletion src/lib/trpc/routes/workouts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,19 @@ export const workouts = t.router({
take: 10,
orderBy: { workout: { startedAt: 'desc' } }
});
})
}),

getUserExercises: t.procedure.input(z.enum(['minimal', 'extensive'])).query(async ({ ctx, input }) => {
const selectQuery: Prisma.WorkoutExerciseSelect | undefined =
input === 'minimal' ? { name: true, targetMuscleGroup: true, customMuscleGroup: true } : undefined;

return prisma.workoutExercise.findMany({
where: { workout: { userId: ctx.userId } },
distinct: ['name'],
orderBy: { workout: { startedAt: 'desc' } },
select: selectQuery
});
})
});

function getBasicDayInfo(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
export const prerender = true;

type ReleaseData = { body: string; published_at: string; tag_name: string };

export const load = async () => {
export const load = async ({ fetch }) => {
const response = await fetch('https://api.github.com/repos/WhyAsh5114/MyFit/releases');
const body = await response.json();
const releases = body.map(({ body, published_at, tag_name }: ReleaseData) => ({
Expand Down
Loading

0 comments on commit b8b78e9

Please sign in to comment.