diff --git a/src/app/(app)/home/page.tsx b/src/app/(app)/home/page.tsx index 450d4d8..c189508 100644 --- a/src/app/(app)/home/page.tsx +++ b/src/app/(app)/home/page.tsx @@ -401,9 +401,7 @@ export default function HomePage() {
💊 Vaccine Reminder
- {vaccineReminders[0].status === "overdue" - ? `${vaccineReminders[0].message}` - : `${vaccineReminders[0].vaccineName} due today`} + {vaccineReminders[0].message}
→ diff --git a/src/app/api/notifications/route.ts b/src/app/api/notifications/route.ts index 607a062..dfb32cf 100644 --- a/src/app/api/notifications/route.ts +++ b/src/app/api/notifications/route.ts @@ -83,6 +83,12 @@ export async function GET(request: NextRequest) { const child = children[0]; const birthDate = new Date(child.birth_date as string); + // Self-heal legacy data: an earlier generator stored "undefined" in the + // message ("undefined is N days overdue"). Those rows were frozen by + // ON CONFLICT DO NOTHING. Delete them so the upsert below regenerates them + // with the correct vaccine name. + await sql`DELETE FROM notifications WHERE family_id = ${familyId} AND message LIKE 'undefined%'`; + // ── 1. Vaccine notifications ────────────────────────────────────────────── const given = await sql` SELECT vaccine_name FROM vaccinations @@ -118,7 +124,11 @@ export async function GET(request: NextRequest) { ${dueDateStr}::date, ${JSON.stringify({ vaccineName: v.name, dueDate: dueDateStr })}::jsonb ) - ON CONFLICT (family_id, child_id, type, scheduled_for) DO NOTHING + ON CONFLICT (family_id, child_id, type, scheduled_for) DO UPDATE SET + title = EXCLUDED.title, + message = EXCLUDED.message, + action_url = EXCLUDED.action_url, + metadata = EXCLUDED.metadata `; }