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:
@@ -9,6 +9,7 @@ import { eq, asc } from 'drizzle-orm'
|
||||
import { StatCard } from '@/components/dashboard/stat-card'
|
||||
import { CapaOwnerActions } from '@/components/capa/capa-owner-actions'
|
||||
import { CapaOwnerNotesForm } from '@/components/capa/capa-owner-notes-form'
|
||||
import { StatusTag } from '@/components/ui/status-tag'
|
||||
|
||||
const STATUS_LABELS: Record<string, string> = {
|
||||
open: 'Open',
|
||||
@@ -20,16 +21,6 @@ const STATUS_LABELS: Record<string, string> = {
|
||||
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() {
|
||||
const session = await getSession()
|
||||
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 PRIORITY_COLORS: Record<string, string> = {
|
||||
high: 'text-red-600 font-semibold',
|
||||
med: 'text-orange-500 font-medium',
|
||||
low: 'text-gray-400',
|
||||
high: 'text-accent-700 font-extrabold',
|
||||
med: 'text-accent-700 font-medium',
|
||||
low: 'text-ink/50',
|
||||
}
|
||||
|
||||
const activeRows = rows.filter(c => !['verified', 'closed'].includes(c.status))
|
||||
@@ -101,9 +92,7 @@ export default async function CapaOwnerPage() {
|
||||
)}
|
||||
</div>
|
||||
<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'}`}>
|
||||
{STATUS_LABELS[capa.status] ?? capa.status}
|
||||
</span>
|
||||
<StatusTag status={capa.status}>{STATUS_LABELS[capa.status] ?? capa.status}</StatusTag>
|
||||
<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'}
|
||||
</p>
|
||||
@@ -131,9 +120,7 @@ export default async function CapaOwnerPage() {
|
||||
{doneRows.map(capa => (
|
||||
<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>
|
||||
<span className={`text-xs rounded-full px-2 py-0.5 ml-4 shrink-0 ${STATUS_COLORS[capa.status] ?? 'bg-gray-100'}`}>
|
||||
{STATUS_LABELS[capa.status] ?? capa.status}
|
||||
</span>
|
||||
<span className="shrink-0"><StatusTag status={capa.status}>{STATUS_LABELS[capa.status] ?? capa.status}</StatusTag></span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
@@ -10,17 +10,12 @@ import { aliasedTable } from 'drizzle-orm'
|
||||
import { VerifyForm } from '@/components/capa/verify-form'
|
||||
import { CloseCapaButton } from '@/components/capa/close-capa-button'
|
||||
import { CapaOwnerActions } from '@/components/capa/capa-owner-actions'
|
||||
import { PriorityTag } from '@/components/ui/status-tag'
|
||||
|
||||
interface Props {
|
||||
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) {
|
||||
const { id } = await params
|
||||
const session = await getSession()
|
||||
@@ -70,9 +65,7 @@ export default async function CapaDetailPage({ params }: Props) {
|
||||
</p>
|
||||
<p className="text-gray-900 font-medium">{capa.description}</p>
|
||||
</div>
|
||||
<span className={`px-2 py-1 text-xs font-semibold ${PRIORITY_BADGE[capa.priority] ?? ''}`}>
|
||||
{capa.priority}
|
||||
</span>
|
||||
<PriorityTag priority={capa.priority} />
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-2 gap-3 text-sm">
|
||||
|
||||
@@ -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_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 (
|
||||
@@ -141,9 +141,9 @@ export default async function ManagementPage() {
|
||||
{([5, 4, 3, 2, 1] as const).map(sev => (
|
||||
<div key={sev} className="flex items-center gap-3">
|
||||
<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
|
||||
className={`h-3 rounded-full ${SEVERITY_COLORS[sev]}`}
|
||||
className={`h-3 ${SEVERITY_COLORS[sev]}`}
|
||||
style={{ width: severityMax > 0 ? `${(severityDist[sev] / severityMax) * 100}%` : '0%' }}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -6,17 +6,12 @@ import { redirect, notFound } from 'next/navigation'
|
||||
import { getSession } from '@/lib/auth/get-session'
|
||||
import { incidents, sites, zones, capaActions } from '@/lib/db/schema'
|
||||
import { eq, and } from 'drizzle-orm'
|
||||
import { StatusTag } from '@/components/ui/status-tag'
|
||||
|
||||
const STATUS_LABELS: Record<string, string> = {
|
||||
reported: 'Reported', triaged: 'Triaged', investigating: 'Investigating',
|
||||
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({
|
||||
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>
|
||||
<p className="text-sm text-gray-500 capitalize">{inc.incidentType?.replace(/_/g, ' ')}</p>
|
||||
</div>
|
||||
<span className={`text-xs rounded-full px-2 py-1 shrink-0 ${STATUS_COLORS[inc.status] ?? 'bg-gray-100 text-gray-600'}`}>
|
||||
{STATUS_LABELS[inc.status] ?? inc.status}
|
||||
</span>
|
||||
<span className="shrink-0"><StatusTag status={inc.status}>{STATUS_LABELS[inc.status] ?? inc.status}</StatusTag></span>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-2 gap-3 text-sm mb-4">
|
||||
|
||||
@@ -6,6 +6,7 @@ import { redirect } from 'next/navigation'
|
||||
import { getSession } from '@/lib/auth/get-session'
|
||||
import { incidents, sites } from '@/lib/db/schema'
|
||||
import { eq, desc } from 'drizzle-orm'
|
||||
import { StatusTag } from '@/components/ui/status-tag'
|
||||
|
||||
const STATUS_LABELS: Record<string, string> = {
|
||||
reported: 'Reported',
|
||||
@@ -16,15 +17,6 @@ const STATUS_LABELS: Record<string, string> = {
|
||||
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> = {
|
||||
injury: 'Injury', near_miss: 'Near Miss', hazard: 'Hazard',
|
||||
asset_damage: 'Asset Damage', environmental: 'Environmental', security: 'Security', fire: 'Fire',
|
||||
@@ -110,9 +102,7 @@ export default async function ReporterPage() {
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
<span className={`text-xs rounded-full px-2 py-0.5 shrink-0 ${STATUS_COLORS[inc.status] ?? 'bg-gray-100 text-gray-600'}`}>
|
||||
{STATUS_LABELS[inc.status] ?? inc.status}
|
||||
</span>
|
||||
<span className="shrink-0"><StatusTag status={inc.status}>{STATUS_LABELS[inc.status] ?? inc.status}</StatusTag></span>
|
||||
</div>
|
||||
</Link>
|
||||
))}
|
||||
|
||||
@@ -8,6 +8,7 @@ import { incidents, sites, capaActions, users } from '@/lib/db/schema'
|
||||
import { eq, not, and, inArray, sql, desc } from 'drizzle-orm'
|
||||
import { aliasedTable } from 'drizzle-orm'
|
||||
import { StatCard } from '@/components/dashboard/stat-card'
|
||||
import { StatusTag } from '@/components/ui/status-tag'
|
||||
|
||||
const STATUS_LABELS: Record<string, string> = {
|
||||
reported: 'Reported',
|
||||
@@ -18,15 +19,6 @@ const STATUS_LABELS: Record<string, string> = {
|
||||
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() {
|
||||
const session = await getSession()
|
||||
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-xs text-gray-500">{TYPE_LABELS[inc.incidentType] ?? inc.incidentType}</p>
|
||||
</div>
|
||||
<span className={`text-xs rounded-full px-2 py-0.5 font-medium ${STATUS_COLORS[inc.status] ?? 'bg-gray-100 text-gray-700'}`}>
|
||||
{STATUS_LABELS[inc.status] ?? inc.status}
|
||||
</span>
|
||||
<StatusTag status={inc.status}>{STATUS_LABELS[inc.status] ?? inc.status}</StatusTag>
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user