From 2fa46175c3b72fe3d03dd78d3a3be38780033f24 Mon Sep 17 00:00:00 2001 From: Saurabh Kumar Bajpai Date: Sun, 2 Aug 2026 20:39:12 +0530 Subject: [PATCH 1/2] fix: code quality and safety improvements --- src/app/api/goals/route.ts | 2 +- src/components/GoalTracker.tsx | 2 +- src/lib/digest-email.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/app/api/goals/route.ts b/src/app/api/goals/route.ts index 0d616ebd3..b4b83346b 100644 --- a/src/app/api/goals/route.ts +++ b/src/app/api/goals/route.ts @@ -239,7 +239,7 @@ try { let safeDeadline: string | null = null; if (typeof deadline === "string") { const d = new Date(deadline); - if (!isNaN(d.getTime())) { + if (!Number.isNaN(d.getTime())) { d.setUTCHours(23, 59, 59, 999); safeDeadline = d.toISOString(); } diff --git a/src/components/GoalTracker.tsx b/src/components/GoalTracker.tsx index d2eecbe22..a643a64f6 100644 --- a/src/components/GoalTracker.tsx +++ b/src/components/GoalTracker.tsx @@ -1064,7 +1064,7 @@ function ConfettiBurst() { id: i, x: Math.cos(angle) * distance, y: Math.sin(angle) * distance - 20, - color: colors[Math.random() * colors.length | 0], + color: colors[Math.floor(Math.random() * colors.length) | 0], rot: Math.random() * 360 + 180, scale: 0.5 + Math.random() * 0.7, speed: 0.8 + Math.random() * 0.6, diff --git a/src/lib/digest-email.ts b/src/lib/digest-email.ts index 717fceee2..a87c5da5b 100644 --- a/src/lib/digest-email.ts +++ b/src/lib/digest-email.ts @@ -398,7 +398,7 @@ export function buildDigestText(data: DigestEmailData): string { if (m.topLanguages.length > 0) { lines.push(`Top languages:`); m.topLanguages.forEach((l) => { - lines.push(` ${l.name.padEnd(14)} ${l.percentage.toFixed(1)}%`); + lines.push(` ${l.name.padEnd(14, " ")} ${l.percentage.toFixed(1)}%`); }); lines.push(``); } From a11082d548ff8755774525a52e318e45aa8d224f Mon Sep 17 00:00:00 2001 From: Saurabh Kumar Bajpai Date: Mon, 3 Aug 2026 00:14:20 +0530 Subject: [PATCH 2/2] fix: additional real bug fixes --- src/app/api/goals/route.ts | 2 +- src/components/GoalTracker.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/api/goals/route.ts b/src/app/api/goals/route.ts index b4b83346b..84218a34a 100644 --- a/src/app/api/goals/route.ts +++ b/src/app/api/goals/route.ts @@ -177,7 +177,7 @@ export async function GET() { } } - const goalsWithHistory = processedGoals.map((goal) => ({ + const goalsWithHistory = (processedGoals ?? []).map((goal) => ({ ...goal, last_period: latestHistoryByGoal.get(goal.id) ?? null, })); diff --git a/src/components/GoalTracker.tsx b/src/components/GoalTracker.tsx index a643a64f6..17d6a1c0c 100644 --- a/src/components/GoalTracker.tsx +++ b/src/components/GoalTracker.tsx @@ -429,7 +429,7 @@ export default function GoalTracker() { const data: { goal: Goal } = await response.json(); setGoals((currentGoals) => - currentGoals.map((goal) => (goal.id === data.goal.id ? data.goal : goal)) + (currentGoals ?? []).map((goal) => (goal.id === data.goal.id ? data.goal : goal)) ); } catch { setShareError("Failed to update goal sharing. Please check your connection.");