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