All checks were successful
CI / update (push) Successful in 2m3s
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.
13 lines
429 B
TypeScript
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 };
|
|
};
|