Files
homepage/src/routes/fitness/[stats=fitnessStats]/+page.server.ts
Alexander Bocken 69b3ac2aa4
All checks were successful
CI / update (push) Successful in 2m3s
fitness: add weekly workout goal with streak counter on stats page
Store a per-user weekly workout target (1-14) in a new FitnessGoal model.
Compute consecutive-week streak from WorkoutSession history via a new
/api/fitness/goal endpoint. Display streak as a 4th lifetime card on the
stats page with an inline goal editor modal.
2026-03-22 21:56:54 +01:00

13 lines
429 B
TypeScript

import type { PageServerLoad } from './$types';
export const load: PageServerLoad = async ({ fetch, locals }) => {
const session = await locals.auth();
const [res, goalRes] = await Promise.all([
fetch('/api/fitness/stats/overview'),
fetch('/api/fitness/goal')
]);
const stats = await res.json();
const goal = goalRes.ok ? await goalRes.json() : { weeklyWorkouts: null, streak: 0 };
return { session, stats, goal };
};