From 4c897164729da425449eb3112fd605e69d90d5bd Mon Sep 17 00:00:00 2001 From: WhyAsh5114 Date: Thu, 17 Oct 2024 11:40:53 +0530 Subject: [PATCH 1/8] fix: show error instead of just redirecting --- src/routes/dashboard/+page.server.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/routes/dashboard/+page.server.ts b/src/routes/dashboard/+page.server.ts index bde9acd3..71cf1654 100644 --- a/src/routes/dashboard/+page.server.ts +++ b/src/routes/dashboard/+page.server.ts @@ -1,13 +1,13 @@ import { createContext } from '$lib/trpc/context'; import { createCaller } from '$lib/trpc/router'; -import { redirect } from '@sveltejs/kit'; +import { error } from 'console'; export const load = async (event) => { event.depends('workouts:all'); const session = await event.locals.auth(); if (session === null) { - redirect(302, '/'); + error(401, 'Not logged in'); } const trpc = createCaller(await createContext(event)); From a84e45aca761c20e7dc5cee480b156e8a84bfedc Mon Sep 17 00:00:00 2001 From: WhyAsh5114 Date: Thu, 17 Oct 2024 11:51:02 +0530 Subject: [PATCH 2/8] fix: filter out 0s in averagePercentageChange util function --- src/lib/utils.ts | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/lib/utils.ts b/src/lib/utils.ts index 91290dcd..ac57b1ff 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -103,16 +103,23 @@ export function arrayAverage(arr: number[]): number { export function averagePercentageChange(arr: number[]): number { if (arr.length < 2) return 0; - const totalPercentageChange = arr.slice(1).reduce((sum, current, index) => { - const previous = arr[index]; + let totalPercentageChange = 0; + let numberOfIncrements = 0; + + for (let i = 1; i < arr.length; i++) { + const previous = arr[i - 1]; + const current = arr[i]; + if (previous === 0 || current === 0) continue; + const percentageChange = ((current - previous) / previous) * 100; - return sum + (isNaN(percentageChange) ? 0 : percentageChange); - }, 0); + totalPercentageChange += isNaN(percentageChange) ? 0 : percentageChange; + numberOfIncrements++; + } - const numberOfIncrements = arr.length - 1; - return totalPercentageChange / numberOfIncrements; + return numberOfIncrements > 0 ? totalPercentageChange / numberOfIncrements : 0; } + export function convertCamelCaseToNormal(text?: string | null): string { if (!text) return ''; return text From 6335e3c45693a28f87b10ad1c094b1699c73ece7 Mon Sep 17 00:00:00 2001 From: WhyAsh5114 Date: Thu, 17 Oct 2024 12:11:03 +0530 Subject: [PATCH 3/8] feat: improved NavLinks --- .../(components)/layout/NavLinks.svelte | 31 ++++++++++++++----- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/src/routes/(components)/layout/NavLinks.svelte b/src/routes/(components)/layout/NavLinks.svelte index ac4cfd03..9e28df95 100644 --- a/src/routes/(components)/layout/NavLinks.svelte +++ b/src/routes/(components)/layout/NavLinks.svelte @@ -1,23 +1,40 @@
    - {#each linkItems as { text, href }} -
  • - -
  • + {#each linkItems as linkItem} + {#if linkItem} +
  • + +
  • + {:else} + + {/if} {/each}
From aa16fd5c5442a15447ba5a6451f99cf687a803b6 Mon Sep 17 00:00:00 2001 From: WhyAsh5114 Date: Thu, 17 Oct 2024 12:51:14 +0530 Subject: [PATCH 4/8] feat: added docs page --- src/routes/docs/+page.server.ts | 1 + src/routes/docs/+page.svelte | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 src/routes/docs/+page.server.ts create mode 100644 src/routes/docs/+page.svelte diff --git a/src/routes/docs/+page.server.ts b/src/routes/docs/+page.server.ts new file mode 100644 index 00000000..189f71e2 --- /dev/null +++ b/src/routes/docs/+page.server.ts @@ -0,0 +1 @@ +export const prerender = true; diff --git a/src/routes/docs/+page.svelte b/src/routes/docs/+page.svelte new file mode 100644 index 00000000..ec63bd13 --- /dev/null +++ b/src/routes/docs/+page.svelte @@ -0,0 +1,25 @@ +
+

Docs

+
Just a basic overview of things work in this app, as there are some differences from V2
+ +

Exercise splits

+

+ An exercise split refers to how workout sessions are divided across different days to target specific muscle groups + or movement patterns. Examples: Push Pull Legs, Upper Lower, and Full Body. +

+

Tha app supports both synchronous (weekly) splits, and asynchronous splits (non-weekly) splits.

+ +

Mesocycle

+

+ A mesocycle is a unit of training consisting of several microcycles (repeated splits), usually lasting 4-6 weeks. + The mesocycle structures progression and recovery, with increasing intensity or volume followed by deload phases to + avoid overtraining. +

+ +

Workouts

+

+ A single workout, consisting of multiple exercises, each with their own sets and options. Workouts can be done with + or without an active mesocycle. Using an active mesocycle allows the app to progress performance and sets every + microcycle. +

+
From c2e7799709744c06b49408c5cb29fc208b346c98 Mon Sep 17 00:00:00 2001 From: WhyAsh5114 Date: Thu, 17 Oct 2024 13:04:45 +0530 Subject: [PATCH 5/8] feat: finished up basic docs --- src/routes/docs/+page.svelte | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/routes/docs/+page.svelte b/src/routes/docs/+page.svelte index ec63bd13..a0f82def 100644 --- a/src/routes/docs/+page.svelte +++ b/src/routes/docs/+page.svelte @@ -13,13 +13,25 @@

A mesocycle is a unit of training consisting of several microcycles (repeated splits), usually lasting 4-6 weeks. The mesocycle structures progression and recovery, with increasing intensity or volume followed by deload phases to - avoid overtraining. + avoid overtraining. Deload feature will be coming soon!

Workouts

A single workout, consisting of multiple exercises, each with their own sets and options. Workouts can be done with - or without an active mesocycle. Using an active mesocycle allows the app to progress performance and sets every - microcycle. + or without an active mesocycle. +

+

Using an active mesocycle allows the app to progress performance and sets every microcycle.

+ +

Mesocycle exercise split

+

+ Whenever you create a mesocycle with an exercise split, that split is actually cloned for that mesocycle. This + allows you and the app to make changes to the mesocycle's split without altering the original split. +

+ +

"I need more help!"

+

+ Feel free to open an issue on the GitHub repository, will be glad + to help you out and add more details to the docs

From 8bb6616a731e5e4a29b0809486bc7f4707d7aeb7 Mon Sep 17 00:00:00 2001 From: WhyAsh5114 Date: Thu, 17 Oct 2024 13:04:57 +0530 Subject: [PATCH 6/8] ui: better separation in NavLinks --- src/routes/(components)/layout/NavLinks.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes/(components)/layout/NavLinks.svelte b/src/routes/(components)/layout/NavLinks.svelte index 9e28df95..6f684bcd 100644 --- a/src/routes/(components)/layout/NavLinks.svelte +++ b/src/routes/(components)/layout/NavLinks.svelte @@ -34,7 +34,7 @@ {:else} - + {/if} {/each} From aa6d8fcbe0e0d671f36f293e744dc871c0e15163 Mon Sep 17 00:00:00 2001 From: WhyAsh5114 Date: Thu, 17 Oct 2024 13:07:24 +0530 Subject: [PATCH 7/8] fix: update URL --- src/routes/privacy-policy/+page.svelte | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/routes/privacy-policy/+page.svelte b/src/routes/privacy-policy/+page.svelte index 9704d009..60cf9ff1 100644 --- a/src/routes/privacy-policy/+page.svelte +++ b/src/routes/privacy-policy/+page.svelte @@ -89,8 +89,8 @@
  • Website refers to MyFit, accessible from - https://my-fit-whyash5114.vercel.apphttps://my-fit-v3.vercel.app

  • From cba45727db4b04b44cfad68ef19875fa22d90ba0 Mon Sep 17 00:00:00 2001 From: WhyAsh5114 Date: Thu, 17 Oct 2024 13:10:36 +0530 Subject: [PATCH 8/8] lint: prettier --- src/lib/utils.ts | 1 - src/routes/privacy-policy/+page.svelte | 4 +--- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/lib/utils.ts b/src/lib/utils.ts index ac57b1ff..206b859d 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -119,7 +119,6 @@ export function averagePercentageChange(arr: number[]): number { return numberOfIncrements > 0 ? totalPercentageChange / numberOfIncrements : 0; } - export function convertCamelCaseToNormal(text?: string | null): string { if (!text) return ''; return text diff --git a/src/routes/privacy-policy/+page.svelte b/src/routes/privacy-policy/+page.svelte index 60cf9ff1..b262c1ca 100644 --- a/src/routes/privacy-policy/+page.svelte +++ b/src/routes/privacy-policy/+page.svelte @@ -89,9 +89,7 @@
  • Website refers to MyFit, accessible from - https://my-fit-v3.vercel.app + https://my-fit-v3.vercel.app