From 622851c1f2c3aef8ae86f3e774349a117a5bb018 Mon Sep 17 00:00:00 2001 From: ssavutu Date: Thu, 6 Aug 2026 02:02:13 -0400 Subject: [PATCH 1/2] Show scheduled articles as "in 7h" instead of "-429m ago" The dashboard's timeAgo() assumed every article was already published, so a scheduled article's future date produced a negative minute count and rendered as "-429m ago". Take the absolute difference and pick the direction from its sign, and guard an unparseable date the same way a missing one is guarded. Co-Authored-By: Claude Opus 5 --- frontend/src/pages/DashboardPage.tsx | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/frontend/src/pages/DashboardPage.tsx b/frontend/src/pages/DashboardPage.tsx index 94be599..f56b0e5 100644 --- a/frontend/src/pages/DashboardPage.tsx +++ b/frontend/src/pages/DashboardPage.tsx @@ -51,14 +51,23 @@ function getHour() { return "Good evening" } +// Scheduled articles sit in the future, so the difference has to be read in +// both directions — otherwise their date reads as "-429m ago". function timeAgo(dateStr: string | null) { if (!dateStr) return "—" - const diff = Date.now() - new Date(dateStr).getTime() - const mins = Math.floor(diff / 60000) - if (mins < 60) return `${mins}m ago` - const hrs = Math.floor(mins / 60) - if (hrs < 24) return `${hrs}h ago` - return `${Math.floor(hrs / 24)}d ago` + const target = new Date(dateStr).getTime() + if (Number.isNaN(target)) return "—" + const diff = Date.now() - target + const ahead = diff < 0 + const mins = Math.floor(Math.abs(diff) / 60000) + if (mins < 1) return "just now" + const label = + mins < 60 + ? `${mins}m` + : mins < 1440 + ? `${Math.floor(mins / 60)}h` + : `${Math.floor(mins / 1440)}d` + return ahead ? `in ${label}` : `${label} ago` } function toCanonicalSlug(value: string) { From 2e40d2807544560d805451ab623fb5e9a0c0d538 Mon Sep 17 00:00:00 2001 From: ssavutu Date: Thu, 6 Aug 2026 02:18:41 -0400 Subject: [PATCH 2/2] Capitalize dashboard status badges The articles page renders "Published"/"Scheduled"; the dashboard was showing the raw lowercase API value. Also widens the RecentArticle status type to include "scheduled", which the endpoint already returns. Co-Authored-By: Claude Opus 5 --- frontend/src/pages/DashboardPage.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/frontend/src/pages/DashboardPage.tsx b/frontend/src/pages/DashboardPage.tsx index f56b0e5..0cbedaf 100644 --- a/frontend/src/pages/DashboardPage.tsx +++ b/frontend/src/pages/DashboardPage.tsx @@ -29,7 +29,7 @@ interface RecentArticle { id: number title: string slug: string - status: "published" | "draft" + status: "published" | "draft" | "scheduled" authors: { name: string }[] categories: { name: string }[] published_date: string | null @@ -70,6 +70,13 @@ function timeAgo(dateStr: string | null) { return ahead ? `in ${label}` : `${label} ago` } +// The articles page shows capitalized status labels ("Published", "Scheduled"), +// so the dashboard badges match rather than showing the raw API value. +function formatStatusLabel(status: string) { + if (!status) return "—" + return status.charAt(0).toUpperCase() + status.slice(1).toLowerCase() +} + function toCanonicalSlug(value: string) { return value .toLowerCase() @@ -444,7 +451,7 @@ export default function DashboardPage() { - {article.status} + {formatStatusLabel(article.status)}