From 86e85136945c11a8dde80aeab42c6023e6a28799 Mon Sep 17 00:00:00 2001 From: renee-png Date: Wed, 17 Jun 2026 23:03:51 -0400 Subject: [PATCH] Inspections: apply violations new-vs-old cue to the map + list Match the violations changes on the Inspections map: add a green "New" badge for violations recorded in the last 7 days, both in the map pin popups and the unit list, so new vs old is distinguishable. (Newest-first ordering and auto-advance-to-next-stage on re-recording a property already existed here.) Also fixed a misleading stage fallback that showed "New" as a notice level. Co-Authored-By: Claude Opus 4.8 --- src/pages/InspectionsPage.tsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/pages/InspectionsPage.tsx b/src/pages/InspectionsPage.tsx index 97f8e40..fba1483 100644 --- a/src/pages/InspectionsPage.tsx +++ b/src/pages/InspectionsPage.tsx @@ -271,13 +271,20 @@ function InteractiveMap({ units, violationsByUnit, selectedUnit, onSelectUnit, o if (days >= 30) lastColor = "#dc3545"; else if (days >= 14) lastColor = "#f59e0b"; } + // "New" badge for recently-recorded violations (last 7 days) — matches the + // violations list, so new vs old is distinguishable on the map too. + const createdDays = v.created_at ? Math.floor((Date.now() - new Date(v.created_at).getTime()) / 86400000) : 999; + const newBadge = createdDays < 7 + ? `New` + : ""; return `
${getIconForCategory(v.category || v.violation_type || "")} ${v.category || v.violation_type || v.title || "Violation"} ${lastLabel ? `${lastLabel}` : ""} - ${v.stage || v.notice_level || "New"} + ${newBadge} + ${v.stage || v.notice_level || "First Notice"} ${escalateBtn}
`; @@ -1023,6 +1030,7 @@ export default function InspectionsPage() { const viols = violsByUnit[u.id] || []; const open = viols.filter((v: any) => v.status === "open" || v.status === "Open" || v.status === "recommended_for_fining").length; const hasPhotos = viols.some((v: any) => v.photo_url || (Array.isArray(v.photo_urls) && v.photo_urls.length > 0)); + const hasNew = viols.some((v: any) => v.created_at && (Date.now() - new Date(v.created_at).getTime()) < 7 * 86400000); const sel = selectedUnit?.id === u.id; const isChecked = selectedUnitIds.includes(u.id); @@ -1037,6 +1045,7 @@ export default function InspectionsPage() {
{i + 1}
{u.address || u.unit_number}
{hasPhotos && } + {hasNew && New} {open > 0 && } {u.owner_name &&
{u.owner_name}
}