fitness: fix type errors, hydration warning, and add gym link

- Add exerciseId to WorkoutSession model (interface + schema)
- Fix button-in-button hydration warning in TemplateCard (use div)
- Expand FitnessChart dataset type to include all Chart.js properties
- Fix getTime type error in session update with proper cast
- Fix weight nullable type in profile stats with non-null assertion
- Fix $or query typing in templates list endpoint
- Re-add gym link on homepage pointing to /fitness
This commit is contained in:
2026-03-19 08:42:47 +01:00
parent 0618cf7f73
commit cd7b1e21f2
6 changed files with 18 additions and 12 deletions
@@ -64,7 +64,7 @@ export const PUT: RequestHandler = async ({ params, request, locals }) => {
// Calculate duration if both times are provided
if (updateData.startTime && updateData.endTime) {
updateData.duration = Math.round((updateData.endTime.getTime() - updateData.startTime.getTime()) / (1000 * 60));
updateData.duration = Math.round(((updateData.endTime as Date).getTime() - (updateData.startTime as Date).getTime()) / (1000 * 60));
}
const workoutSession = await WorkoutSession.findOneAndUpdate(
@@ -88,8 +88,8 @@ export const GET: RequestHandler = async ({ locals }) => {
weightChart.labels.push(
d.toLocaleDateString('en', { month: 'short', day: 'numeric' })
);
weightChart.data.push(m.weight);
weights.push(m.weight);
weightChart.data.push(m.weight!);
weights.push(m.weight!);
}
// Adaptive window: 7 if enough data, otherwise half the data (min 2)
+6 -6
View File
@@ -15,16 +15,16 @@ export const GET: RequestHandler = async ({ url, locals }) => {
const includePublic = url.searchParams.get('include_public') === 'true';
let query: Record<string, unknown> = {
$or: [
{ createdBy: session.user.nickname }
]
};
const orConditions: Record<string, unknown>[] = [
{ createdBy: session.user.nickname }
];
if (includePublic) {
query.$or.push({ isPublic: true });
orConditions.push({ isPublic: true });
}
const query = { $or: orConditions };
const templates = await WorkoutTemplate.find(query).sort({ updatedAt: -1 });
return json({ templates });