refactor(design): replace status, priority and severity color maps with StatusTag and mono tokens

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-09-30 19:08:18 +08:00
co-authored by Claude Haiku 4.5
parent 0b5020b3d0
commit ba9eeefe47
12 changed files with 45 additions and 125 deletions
+6 -19
View File
@@ -9,6 +9,7 @@ import { eq, asc } from 'drizzle-orm'
import { StatCard } from '@/components/dashboard/stat-card' import { StatCard } from '@/components/dashboard/stat-card'
import { CapaOwnerActions } from '@/components/capa/capa-owner-actions' import { CapaOwnerActions } from '@/components/capa/capa-owner-actions'
import { CapaOwnerNotesForm } from '@/components/capa/capa-owner-notes-form' import { CapaOwnerNotesForm } from '@/components/capa/capa-owner-notes-form'
import { StatusTag } from '@/components/ui/status-tag'
const STATUS_LABELS: Record<string, string> = { const STATUS_LABELS: Record<string, string> = {
open: 'Open', open: 'Open',
@@ -20,16 +21,6 @@ const STATUS_LABELS: Record<string, string> = {
closed: 'Closed', closed: 'Closed',
} }
const STATUS_COLORS: Record<string, string> = {
open: 'bg-gray-100 text-gray-700',
in_progress: 'bg-blue-100 text-blue-700',
overdue: 'bg-red-100 text-red-700',
pending_verification: 'bg-purple-100 text-purple-700',
verified: 'bg-green-100 text-green-700',
reopened: 'bg-orange-100 text-orange-700',
closed: 'bg-gray-100 text-gray-500',
}
export default async function CapaOwnerPage() { export default async function CapaOwnerPage() {
const session = await getSession() const session = await getSession()
if (!session) redirect('/login') if (!session) redirect('/login')
@@ -63,9 +54,9 @@ export default async function CapaOwnerPage() {
const doneCount = rows.filter(c => ['verified', 'closed'].includes(c.status)).length const doneCount = rows.filter(c => ['verified', 'closed'].includes(c.status)).length
const PRIORITY_COLORS: Record<string, string> = { const PRIORITY_COLORS: Record<string, string> = {
high: 'text-red-600 font-semibold', high: 'text-accent-700 font-extrabold',
med: 'text-orange-500 font-medium', med: 'text-accent-700 font-medium',
low: 'text-gray-400', low: 'text-ink/50',
} }
const activeRows = rows.filter(c => !['verified', 'closed'].includes(c.status)) const activeRows = rows.filter(c => !['verified', 'closed'].includes(c.status))
@@ -101,9 +92,7 @@ export default async function CapaOwnerPage() {
)} )}
</div> </div>
<div className="shrink-0 text-right space-y-1"> <div className="shrink-0 text-right space-y-1">
<span className={`text-xs rounded-full px-2 py-0.5 ${STATUS_COLORS[capa.status] ?? 'bg-gray-100 text-gray-600'}`}> <StatusTag status={capa.status}>{STATUS_LABELS[capa.status] ?? capa.status}</StatusTag>
{STATUS_LABELS[capa.status] ?? capa.status}
</span>
<p className={`text-xs ${isOverdue ? 'text-red-600 font-semibold' : 'text-gray-400'}`}> <p className={`text-xs ${isOverdue ? 'text-red-600 font-semibold' : 'text-gray-400'}`}>
{capa.dueDate ? `Due ${new Date(capa.dueDate).toLocaleDateString('en-MY')}` : 'No due date'} {capa.dueDate ? `Due ${new Date(capa.dueDate).toLocaleDateString('en-MY')}` : 'No due date'}
</p> </p>
@@ -131,9 +120,7 @@ export default async function CapaOwnerPage() {
{doneRows.map(capa => ( {doneRows.map(capa => (
<div key={capa.id} className="p-4 flex items-center justify-between"> <div key={capa.id} className="p-4 flex items-center justify-between">
<p className="text-sm text-gray-500 line-clamp-1">{capa.description}</p> <p className="text-sm text-gray-500 line-clamp-1">{capa.description}</p>
<span className={`text-xs rounded-full px-2 py-0.5 ml-4 shrink-0 ${STATUS_COLORS[capa.status] ?? 'bg-gray-100'}`}> <span className="shrink-0"><StatusTag status={capa.status}>{STATUS_LABELS[capa.status] ?? capa.status}</StatusTag></span>
{STATUS_LABELS[capa.status] ?? capa.status}
</span>
</div> </div>
))} ))}
</div> </div>
+2 -9
View File
@@ -10,17 +10,12 @@ import { aliasedTable } from 'drizzle-orm'
import { VerifyForm } from '@/components/capa/verify-form' import { VerifyForm } from '@/components/capa/verify-form'
import { CloseCapaButton } from '@/components/capa/close-capa-button' import { CloseCapaButton } from '@/components/capa/close-capa-button'
import { CapaOwnerActions } from '@/components/capa/capa-owner-actions' import { CapaOwnerActions } from '@/components/capa/capa-owner-actions'
import { PriorityTag } from '@/components/ui/status-tag'
interface Props { interface Props {
params: Promise<{ id: string }> params: Promise<{ id: string }>
} }
const PRIORITY_BADGE: Record<string, string> = {
low: 'bg-gray-100 text-gray-600',
med: 'bg-yellow-100 text-yellow-700',
high: 'bg-red-100 text-red-700',
}
export default async function CapaDetailPage({ params }: Props) { export default async function CapaDetailPage({ params }: Props) {
const { id } = await params const { id } = await params
const session = await getSession() const session = await getSession()
@@ -70,9 +65,7 @@ export default async function CapaDetailPage({ params }: Props) {
</p> </p>
<p className="text-gray-900 font-medium">{capa.description}</p> <p className="text-gray-900 font-medium">{capa.description}</p>
</div> </div>
<span className={`px-2 py-1 text-xs font-semibold ${PRIORITY_BADGE[capa.priority] ?? ''}`}> <PriorityTag priority={capa.priority} />
{capa.priority}
</span>
</div> </div>
<div className="grid grid-cols-2 gap-3 text-sm"> <div className="grid grid-cols-2 gap-3 text-sm">
+3 -3
View File
@@ -88,7 +88,7 @@ export default async function ManagementPage() {
const SEVERITY_LABELS: Record<number, string> = { 1: 'Minor', 2: 'Low', 3: 'Moderate', 4: 'Serious', 5: 'Critical' } const SEVERITY_LABELS: Record<number, string> = { 1: 'Minor', 2: 'Low', 3: 'Moderate', 4: 'Serious', 5: 'Critical' }
const SEVERITY_COLORS: Record<number, string> = { const SEVERITY_COLORS: Record<number, string> = {
1: 'bg-green-400', 2: 'bg-yellow-400', 3: 'bg-orange-400', 4: 'bg-red-500', 5: 'bg-red-700', 1: 'bg-neutral-300', 2: 'bg-neutral-500', 3: 'bg-accent-300', 4: 'bg-accent', 5: 'bg-accent-700',
} }
return ( return (
@@ -141,9 +141,9 @@ export default async function ManagementPage() {
{([5, 4, 3, 2, 1] as const).map(sev => ( {([5, 4, 3, 2, 1] as const).map(sev => (
<div key={sev} className="flex items-center gap-3"> <div key={sev} className="flex items-center gap-3">
<span className="text-sm text-gray-600 w-24 shrink-0">{SEVERITY_LABELS[sev]}</span> <span className="text-sm text-gray-600 w-24 shrink-0">{SEVERITY_LABELS[sev]}</span>
<div className="flex-1 bg-gray-100 rounded-full h-3"> <div className="flex-1 bg-gray-100 h-3">
<div <div
className={`h-3 rounded-full ${SEVERITY_COLORS[sev]}`} className={`h-3 ${SEVERITY_COLORS[sev]}`}
style={{ width: severityMax > 0 ? `${(severityDist[sev] / severityMax) * 100}%` : '0%' }} style={{ width: severityMax > 0 ? `${(severityDist[sev] / severityMax) * 100}%` : '0%' }}
/> />
</div> </div>
@@ -6,17 +6,12 @@ import { redirect, notFound } from 'next/navigation'
import { getSession } from '@/lib/auth/get-session' import { getSession } from '@/lib/auth/get-session'
import { incidents, sites, zones, capaActions } from '@/lib/db/schema' import { incidents, sites, zones, capaActions } from '@/lib/db/schema'
import { eq, and } from 'drizzle-orm' import { eq, and } from 'drizzle-orm'
import { StatusTag } from '@/components/ui/status-tag'
const STATUS_LABELS: Record<string, string> = { const STATUS_LABELS: Record<string, string> = {
reported: 'Reported', triaged: 'Triaged', investigating: 'Investigating', reported: 'Reported', triaged: 'Triaged', investigating: 'Investigating',
capa_pending: 'CAPA Pending', verification: 'Verification', closed: 'Closed', capa_pending: 'CAPA Pending', verification: 'Verification', closed: 'Closed',
} }
const STATUS_COLORS: Record<string, string> = {
reported: 'bg-gray-100 text-gray-600', triaged: 'bg-yellow-100 text-yellow-800',
investigating: 'bg-blue-100 text-blue-700', capa_pending: 'bg-orange-100 text-orange-700',
verification: 'bg-purple-100 text-purple-700', closed: 'bg-green-100 text-green-700',
}
export default async function ReporterIncidentDetail({ export default async function ReporterIncidentDetail({
params, params,
}: { }: {
@@ -74,9 +69,7 @@ export default async function ReporterIncidentDetail({
<h1 className="text-lg font-bold text-gray-900">{inc.referenceNo ?? inc.id.slice(0, 8)}</h1> <h1 className="text-lg font-bold text-gray-900">{inc.referenceNo ?? inc.id.slice(0, 8)}</h1>
<p className="text-sm text-gray-500 capitalize">{inc.incidentType?.replace(/_/g, ' ')}</p> <p className="text-sm text-gray-500 capitalize">{inc.incidentType?.replace(/_/g, ' ')}</p>
</div> </div>
<span className={`text-xs rounded-full px-2 py-1 shrink-0 ${STATUS_COLORS[inc.status] ?? 'bg-gray-100 text-gray-600'}`}> <span className="shrink-0"><StatusTag status={inc.status}>{STATUS_LABELS[inc.status] ?? inc.status}</StatusTag></span>
{STATUS_LABELS[inc.status] ?? inc.status}
</span>
</div> </div>
<div className="grid grid-cols-2 gap-3 text-sm mb-4"> <div className="grid grid-cols-2 gap-3 text-sm mb-4">
+2 -12
View File
@@ -6,6 +6,7 @@ import { redirect } from 'next/navigation'
import { getSession } from '@/lib/auth/get-session' import { getSession } from '@/lib/auth/get-session'
import { incidents, sites } from '@/lib/db/schema' import { incidents, sites } from '@/lib/db/schema'
import { eq, desc } from 'drizzle-orm' import { eq, desc } from 'drizzle-orm'
import { StatusTag } from '@/components/ui/status-tag'
const STATUS_LABELS: Record<string, string> = { const STATUS_LABELS: Record<string, string> = {
reported: 'Reported', reported: 'Reported',
@@ -16,15 +17,6 @@ const STATUS_LABELS: Record<string, string> = {
closed: 'Closed', closed: 'Closed',
} }
const STATUS_COLORS: Record<string, string> = {
reported: 'bg-gray-100 text-gray-600',
triaged: 'bg-yellow-100 text-yellow-800',
investigating: 'bg-blue-100 text-blue-700',
capa_pending: 'bg-orange-100 text-orange-700',
verification: 'bg-purple-100 text-purple-700',
closed: 'bg-green-100 text-green-700',
}
const TYPE_LABELS: Record<string, string> = { const TYPE_LABELS: Record<string, string> = {
injury: 'Injury', near_miss: 'Near Miss', hazard: 'Hazard', injury: 'Injury', near_miss: 'Near Miss', hazard: 'Hazard',
asset_damage: 'Asset Damage', environmental: 'Environmental', security: 'Security', fire: 'Fire', asset_damage: 'Asset Damage', environmental: 'Environmental', security: 'Security', fire: 'Fire',
@@ -110,9 +102,7 @@ export default async function ReporterPage() {
</p> </p>
)} )}
</div> </div>
<span className={`text-xs rounded-full px-2 py-0.5 shrink-0 ${STATUS_COLORS[inc.status] ?? 'bg-gray-100 text-gray-600'}`}> <span className="shrink-0"><StatusTag status={inc.status}>{STATUS_LABELS[inc.status] ?? inc.status}</StatusTag></span>
{STATUS_LABELS[inc.status] ?? inc.status}
</span>
</div> </div>
</Link> </Link>
))} ))}
+2 -12
View File
@@ -8,6 +8,7 @@ import { incidents, sites, capaActions, users } from '@/lib/db/schema'
import { eq, not, and, inArray, sql, desc } from 'drizzle-orm' import { eq, not, and, inArray, sql, desc } from 'drizzle-orm'
import { aliasedTable } from 'drizzle-orm' import { aliasedTable } from 'drizzle-orm'
import { StatCard } from '@/components/dashboard/stat-card' import { StatCard } from '@/components/dashboard/stat-card'
import { StatusTag } from '@/components/ui/status-tag'
const STATUS_LABELS: Record<string, string> = { const STATUS_LABELS: Record<string, string> = {
reported: 'Reported', reported: 'Reported',
@@ -18,15 +19,6 @@ const STATUS_LABELS: Record<string, string> = {
closed: 'Closed', closed: 'Closed',
} }
const STATUS_COLORS: Record<string, string> = {
reported: 'bg-gray-100 text-gray-700',
triaged: 'bg-yellow-100 text-yellow-800',
investigating: 'bg-blue-100 text-blue-700',
capa_pending: 'bg-orange-100 text-orange-700',
verification: 'bg-purple-100 text-purple-700',
closed: 'bg-green-100 text-green-700',
}
export default async function SupervisorPage() { export default async function SupervisorPage() {
const session = await getSession() const session = await getSession()
if (!session) redirect('/login') if (!session) redirect('/login')
@@ -149,9 +141,7 @@ export default async function SupervisorPage() {
<p className="text-sm font-medium text-gray-900">{inc.referenceNo ?? inc.id.slice(0, 8)}</p> <p className="text-sm font-medium text-gray-900">{inc.referenceNo ?? inc.id.slice(0, 8)}</p>
<p className="text-xs text-gray-500">{TYPE_LABELS[inc.incidentType] ?? inc.incidentType}</p> <p className="text-xs text-gray-500">{TYPE_LABELS[inc.incidentType] ?? inc.incidentType}</p>
</div> </div>
<span className={`text-xs rounded-full px-2 py-0.5 font-medium ${STATUS_COLORS[inc.status] ?? 'bg-gray-100 text-gray-700'}`}> <StatusTag status={inc.status}>{STATUS_LABELS[inc.status] ?? inc.status}</StatusTag>
{STATUS_LABELS[inc.status] ?? inc.status}
</span>
</Link> </Link>
))} ))}
</div> </div>
+14 -20
View File
@@ -2,6 +2,7 @@
import { useState } from 'react' import { useState } from 'react'
import Link from 'next/link' import Link from 'next/link'
import { PriorityTag } from '@/components/ui/status-tag'
type CapaStatus = 'open' | 'in_progress' | 'overdue' | 'pending_verification' | 'verified' | 'reopened' | 'closed' type CapaStatus = 'open' | 'in_progress' | 'overdue' | 'pending_verification' | 'verified' | 'reopened' | 'closed'
@@ -27,19 +28,14 @@ const STATUS_LABELS: Record<CapaStatus, string> = {
reopened: 'Reopened', reopened: 'Reopened',
closed: 'Closed', closed: 'Closed',
} }
const STATUS_COLORS: Record<CapaStatus, string> = { const COLUMN_BORDER: Record<CapaStatus, string> = {
open: 'bg-blue-50 border-blue-200', open: 'border-divider',
in_progress: 'bg-yellow-50 border-yellow-200', in_progress: 'border-divider',
overdue: 'bg-red-50 border-red-200', overdue: 'border-accent',
pending_verification: 'bg-purple-50 border-purple-200', pending_verification: 'border-divider',
verified: 'bg-green-50 border-green-200', verified: 'border-divider',
reopened: 'bg-orange-50 border-orange-200', reopened: 'border-accent',
closed: 'bg-gray-50 border-gray-200', closed: 'border-divider',
}
const PRIORITY_BADGE: Record<'low' | 'med' | 'high', string> = {
low: 'bg-gray-100 text-gray-600',
med: 'bg-yellow-100 text-yellow-700',
high: 'bg-red-100 text-red-700',
} }
interface Props { interface Props {
@@ -86,9 +82,7 @@ export function CapaBoard({ capas }: Props) {
<td className="py-2 pr-4 text-gray-600">{(c.owner as { name: string } | null)?.name ?? '—'}</td> <td className="py-2 pr-4 text-gray-600">{(c.owner as { name: string } | null)?.name ?? '—'}</td>
<td className="py-2 pr-4 text-gray-600">{c.due_date}</td> <td className="py-2 pr-4 text-gray-600">{c.due_date}</td>
<td className="py-2 pr-4"> <td className="py-2 pr-4">
<span className={`px-2 py-0.5 text-xs font-medium ${PRIORITY_BADGE[c.priority]}`}> <PriorityTag priority={c.priority} />
{c.priority}
</span>
</td> </td>
<td className="py-2 text-gray-600 text-xs">{STATUS_LABELS[c.status]}</td> <td className="py-2 text-gray-600 text-xs">{STATUS_LABELS[c.status]}</td>
</tr> </tr>
@@ -103,12 +97,12 @@ export function CapaBoard({ capas }: Props) {
return ( return (
<div> <div>
<div className="flex justify-end mb-3"> <div className="flex justify-end mb-3">
<button onClick={() => setView('table')} className="text-sm text-blue-600 hover:underline">Table view</button> <button onClick={() => setView('table')} className="text-sm text-accent-700 hover:underline">Table view</button>
</div> </div>
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4"> <div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4">
{STATUS_ORDER.filter(s => s !== 'reopened').map(status => ( {STATUS_ORDER.filter(s => s !== 'reopened').map(status => (
<div key={status} className={`border p-4 ${STATUS_COLORS[status]}`}> <div key={status} className={`border-2 p-4 bg-ground ${COLUMN_BORDER[status]}`}>
<h3 className="text-xs font-semibold uppercase tracking-wide text-gray-600 mb-3"> <h3 className="text-xs font-extrabold uppercase tracking-wide text-ink/70 mb-3 pb-2 border-b-2 border-divider">
{STATUS_LABELS[status]} ({byStatus[status].length}) {STATUS_LABELS[status]} ({byStatus[status].length})
</h3> </h3>
<div className="space-y-2 max-h-96 overflow-y-auto pr-2"> <div className="space-y-2 max-h-96 overflow-y-auto pr-2">
@@ -118,7 +112,7 @@ export function CapaBoard({ capas }: Props) {
<p className="text-sm text-gray-800 line-clamp-2 mb-1">{c.description}</p> <p className="text-sm text-gray-800 line-clamp-2 mb-1">{c.description}</p>
<div className="flex items-center justify-between text-xs text-gray-500"> <div className="flex items-center justify-between text-xs text-gray-500">
<span>{(c.owner as { name: string } | null)?.name ?? '—'}</span> <span>{(c.owner as { name: string } | null)?.name ?? '—'}</span>
<span className={`px-1.5 py-0.5 ${PRIORITY_BADGE[c.priority]}`}>{c.priority}</span> <PriorityTag priority={c.priority} />
</div> </div>
<p className="text-xs text-gray-400 mt-1">Due {c.due_date}</p> <p className="text-xs text-gray-400 mt-1">Due {c.due_date}</p>
</Link> </Link>
+3 -3
View File
@@ -11,9 +11,9 @@ type RiskFlag = {
} }
const LEVEL_COLORS: Record<RiskFlag['risk_level'], string> = { const LEVEL_COLORS: Record<RiskFlag['risk_level'], string> = {
low: 'bg-yellow-50 text-yellow-700 border-yellow-200', low: 'bg-neutral-100 text-neutral-800 border-divider',
medium: 'bg-orange-50 text-orange-700 border-orange-200', medium: 'bg-ground text-accent-700 border-accent',
high: 'bg-red-50 text-red-700 border-red-200', high: 'bg-accent-100 text-accent-800 border-accent',
} }
export function RiskFlagsPanel() { export function RiskFlagsPanel() {
+2 -12
View File
@@ -1,4 +1,5 @@
import { EvidenceGallery } from './evidence-gallery' import { EvidenceGallery } from './evidence-gallery'
import { StatusTag } from '@/components/ui/status-tag'
const TYPE_LABELS: Record<string, string> = { const TYPE_LABELS: Record<string, string> = {
injury: 'Injury / Medical', injury: 'Injury / Medical',
@@ -11,15 +12,6 @@ const TYPE_LABELS: Record<string, string> = {
transport: 'Transport / Vehicle', transport: 'Transport / Vehicle',
} }
const STATUS_COLORS: Record<string, string> = {
reported: 'bg-yellow-100 text-yellow-800',
triaged: 'bg-blue-100 text-blue-800',
investigating: 'bg-purple-100 text-purple-800',
capa_pending: 'bg-orange-100 text-orange-800',
verification: 'bg-indigo-100 text-indigo-800',
closed: 'bg-green-100 text-green-800',
}
const MEDICAL_LABELS: Record<string, string> = { const MEDICAL_LABELS: Record<string, string> = {
none: 'None', none: 'None',
first_aid: 'First Aid', first_aid: 'First Aid',
@@ -80,9 +72,7 @@ export function IncidentDetail({ incident }: Props) {
</h1> </h1>
<p className="text-sm text-gray-600 mt-0.5">{TYPE_LABELS[incident.incident_type] ?? incident.incident_type}</p> <p className="text-sm text-gray-600 mt-0.5">{TYPE_LABELS[incident.incident_type] ?? incident.incident_type}</p>
</div> </div>
<span className={`text-xs px-2.5 py-1 rounded-full font-medium ${STATUS_COLORS[incident.status] ?? 'bg-gray-100'}`}> <StatusTag status={incident.status}>{incident.status.replace(/_/g, ' ').toUpperCase()}</StatusTag>
{incident.status.replace(/_/g, ' ').toUpperCase()}
</span>
</div> </div>
<dl className="grid grid-cols-2 gap-4 sm:grid-cols-3"> <dl className="grid grid-cols-2 gap-4 sm:grid-cols-3">
+2 -12
View File
@@ -1,6 +1,7 @@
'use client' 'use client'
import Link from 'next/link' import Link from 'next/link'
import { StatusTag } from '@/components/ui/status-tag'
interface Props { interface Props {
incidentId: string incidentId: string
@@ -12,15 +13,6 @@ interface Props {
canAddCapa?: boolean canAddCapa?: boolean
} }
const STATUS_COLORS: Record<string, string> = {
reported: 'bg-yellow-100 text-yellow-800',
triaged: 'bg-blue-100 text-blue-800',
investigating: 'bg-purple-100 text-purple-800',
capa_pending: 'bg-orange-100 text-orange-800',
verification: 'bg-indigo-100 text-indigo-800',
closed: 'bg-green-100 text-green-800',
}
const STATUS_LABELS: Record<string, string> = { const STATUS_LABELS: Record<string, string> = {
reported: 'Reported', reported: 'Reported',
triaged: 'Triaged', triaged: 'Triaged',
@@ -45,9 +37,7 @@ export function IncidentHeader({
<span className="text-sm font-mono font-semibold text-gray-900 truncate"> <span className="text-sm font-mono font-semibold text-gray-900 truncate">
{referenceNo ?? 'Pending'} {referenceNo ?? 'Pending'}
</span> </span>
<span className={`text-xs px-2 py-0.5 rounded-full font-medium shrink-0 ${STATUS_COLORS[status] ?? 'bg-gray-100 text-gray-800'}`}> <span className="shrink-0"><StatusTag status={status}>{STATUS_LABELS[status] ?? status.replace(/_/g, ' ')}</StatusTag></span>
{STATUS_LABELS[status] ?? status.replace(/_/g, ' ')}
</span>
</div> </div>
<div className="flex gap-2 shrink-0"> <div className="flex gap-2 shrink-0">
{canTriage && ( {canTriage && (
+4 -12
View File
@@ -2,6 +2,7 @@
import { useState } from 'react' import { useState } from 'react'
import Link from 'next/link' import Link from 'next/link'
import { StatusTag } from '@/components/ui/status-tag'
const TYPE_LABELS: Record<string, string> = { const TYPE_LABELS: Record<string, string> = {
injury: 'Injury / Medical', injury: 'Injury / Medical',
@@ -14,14 +15,7 @@ const TYPE_LABELS: Record<string, string> = {
transport: 'Transport / Vehicle', transport: 'Transport / Vehicle',
} }
const STATUS_COLORS: Record<string, string> = { const STATUS_ORDER = ['reported', 'triaged', 'investigating', 'capa_pending', 'verification', 'closed'] as const
reported: 'bg-yellow-100 text-yellow-800',
triaged: 'bg-blue-100 text-blue-800',
investigating: 'bg-purple-100 text-purple-800',
capa_pending: 'bg-orange-100 text-orange-800',
verification: 'bg-indigo-100 text-indigo-800',
closed: 'bg-green-100 text-green-800',
}
export type Incident = { export type Incident = {
id: string id: string
@@ -86,7 +80,7 @@ export function IncidentList({ incidents, basePath }: Props) {
onChange={e => setStatusFilter(e.target.value)} onChange={e => setStatusFilter(e.target.value)}
> >
<option value="">All statuses</option> <option value="">All statuses</option>
{Object.keys(STATUS_COLORS).map(s => ( {STATUS_ORDER.map(s => (
<option key={s} value={s}>{s.replace(/_/g, ' ')}</option> <option key={s} value={s}>{s.replace(/_/g, ' ')}</option>
))} ))}
</select> </select>
@@ -107,9 +101,7 @@ export function IncidentList({ incidents, basePath }: Props) {
<span className="font-mono text-sm font-semibold text-gray-900"> <span className="font-mono text-sm font-semibold text-gray-900">
{inc.reference_no ?? '—'} {inc.reference_no ?? '—'}
</span> </span>
<span className={`text-xs px-2 py-0.5 rounded-full font-medium ${STATUS_COLORS[inc.status] ?? 'bg-gray-100 text-gray-700'}`}> <StatusTag status={inc.status}>{inc.status.replace(/_/g, ' ').toUpperCase()}</StatusTag>
{inc.status.replace(/_/g, ' ').toUpperCase()}
</span>
</div> </div>
<div className="text-sm text-gray-600"> <div className="text-sm text-gray-600">
{TYPE_LABELS[inc.incident_type] ?? inc.incident_type} {TYPE_LABELS[inc.incident_type] ?? inc.incident_type}
@@ -42,7 +42,7 @@
- `app/layout.tsx` — Archivo replaces Geist - `app/layout.tsx` — Archivo replaces Geist
- `package.json` — `lucide-react`, `check:design` script - `package.json` — `lucide-react`, `check:design` script
- `components/ui/modal.tsx`, `components/layout/sidebar.tsx`, `components/notifications/bell.tsx`, `app/(protected)/layout.tsx` - `components/ui/modal.tsx`, `components/layout/sidebar.tsx`, `components/notifications/bell.tsx`, `app/(protected)/layout.tsx`
- 10 files holding status, priority or severity color maps (listed in Task 6) - 11 files holding status, priority or severity color maps (listed in Task 6)
- All remaining TSX files flagged by the gate script (Task 7) - All remaining TSX files flagged by the gate script (Task 7)
- `CLAUDE.md`, plus memory file `ims-design-system.md` and `MEMORY.md` index (Task 8) - `CLAUDE.md`, plus memory file `ims-design-system.md` and `MEMORY.md` index (Task 8)
@@ -1401,7 +1401,7 @@ Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>"
### Task 6: Replace scattered status, priority and severity color maps ### Task 6: Replace scattered status, priority and severity color maps
**Files (10), each holds a color map to delete or replace:** **Files (11), each holds a color map to delete or replace:**
- `app/(protected)/reporter/page.tsx` (`STATUS_COLORS`, used ~line 113) - `app/(protected)/reporter/page.tsx` (`STATUS_COLORS`, used ~line 113)
- `app/(protected)/reporter/incidents/[id]/page.tsx` (`STATUS_COLORS`, ~line 77) - `app/(protected)/reporter/incidents/[id]/page.tsx` (`STATUS_COLORS`, ~line 77)
- `app/(protected)/supervisor/page.tsx` (`STATUS_COLORS`, ~line 152) - `app/(protected)/supervisor/page.tsx` (`STATUS_COLORS`, ~line 152)
@@ -1412,6 +1412,7 @@ Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>"
- `components/incidents/incident-header.tsx` (`STATUS_COLORS`, ~line 48) - `components/incidents/incident-header.tsx` (`STATUS_COLORS`, ~line 48)
- `components/capa/capa-board.tsx` (`STATUS_COLORS`, `PRIORITY_BADGE`) - `components/capa/capa-board.tsx` (`STATUS_COLORS`, `PRIORITY_BADGE`)
- `components/dashboard/risk-flags-panel.tsx` (`LEVEL_COLORS`) - `components/dashboard/risk-flags-panel.tsx` (`LEVEL_COLORS`)
- `app/(protected)/hse/capa/[id]/page.tsx` (`PRIORITY_BADGE`, found during execution; the CAPA board table view also used `PRIORITY_BADGE`)
- Test: `tests/components/incidents/incident-list.test.tsx` (existing, must keep passing) - Test: `tests/components/incidents/incident-list.test.tsx` (existing, must keep passing)
**Interfaces:** **Interfaces:**