import React, { useState } from 'react'; const s = { wrapper: { marginTop: '24px' }, title: { color: '#b5b5c0', fontSize: '16px', fontWeight: 700, marginBottom: '10px' }, table: { width: '100%', borderCollapse: 'collapse', fontSize: '13px', background: '#111217', borderRadius: '6px', overflow: 'hidden', border: '1px solid #222' }, th: { background: '#000000', color: '#f8f9fa', padding: '8px 10px', textAlign: 'left', fontSize: '12px', fontWeight: 600, textTransform: 'uppercase', letterSpacing: '0.5px' }, td: { padding: '8px 10px', borderBottom: '1px solid #1c1d29', color: '#f8f9fa', verticalAlign: 'middle' }, trEven: { background: '#111217' }, trOdd: { background: '#151622' }, pts: { fontWeight: 700, color: '#667eea' }, toggle: { background: 'none', border: 'none', color: '#667eea', cursor: 'pointer', fontSize: '13px', padding: 0, textDecoration: 'underline' }, empty: { color: '#77798a', fontStyle: 'italic', fontSize: '13px', marginTop: '8px' }, }; function formatDate(d) { if (!d) return '–'; const dt = new Date(d + 'T12:00:00'); return dt.toLocaleDateString('en-US', { year: 'numeric', month: 'short', day: 'numeric', timeZone: 'America/Chicago' }); } export default function ViolationHistory({ history, loading }) { const [expanded, setExpanded] = useState(false); const visible = expanded ? history : history.slice(0, 5); if (loading) return
Loading history...
; if (!history.length) returnNo violations on record for this employee.
; return (| Date | Violation | Category | Points | Details |
|---|---|---|---|---|
| {formatDate(v.incident_date)} | {v.violation_name} | {v.category} | {v.points} | {v.details || '–'} |