fitness: fix type errors, hydration warning, and add gym link
All checks were successful
CI / update (push) Successful in 2m0s

- 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 5890d3f3db
commit 48f381e215
6 changed files with 18 additions and 12 deletions

View File

@@ -5,7 +5,7 @@
/**
* @type {{
* type?: 'line' | 'bar',
* data: { labels: string[], datasets: Array<{ label: string, data: number[], borderColor?: string, backgroundColor?: string }> },
* data: { labels: string[], datasets: Array<{ label: string, data: (number|null)[], borderColor?: string, backgroundColor?: string, borderWidth?: number, pointRadius?: number, pointBackgroundColor?: string, tension?: number, fill?: boolean|string, order?: number }> },
* title?: string,
* height?: string,
* yUnit?: string

View File

@@ -25,7 +25,7 @@
}
</script>
<button class="template-card" onclick={() => onStart?.()}>
<div class="template-card" role="button" tabindex="0" onclick={() => onStart?.()} onkeydown={(e) => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); onStart?.(); }}}>
<div class="card-header">
<h3 class="card-title">{template.name}</h3>
{#if onMenu}
@@ -50,7 +50,7 @@
{#if lastUsed}
<p class="last-used">Last performed: {formatDate(lastUsed)}</p>
{/if}
</button>
</div>
<style>
.template-card {

View File

@@ -9,6 +9,7 @@ export interface ICompletedSet {
}
export interface ICompletedExercise {
exerciseId: string;
name: string;
sets: ICompletedSet[];
restTime?: number;
@@ -59,6 +60,11 @@ const CompletedSetSchema = new mongoose.Schema({
});
const CompletedExerciseSchema = new mongoose.Schema({
exerciseId: {
type: String,
required: true,
trim: true
},
name: {
type: String,
required: true,

View File

@@ -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(

View File

@@ -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)

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 });