Author SHA1 Message Date
adminandClaude Haiku 4.5 397f4900b0 docs: update - Supabase migration complete to local postgres
Database migrated Sep 30 2026. Production now uses local postgres at 127.0.0.1:5433.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-09-30 12:58:16 +08:00
91 changed files with 632 additions and 3819 deletions
-3
View File
@@ -51,6 +51,3 @@ graphify-out/
# iCloud sync conflict copies ("name 2.ext") # iCloud sync conflict copies ("name 2.ext")
* 2.* * 2.*
# local scratch (data exports, deploy archives)
tmp/
-15
View File
@@ -62,21 +62,6 @@ IMS/
- `[[phases]]` — 4 phases + deliverables, current phase - `[[phases]]` — 4 phases + deliverables, current phase
- `[[compliance]]` — NADOPOD 2004, JKKP 6/7/8 rules - `[[compliance]]` — NADOPOD 2004, JKKP 6/7/8 rules
## Design system (Modernist)
Source of truth: the Modernist `readme.md` and `styles.css` under `design-system/_ds/`. Tokens live in `app/globals.css` (`@theme static`). Do not use `design-system/IMS Admin.dc.html` as a style reference.
- Flat and architectural: Archivo, ink on a `#f3f2f2` ground, one accent `#ec3013`. Zero corner radius, visible grid, strong 2px rules between major sections (`border-divider`, `border-b-2`).
- Use tokens, never hard-coded hex, font names or px values the tokens carry: `bg-ground`, `bg-surface`, `text-ink`, `bg-accent`, `border-divider`, `accent-100…900`, `neutral-100…900`. `gray-*`, `blue-*` and `red-*` are remapped onto the neutral and accent ramps.
- No `rounded-*` (except circular avatars, allowlisted in `scripts/check-design-gates.mjs`). Labels and headings are flush left, including button labels. No centered hero copy.
- Body-size accent text uses `accent-700`; the accent itself is for buttons, icons and large text.
- Icons: Lucide (`lucide-react`). Interaction: hover tint, pressed step from the accent ramp, `:focus-visible` 2px accent ring (global), disabled at 45% opacity.
- Build UI with `components/ui/*`: `Button`, `Tag`, `StatusTag`, `PriorityTag`, `Field`/`Input`/`Select`/`Textarea`, `Card`, `Modal`, and the `TABLE/TH/TR/TD` class constants.
- Status is never color alone. Needs attention, open, overdue, reported or severity 4-5 = accent tag; in progress = outline tag; done, closed, verified, low = neutral tag. Always keep the text label and an icon. Add new statuses in `components/ui/status-tag.tsx`, not per page.
- Incident evidence photos stay full color. `.grayscale` is for decorative photography only.
- Gotcha: never write `*/` inside a CSS comment in `globals.css` (for example a glob like `modernist-*/`); it ends the comment and silently swallows the `@theme` block.
- Run `npm run check:design` before committing UI changes; it must print `design gates: clean`.
## graphify ## graphify
When graphify-out/graph.json exists: When graphify-out/graph.json exists:
- Run `graphify query "<question>"` before browsing source. - Run `graphify query "<question>"` before browsing source.
+4 -4
View File
@@ -32,7 +32,7 @@ export default function ForgotPasswordPage() {
<p className="text-sm text-gray-500"> <p className="text-sm text-gray-500">
If an account exists for <strong>{email}</strong>, a password reset link has been sent. If an account exists for <strong>{email}</strong>, a password reset link has been sent.
</p> </p>
<Link href="/login" className="text-sm text-accent-700 hover:underline"> <Link href="/login" className="text-sm text-blue-600 hover:underline">
Back to sign in Back to sign in
</Link> </Link>
</div> </div>
@@ -57,19 +57,19 @@ export default function ForgotPasswordPage() {
onChange={e => setEmail(e.target.value)} onChange={e => setEmail(e.target.value)}
required required
autoComplete="email" autoComplete="email"
className="border border-divider px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-accent" className="border border-gray-300 rounded-md px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"
/> />
<button <button
type="submit" type="submit"
disabled={loading} disabled={loading}
className="bg-accent hover:bg-accent-600 text-white font-medium py-2 disabled:opacity-50 transition-colors" className="bg-blue-600 hover:bg-blue-700 text-white font-medium py-2 rounded-md disabled:opacity-50 transition-colors"
> >
{loading ? 'Sending…' : 'Send reset link'} {loading ? 'Sending…' : 'Send reset link'}
</button> </button>
<p className="text-center text-sm text-gray-500"> <p className="text-center text-sm text-gray-500">
<Link href="/login" className="text-accent-700 hover:underline"> <Link href="/login" className="text-blue-600 hover:underline">
Back to sign in Back to sign in
</Link> </Link>
</p> </p>
+3 -3
View File
@@ -8,13 +8,13 @@ interface Props {
export default async function LoginPage({ searchParams }: Props) { export default async function LoginPage({ searchParams }: Props) {
const { message } = await searchParams const { message } = await searchParams
return ( return (
<main className="min-h-screen flex items-center justify-center bg-ground p-4"> <main className="min-h-screen flex items-center justify-center bg-gray-50 p-4">
{message === 'password_reset' && ( {message === 'password_reset' && (
<div className="fixed top-4 left-1/2 -translate-x-1/2 bg-neutral-100 border border-divider text-ink text-sm px-4 py-2 shadow"> <div className="fixed top-4 left-1/2 -translate-x-1/2 bg-green-50 border border-green-200 text-green-700 text-sm rounded px-4 py-2 shadow">
Password updated — sign in with your new password. Password updated — sign in with your new password.
</div> </div>
)} )}
<div className="bg-surface border-2 border-divider p-8 w-full max-w-sm"> <div className="bg-white rounded-xl shadow-sm border p-8 w-full max-w-sm">
<LoginForm /> <LoginForm />
</div> </div>
</main> </main>
+4 -4
View File
@@ -50,7 +50,7 @@ export default function ResetPasswordPage() {
</div> </div>
{error && ( {error && (
<p className="bg-red-50 border border-red-200 text-red-700 text-sm px-3 py-2"> <p className="bg-red-50 border border-red-200 text-red-700 text-sm rounded px-3 py-2">
{error}{' '} {error}{' '}
{error.includes('expired') && ( {error.includes('expired') && (
<Link href="/forgot-password" className="underline"> <Link href="/forgot-password" className="underline">
@@ -68,7 +68,7 @@ export default function ResetPasswordPage() {
required required
minLength={8} minLength={8}
autoComplete="new-password" autoComplete="new-password"
className="border border-divider px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-accent" className="border border-gray-300 rounded-md px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"
/> />
<input <input
type="password" type="password"
@@ -77,13 +77,13 @@ export default function ResetPasswordPage() {
onChange={e => setConfirm(e.target.value)} onChange={e => setConfirm(e.target.value)}
required required
autoComplete="new-password" autoComplete="new-password"
className="border border-divider px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-accent" className="border border-gray-300 rounded-md px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"
/> />
<button <button
type="submit" type="submit"
disabled={loading} disabled={loading}
className="bg-accent hover:bg-accent-600 text-white font-medium py-2 disabled:opacity-50 transition-colors" className="bg-blue-600 hover:bg-blue-700 text-white font-medium py-2 rounded-md disabled:opacity-50 transition-colors"
> >
{loading ? 'Saving…' : 'Set password'} {loading ? 'Saving…' : 'Set password'}
</button> </button>
+1 -1
View File
@@ -57,7 +57,7 @@ export default async function AdminHome() {
<p className="text-sm text-gray-500 mt-0.5">Manage users, sites, zones, and trucks</p> <p className="text-sm text-gray-500 mt-0.5">Manage users, sites, zones, and trucks</p>
</div> </div>
<div className="mb-6 flex gap-3"> <div className="mb-6 flex gap-3">
<Link href="/bulk-import" className="px-4 py-2 bg-accent text-white text-sm font-medium hover:bg-accent-600"> <Link href="/bulk-import" className="px-4 py-2 bg-green-600 text-white rounded-lg text-sm font-medium hover:bg-green-700">
Bulk Import Incidents Bulk Import Incidents
</Link> </Link>
</div> </div>
+23 -10
View File
@@ -9,7 +9,6 @@ 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',
@@ -21,6 +20,16 @@ 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')
@@ -54,9 +63,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-accent-700 font-extrabold', high: 'text-red-600 font-semibold',
med: 'text-accent-700 font-medium', med: 'text-orange-500 font-medium',
low: 'text-ink/50', low: 'text-gray-400',
} }
const activeRows = rows.filter(c => !['verified', 'closed'].includes(c.status)) const activeRows = rows.filter(c => !['verified', 'closed'].includes(c.status))
@@ -73,11 +82,11 @@ export default async function CapaOwnerPage() {
</div> </div>
{activeRows.length === 0 ? ( {activeRows.length === 0 ? (
<div className="bg-surface shadow-sm p-8 text-center"> <div className="bg-white rounded-xl shadow-sm p-8 text-center">
<p className="text-gray-400 text-sm">No active CAPAs assigned to you.</p> <p className="text-gray-400 text-sm">No active CAPAs assigned to you.</p>
</div> </div>
) : ( ) : (
<div className="bg-surface shadow-sm divide-y divide-gray-50"> <div className="bg-white rounded-xl shadow-sm divide-y divide-gray-50">
{activeRows.map(capa => { {activeRows.map(capa => {
const isOverdue = isCapaOverdue(capa) const isOverdue = isCapaOverdue(capa)
return ( return (
@@ -86,13 +95,15 @@ export default async function CapaOwnerPage() {
<div className="flex-1 min-w-0"> <div className="flex-1 min-w-0">
<p className="text-sm text-gray-800">{capa.description}</p> <p className="text-sm text-gray-800">{capa.description}</p>
{capa.incidentRefNo && ( {capa.incidentRefNo && (
<Link href={`/hse/incidents/${capa.incidentId}`} className="text-xs text-accent-700 hover:underline mt-0.5 inline-block"> <Link href={`/hse/incidents/${capa.incidentId}`} className="text-xs text-blue-600 hover:underline mt-0.5 inline-block">
{capa.incidentRefNo} {capa.incidentRefNo}
</Link> </Link>
)} )}
</div> </div>
<div className="shrink-0 text-right space-y-1"> <div className="shrink-0 text-right space-y-1">
<StatusTag status={capa.status}>{STATUS_LABELS[capa.status] ?? capa.status}</StatusTag> <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>
<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>
@@ -116,11 +127,13 @@ export default async function CapaOwnerPage() {
{doneRows.length > 0 && ( {doneRows.length > 0 && (
<div className="mt-6"> <div className="mt-6">
<h2 className="text-xs font-semibold text-gray-400 uppercase tracking-wide mb-2">Completed ({doneCount})</h2> <h2 className="text-xs font-semibold text-gray-400 uppercase tracking-wide mb-2">Completed ({doneCount})</h2>
<div className="bg-surface shadow-sm divide-y divide-gray-50 opacity-60"> <div className="bg-white rounded-xl shadow-sm divide-y divide-gray-50 opacity-60">
{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="shrink-0"><StatusTag status={capa.status}>{STATUS_LABELS[capa.status] ?? capa.status}</StatusTag></span> <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>
</div> </div>
))} ))}
</div> </div>
+11 -4
View File
@@ -10,12 +10,17 @@ 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()
@@ -53,11 +58,11 @@ export default async function CapaDetailPage({ params }: Props) {
return ( return (
<main className="max-w-2xl mx-auto px-4 py-6"> <main className="max-w-2xl mx-auto px-4 py-6">
<Link href="/hse/capa" className="text-sm text-accent-700 hover:underline mb-4 inline-block"> <Link href="/hse/capa" className="text-sm text-blue-600 hover:underline mb-4 inline-block">
← CAPA Board ← CAPA Board
</Link> </Link>
<div className="bg-surface shadow-sm p-5 mb-4 space-y-4"> <div className="bg-white rounded-xl shadow-sm p-5 mb-4 space-y-4">
<div className="flex items-start justify-between"> <div className="flex items-start justify-between">
<div> <div>
<p className="text-xs text-gray-500 mb-1"> <p className="text-xs text-gray-500 mb-1">
@@ -65,7 +70,9 @@ 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>
<PriorityTag priority={capa.priority} /> <span className={`px-2 py-1 rounded text-xs font-semibold ${PRIORITY_BADGE[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">
+1 -1
View File
@@ -52,7 +52,7 @@ export default async function CapaListPage() {
<main className="max-w-6xl mx-auto px-4 py-6"> <main className="max-w-6xl mx-auto px-4 py-6">
<div className="flex items-center justify-between mb-6"> <div className="flex items-center justify-between mb-6">
<h1 className="text-2xl font-bold text-gray-900">CAPA Board</h1> <h1 className="text-2xl font-bold text-gray-900">CAPA Board</h1>
<Link href="/hse/incidents" className="text-sm text-accent-700 hover:underline"> <Link href="/hse/incidents" className="text-sm text-blue-600 hover:underline">
← Incidents ← Incidents
</Link> </Link>
</div> </div>
+23 -23
View File
@@ -165,17 +165,17 @@ export default async function HseDashboardPage({
<div className="flex gap-3"> <div className="flex gap-3">
<a <a
href="/api/dashboard/export?role=hse" href="/api/dashboard/export?role=hse"
className="text-sm text-gray-500 hover:text-gray-700 border border-divider px-3 py-1.5" className="text-sm text-gray-500 hover:text-gray-700 border border-gray-200 rounded-lg px-3 py-1.5"
> >
Export CSV Export CSV
</a> </a>
<a <a
href={`/api/reports/jkkp8?year=${now.getFullYear()}`} href={`/api/reports/jkkp8?year=${now.getFullYear()}`}
className="text-sm text-gray-500 hover:text-gray-700 border border-divider px-3 py-1.5" className="text-sm text-gray-500 hover:text-gray-700 border border-gray-200 rounded-lg px-3 py-1.5"
> >
JKKP 8 JKKP 8
</a> </a>
<Link href="/hse/incidents" className="text-sm text-accent-700 hover:underline"> <Link href="/hse/incidents" className="text-sm text-blue-600 hover:underline">
All incidents → All incidents →
</Link> </Link>
</div> </div>
@@ -187,8 +187,8 @@ export default async function HseDashboardPage({
{(tab === 'overview') && ( {(tab === 'overview') && (
<> <>
{now.getMonth() === 0 && ( {now.getMonth() === 0 && (
<div className="bg-accent-100 border border-accent-300 p-4 mb-6"> <div className="bg-amber-50 border border-amber-200 rounded-xl p-4 mb-6">
<p className="text-sm text-accent-700"> <p className="text-sm text-amber-800">
<strong>JKKP 8 annual register due:</strong> the {now.getFullYear() - 1} register must be <strong>JKKP 8 annual register due:</strong> the {now.getFullYear() - 1} register must be
submitted to DOSH before 31 January {now.getFullYear()}.{' '} submitted to DOSH before 31 January {now.getFullYear()}.{' '}
<a href={`/api/reports/jkkp8?year=${now.getFullYear() - 1}`} className="underline font-medium"> <a href={`/api/reports/jkkp8?year=${now.getFullYear() - 1}`} className="underline font-medium">
@@ -210,7 +210,7 @@ export default async function HseDashboardPage({
/> />
</div> </div>
<div className="bg-surface shadow-sm p-5"> <div className="bg-white rounded-xl shadow-sm p-5">
<h2 className="text-sm font-semibold text-gray-900 mb-1"> <h2 className="text-sm font-semibold text-gray-900 mb-1">
Leading vs Lagging — Last 30 Days Leading vs Lagging — Last 30 Days
</h2> </h2>
@@ -218,18 +218,18 @@ export default async function HseDashboardPage({
Leading: hazard + near-miss reports (predict risk) · Lagging: injuries (past harm) Leading: hazard + near-miss reports (predict risk) · Lagging: injuries (past harm)
</p> </p>
<div className="flex gap-4"> <div className="flex gap-4">
<div className="flex-1 text-center bg-neutral-100 p-4"> <div className="flex-1 text-center bg-blue-50 rounded-lg p-4">
<p className="text-3xl font-bold text-accent-700">{leadingCount}</p> <p className="text-3xl font-bold text-blue-600">{leadingCount}</p>
<p className="text-xs text-accent-700 mt-1">Leading (Hazards + Near Misses)</p> <p className="text-xs text-blue-700 mt-1">Leading (Hazards + Near Misses)</p>
</div> </div>
<div className="flex-1 text-center bg-red-50 p-4"> <div className="flex-1 text-center bg-red-50 rounded-lg p-4">
<p className="text-3xl font-bold text-red-600">{laggingCount}</p> <p className="text-3xl font-bold text-red-600">{laggingCount}</p>
<p className="text-xs text-red-700 mt-1">Lagging (Injuries)</p> <p className="text-xs text-red-700 mt-1">Lagging (Injuries)</p>
</div> </div>
{capaOnTimeRate !== null && ( {capaOnTimeRate !== null && (
<div className="flex-1 text-center bg-neutral-100 p-4"> <div className="flex-1 text-center bg-green-50 rounded-lg p-4">
<p className="text-3xl font-bold text-ink">{capaOnTimeRate}%</p> <p className="text-3xl font-bold text-green-600">{capaOnTimeRate}%</p>
<p className="text-xs text-ink mt-1">CAPA On-Time Rate</p> <p className="text-xs text-green-700 mt-1">CAPA On-Time Rate</p>
</div> </div>
)} )}
</div> </div>
@@ -240,7 +240,7 @@ export default async function HseDashboardPage({
{/* Trends tab */} {/* Trends tab */}
{tab === 'trends' && ( {tab === 'trends' && (
<> <>
<div className="bg-surface shadow-sm p-5 mb-4"> <div className="bg-white rounded-xl shadow-sm p-5 mb-4">
<h2 className="text-sm font-semibold text-gray-900 mb-1"> <h2 className="text-sm font-semibold text-gray-900 mb-1">
Incident Trend — Last 12 Months Incident Trend — Last 12 Months
</h2> </h2>
@@ -253,7 +253,7 @@ export default async function HseDashboardPage({
return ( return (
<div key={m.month} className="flex-1 flex flex-col items-center gap-1"> <div key={m.month} className="flex-1 flex flex-col items-center gap-1">
<div className="w-full flex flex-col-reverse" style={{ height: '192px' }}> <div className="w-full flex flex-col-reverse" style={{ height: '192px' }}>
<div className="w-full bg-accent-400" style={{ height: `${(m.leading / monthlyMax) * 192}px` }} /> <div className="w-full bg-blue-400" style={{ height: `${(m.leading / monthlyMax) * 192}px` }} />
<div className="w-full bg-red-400" style={{ height: `${(m.lagging / monthlyMax) * 192}px` }} /> <div className="w-full bg-red-400" style={{ height: `${(m.lagging / monthlyMax) * 192}px` }} />
<div className="w-full bg-gray-300" style={{ height: `${(Math.max(0, other) / monthlyMax) * 192}px` }} /> <div className="w-full bg-gray-300" style={{ height: `${(Math.max(0, other) / monthlyMax) * 192}px` }} />
</div> </div>
@@ -266,7 +266,7 @@ export default async function HseDashboardPage({
</div> </div>
{rootCauses.length > 0 && ( {rootCauses.length > 0 && (
<div className="bg-surface shadow-sm p-5"> <div className="bg-white rounded-xl shadow-sm p-5">
<h2 className="text-sm font-semibold text-gray-900 mb-4">Top Root Causes</h2> <h2 className="text-sm font-semibold text-gray-900 mb-4">Top Root Causes</h2>
<ol className="space-y-2"> <ol className="space-y-2">
{rootCauses.map((rc, i) => ( {rootCauses.map((rc, i) => (
@@ -288,7 +288,7 @@ export default async function HseDashboardPage({
{tab === 'zones' && ( {tab === 'zones' && (
<> <>
{by_zone.length > 0 && ( {by_zone.length > 0 && (
<div className="bg-surface shadow-sm p-5 mb-4"> <div className="bg-white rounded-xl shadow-sm p-5 mb-4">
<h2 className="text-sm font-semibold text-gray-900 mb-4"> <h2 className="text-sm font-semibold text-gray-900 mb-4">
Zone Incident Heatmap — Last 90 Days Zone Incident Heatmap — Last 90 Days
</h2> </h2>
@@ -296,9 +296,9 @@ export default async function HseDashboardPage({
{by_zone.map(({ name, count }) => ( {by_zone.map(({ name, count }) => (
<div key={name} className="flex items-center gap-3"> <div key={name} className="flex items-center gap-3">
<span className="text-sm text-gray-600 w-36 shrink-0 truncate">{name}</span> <span className="text-sm text-gray-600 w-36 shrink-0 truncate">{name}</span>
<div className="flex-1 bg-gray-100 h-3"> <div className="flex-1 bg-gray-100 rounded-full h-3">
<div <div
className="h-3" className="h-3 rounded-full"
style={{ style={{
width: `${(count / zoneMax) * 100}%`, width: `${(count / zoneMax) * 100}%`,
backgroundColor: `hsl(220, 70%, ${Math.max(30, 80 - Math.round((count / zoneMax) * 50))}%)`, backgroundColor: `hsl(220, 70%, ${Math.max(30, 80 - Math.round((count / zoneMax) * 50))}%)`,
@@ -312,15 +312,15 @@ export default async function HseDashboardPage({
</div> </div>
)} )}
<div className="bg-surface shadow-sm p-5 mb-4"> <div className="bg-white rounded-xl shadow-sm p-5 mb-4">
<h2 className="text-sm font-semibold text-gray-900 mb-4">By Incident Type</h2> <h2 className="text-sm font-semibold text-gray-900 mb-4">By Incident Type</h2>
<div className="space-y-2"> <div className="space-y-2">
{Object.entries(by_type).sort((a, b) => b[1] - a[1]).map(([type, count]) => ( {Object.entries(by_type).sort((a, b) => b[1] - a[1]).map(([type, count]) => (
<div key={type} className="flex items-center gap-3"> <div key={type} className="flex items-center gap-3">
<span className="text-sm text-gray-600 w-32 shrink-0">{TYPE_LABELS[type] ?? type}</span> <span className="text-sm text-gray-600 w-32 shrink-0">{TYPE_LABELS[type] ?? type}</span>
<div className="flex-1 bg-gray-100 h-2"> <div className="flex-1 bg-gray-100 rounded-full h-2">
<div <div
className="bg-accent h-2" className="bg-blue-500 h-2 rounded-full"
style={{ width: total > 0 ? `${(count / total) * 100}%` : '0%' }} style={{ width: total > 0 ? `${(count / total) * 100}%` : '0%' }}
/> />
</div> </div>
@@ -333,7 +333,7 @@ export default async function HseDashboardPage({
</div> </div>
</div> </div>
<div className="bg-surface shadow-sm p-5"> <div className="bg-white rounded-xl shadow-sm p-5">
<h2 className="text-sm font-semibold text-gray-900 mb-4">By Site</h2> <h2 className="text-sm font-semibold text-gray-900 mb-4">By Site</h2>
<div className="space-y-2"> <div className="space-y-2">
{by_site.map(({ name, count }) => ( {by_site.map(({ name, count }) => (
@@ -31,7 +31,7 @@ export default async function NewCapaPage({ params }: Props) {
return ( return (
<main className="max-w-lg mx-auto px-4 py-6"> <main className="max-w-lg mx-auto px-4 py-6">
<Link href={`/hse/incidents/${id}`} className="text-sm text-accent-700 hover:underline mb-4 inline-block"> <Link href={`/hse/incidents/${id}`} className="text-sm text-blue-600 hover:underline mb-4 inline-block">
← Back to incident ← Back to incident
</Link> </Link>
<h1 className="text-xl font-bold text-gray-900 mb-1">Add CAPA Action</h1> <h1 className="text-xl font-bold text-gray-900 mb-1">Add CAPA Action</h1>
@@ -43,7 +43,7 @@ export default async function InvestigationPage({ params }: Props) {
return ( return (
<main className="max-w-2xl mx-auto px-4 py-6"> <main className="max-w-2xl mx-auto px-4 py-6">
<Link href={`/hse/incidents/${id}`} className="text-sm text-accent-700 hover:underline mb-4 inline-block"> <Link href={`/hse/incidents/${id}`} className="text-sm text-blue-600 hover:underline mb-4 inline-block">
← Back to incident ← Back to incident
</Link> </Link>
<h1 className="text-xl font-bold text-gray-900 mb-1">Investigation Workspace</h1> <h1 className="text-xl font-bold text-gray-900 mb-1">Investigation Workspace</h1>
+3 -3
View File
@@ -175,14 +175,14 @@ export default async function HseIncidentDetailPage({ params }: Props) {
<a <a
href={`/api/incidents/${id}/jkkp-pdf?form=jkkp6`} href={`/api/incidents/${id}/jkkp-pdf?form=jkkp6`}
target="_blank" target="_blank"
className="inline-block bg-gray-800 text-white px-4 py-2 text-sm font-semibold hover:bg-gray-900" className="inline-block bg-gray-800 text-white rounded-lg px-4 py-2 text-sm font-semibold hover:bg-gray-900"
> >
Download JKKP 6 (PDF) Download JKKP 6 (PDF)
</a> </a>
<a <a
href={`/api/incidents/${id}/jkkp-pdf?form=jkkp7`} href={`/api/incidents/${id}/jkkp-pdf?form=jkkp7`}
target="_blank" target="_blank"
className="inline-block bg-gray-600 text-white px-4 py-2 text-sm font-semibold hover:bg-gray-700" className="inline-block bg-gray-600 text-white rounded-lg px-4 py-2 text-sm font-semibold hover:bg-gray-700"
> >
Download JKKP 7 (PDF) Download JKKP 7 (PDF)
</a> </a>
@@ -194,7 +194,7 @@ export default async function HseIncidentDetailPage({ params }: Props) {
href={`/api/incidents/${id}/report-pdf`} href={`/api/incidents/${id}/report-pdf`}
target="_blank" target="_blank"
rel="noopener noreferrer" rel="noopener noreferrer"
className="flex items-center gap-1.5 px-3 py-1.5 bg-accent text-white text-xs font-semibold hover:bg-accent-600 transition-colors" className="flex items-center gap-1.5 px-3 py-1.5 bg-green-600 text-white text-xs font-semibold rounded-lg hover:bg-green-700 transition-colors"
> >
<svg className="w-3.5 h-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2}> <svg className="w-3.5 h-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2}>
<path strokeLinecap="round" strokeLinejoin="round" d="M12 10v6m0 0l-3-3m3 3l3-3m2 8H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" /> <path strokeLinecap="round" strokeLinejoin="round" d="M12 10v6m0 0l-3-3m3 3l3-3m2 8H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" />
@@ -35,7 +35,7 @@ export default async function TriagePage({ params }: Props) {
return ( return (
<main className="max-w-lg mx-auto px-4 py-6"> <main className="max-w-lg mx-auto px-4 py-6">
<Link href={`/hse/incidents/${id}`} className="text-sm text-accent-700 hover:underline mb-4 inline-block"> <Link href={`/hse/incidents/${id}`} className="text-sm text-blue-600 hover:underline mb-4 inline-block">
← Back to incident ← Back to incident
</Link> </Link>
<h1 className="text-xl font-bold text-gray-900 mb-1">Triage Incident</h1> <h1 className="text-xl font-bold text-gray-900 mb-1">Triage Incident</h1>
+2 -2
View File
@@ -13,12 +13,12 @@ export default async function HsePage() {
<h1 className="text-2xl font-bold text-gray-900 mb-1">HSE Officer Portal</h1> <h1 className="text-2xl font-bold text-gray-900 mb-1">HSE Officer Portal</h1>
<p className="text-gray-500 text-sm mb-8">Welcome, {session.name}</p> <p className="text-gray-500 text-sm mb-8">Welcome, {session.name}</p>
<div className="grid grid-cols-2 gap-4 sm:grid-cols-3"> <div className="grid grid-cols-2 gap-4 sm:grid-cols-3">
<Link href="/hse/incidents" className="bg-surface shadow-sm p-5 hover:shadow-md transition-shadow border border-divider"> <Link href="/hse/incidents" className="bg-white rounded-xl shadow-sm p-5 hover:shadow-md transition-shadow border border-gray-100">
<div className="text-2xl mb-2">📋</div> <div className="text-2xl mb-2">📋</div>
<div className="font-semibold text-gray-900">Incident Inbox</div> <div className="font-semibold text-gray-900">Incident Inbox</div>
<div className="text-xs text-gray-500 mt-1">View all incidents</div> <div className="text-xs text-gray-500 mt-1">View all incidents</div>
</Link> </Link>
<Link href="/hse/dashboard" className="bg-surface shadow-sm p-5 hover:shadow-md transition-shadow border border-divider"> <Link href="/hse/dashboard" className="bg-white rounded-xl shadow-sm p-5 hover:shadow-md transition-shadow border border-gray-100">
<div className="text-2xl mb-2">📊</div> <div className="text-2xl mb-2">📊</div>
<div className="font-semibold text-gray-900">Dashboard</div> <div className="font-semibold text-gray-900">Dashboard</div>
<div className="text-xs text-gray-500 mt-1">Stats & overview</div> <div className="text-xs text-gray-500 mt-1">Stats & overview</div>
+1 -1
View File
@@ -13,7 +13,7 @@ export default async function ProtectedLayout({
if (!session) redirect('/login') if (!session) redirect('/login')
return ( return (
<div className="min-h-screen bg-ground"> <div className="min-h-screen bg-gray-50">
<Sidebar <Sidebar
role={session.role} role={session.role}
userName={session.name} userName={session.name}
+11 -11
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-neutral-300', 2: 'bg-neutral-500', 3: 'bg-accent-300', 4: 'bg-accent', 5: 'bg-accent-700', 1: 'bg-green-400', 2: 'bg-yellow-400', 3: 'bg-orange-400', 4: 'bg-red-500', 5: 'bg-red-700',
} }
return ( return (
@@ -97,7 +97,7 @@ export default async function ManagementPage() {
<h1 className="text-2xl font-bold text-gray-900">Management Dashboard</h1> <h1 className="text-2xl font-bold text-gray-900">Management Dashboard</h1>
<a <a
href="/api/dashboard/export?role=management" href="/api/dashboard/export?role=management"
className="text-sm text-gray-500 hover:text-gray-700 border border-divider px-3 py-1.5" className="text-sm text-gray-500 hover:text-gray-700 border border-gray-200 rounded-lg px-3 py-1.5"
> >
Export CSV Export CSV
</a> </a>
@@ -119,15 +119,15 @@ export default async function ManagementPage() {
</div> </div>
{/* Leading vs lagging */} {/* Leading vs lagging */}
<div className="bg-surface shadow-sm p-5 mb-4"> <div className="bg-white rounded-xl shadow-sm p-5 mb-4">
<h2 className="text-sm font-semibold text-gray-700 uppercase tracking-wide mb-1">Leading vs Lagging — Last 30 Days</h2> <h2 className="text-sm font-semibold text-gray-700 uppercase tracking-wide mb-1">Leading vs Lagging — Last 30 Days</h2>
<p className="text-xs text-gray-400 mb-4">Leading: hazard + near-miss · Lagging: injuries</p> <p className="text-xs text-gray-400 mb-4">Leading: hazard + near-miss · Lagging: injuries</p>
<div className="flex gap-6"> <div className="flex gap-6">
<div className="flex-1 text-center bg-neutral-100 p-4"> <div className="flex-1 text-center bg-blue-50 rounded-lg p-4">
<p className="text-3xl font-bold text-accent-700">{leadingCount}</p> <p className="text-3xl font-bold text-blue-600">{leadingCount}</p>
<p className="text-xs text-accent-700 mt-1">Leading (Hazards + Near Misses)</p> <p className="text-xs text-blue-700 mt-1">Leading (Hazards + Near Misses)</p>
</div> </div>
<div className="flex-1 text-center bg-red-50 p-4"> <div className="flex-1 text-center bg-red-50 rounded-lg p-4">
<p className="text-3xl font-bold text-red-600">{laggingCount}</p> <p className="text-3xl font-bold text-red-600">{laggingCount}</p>
<p className="text-xs text-red-700 mt-1">Lagging (Injuries)</p> <p className="text-xs text-red-700 mt-1">Lagging (Injuries)</p>
</div> </div>
@@ -135,15 +135,15 @@ export default async function ManagementPage() {
</div> </div>
{/* Severity distribution */} {/* Severity distribution */}
<div className="bg-surface shadow-sm p-5 mb-4"> <div className="bg-white rounded-xl shadow-sm p-5 mb-4">
<h2 className="text-sm font-semibold text-gray-700 uppercase tracking-wide mb-4">Severity Distribution (All Time)</h2> <h2 className="text-sm font-semibold text-gray-700 uppercase tracking-wide mb-4">Severity Distribution (All Time)</h2>
<div className="space-y-2"> <div className="space-y-2">
{([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 h-3"> <div className="flex-1 bg-gray-100 rounded-full h-3">
<div <div
className={`h-3 ${SEVERITY_COLORS[sev]}`} className={`h-3 rounded-full ${SEVERITY_COLORS[sev]}`}
style={{ width: severityMax > 0 ? `${(severityDist[sev] / severityMax) * 100}%` : '0%' }} style={{ width: severityMax > 0 ? `${(severityDist[sev] / severityMax) * 100}%` : '0%' }}
/> />
</div> </div>
@@ -154,7 +154,7 @@ export default async function ManagementPage() {
</div> </div>
{/* Site comparison */} {/* Site comparison */}
<div className="bg-surface shadow-sm p-5"> <div className="bg-white rounded-xl shadow-sm p-5">
<h2 className="text-sm font-semibold text-gray-700 uppercase tracking-wide mb-4">Incidents by Site</h2> <h2 className="text-sm font-semibold text-gray-700 uppercase tracking-wide mb-4">Incidents by Site</h2>
{by_site.length === 0 ? ( {by_site.length === 0 ? (
<p className="text-sm text-gray-400">No data</p> <p className="text-sm text-gray-400">No data</p>
@@ -6,12 +6,17 @@ 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,
}: { }: {
@@ -60,16 +65,18 @@ export default async function ReporterIncidentDetail({
return ( return (
<main className="max-w-2xl mx-auto px-4 py-6 space-y-4"> <main className="max-w-2xl mx-auto px-4 py-6 space-y-4">
<div className="flex items-center gap-2 mb-2"> <div className="flex items-center gap-2 mb-2">
<Link href="/reporter" className="text-sm text-accent-700 hover:underline">← My Reports</Link> <Link href="/reporter" className="text-sm text-blue-600 hover:underline">← My Reports</Link>
</div> </div>
<div className="bg-surface shadow-sm p-5"> <div className="bg-white rounded-xl shadow-sm p-5">
<div className="flex items-start justify-between gap-3 mb-4"> <div className="flex items-start justify-between gap-3 mb-4">
<div> <div>
<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="shrink-0"><StatusTag status={inc.status}>{STATUS_LABELS[inc.status] ?? inc.status}</StatusTag></span> <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>
</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">
@@ -91,7 +98,7 @@ export default async function ReporterIncidentDetail({
</div> </div>
{inc.description && ( {inc.description && (
<div className="border-t border-divider pt-4"> <div className="border-t border-gray-100 pt-4">
<p className="text-xs text-gray-500 mb-1">Description</p> <p className="text-xs text-gray-500 mb-1">Description</p>
<p className="text-sm text-gray-800 whitespace-pre-line">{inc.description}</p> <p className="text-sm text-gray-800 whitespace-pre-line">{inc.description}</p>
</div> </div>
@@ -99,15 +106,15 @@ export default async function ReporterIncidentDetail({
</div> </div>
{capas.length > 0 && ( {capas.length > 0 && (
<div className="bg-surface shadow-sm p-5"> <div className="bg-white rounded-xl shadow-sm p-5">
<h2 className="text-sm font-semibold text-gray-900 mb-3">Corrective Actions ({capas.length})</h2> <h2 className="text-sm font-semibold text-gray-900 mb-3">Corrective Actions ({capas.length})</h2>
<div className="space-y-2"> <div className="space-y-2">
{capas.map(c => ( {capas.map(c => (
<div key={c.id} className="flex items-start justify-between gap-3 text-sm"> <div key={c.id} className="flex items-start justify-between gap-3 text-sm">
<p className="text-gray-700 flex-1">{c.description}</p> <p className="text-gray-700 flex-1">{c.description}</p>
<span className={`text-xs px-2 py-0.5 shrink-0 ${ <span className={`text-xs rounded-full px-2 py-0.5 shrink-0 ${
c.status === 'verified' ? 'bg-neutral-100 text-ink' : c.status === 'verified' ? 'bg-green-100 text-green-700' :
c.status === 'pending_verification' ? 'bg-accent-100 text-accent-700' : c.status === 'pending_verification' ? 'bg-purple-100 text-purple-700' :
'bg-gray-100 text-gray-600' 'bg-gray-100 text-gray-600'
}`}>{c.status.replace(/_/g, ' ')}</span> }`}>{c.status.replace(/_/g, ' ')}</span>
</div> </div>
+21 -11
View File
@@ -6,7 +6,6 @@ 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',
@@ -17,6 +16,15 @@ 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',
@@ -54,34 +62,34 @@ export default async function ReporterPage() {
</div> </div>
<Link <Link
href="/report" href="/report"
className="bg-accent text-white px-4 py-2 text-sm font-semibold hover:bg-accent-600" className="bg-blue-600 text-white rounded-lg px-4 py-2 text-sm font-semibold hover:bg-blue-700"
> >
+ New Report + New Report
</Link> </Link>
</div> </div>
<div className="flex gap-4 mb-6 text-sm"> <div className="flex gap-4 mb-6 text-sm">
<div className="bg-surface shadow-sm p-4 flex-1 text-center"> <div className="bg-white rounded-xl shadow-sm p-4 flex-1 text-center">
<p className="text-2xl font-bold text-gray-900">{rows.length}</p> <p className="text-2xl font-bold text-gray-900">{rows.length}</p>
<p className="text-xs text-gray-500 mt-1">Total Submitted</p> <p className="text-xs text-gray-500 mt-1">Total Submitted</p>
</div> </div>
<div className="bg-surface shadow-sm p-4 flex-1 text-center"> <div className="bg-white rounded-xl shadow-sm p-4 flex-1 text-center">
<p className="text-2xl font-bold text-accent-700">{openCount}</p> <p className="text-2xl font-bold text-yellow-600">{openCount}</p>
<p className="text-xs text-gray-500 mt-1">In Progress</p> <p className="text-xs text-gray-500 mt-1">In Progress</p>
</div> </div>
<div className="bg-surface shadow-sm p-4 flex-1 text-center"> <div className="bg-white rounded-xl shadow-sm p-4 flex-1 text-center">
<p className="text-2xl font-bold text-ink">{closedCount}</p> <p className="text-2xl font-bold text-green-600">{closedCount}</p>
<p className="text-xs text-gray-500 mt-1">Closed</p> <p className="text-xs text-gray-500 mt-1">Closed</p>
</div> </div>
</div> </div>
{rows.length === 0 ? ( {rows.length === 0 ? (
<div className="bg-surface shadow-sm p-8 text-center"> <div className="bg-white rounded-xl shadow-sm p-8 text-center">
<p className="text-gray-400 text-sm mb-4">No incidents reported yet.</p> <p className="text-gray-400 text-sm mb-4">No incidents reported yet.</p>
<Link href="/report" className="text-accent-700 text-sm hover:underline">Submit your first report →</Link> <Link href="/report" className="text-blue-600 text-sm hover:underline">Submit your first report →</Link>
</div> </div>
) : ( ) : (
<div className="bg-surface shadow-sm divide-y divide-gray-50"> <div className="bg-white rounded-xl shadow-sm divide-y divide-gray-50">
{rows.map(inc => ( {rows.map(inc => (
<Link key={inc.id} href={`/reporter/incidents/${inc.id}`} className="block p-4 cursor-pointer hover:bg-gray-50 transition-colors"> <Link key={inc.id} href={`/reporter/incidents/${inc.id}`} className="block p-4 cursor-pointer hover:bg-gray-50 transition-colors">
<div className="flex items-start justify-between gap-3"> <div className="flex items-start justify-between gap-3">
@@ -102,7 +110,9 @@ export default async function ReporterPage() {
</p> </p>
)} )}
</div> </div>
<span className="shrink-0"><StatusTag status={inc.status}>{STATUS_LABELS[inc.status] ?? inc.status}</StatusTag></span> <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>
</div> </div>
</Link> </Link>
))} ))}
@@ -136,7 +136,7 @@ export default async function SupervisorIncidentDetailPage({ params }: Props) {
return ( return (
<main className="max-w-3xl mx-auto px-4 py-6"> <main className="max-w-3xl mx-auto px-4 py-6">
<Link href="/supervisor/incidents" className="text-sm text-accent-700 hover:underline mb-4 inline-block"> <Link href="/supervisor/incidents" className="text-sm text-blue-600 hover:underline mb-4 inline-block">
← Back to inbox ← Back to inbox
</Link> </Link>
<IncidentDetail incident={incidentProp} /> <IncidentDetail incident={incidentProp} />
+16 -6
View File
@@ -8,7 +8,6 @@ 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',
@@ -19,6 +18,15 @@ 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')
@@ -111,7 +119,7 @@ export default async function SupervisorPage() {
<h1 className="text-2xl font-bold text-gray-900">Supervisor Portal</h1> <h1 className="text-2xl font-bold text-gray-900">Supervisor Portal</h1>
<p className="text-sm text-gray-500 mt-1">{siteName}</p> <p className="text-sm text-gray-500 mt-1">{siteName}</p>
</div> </div>
<Link href="/supervisor/incidents" className="text-sm text-accent-700 hover:underline"> <Link href="/supervisor/incidents" className="text-sm text-blue-600 hover:underline">
All incidents → All incidents →
</Link> </Link>
</div> </div>
@@ -125,7 +133,7 @@ export default async function SupervisorPage() {
</div> </div>
{/* Open incidents */} {/* Open incidents */}
<div className="bg-surface shadow-sm p-5 mb-4"> <div className="bg-white rounded-xl shadow-sm p-5 mb-4">
<h2 className="text-sm font-semibold text-gray-700 uppercase tracking-wide mb-4">Open Incidents</h2> <h2 className="text-sm font-semibold text-gray-700 uppercase tracking-wide mb-4">Open Incidents</h2>
{openIncidents.length === 0 ? ( {openIncidents.length === 0 ? (
<p className="text-sm text-gray-400">No open incidents.</p> <p className="text-sm text-gray-400">No open incidents.</p>
@@ -135,13 +143,15 @@ export default async function SupervisorPage() {
<Link <Link
key={inc.id} key={inc.id}
href={`/supervisor/incidents/${inc.id}`} href={`/supervisor/incidents/${inc.id}`}
className="flex items-center justify-between py-2 border-b border-gray-50 last:border-0 hover:bg-gray-50 -mx-2 px-2" className="flex items-center justify-between py-2 border-b border-gray-50 last:border-0 hover:bg-gray-50 -mx-2 px-2 rounded"
> >
<div> <div>
<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>
<StatusTag status={inc.status}>{STATUS_LABELS[inc.status] ?? inc.status}</StatusTag> <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>
</Link> </Link>
))} ))}
</div> </div>
@@ -150,7 +160,7 @@ export default async function SupervisorPage() {
{/* Overdue CAPAs */} {/* Overdue CAPAs */}
{overdueCount > 0 && ( {overdueCount > 0 && (
<div className="bg-surface shadow-sm p-5"> <div className="bg-white rounded-xl shadow-sm p-5">
<h2 className="text-sm font-semibold text-red-600 uppercase tracking-wide mb-4">Overdue CAPAs</h2> <h2 className="text-sm font-semibold text-red-600 uppercase tracking-wide mb-4">Overdue CAPAs</h2>
<div className="space-y-2"> <div className="space-y-2">
{overdueCapas.map(capa => ( {overdueCapas.map(capa => (
+20 -147
View File
@@ -1,164 +1,37 @@
@import "tailwindcss"; @import "tailwindcss";
/* Modernist tokens. Source of truth: the Modernist styles.css under design-system/_ds. :root {
Static emits every variable so plain CSS can use var(--color-*) too. */ --background: #ffffff;
@theme static { --foreground: #171717;
--color-bg: #f3f2f2;
--color-surface: #eae9e9;
--color-text: #201e1d;
--color-accent: #ec3013;
--color-accent-2: #e15b47;
--color-divider: color-mix(in srgb, #201e1d 40%, transparent);
/* Utility-friendly aliases: bg-ground, text-ink */
--color-ground: var(--color-bg);
--color-ink: var(--color-text);
--color-neutral-100: #f8f4f4;
--color-neutral-200: #eae7e7;
--color-neutral-300: #d7d3d3;
--color-neutral-400: #bab6b6;
--color-neutral-500: #9b9797;
--color-neutral-600: #7d7979;
--color-neutral-700: #605d5d;
--color-neutral-800: #444141;
--color-neutral-900: #2d2b2b;
--color-accent-100: #fff2ef;
--color-accent-200: #ffe0d9;
--color-accent-300: #ffc4b8;
--color-accent-400: #ff9783;
--color-accent-500: #ff563c;
--color-accent-600: #dd2b0f;
--color-accent-700: #ae1800;
--color-accent-800: #7c1405;
--color-accent-900: #4d170e;
--color-accent-2-100: #fff2ef;
--color-accent-2-200: #ffe0da;
--color-accent-2-300: #ffc4b9;
--color-accent-2-400: #ff9784;
--color-accent-2-500: #ef6853;
--color-accent-2-600: #c94b39;
--color-accent-2-700: #9e3526;
--color-accent-2-800: #71261b;
--color-accent-2-900: #471d16;
/* Existing gray-* utilities render on the neutral ramp. */
--color-gray-50: var(--color-neutral-100);
--color-gray-100: var(--color-neutral-200);
--color-gray-200: var(--color-neutral-300);
--color-gray-300: var(--color-neutral-400);
--color-gray-400: var(--color-neutral-500);
--color-gray-500: var(--color-neutral-600);
--color-gray-600: var(--color-neutral-700);
--color-gray-700: var(--color-neutral-800);
--color-gray-800: var(--color-neutral-900);
--color-gray-900: var(--color-text);
--color-gray-950: var(--color-text);
/* Existing blue-* utilities render on the accent ramp. 600 is the canonical
accent; 700 and darker are safe for body-size text. */
--color-blue-50: var(--color-accent-100);
--color-blue-100: var(--color-accent-100);
--color-blue-200: var(--color-accent-200);
--color-blue-300: var(--color-accent-300);
--color-blue-400: var(--color-accent-400);
--color-blue-500: var(--color-accent-500);
--color-blue-600: var(--color-accent);
--color-blue-700: var(--color-accent-700);
--color-blue-800: var(--color-accent-800);
--color-blue-900: var(--color-accent-900);
--color-blue-950: var(--color-accent-900);
/* Existing red-* utilities (errors, destructive) render on the accent ramp;
600 and 700 map to accent-700 so body-size text clears contrast. */
--color-red-50: var(--color-accent-100);
--color-red-100: var(--color-accent-100);
--color-red-200: var(--color-accent-200);
--color-red-300: var(--color-accent-300);
--color-red-400: var(--color-accent-400);
--color-red-500: var(--color-accent-600);
--color-red-600: var(--color-accent-700);
--color-red-700: var(--color-accent-700);
--color-red-800: var(--color-accent-800);
--color-red-900: var(--color-accent-900);
/* Zero corner radius, everywhere. */
--radius: 0px;
--radius-xs: 0px;
--radius-sm: 0px;
--radius-md: 0px;
--radius-lg: 0px;
--radius-xl: 0px;
--radius-2xl: 0px;
--radius-3xl: 0px;
--radius-4xl: 0px;
/* Elevation, tuned to the ground. */
--shadow-sm: 0 1px 2px color-mix(in srgb, #2d2b2b 14%, transparent);
--shadow-md: 0 3px 10px color-mix(in srgb, #2d2b2b 16%, transparent);
--shadow-lg: 0 12px 32px color-mix(in srgb, #2d2b2b 22%, transparent);
--shadow-xl: var(--shadow-lg);
--shadow-2xl: var(--shadow-lg);
--font-sans: var(--font-archivo), system-ui, sans-serif;
--font-heading: var(--font-archivo), system-ui, sans-serif;
} }
@layer base { @theme inline {
html { --color-background: var(--background);
background: var(--color-bg); --color-foreground: var(--foreground);
--font-sans: var(--font-geist-sans);
--font-mono: var(--font-geist-mono);
}
@media (prefers-color-scheme: dark) {
:root {
--background: #0a0a0a;
--foreground: #ededed;
}
} }
body { body {
background: var(--color-bg); background: var(--background);
color: var(--color-text); color: var(--foreground);
font-family: var(--font-sans); font-family: Arial, Helvetica, sans-serif;
font-size: 15px;
line-height: 1.55;
}
h1, h2, h3, h4, h5, h6 {
font-family: var(--font-heading);
font-weight: 800;
line-height: 1.12;
letter-spacing: -0.015em;
}
:focus {
outline: none;
}
:focus-visible {
outline: 2px solid var(--color-accent);
outline-offset: 2px;
}
::selection {
background: color-mix(in srgb, var(--color-accent) 30%, transparent);
} }
input, input,
textarea, textarea,
select { select {
color: var(--color-text); color: #111827; /* gray-900 — dark typed text */
} }
input::placeholder, input::placeholder,
textarea::placeholder { textarea::placeholder {
color: color-mix(in srgb, var(--color-text) 55%, transparent); color: #6b7280; /* gray-500 — readable placeholder */
}
button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
opacity: 0.45;
cursor: not-allowed;
}
}
.grayscale {
filter: grayscale(1) contrast(1.08);
} }
+9 -4
View File
@@ -1,11 +1,16 @@
import type { Metadata } from 'next' import type { Metadata } from 'next'
import { Archivo } from 'next/font/google' import { Geist, Geist_Mono } from 'next/font/google'
import './globals.css' import './globals.css'
import { I18nProvider } from '@/lib/i18n/context' import { I18nProvider } from '@/lib/i18n/context'
import { getLocale, loadMessages } from '@/lib/i18n/server' import { getLocale, loadMessages } from '@/lib/i18n/server'
const archivo = Archivo({ const geistSans = Geist({
variable: '--font-archivo', variable: '--font-geist-sans',
subsets: ['latin'],
})
const geistMono = Geist_Mono({
variable: '--font-geist-mono',
subsets: ['latin'], subsets: ['latin'],
}) })
@@ -25,7 +30,7 @@ export default async function RootLayout({
return ( return (
<html <html
lang={locale} lang={locale}
className={`${archivo.variable} h-full antialiased`} className={`${geistSans.variable} ${geistMono.variable} h-full antialiased`}
> >
<head> <head>
<link rel="manifest" href="/manifest.json" /> <link rel="manifest" href="/manifest.json" />
+1 -1
View File
@@ -67,7 +67,7 @@ export default async function ReportPage({ searchParams }: Props) {
{siteName ?? 'Unknown Site'} — {zoneName} {siteName ?? 'Unknown Site'} — {zoneName}
</p> </p>
) : ( ) : (
<p className="text-sm text-accent-700 mt-1">No zone detected — zone will not be recorded</p> <p className="text-sm text-amber-600 mt-1">No zone detected — zone will not be recorded</p>
)} )}
</div> </div>
<ReportForm <ReportForm
+2 -2
View File
@@ -10,7 +10,7 @@ export default async function ReportSuccessPage({ searchParams }: Props) {
const { ref } = await searchParams const { ref } = await searchParams
return ( return (
<main className="min-h-screen bg-gray-50 flex items-center justify-center px-4"> <main className="min-h-screen bg-gray-50 flex items-center justify-center px-4">
<div className="bg-surface shadow-sm p-8 max-w-sm w-full text-center"> <div className="bg-white rounded-xl shadow-sm p-8 max-w-sm w-full text-center">
<div className="text-4xl mb-4">✓</div> <div className="text-4xl mb-4">✓</div>
<h1 className="text-xl font-bold text-gray-900 mb-2">Report submitted</h1> <h1 className="text-xl font-bold text-gray-900 mb-2">Report submitted</h1>
{ref && ( {ref && (
@@ -21,7 +21,7 @@ export default async function ReportSuccessPage({ searchParams }: Props) {
<p className="text-sm text-gray-500 mb-6"> <p className="text-sm text-gray-500 mb-6">
The supervisor and HSE officer have been notified. The supervisor and HSE officer have been notified.
</p> </p>
<Link href="/report" className="text-sm text-accent-700 hover:underline"> <Link href="/report" className="text-sm text-blue-600 hover:underline">
Submit another report Submit another report
</Link> </Link>
</div> </div>
+6 -6
View File
@@ -54,7 +54,7 @@ export default function ChangePasswordForm() {
} }
return ( return (
<div className="bg-surface shadow-sm p-5"> <div className="bg-white rounded-xl shadow-sm p-5">
<h2 className="text-base font-semibold text-gray-900 mb-4">Change Password</h2> <h2 className="text-base font-semibold text-gray-900 mb-4">Change Password</h2>
<form onSubmit={handleSubmit} className="space-y-4"> <form onSubmit={handleSubmit} className="space-y-4">
<div> <div>
@@ -67,7 +67,7 @@ export default function ChangePasswordForm() {
onChange={e => setCurrent(e.target.value)} onChange={e => setCurrent(e.target.value)}
disabled={loading} disabled={loading}
autoComplete="current-password" autoComplete="current-password"
className="w-full border border-divider px-3 py-2 text-sm focus:ring-2 focus:ring-accent focus:border-transparent disabled:opacity-50" className="w-full border border-gray-300 rounded-lg px-3 py-2 text-sm focus:ring-2 focus:ring-blue-500 focus:border-transparent disabled:opacity-50"
/> />
</div> </div>
<div> <div>
@@ -80,7 +80,7 @@ export default function ChangePasswordForm() {
onChange={e => setNewPass(e.target.value)} onChange={e => setNewPass(e.target.value)}
disabled={loading} disabled={loading}
autoComplete="new-password" autoComplete="new-password"
className="w-full border border-divider px-3 py-2 text-sm focus:ring-2 focus:ring-accent focus:border-transparent disabled:opacity-50" className="w-full border border-gray-300 rounded-lg px-3 py-2 text-sm focus:ring-2 focus:ring-blue-500 focus:border-transparent disabled:opacity-50"
/> />
</div> </div>
<div> <div>
@@ -93,17 +93,17 @@ export default function ChangePasswordForm() {
onChange={e => setConfirm(e.target.value)} onChange={e => setConfirm(e.target.value)}
disabled={loading} disabled={loading}
autoComplete="new-password" autoComplete="new-password"
className="w-full border border-divider px-3 py-2 text-sm focus:ring-2 focus:ring-accent focus:border-transparent disabled:opacity-50" className="w-full border border-gray-300 rounded-lg px-3 py-2 text-sm focus:ring-2 focus:ring-blue-500 focus:border-transparent disabled:opacity-50"
/> />
</div> </div>
{error && <p className="text-xs text-red-600 mt-1">{error}</p>} {error && <p className="text-xs text-red-600 mt-1">{error}</p>}
{success && <p className="text-xs text-ink mt-1">Password changed successfully.</p>} {success && <p className="text-xs text-green-600 mt-1">Password changed successfully.</p>}
<button <button
type="submit" type="submit"
disabled={loading} disabled={loading}
className="bg-accent text-white px-4 py-2 text-sm font-semibold disabled:opacity-50 hover:bg-accent-600" className="bg-blue-600 text-white rounded-lg px-4 py-2 text-sm font-semibold disabled:opacity-50 hover:bg-blue-700"
> >
{loading ? 'Saving…' : 'Update Password'} {loading ? 'Saving…' : 'Update Password'}
</button> </button>
+4 -4
View File
@@ -25,20 +25,20 @@ export function AdminPanel({ users, sites, siteOptions, trucks }: Props) {
return ( return (
<div> <div>
<div className="flex gap-1 border-b border-divider mb-6"> <div className="flex gap-1 border-b border-gray-200 mb-6">
{tabs.map(t => ( {tabs.map(t => (
<button <button
key={t.id} key={t.id}
onClick={() => setTab(t.id)} onClick={() => setTab(t.id)}
className={`px-4 py-2.5 text-sm font-medium border-b-2 -mb-px transition-colors cursor-pointer ${ className={`px-4 py-2.5 text-sm font-medium border-b-2 -mb-px transition-colors cursor-pointer ${
tab === t.id tab === t.id
? 'border-accent text-ink' ? 'border-green-600 text-green-700'
: 'border-transparent text-gray-500 hover:text-gray-700' : 'border-transparent text-gray-500 hover:text-gray-700'
}`} }`}
> >
{t.label} {t.label}
<span className={`ml-1.5 text-xs px-1.5 py-0.5 ${ <span className={`ml-1.5 text-xs px-1.5 py-0.5 rounded-full ${
tab === t.id ? 'bg-neutral-100 text-ink' : 'bg-gray-100 text-gray-500' tab === t.id ? 'bg-green-100 text-green-700' : 'bg-gray-100 text-gray-500'
}`}>{t.count}</span> }`}>{t.count}</span>
</button> </button>
))} ))}
+5 -5
View File
@@ -83,7 +83,7 @@ export function BulkImportForm() {
if (stage === 'upload') { if (stage === 'upload') {
return ( return (
<div className="space-y-4"> <div className="space-y-4">
<label className="block cursor-pointer border-2 border-dashed border-divider p-6 text-center hover:bg-gray-50"> <label className="block cursor-pointer rounded border-2 border-dashed border-gray-300 p-6 text-center hover:bg-gray-50">
<input <input
type="file" type="file"
onChange={handleUpload} onChange={handleUpload}
@@ -201,14 +201,14 @@ export function BulkImportForm() {
<div className="flex gap-2"> <div className="flex gap-2">
<button <button
onClick={() => setStage('upload')} onClick={() => setStage('upload')}
className="px-4 py-2 text-gray-600 hover:bg-gray-100" className="px-4 py-2 text-gray-600 hover:bg-gray-100 rounded"
> >
Back Back
</button> </button>
<button <button
onClick={handleImport} onClick={handleImport}
disabled={!canImport || loading} disabled={!canImport || loading}
className="px-4 py-2 bg-accent text-white disabled:opacity-50 disabled:cursor-not-allowed" className="px-4 py-2 bg-blue-600 text-white rounded disabled:opacity-50 disabled:cursor-not-allowed"
> >
{loading ? 'Importing...' : 'Import All'} {loading ? 'Importing...' : 'Import All'}
</button> </button>
@@ -220,9 +220,9 @@ export function BulkImportForm() {
return ( return (
<div className="space-y-4"> <div className="space-y-4">
<h3 className="font-bold text-ink">✓ Import Complete</h3> <h3 className="font-bold text-green-600">✓ Import Complete</h3>
<p>{folders.length} incidents created</p> <p>{folders.length} incidents created</p>
{message && <p className="text-ink text-sm">{message}</p>} {message && <p className="text-green-600 text-sm">{message}</p>}
</div> </div>
) )
} }
+21 -21
View File
@@ -3,7 +3,6 @@
import { useState } from 'react' import { useState } from 'react'
import { useRouter } from 'next/navigation' import { useRouter } from 'next/navigation'
import { Modal } from '@/components/ui/modal' import { Modal } from '@/components/ui/modal'
import { INPUT_CLASS as inp } from '@/components/ui/field'
export type SiteWithZones = { export type SiteWithZones = {
id: string id: string
@@ -17,6 +16,7 @@ interface Props {
sites: SiteWithZones[] sites: SiteWithZones[]
} }
const inp = 'w-full border border-gray-300 rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-green-500 focus:border-green-500'
const lbl = 'block text-xs font-medium text-gray-600 mb-1' const lbl = 'block text-xs font-medium text-gray-600 mb-1'
type DeleteTarget = { kind: 'site'; id: string; name: string } | { kind: 'zone'; id: string; name: string } type DeleteTarget = { kind: 'site'; id: string; name: string } | { kind: 'zone'; id: string; name: string }
@@ -81,22 +81,22 @@ export function SiteZoneManager({ sites }: Props) {
const totalZones = sites.reduce((n, s) => n + s.zones.length, 0) const totalZones = sites.reduce((n, s) => n + s.zones.length, 0)
return ( return (
<div className="bg-surface border border-divider shadow-sm overflow-hidden"> <div className="bg-white rounded-xl border border-gray-200 shadow-sm overflow-hidden">
<div className="flex items-center justify-between px-5 py-4 border-b border-divider"> <div className="flex items-center justify-between px-5 py-4 border-b border-gray-100">
<div> <div>
<h2 className="text-sm font-semibold text-gray-900">Sites & Zones</h2> <h2 className="text-sm font-semibold text-gray-900">Sites & Zones</h2>
<p className="text-xs text-gray-400 mt-0.5">{sites.length} site{sites.length !== 1 ? 's' : ''} · {totalZones} zone{totalZones !== 1 ? 's' : ''}</p> <p className="text-xs text-gray-400 mt-0.5">{sites.length} site{sites.length !== 1 ? 's' : ''} · {totalZones} zone{totalZones !== 1 ? 's' : ''}</p>
</div> </div>
<div className="flex gap-2"> <div className="flex gap-2">
<button onClick={() => { setShowAddZone(true); setError(null) }} <button onClick={() => { setShowAddZone(true); setError(null) }}
className="flex items-center gap-1.5 px-3 py-1.5 bg-gray-100 text-gray-700 text-xs font-semibold hover:bg-gray-200 transition-colors cursor-pointer"> className="flex items-center gap-1.5 px-3 py-1.5 bg-gray-100 text-gray-700 text-xs font-semibold rounded-lg hover:bg-gray-200 transition-colors cursor-pointer">
<svg className="w-3.5 h-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2.5}> <svg className="w-3.5 h-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2.5}>
<path strokeLinecap="round" strokeLinejoin="round" d="M12 4v16m8-8H4" /> <path strokeLinecap="round" strokeLinejoin="round" d="M12 4v16m8-8H4" />
</svg> </svg>
Add Zone Add Zone
</button> </button>
<button onClick={() => { setShowAddSite(true); setError(null) }} <button onClick={() => { setShowAddSite(true); setError(null) }}
className="flex items-center gap-1.5 px-3 py-1.5 bg-accent text-white text-xs font-semibold hover:bg-accent-600 transition-colors cursor-pointer"> className="flex items-center gap-1.5 px-3 py-1.5 bg-green-600 text-white text-xs font-semibold rounded-lg hover:bg-green-700 transition-colors cursor-pointer">
<svg className="w-3.5 h-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2.5}> <svg className="w-3.5 h-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2.5}>
<path strokeLinecap="round" strokeLinejoin="round" d="M12 4v16m8-8H4" /> <path strokeLinecap="round" strokeLinejoin="round" d="M12 4v16m8-8H4" />
</svg> </svg>
@@ -118,10 +118,10 @@ export function SiteZoneManager({ sites }: Props) {
<div className="flex items-center gap-2"> <div className="flex items-center gap-2">
<button disabled={busyId === site.id} <button disabled={busyId === site.id}
onClick={() => send('PATCH', { kind: 'site', id: site.id, active: !site.active })} onClick={() => send('PATCH', { kind: 'site', id: site.id, active: !site.active })}
className={`text-xs font-medium px-2.5 py-1 border transition-colors cursor-pointer disabled:opacity-50 ${ className={`text-xs font-medium px-2.5 py-1 rounded-full border transition-colors cursor-pointer disabled:opacity-50 ${
site.active site.active
? 'bg-neutral-100 text-ink border-divider hover:bg-neutral-200' ? 'bg-green-50 text-green-700 border-green-200 hover:bg-green-100'
: 'bg-gray-50 text-gray-500 border-divider hover:bg-gray-100' : 'bg-gray-50 text-gray-500 border-gray-200 hover:bg-gray-100'
}`}> }`}>
{site.active ? 'Active' : 'Inactive'} {site.active ? 'Active' : 'Inactive'}
</button> </button>
@@ -134,21 +134,21 @@ export function SiteZoneManager({ sites }: Props) {
</div> </div>
{site.zones.length > 0 && ( {site.zones.length > 0 && (
<ul className="mt-3 space-y-1.5 pl-3 border-l-2 border-divider"> <ul className="mt-3 space-y-1.5 pl-3 border-l-2 border-gray-100">
{site.zones.map(z => ( {site.zones.map(z => (
<li key={z.id} className={`flex items-center justify-between ${!z.active ? 'opacity-50' : ''}`}> <li key={z.id} className={`flex items-center justify-between ${!z.active ? 'opacity-50' : ''}`}>
<span className="text-xs text-gray-700 font-medium">{z.name}</span> <span className="text-xs text-gray-700 font-medium">{z.name}</span>
<div className="flex items-center gap-3"> <div className="flex items-center gap-3">
<a href={`/report?zone=${z.qr_code_token}`} target="_blank" <a href={`/report?zone=${z.qr_code_token}`} target="_blank"
className="text-xs text-accent-700 hover:underline cursor-pointer"> className="text-xs text-blue-600 hover:underline cursor-pointer">
Report link Report link
</a> </a>
<button disabled={busyId === z.id} <button disabled={busyId === z.id}
onClick={() => send('PATCH', { kind: 'zone', id: z.id, active: !z.active })} onClick={() => send('PATCH', { kind: 'zone', id: z.id, active: !z.active })}
className={`text-xs font-medium px-2 py-0.5 border transition-colors cursor-pointer disabled:opacity-50 ${ className={`text-xs font-medium px-2 py-0.5 rounded-full border transition-colors cursor-pointer disabled:opacity-50 ${
z.active z.active
? 'bg-neutral-100 text-ink border-divider hover:bg-neutral-200' ? 'bg-green-50 text-green-700 border-green-200 hover:bg-green-100'
: 'bg-gray-50 text-gray-500 border-divider hover:bg-gray-100' : 'bg-gray-50 text-gray-500 border-gray-200 hover:bg-gray-100'
}`}> }`}>
{z.active ? 'Active' : 'Inactive'} {z.active ? 'Active' : 'Inactive'}
</button> </button>
@@ -178,18 +178,18 @@ export function SiteZoneManager({ sites }: Props) {
footer={ footer={
<> <>
<button onClick={() => { setShowAddSite(false); setSiteName(''); setError(null) }} <button onClick={() => { setShowAddSite(false); setSiteName(''); setError(null) }}
className="px-4 py-2 text-sm font-medium border border-divider text-gray-700 hover:bg-gray-50 cursor-pointer transition-colors"> className="px-4 py-2 text-sm font-medium rounded-lg border border-gray-300 text-gray-700 hover:bg-gray-50 cursor-pointer transition-colors">
Cancel Cancel
</button> </button>
<button disabled={busy || !siteName.trim()} <button disabled={busy || !siteName.trim()}
onClick={async () => { if (await post({ kind: 'site', name: siteName })) { setSiteName(''); setShowAddSite(false) } }} onClick={async () => { if (await post({ kind: 'site', name: siteName })) { setSiteName(''); setShowAddSite(false) } }}
className="px-4 py-2 bg-accent text-white text-sm font-semibold hover:bg-accent-600 disabled:opacity-50 cursor-pointer transition-colors"> className="px-4 py-2 bg-green-600 text-white text-sm font-semibold rounded-lg hover:bg-green-700 disabled:opacity-50 cursor-pointer transition-colors">
{busy ? 'Adding…' : 'Add Site'} {busy ? 'Adding…' : 'Add Site'}
</button> </button>
</> </>
} }
> >
{error && <p className="text-xs text-red-600 bg-red-50 px-3 py-2 mb-3">{error}</p>} {error && <p className="text-xs text-red-600 bg-red-50 px-3 py-2 rounded-lg mb-3">{error}</p>}
<div> <div>
<label className={lbl} htmlFor="add-site-name">Site Name *</label> <label className={lbl} htmlFor="add-site-name">Site Name *</label>
<input id="add-site-name" type="text" placeholder="e.g. Setia Warehouse KL" <input id="add-site-name" type="text" placeholder="e.g. Setia Warehouse KL"
@@ -205,7 +205,7 @@ export function SiteZoneManager({ sites }: Props) {
footer={ footer={
<> <>
<button onClick={() => { setShowAddZone(false); setZoneName(''); setZoneSiteId(''); setError(null) }} <button onClick={() => { setShowAddZone(false); setZoneName(''); setZoneSiteId(''); setError(null) }}
className="px-4 py-2 text-sm font-medium border border-divider text-gray-700 hover:bg-gray-50 cursor-pointer transition-colors"> className="px-4 py-2 text-sm font-medium rounded-lg border border-gray-300 text-gray-700 hover:bg-gray-50 cursor-pointer transition-colors">
Cancel Cancel
</button> </button>
<button disabled={busy || !zoneName.trim() || !zoneSiteId} <button disabled={busy || !zoneName.trim() || !zoneSiteId}
@@ -214,13 +214,13 @@ export function SiteZoneManager({ sites }: Props) {
setZoneName(''); setZoneSiteId(''); setShowAddZone(false) setZoneName(''); setZoneSiteId(''); setShowAddZone(false)
} }
}} }}
className="px-4 py-2 bg-accent text-white text-sm font-semibold hover:bg-accent-600 disabled:opacity-50 cursor-pointer transition-colors"> className="px-4 py-2 bg-green-600 text-white text-sm font-semibold rounded-lg hover:bg-green-700 disabled:opacity-50 cursor-pointer transition-colors">
{busy ? 'Adding…' : 'Add Zone'} {busy ? 'Adding…' : 'Add Zone'}
</button> </button>
</> </>
} }
> >
{error && <p className="text-xs text-red-600 bg-red-50 px-3 py-2 mb-3">{error}</p>} {error && <p className="text-xs text-red-600 bg-red-50 px-3 py-2 rounded-lg mb-3">{error}</p>}
<div className="space-y-4"> <div className="space-y-4">
<div> <div>
<label className={lbl} htmlFor="add-zone-site">Site *</label> <label className={lbl} htmlFor="add-zone-site">Site *</label>
@@ -243,12 +243,12 @@ export function SiteZoneManager({ sites }: Props) {
footer={ footer={
<> <>
<button onClick={() => setConfirmDelete(null)} <button onClick={() => setConfirmDelete(null)}
className="px-4 py-2 text-sm font-medium border border-divider text-gray-700 hover:bg-gray-50 cursor-pointer transition-colors"> className="px-4 py-2 text-sm font-medium rounded-lg border border-gray-300 text-gray-700 hover:bg-gray-50 cursor-pointer transition-colors">
Cancel Cancel
</button> </button>
<button disabled={!!(confirmDelete && busyId === confirmDelete.id)} <button disabled={!!(confirmDelete && busyId === confirmDelete.id)}
onClick={() => confirmDelete && handleDelete(confirmDelete)} onClick={() => confirmDelete && handleDelete(confirmDelete)}
className="px-4 py-2 bg-red-600 text-white text-sm font-semibold hover:bg-red-700 disabled:opacity-50 cursor-pointer transition-colors"> className="px-4 py-2 bg-red-600 text-white text-sm font-semibold rounded-lg hover:bg-red-700 disabled:opacity-50 cursor-pointer transition-colors">
Delete Delete
</button> </button>
</> </>
+13 -13
View File
@@ -3,7 +3,6 @@
import { useState } from 'react' import { useState } from 'react'
import { useRouter } from 'next/navigation' import { useRouter } from 'next/navigation'
import { Modal } from '@/components/ui/modal' import { Modal } from '@/components/ui/modal'
import { INPUT_CLASS as inp } from '@/components/ui/field'
export type Truck = { export type Truck = {
id: string id: string
@@ -16,6 +15,7 @@ interface Props {
trucks: Truck[] trucks: Truck[]
} }
const inp = 'w-full border border-gray-300 rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-green-500 focus:border-green-500'
const lbl = 'block text-xs font-medium text-gray-600 mb-1' const lbl = 'block text-xs font-medium text-gray-600 mb-1'
export function TruckManager({ trucks }: Props) { export function TruckManager({ trucks }: Props) {
@@ -83,14 +83,14 @@ export function TruckManager({ trucks }: Props) {
} }
return ( return (
<div className="bg-surface border border-divider shadow-sm overflow-hidden"> <div className="bg-white rounded-xl border border-gray-200 shadow-sm overflow-hidden">
<div className="flex items-center justify-between px-5 py-4 border-b border-divider"> <div className="flex items-center justify-between px-5 py-4 border-b border-gray-100">
<div> <div>
<h2 className="text-sm font-semibold text-gray-900">Trucks</h2> <h2 className="text-sm font-semibold text-gray-900">Trucks</h2>
<p className="text-xs text-gray-400 mt-0.5">{trucks.length} vehicle{trucks.length !== 1 ? 's' : ''}</p> <p className="text-xs text-gray-400 mt-0.5">{trucks.length} vehicle{trucks.length !== 1 ? 's' : ''}</p>
</div> </div>
<button onClick={() => { setShowAdd(true); setError(null) }} <button onClick={() => { setShowAdd(true); setError(null) }}
className="flex items-center gap-1.5 px-3 py-1.5 bg-accent text-white text-xs font-semibold hover:bg-accent-600 transition-colors cursor-pointer"> className="flex items-center gap-1.5 px-3 py-1.5 bg-green-600 text-white text-xs font-semibold rounded-lg hover:bg-green-700 transition-colors cursor-pointer">
<svg className="w-3.5 h-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2.5}> <svg className="w-3.5 h-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2.5}>
<path strokeLinecap="round" strokeLinejoin="round" d="M12 4v16m8-8H4" /> <path strokeLinecap="round" strokeLinejoin="round" d="M12 4v16m8-8H4" />
</svg> </svg>
@@ -109,15 +109,15 @@ export function TruckManager({ trucks }: Props) {
</div> </div>
<div className="flex items-center gap-3"> <div className="flex items-center gap-3">
<a href={`/report?truck_id=${tk.id}`} target="_blank" <a href={`/report?truck_id=${tk.id}`} target="_blank"
className="text-xs text-accent-700 hover:underline cursor-pointer"> className="text-xs text-blue-600 hover:underline cursor-pointer">
Report link Report link
</a> </a>
<button disabled={busyId === tk.id} <button disabled={busyId === tk.id}
onClick={() => send('PATCH', { id: tk.id, active: !tk.active })} onClick={() => send('PATCH', { id: tk.id, active: !tk.active })}
className={`text-xs font-medium px-2.5 py-1 border transition-colors cursor-pointer disabled:opacity-50 ${ className={`text-xs font-medium px-2.5 py-1 rounded-full border transition-colors cursor-pointer disabled:opacity-50 ${
tk.active tk.active
? 'bg-neutral-100 text-ink border-divider hover:bg-neutral-200' ? 'bg-green-50 text-green-700 border-green-200 hover:bg-green-100'
: 'bg-gray-50 text-gray-500 border-divider hover:bg-gray-100' : 'bg-gray-50 text-gray-500 border-gray-200 hover:bg-gray-100'
}`}> }`}>
{tk.active ? 'Active' : 'Inactive'} {tk.active ? 'Active' : 'Inactive'}
</button> </button>
@@ -139,17 +139,17 @@ export function TruckManager({ trucks }: Props) {
footer={ footer={
<> <>
<button onClick={() => { setShowAdd(false); setTruckNo(''); setCarrier(''); setError(null) }} <button onClick={() => { setShowAdd(false); setTruckNo(''); setCarrier(''); setError(null) }}
className="px-4 py-2 text-sm font-medium border border-divider text-gray-700 hover:bg-gray-50 cursor-pointer transition-colors"> className="px-4 py-2 text-sm font-medium rounded-lg border border-gray-300 text-gray-700 hover:bg-gray-50 cursor-pointer transition-colors">
Cancel Cancel
</button> </button>
<button disabled={submitting || !truckNo.trim()} onClick={handleAdd} <button disabled={submitting || !truckNo.trim()} onClick={handleAdd}
className="px-4 py-2 bg-accent text-white text-sm font-semibold hover:bg-accent-600 disabled:opacity-50 cursor-pointer transition-colors"> className="px-4 py-2 bg-green-600 text-white text-sm font-semibold rounded-lg hover:bg-green-700 disabled:opacity-50 cursor-pointer transition-colors">
{submitting ? 'Adding…' : 'Add Truck'} {submitting ? 'Adding…' : 'Add Truck'}
</button> </button>
</> </>
} }
> >
{error && <p className="text-xs text-red-600 bg-red-50 px-3 py-2 mb-3">{error}</p>} {error && <p className="text-xs text-red-600 bg-red-50 px-3 py-2 rounded-lg mb-3">{error}</p>}
<div className="space-y-4"> <div className="space-y-4">
<div> <div>
<label className={lbl} htmlFor="add-truck-no">Truck Number *</label> <label className={lbl} htmlFor="add-truck-no">Truck Number *</label>
@@ -173,12 +173,12 @@ export function TruckManager({ trucks }: Props) {
footer={ footer={
<> <>
<button onClick={() => setConfirmDelete(null)} <button onClick={() => setConfirmDelete(null)}
className="px-4 py-2 text-sm font-medium border border-divider text-gray-700 hover:bg-gray-50 cursor-pointer transition-colors"> className="px-4 py-2 text-sm font-medium rounded-lg border border-gray-300 text-gray-700 hover:bg-gray-50 cursor-pointer transition-colors">
Cancel Cancel
</button> </button>
<button disabled={busyId === confirmDelete?.id} <button disabled={busyId === confirmDelete?.id}
onClick={() => confirmDelete && handleDelete(confirmDelete)} onClick={() => confirmDelete && handleDelete(confirmDelete)}
className="px-4 py-2 bg-red-600 text-white text-sm font-semibold hover:bg-red-700 disabled:opacity-50 cursor-pointer transition-colors"> className="px-4 py-2 bg-red-600 text-white text-sm font-semibold rounded-lg hover:bg-red-700 disabled:opacity-50 cursor-pointer transition-colors">
{busyId === confirmDelete?.id ? 'Deleting…' : 'Delete'} {busyId === confirmDelete?.id ? 'Deleting…' : 'Delete'}
</button> </button>
</> </>
+14 -14
View File
@@ -4,7 +4,6 @@ import { useState } from 'react'
import { useRouter } from 'next/navigation' import { useRouter } from 'next/navigation'
import { ALL_ROLES, type UserRole } from '@/lib/auth/roles' import { ALL_ROLES, type UserRole } from '@/lib/auth/roles'
import { Modal } from '@/components/ui/modal' import { Modal } from '@/components/ui/modal'
import { INPUT_CLASS as inp } from '@/components/ui/field'
export type AdminUser = { export type AdminUser = {
id: string id: string
@@ -25,6 +24,7 @@ interface Props {
const EMPTY = { email: '', name: '', phone: '', role: 'reporter' as UserRole, site_id: '', password: '' } const EMPTY = { email: '', name: '', phone: '', role: 'reporter' as UserRole, site_id: '', password: '' }
const inp = 'w-full border border-gray-300 rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-green-500 focus:border-green-500'
const lbl = 'block text-xs font-medium text-gray-600 mb-1' const lbl = 'block text-xs font-medium text-gray-600 mb-1'
export function UserManager({ users, sites }: Props) { export function UserManager({ users, sites }: Props) {
@@ -95,15 +95,15 @@ export function UserManager({ users, sites }: Props) {
} }
return ( return (
<div className="bg-surface border border-divider shadow-sm overflow-hidden"> <div className="bg-white rounded-xl border border-gray-200 shadow-sm overflow-hidden">
<div className="flex items-center justify-between px-5 py-4 border-b border-divider"> <div className="flex items-center justify-between px-5 py-4 border-b border-gray-100">
<div> <div>
<h2 className="text-sm font-semibold text-gray-900">Users</h2> <h2 className="text-sm font-semibold text-gray-900">Users</h2>
<p className="text-xs text-gray-400 mt-0.5">{users.length} account{users.length !== 1 ? 's' : ''}</p> <p className="text-xs text-gray-400 mt-0.5">{users.length} account{users.length !== 1 ? 's' : ''}</p>
</div> </div>
<button <button
onClick={() => { setShowAdd(true); setError(null) }} onClick={() => { setShowAdd(true); setError(null) }}
className="flex items-center gap-1.5 px-3 py-1.5 bg-accent text-white text-xs font-semibold hover:bg-accent-600 transition-colors cursor-pointer" className="flex items-center gap-1.5 px-3 py-1.5 bg-green-600 text-white text-xs font-semibold rounded-lg hover:bg-green-700 transition-colors cursor-pointer"
> >
<svg className="w-3.5 h-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2.5}> <svg className="w-3.5 h-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2.5}>
<path strokeLinecap="round" strokeLinejoin="round" d="M12 4v16m8-8H4" /> <path strokeLinecap="round" strokeLinejoin="round" d="M12 4v16m8-8H4" />
@@ -134,14 +134,14 @@ export function UserManager({ users, sites }: Props) {
<td className="px-5 py-3"> <td className="px-5 py-3">
<select value={u.role} disabled={busyId === u.id} <select value={u.role} disabled={busyId === u.id}
onChange={e => patchUser(u.id, { role: e.target.value })} onChange={e => patchUser(u.id, { role: e.target.value })}
className="border border-divider px-2 py-1 text-xs focus:outline-none focus:ring-1 focus:ring-accent cursor-pointer"> className="border border-gray-200 rounded-lg px-2 py-1 text-xs focus:outline-none focus:ring-1 focus:ring-green-500 cursor-pointer">
{ALL_ROLES.map(r => <option key={r} value={r}>{r.replace(/_/g, ' ')}</option>)} {ALL_ROLES.map(r => <option key={r} value={r}>{r.replace(/_/g, ' ')}</option>)}
</select> </select>
</td> </td>
<td className="px-5 py-3"> <td className="px-5 py-3">
<select value={u.site_id ?? ''} disabled={busyId === u.id} <select value={u.site_id ?? ''} disabled={busyId === u.id}
onChange={e => patchUser(u.id, { site_id: e.target.value || null })} onChange={e => patchUser(u.id, { site_id: e.target.value || null })}
className="border border-divider px-2 py-1 text-xs focus:outline-none focus:ring-1 focus:ring-accent cursor-pointer"> className="border border-gray-200 rounded-lg px-2 py-1 text-xs focus:outline-none focus:ring-1 focus:ring-green-500 cursor-pointer">
<option value="">No site</option> <option value="">No site</option>
{sites.map(s => <option key={s.id} value={s.id}>{s.name}</option>)} {sites.map(s => <option key={s.id} value={s.id}>{s.name}</option>)}
</select> </select>
@@ -149,10 +149,10 @@ export function UserManager({ users, sites }: Props) {
<td className="px-5 py-3"> <td className="px-5 py-3">
<button disabled={busyId === u.id} <button disabled={busyId === u.id}
onClick={() => patchUser(u.id, { active: !u.active })} onClick={() => patchUser(u.id, { active: !u.active })}
className={`text-xs px-2.5 py-1 font-medium border transition-colors cursor-pointer ${ className={`text-xs px-2.5 py-1 rounded-full font-medium border transition-colors cursor-pointer ${
u.active u.active
? 'bg-neutral-100 text-ink border-divider hover:bg-neutral-200' ? 'bg-green-50 text-green-700 border-green-200 hover:bg-green-100'
: 'bg-gray-50 text-gray-500 border-divider hover:bg-gray-100' : 'bg-gray-50 text-gray-500 border-gray-200 hover:bg-gray-100'
}`}> }`}>
{u.active ? 'Active' : 'Inactive'} {u.active ? 'Active' : 'Inactive'}
</button> </button>
@@ -178,18 +178,18 @@ export function UserManager({ users, sites }: Props) {
footer={ footer={
<> <>
<button type="button" onClick={() => { setShowAdd(false); setForm(EMPTY); setError(null) }} <button type="button" onClick={() => { setShowAdd(false); setForm(EMPTY); setError(null) }}
className="px-4 py-2 text-sm font-medium border border-divider text-gray-700 hover:bg-gray-50 cursor-pointer transition-colors"> className="px-4 py-2 text-sm font-medium rounded-lg border border-gray-300 text-gray-700 hover:bg-gray-50 cursor-pointer transition-colors">
Cancel Cancel
</button> </button>
<button form="add-user-form" type="submit" disabled={submitting} <button form="add-user-form" type="submit" disabled={submitting}
className="px-4 py-2 bg-accent text-white text-sm font-semibold hover:bg-accent-600 disabled:opacity-50 cursor-pointer transition-colors"> className="px-4 py-2 bg-green-600 text-white text-sm font-semibold rounded-lg hover:bg-green-700 disabled:opacity-50 cursor-pointer transition-colors">
{submitting ? 'Adding…' : 'Add User'} {submitting ? 'Adding…' : 'Add User'}
</button> </button>
</> </>
} }
> >
<form id="add-user-form" onSubmit={handleSubmit} className="space-y-4"> <form id="add-user-form" onSubmit={handleSubmit} className="space-y-4">
{error && <p className="text-xs text-red-600 bg-red-50 px-3 py-2">{error}</p>} {error && <p className="text-xs text-red-600 bg-red-50 px-3 py-2 rounded-lg">{error}</p>}
<div className="grid grid-cols-2 gap-3"> <div className="grid grid-cols-2 gap-3">
<div> <div>
<label className={lbl} htmlFor="au-email">Email *</label> <label className={lbl} htmlFor="au-email">Email *</label>
@@ -245,12 +245,12 @@ export function UserManager({ users, sites }: Props) {
footer={ footer={
<> <>
<button onClick={() => setConfirmDelete(null)} <button onClick={() => setConfirmDelete(null)}
className="px-4 py-2 text-sm font-medium border border-divider text-gray-700 hover:bg-gray-50 cursor-pointer transition-colors"> className="px-4 py-2 text-sm font-medium rounded-lg border border-gray-300 text-gray-700 hover:bg-gray-50 cursor-pointer transition-colors">
Cancel Cancel
</button> </button>
<button disabled={busyId === confirmDelete?.id} <button disabled={busyId === confirmDelete?.id}
onClick={() => confirmDelete && deleteUser(confirmDelete)} onClick={() => confirmDelete && deleteUser(confirmDelete)}
className="px-4 py-2 bg-red-600 text-white text-sm font-semibold hover:bg-red-700 disabled:opacity-50 cursor-pointer transition-colors"> className="px-4 py-2 bg-red-600 text-white text-sm font-semibold rounded-lg hover:bg-red-700 disabled:opacity-50 cursor-pointer transition-colors">
{busyId === confirmDelete?.id ? 'Deleting…' : 'Delete'} {busyId === confirmDelete?.id ? 'Deleting…' : 'Delete'}
</button> </button>
</> </>
+16 -12
View File
@@ -4,8 +4,6 @@
import { useState } from 'react' import { useState } from 'react'
import { useRouter } from 'next/navigation' import { useRouter } from 'next/navigation'
import Link from 'next/link' import Link from 'next/link'
import { Button } from '@/components/ui/button'
import { Input } from '@/components/ui/field'
export function LoginForm() { export function LoginForm() {
const [email, setEmail] = useState('') const [email, setEmail] = useState('')
@@ -39,38 +37,44 @@ export function LoginForm() {
return ( return (
<form onSubmit={handleSubmit} className="flex flex-col gap-4 w-full max-w-sm"> <form onSubmit={handleSubmit} className="flex flex-col gap-4 w-full max-w-sm">
<div className="pb-3 border-b-2 border-divider"> <div className="text-center">
<h1 className="text-3xl font-extrabold">IMS</h1> <h1 className="text-2xl font-bold">IMS</h1>
<p className="text-sm text-ink/60 mt-1">HSE Incident Management</p> <p className="text-sm text-gray-500 mt-1">HSE Incident Management</p>
</div> </div>
{error && ( {error && (
<p className="bg-accent-100 border border-accent text-accent-800 text-sm px-3 py-2"> <p className="bg-red-50 border border-red-200 text-red-700 text-sm rounded px-3 py-2">
{error} {error}
</p> </p>
)} )}
<Input <input
type="email" type="email"
placeholder="Email" placeholder="Email"
value={email} value={email}
onChange={(e) => setEmail(e.target.value)} onChange={(e) => setEmail(e.target.value)}
required required
autoComplete="email" autoComplete="email"
className="border rounded-md px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"
/> />
<Input <input
type="password" type="password"
placeholder="Password" placeholder="Password"
value={password} value={password}
onChange={(e) => setPassword(e.target.value)} onChange={(e) => setPassword(e.target.value)}
required required
autoComplete="current-password" autoComplete="current-password"
className="border rounded-md px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"
/> />
<Button type="submit" variant="primary" block disabled={loading}> <button
type="submit"
disabled={loading}
className="bg-blue-600 hover:bg-blue-700 text-white font-medium py-2 rounded-md disabled:opacity-50 transition-colors"
>
{loading ? 'Signing in…' : 'Sign in'} {loading ? 'Signing in…' : 'Sign in'}
</Button> </button>
<p className="text-sm text-ink/60"> <p className="text-center text-sm text-gray-500">
<Link href="/forgot-password" className="text-accent-700 hover:underline"> <Link href="/forgot-password" className="text-blue-600 hover:underline">
Forgot password? Forgot password?
</Link> </Link>
</p> </p>
+24 -18
View File
@@ -2,7 +2,6 @@
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'
@@ -28,14 +27,19 @@ const STATUS_LABELS: Record<CapaStatus, string> = {
reopened: 'Reopened', reopened: 'Reopened',
closed: 'Closed', closed: 'Closed',
} }
const COLUMN_BORDER: Record<CapaStatus, string> = { const STATUS_COLORS: Record<CapaStatus, string> = {
open: 'border-divider', open: 'bg-blue-50 border-blue-200',
in_progress: 'border-divider', in_progress: 'bg-yellow-50 border-yellow-200',
overdue: 'border-accent', overdue: 'bg-red-50 border-red-200',
pending_verification: 'border-divider', pending_verification: 'bg-purple-50 border-purple-200',
verified: 'border-divider', verified: 'bg-green-50 border-green-200',
reopened: 'border-accent', reopened: 'bg-orange-50 border-orange-200',
closed: 'border-divider', closed: 'bg-gray-50 border-gray-200',
}
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 {
@@ -54,7 +58,7 @@ 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('board')} className="text-sm text-accent-700 hover:underline">Board view</button> <button onClick={() => setView('board')} className="text-sm text-blue-600 hover:underline">Board view</button>
</div> </div>
<div className="overflow-x-auto"> <div className="overflow-x-auto">
<table className="w-full text-sm"> <table className="w-full text-sm">
@@ -68,21 +72,23 @@ export function CapaBoard({ capas }: Props) {
<th className="pb-2">Status</th> <th className="pb-2">Status</th>
</tr> </tr>
</thead> </thead>
<tbody className="divide-y divide-divider"> <tbody className="divide-y divide-gray-100">
{capas.map(c => ( {capas.map(c => (
<tr key={c.id}> <tr key={c.id}>
<td className="py-2 pr-4 text-gray-500 text-xs"> <td className="py-2 pr-4 text-gray-500 text-xs">
{(c.incidents as { reference_no: string | null } | null)?.reference_no ?? '—'} {(c.incidents as { reference_no: string | null } | null)?.reference_no ?? '—'}
</td> </td>
<td className="py-2 pr-4"> <td className="py-2 pr-4">
<Link href={`/hse/capa/${c.id}`} className="text-accent-700 hover:underline line-clamp-2"> <Link href={`/hse/capa/${c.id}`} className="text-blue-600 hover:underline line-clamp-2">
{c.description} {c.description}
</Link> </Link>
</td> </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.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">
<PriorityTag priority={c.priority} /> <span className={`px-2 py-0.5 rounded text-xs font-medium ${PRIORITY_BADGE[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>
@@ -97,22 +103,22 @@ 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-accent-700 hover:underline">Table view</button> <button onClick={() => setView('table')} className="text-sm text-blue-600 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-2 p-4 bg-ground ${COLUMN_BORDER[status]}`}> <div key={status} className={`rounded-xl border p-4 ${STATUS_COLORS[status]}`}>
<h3 className="text-xs font-extrabold uppercase tracking-wide text-ink/70 mb-3 pb-2 border-b-2 border-divider"> <h3 className="text-xs font-semibold uppercase tracking-wide text-gray-600 mb-3">
{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">
{byStatus[status].map(c => ( {byStatus[status].map(c => (
<Link key={c.id} href={`/hse/capa/${c.id}`} <Link key={c.id} href={`/hse/capa/${c.id}`}
className="block bg-surface p-3 shadow-sm hover:shadow-md transition-shadow border border-divider"> className="block bg-white rounded-lg p-3 shadow-sm hover:shadow-md transition-shadow border border-gray-100">
<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>
<PriorityTag priority={c.priority} /> <span className={`px-1.5 py-0.5 rounded ${PRIORITY_BADGE[c.priority]}`}>{c.priority}</span>
</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>
+6 -6
View File
@@ -77,7 +77,7 @@ export function CapaForm({ incidentId }: Props) {
value={description} value={description}
onChange={e => setDescription(e.target.value)} onChange={e => setDescription(e.target.value)}
rows={3} required rows={3} required
className="w-full border border-divider px-3 py-2 text-sm" className="w-full rounded-lg border border-gray-300 px-3 py-2 text-sm"
placeholder="What corrective action will be taken?" placeholder="What corrective action will be taken?"
/> />
</div> </div>
@@ -86,14 +86,14 @@ export function CapaForm({ incidentId }: Props) {
<label className="block text-sm font-medium text-gray-700 mb-1">Root Cause Reference</label> <label className="block text-sm font-medium text-gray-700 mb-1">Root Cause Reference</label>
<input type="text" value={rootCauseRef} <input type="text" value={rootCauseRef}
onChange={e => setRootCauseRef(e.target.value)} onChange={e => setRootCauseRef(e.target.value)}
className="w-full border border-divider px-3 py-2 text-sm" className="w-full rounded-lg border border-gray-300 px-3 py-2 text-sm"
placeholder="e.g. Why #3 — inadequate training" /> placeholder="e.g. Why #3 — inadequate training" />
</div> </div>
<div> <div>
<label className="block text-sm font-medium text-gray-700 mb-1">Assigned To *</label> <label className="block text-sm font-medium text-gray-700 mb-1">Assigned To *</label>
<select value={ownerId} onChange={e => handleOwnerChange(e.target.value)} required <select value={ownerId} onChange={e => handleOwnerChange(e.target.value)} required
className="w-full border border-divider px-3 py-2 text-sm"> className="w-full rounded-lg border border-gray-300 px-3 py-2 text-sm">
<option value="">Select owner…</option> <option value="">Select owner…</option>
{users.map(u => ( {users.map(u => (
<option key={u.id} value={u.id}>{u.name} ({u.department})</option> <option key={u.id} value={u.id}>{u.name} ({u.department})</option>
@@ -105,12 +105,12 @@ export function CapaForm({ incidentId }: Props) {
<div> <div>
<label className="block text-sm font-medium text-gray-700 mb-1">Due Date *</label> <label className="block text-sm font-medium text-gray-700 mb-1">Due Date *</label>
<input type="date" value={dueDate} onChange={e => setDueDate(e.target.value)} required <input type="date" value={dueDate} onChange={e => setDueDate(e.target.value)} required
className="w-full border border-divider px-3 py-2 text-sm" /> className="w-full rounded-lg border border-gray-300 px-3 py-2 text-sm" />
</div> </div>
<div> <div>
<label className="block text-sm font-medium text-gray-700 mb-1">Priority</label> <label className="block text-sm font-medium text-gray-700 mb-1">Priority</label>
<select value={priority} onChange={e => setPriority(e.target.value as 'low' | 'med' | 'high')} <select value={priority} onChange={e => setPriority(e.target.value as 'low' | 'med' | 'high')}
className="w-full border border-divider px-3 py-2 text-sm"> className="w-full rounded-lg border border-gray-300 px-3 py-2 text-sm">
<option value="low">Low</option> <option value="low">Low</option>
<option value="med">Medium</option> <option value="med">Medium</option>
<option value="high">High</option> <option value="high">High</option>
@@ -121,7 +121,7 @@ export function CapaForm({ incidentId }: Props) {
{error && <p className="text-sm text-red-600">{error}</p>} {error && <p className="text-sm text-red-600">{error}</p>}
<button type="submit" disabled={saving} <button type="submit" disabled={saving}
className="w-full bg-accent text-white py-2 text-sm font-semibold disabled:opacity-50"> className="w-full bg-amber-600 text-white rounded-lg py-2 text-sm font-semibold disabled:opacity-50">
{saving ? 'Creating…' : 'Create CAPA Action'} {saving ? 'Creating…' : 'Create CAPA Action'}
</button> </button>
</form> </form>
+2 -2
View File
@@ -36,7 +36,7 @@ export function CapaOwnerActions({ capaId, currentStatus }: Props) {
<button <button
onClick={() => updateStatus('in_progress')} onClick={() => updateStatus('in_progress')}
disabled={loading} disabled={loading}
className="text-sm px-3 py-1.5 border border-divider hover:bg-gray-50 disabled:opacity-50" className="text-sm px-3 py-1.5 border border-gray-300 rounded-md hover:bg-gray-50 disabled:opacity-50"
> >
{loading ? '…' : 'Mark In Progress'} {loading ? '…' : 'Mark In Progress'}
</button> </button>
@@ -48,7 +48,7 @@ export function CapaOwnerActions({ capaId, currentStatus }: Props) {
<button <button
onClick={() => updateStatus('pending_verification')} onClick={() => updateStatus('pending_verification')}
disabled={loading} disabled={loading}
className="text-sm px-3 py-1.5 bg-accent text-white hover:bg-accent-600 disabled:opacity-50" className="text-sm px-3 py-1.5 bg-blue-600 text-white rounded-md hover:bg-blue-700 disabled:opacity-50"
> >
{loading ? '…' : 'Submit for Verification'} {loading ? '…' : 'Submit for Verification'}
</button> </button>
+3 -3
View File
@@ -39,18 +39,18 @@ export function CapaOwnerNotesForm({ capaId, initialNotes }: Props) {
onChange={e => { setNotes(e.target.value); setSaved(false) }} onChange={e => { setNotes(e.target.value); setSaved(false) }}
rows={2} rows={2}
placeholder="Add any notes or updates for this action…" placeholder="Add any notes or updates for this action…"
className="w-full border border-divider px-3 py-2 text-sm text-gray-800 resize-none focus:outline-none focus:ring-2 focus:ring-accent" className="w-full rounded-md border border-gray-200 px-3 py-2 text-sm text-gray-800 resize-none focus:outline-none focus:ring-2 focus:ring-blue-500"
/> />
{error && <p className="text-xs text-red-600">{error}</p>} {error && <p className="text-xs text-red-600">{error}</p>}
<div className="flex items-center gap-2"> <div className="flex items-center gap-2">
<button <button
onClick={handleSave} onClick={handleSave}
disabled={saving} disabled={saving}
className="text-xs px-3 py-1 bg-gray-800 text-white hover:bg-gray-700 disabled:opacity-50" className="text-xs px-3 py-1 bg-gray-800 text-white rounded-md hover:bg-gray-700 disabled:opacity-50"
> >
{saving ? 'Saving…' : 'Save Notes'} {saving ? 'Saving…' : 'Save Notes'}
</button> </button>
{saved && <span className="text-xs text-ink">Saved</span>} {saved && <span className="text-xs text-green-600">Saved</span>}
</div> </div>
</div> </div>
) )
+2 -2
View File
@@ -31,7 +31,7 @@ export function CloseCapaButton({ capaId }: Props) {
} }
return ( return (
<div className="border border-divider p-5 space-y-3 bg-neutral-100"> <div className="border border-gray-200 rounded-xl p-5 space-y-3 bg-green-50">
<h3 className="text-sm font-semibold text-gray-800">Close CAPA</h3> <h3 className="text-sm font-semibold text-gray-800">Close CAPA</h3>
<p className="text-sm text-gray-600"> <p className="text-sm text-gray-600">
This CAPA has been verified as effective. Close it to mark it fully resolved. This CAPA has been verified as effective. Close it to mark it fully resolved.
@@ -40,7 +40,7 @@ export function CloseCapaButton({ capaId }: Props) {
<button <button
onClick={handleClose} onClick={handleClose}
disabled={loading} disabled={loading}
className="w-full bg-accent text-white py-2 text-sm font-semibold hover:bg-accent-700 disabled:opacity-50" className="w-full bg-green-700 text-white rounded-lg py-2 text-sm font-semibold hover:bg-green-800 disabled:opacity-50"
> >
{loading ? 'Closing…' : 'Close CAPA'} {loading ? 'Closing…' : 'Close CAPA'}
</button> </button>
+9 -9
View File
@@ -39,16 +39,16 @@ export function VerifyForm({ capaId }: Props) {
} }
return ( return (
<form onSubmit={handleSubmit} className="border border-divider p-5 space-y-4 bg-accent-100"> <form onSubmit={handleSubmit} className="border border-gray-200 rounded-xl p-5 space-y-4 bg-purple-50">
<h3 className="text-sm font-semibold text-gray-800">HSE Verification</h3> <h3 className="text-sm font-semibold text-gray-800">HSE Verification</h3>
<div className="flex gap-3"> <div className="flex gap-3">
<button <button
type="button" type="button"
onClick={() => setVerdict('verified')} onClick={() => setVerdict('verified')}
className={`flex-1 py-2 text-sm font-medium border ${ className={`flex-1 py-2 rounded-lg text-sm font-medium border ${
verdict === 'verified' verdict === 'verified'
? 'bg-accent text-white border-accent' ? 'bg-green-600 text-white border-green-600'
: 'bg-surface text-gray-700 border-divider hover:border-accent' : 'bg-white text-gray-700 border-gray-300 hover:border-green-500'
}`} }`}
> >
Verified — Effective Verified — Effective
@@ -56,10 +56,10 @@ export function VerifyForm({ capaId }: Props) {
<button <button
type="button" type="button"
onClick={() => setVerdict('reopened')} onClick={() => setVerdict('reopened')}
className={`flex-1 py-2 text-sm font-medium border ${ className={`flex-1 py-2 rounded-lg text-sm font-medium border ${
verdict === 'reopened' verdict === 'reopened'
? 'bg-accent text-white border-accent' ? 'bg-orange-600 text-white border-orange-600'
: 'bg-surface text-gray-700 border-divider hover:border-accent' : 'bg-white text-gray-700 border-gray-300 hover:border-orange-500'
}`} }`}
> >
Reopen — Ineffective Reopen — Ineffective
@@ -72,7 +72,7 @@ export function VerifyForm({ capaId }: Props) {
value={reopenReason} value={reopenReason}
onChange={e => setReopenReason(e.target.value)} onChange={e => setReopenReason(e.target.value)}
rows={2} required rows={2} required
className="w-full border border-divider px-3 py-2 text-sm" className="w-full rounded-lg border border-gray-300 px-3 py-2 text-sm"
placeholder="Describe why the corrective action did not resolve the root cause…" placeholder="Describe why the corrective action did not resolve the root cause…"
/> />
</div> </div>
@@ -80,7 +80,7 @@ export function VerifyForm({ capaId }: Props) {
{error && <p className="text-sm text-red-600">{error}</p>} {error && <p className="text-sm text-red-600">{error}</p>}
{verdict && ( {verdict && (
<button type="submit" disabled={saving} <button type="submit" disabled={saving}
className="w-full bg-gray-900 text-white py-2 text-sm font-semibold disabled:opacity-50"> className="w-full bg-gray-900 text-white rounded-lg py-2 text-sm font-semibold disabled:opacity-50">
{saving ? 'Saving…' : 'Submit Verification'} {saving ? 'Saving…' : 'Submit Verification'}
</button> </button>
)} )}
+4 -4
View File
@@ -15,15 +15,15 @@ function TabsInner({ activeTab }: { activeTab: string }) {
const pathname = usePathname() const pathname = usePathname()
return ( return (
<div className="flex border-b border-divider mb-6 overflow-x-auto -mx-4 px-4"> <div className="flex border-b border-gray-200 mb-6 overflow-x-auto -mx-4 px-4">
{TABS.map(tab => ( {TABS.map(tab => (
<button <button
key={tab.key} key={tab.key}
onClick={() => router.replace(`${pathname}?tab=${tab.key}`)} onClick={() => router.replace(`${pathname}?tab=${tab.key}`)}
className={`px-4 py-2.5 text-sm font-medium whitespace-nowrap border-b-2 transition-colors ${ className={`px-4 py-2.5 text-sm font-medium whitespace-nowrap border-b-2 transition-colors ${
activeTab === tab.key activeTab === tab.key
? 'border-accent text-accent-700' ? 'border-blue-600 text-blue-600'
: 'border-transparent text-gray-500 hover:text-gray-700 hover:border-divider' : 'border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300'
}`} }`}
> >
{tab.label} {tab.label}
@@ -35,7 +35,7 @@ function TabsInner({ activeTab }: { activeTab: string }) {
export function DashboardTabs({ activeTab }: { activeTab: string }) { export function DashboardTabs({ activeTab }: { activeTab: string }) {
return ( return (
<Suspense fallback={<div className="h-11 mb-6 border-b border-divider" />}> <Suspense fallback={<div className="h-11 mb-6 border-b border-gray-200" />}>
<TabsInner activeTab={activeTab} /> <TabsInner activeTab={activeTab} />
</Suspense> </Suspense>
) )
+6 -6
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-neutral-100 text-neutral-800 border-divider', low: 'bg-yellow-50 text-yellow-700 border-yellow-200',
medium: 'bg-ground text-accent-700 border-accent', medium: 'bg-orange-50 text-orange-700 border-orange-200',
high: 'bg-accent-100 text-accent-800 border-accent', high: 'bg-red-50 text-red-700 border-red-200',
} }
export function RiskFlagsPanel() { export function RiskFlagsPanel() {
@@ -43,7 +43,7 @@ export function RiskFlagsPanel() {
} }
return ( return (
<div className="bg-surface shadow-sm p-5 mb-4"> <div className="bg-white rounded-xl shadow-sm p-5 mb-4">
<div className="flex items-center justify-between mb-1"> <div className="flex items-center justify-between mb-1">
<h2 className="text-sm font-semibold text-gray-700 uppercase tracking-wide"> <h2 className="text-sm font-semibold text-gray-700 uppercase tracking-wide">
Rising-Risk Zones (AI) Rising-Risk Zones (AI)
@@ -51,7 +51,7 @@ export function RiskFlagsPanel() {
<button <button
onClick={analyze} onClick={analyze}
disabled={loading} disabled={loading}
className="bg-accent-100 text-accent-700 border border-accent-300 px-3 py-1.5 text-xs font-semibold disabled:opacity-50 hover:bg-accent-200" className="bg-purple-50 text-purple-700 border border-purple-300 rounded-lg px-3 py-1.5 text-xs font-semibold disabled:opacity-50 hover:bg-purple-100"
> >
{loading ? 'Analyzing…' : flags ? 'Re-analyze' : 'Analyze 90-Day Risk'} {loading ? 'Analyzing…' : flags ? 'Re-analyze' : 'Analyze 90-Day Risk'}
</button> </button>
@@ -71,7 +71,7 @@ export function RiskFlagsPanel() {
<p className="text-sm text-gray-700 mb-3">{summary}</p> <p className="text-sm text-gray-700 mb-3">{summary}</p>
<div className="space-y-2"> <div className="space-y-2">
{flags.map(f => ( {flags.map(f => (
<div key={`${f.site}-${f.zone}`} className={`border p-3 ${LEVEL_COLORS[f.risk_level]}`}> <div key={`${f.site}-${f.zone}`} className={`border rounded-lg p-3 ${LEVEL_COLORS[f.risk_level]}`}>
<div className="flex items-center justify-between mb-1"> <div className="flex items-center justify-between mb-1">
<span className="text-sm font-semibold">{f.zone} · {f.site}</span> <span className="text-sm font-semibold">{f.zone} · {f.site}</span>
<span className="text-xs font-bold uppercase">{f.risk_level}</span> <span className="text-xs font-bold uppercase">{f.risk_level}</span>
+3 -3
View File
@@ -7,14 +7,14 @@ interface Props {
const ACCENT = { const ACCENT = {
default: 'border-gray-200', default: 'border-gray-200',
green: 'border-divider', green: 'border-green-400',
yellow: 'border-accent-300', yellow: 'border-yellow-400',
red: 'border-red-400', red: 'border-red-400',
} }
export function StatCard({ label, value, sub, accent = 'default' }: Props) { export function StatCard({ label, value, sub, accent = 'default' }: Props) {
return ( return (
<div className={`bg-surface shadow-sm p-5 border-t-4 ${ACCENT[accent]}`}> <div className={`bg-white rounded-xl shadow-sm p-5 border-t-4 ${ACCENT[accent]}`}>
<p className="text-xs text-gray-500 uppercase tracking-wide font-medium">{label}</p> <p className="text-xs text-gray-500 uppercase tracking-wide font-medium">{label}</p>
<p className="text-3xl font-bold text-gray-900 mt-1">{value}</p> <p className="text-3xl font-bold text-gray-900 mt-1">{value}</p>
{sub && <p className="text-xs text-gray-400 mt-1">{sub}</p>} {sub && <p className="text-xs text-gray-400 mt-1">{sub}</p>}
+5 -5
View File
@@ -78,7 +78,7 @@ export function ClosurePanel({ incidentId, status, canClose, canAddAddenda }: Pr
<button <button
onClick={closeIncident} onClick={closeIncident}
disabled={busy} disabled={busy}
className="bg-accent text-white px-4 py-2 text-sm font-semibold hover:bg-accent-700 disabled:opacity-50" className="bg-green-700 text-white rounded-lg px-4 py-2 text-sm font-semibold hover:bg-green-800 disabled:opacity-50"
> >
{busy ? 'Closing…' : 'Close Incident'} {busy ? 'Closing…' : 'Close Incident'}
</button> </button>
@@ -89,7 +89,7 @@ export function ClosurePanel({ incidentId, status, canClose, canAddAddenda }: Pr
} }
return ( return (
<div className="mt-6 bg-surface shadow-sm p-5"> <div className="mt-6 bg-white rounded-xl shadow-sm p-5">
<h2 className="text-sm font-semibold text-gray-700 uppercase tracking-wide mb-1">Addenda</h2> <h2 className="text-sm font-semibold text-gray-700 uppercase tracking-wide mb-1">Addenda</h2>
<p className="text-xs text-gray-400 mb-3"> <p className="text-xs text-gray-400 mb-3">
This incident is closed and locked. New information is recorded as addenda. This incident is closed and locked. New information is recorded as addenda.
@@ -99,7 +99,7 @@ export function ClosurePanel({ incidentId, status, canClose, canAddAddenda }: Pr
) : ( ) : (
<ul className="space-y-3"> <ul className="space-y-3">
{addenda.map(a => ( {addenda.map(a => (
<li key={a.id} className="border border-divider p-3"> <li key={a.id} className="border border-gray-100 rounded-lg p-3">
<p className="text-sm text-gray-800 whitespace-pre-wrap">{a.body}</p> <p className="text-sm text-gray-800 whitespace-pre-wrap">{a.body}</p>
<p className="text-xs text-gray-400 mt-1"> <p className="text-xs text-gray-400 mt-1">
{a.author?.name ?? 'Unknown'} · {new Date(a.created_at).toLocaleString('en-MY', { timeZone: 'Asia/Kuala_Lumpur' })} {a.author?.name ?? 'Unknown'} · {new Date(a.created_at).toLocaleString('en-MY', { timeZone: 'Asia/Kuala_Lumpur' })}
@@ -115,12 +115,12 @@ export function ClosurePanel({ incidentId, status, canClose, canAddAddenda }: Pr
onChange={e => setDraft(e.target.value)} onChange={e => setDraft(e.target.value)}
rows={3} rows={3}
placeholder="Add an addendum…" placeholder="Add an addendum…"
className="w-full border border-divider p-2 text-sm" className="w-full border border-gray-200 rounded-lg p-2 text-sm"
/> />
<button <button
onClick={addAddendum} onClick={addAddendum}
disabled={busy || !draft.trim()} disabled={busy || !draft.trim()}
className="mt-2 bg-gray-800 text-white px-4 py-2 text-sm font-semibold hover:bg-gray-900 disabled:opacity-50" className="mt-2 bg-gray-800 text-white rounded-lg px-4 py-2 text-sm font-semibold hover:bg-gray-900 disabled:opacity-50"
> >
{busy ? 'Saving…' : 'Add Addendum'} {busy ? 'Saving…' : 'Add Addendum'}
</button> </button>
+1 -1
View File
@@ -34,7 +34,7 @@ export function EvidenceGallery({ files, stage }: Props) {
href={file.file_url} href={file.file_url}
target="_blank" target="_blank"
rel="noopener noreferrer" rel="noopener noreferrer"
className="block overflow-hidden bg-gray-100 aspect-square hover:opacity-90 transition-opacity" className="block rounded-lg overflow-hidden bg-gray-100 aspect-square hover:opacity-90 transition-opacity"
> >
{isImage(file.file_type) ? ( {isImage(file.file_type) ? (
<img <img
+3 -3
View File
@@ -57,8 +57,8 @@ export function FileUpload({ onFilesChange, disabled = false }: Props) {
return ( return (
<div className="space-y-2"> <div className="space-y-2">
<div <div
className={`border-2 border-dashed p-6 text-center cursor-pointer transition-colors className={`border-2 border-dashed rounded-lg p-6 text-center cursor-pointer transition-colors
${dragging ? 'border-accent bg-accent-100' : 'border-divider hover:border-gray-400'} ${dragging ? 'border-blue-500 bg-blue-50' : 'border-gray-300 hover:border-gray-400'}
${disabled ? 'opacity-50 pointer-events-none' : ''}`} ${disabled ? 'opacity-50 pointer-events-none' : ''}`}
onClick={() => inputRef.current?.click()} onClick={() => inputRef.current?.click()}
onDragOver={e => { e.preventDefault(); setDragging(true) }} onDragOver={e => { e.preventDefault(); setDragging(true) }}
@@ -94,7 +94,7 @@ export function FileUpload({ onFilesChange, disabled = false }: Props) {
{files.length > 0 && ( {files.length > 0 && (
<ul className="space-y-1"> <ul className="space-y-1">
{files.map((f, i) => ( {files.map((f, i) => (
<li key={i} className="flex items-center justify-between bg-gray-50 px-3 py-2 text-sm"> <li key={i} className="flex items-center justify-between bg-gray-50 rounded px-3 py-2 text-sm">
<span className="truncate max-w-xs">{f.name}</span> <span className="truncate max-w-xs">{f.name}</span>
<button <button
type="button" type="button"
+15 -5
View File
@@ -1,5 +1,4 @@
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',
@@ -12,6 +11,15 @@ 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',
@@ -64,7 +72,7 @@ export function IncidentDetail({ incident }: Props) {
return ( return (
<div className="space-y-6"> <div className="space-y-6">
<div className="bg-surface shadow-sm p-5"> <div className="bg-white rounded-xl shadow-sm p-5">
<div className="flex items-start justify-between mb-4"> <div className="flex items-start justify-between mb-4">
<div> <div>
<h1 className="text-xl font-bold text-gray-900 font-mono"> <h1 className="text-xl font-bold text-gray-900 font-mono">
@@ -72,7 +80,9 @@ 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>
<StatusTag status={incident.status}>{incident.status.replace(/_/g, ' ').toUpperCase()}</StatusTag> <span className={`text-xs px-2.5 py-1 rounded-full font-medium ${STATUS_COLORS[incident.status] ?? 'bg-gray-100'}`}>
{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">
@@ -104,12 +114,12 @@ export function IncidentDetail({ incident }: Props) {
</dl> </dl>
</div> </div>
<div className="bg-surface shadow-sm p-5"> <div className="bg-white rounded-xl shadow-sm p-5">
<h2 className="text-sm font-semibold text-gray-900 mb-2">Description</h2> <h2 className="text-sm font-semibold text-gray-900 mb-2">Description</h2>
<p className="text-sm text-gray-800 leading-relaxed whitespace-pre-wrap">{incident.description}</p> <p className="text-sm text-gray-800 leading-relaxed whitespace-pre-wrap">{incident.description}</p>
</div> </div>
<div className="bg-surface shadow-sm p-5"> <div className="bg-white rounded-xl shadow-sm p-5">
<h2 className="text-sm font-semibold text-gray-900 mb-3"> <h2 className="text-sm font-semibold text-gray-900 mb-3">
Evidence — Report Stage Evidence — Report Stage
<span className="ml-2 text-gray-400 font-normal normal-case"> <span className="ml-2 text-gray-400 font-normal normal-case">
+5 -5
View File
@@ -77,20 +77,20 @@ function FiltersInner({ sites, trucks }: FiltersProps) {
placeholder="Search reference or description..." placeholder="Search reference or description..."
value={search} value={search}
onChange={e => handleSearch(e.target.value)} onChange={e => handleSearch(e.target.value)}
className="w-full pl-8 pr-3 py-1.5 text-sm border border-divider focus:outline-none focus:ring-2 focus:ring-accent" className="w-full pl-8 pr-3 py-1.5 text-sm border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"
/> />
</div> </div>
<select <select
value={searchParams.get('status') ?? ''} value={searchParams.get('status') ?? ''}
onChange={e => updateParam('status', e.target.value)} onChange={e => updateParam('status', e.target.value)}
className="text-sm border border-divider px-2 py-1.5 focus:outline-none focus:ring-2 focus:ring-accent bg-surface" className="text-sm border border-gray-300 rounded-lg px-2 py-1.5 focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white"
> >
{STATUS_OPTIONS.map(o => <option key={o.value} value={o.value}>{o.label}</option>)} {STATUS_OPTIONS.map(o => <option key={o.value} value={o.value}>{o.label}</option>)}
</select> </select>
<select <select
value={searchParams.get('type') ?? ''} value={searchParams.get('type') ?? ''}
onChange={e => updateParam('type', e.target.value)} onChange={e => updateParam('type', e.target.value)}
className="text-sm border border-divider px-2 py-1.5 focus:outline-none focus:ring-2 focus:ring-accent bg-surface" className="text-sm border border-gray-300 rounded-lg px-2 py-1.5 focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white"
> >
{TYPE_OPTIONS.map(o => <option key={o.value} value={o.value}>{o.label}</option>)} {TYPE_OPTIONS.map(o => <option key={o.value} value={o.value}>{o.label}</option>)}
</select> </select>
@@ -98,7 +98,7 @@ function FiltersInner({ sites, trucks }: FiltersProps) {
<select <select
value={searchParams.get('site_id') ?? ''} value={searchParams.get('site_id') ?? ''}
onChange={e => updateParam('site_id', e.target.value)} onChange={e => updateParam('site_id', e.target.value)}
className="text-sm border border-divider px-2 py-1.5 focus:outline-none focus:ring-2 focus:ring-accent bg-surface" className="text-sm border border-gray-300 rounded-lg px-2 py-1.5 focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white"
> >
<option value="">All Sites</option> <option value="">All Sites</option>
{sites.map(s => <option key={s.id} value={s.id}>{s.name}</option>)} {sites.map(s => <option key={s.id} value={s.id}>{s.name}</option>)}
@@ -108,7 +108,7 @@ function FiltersInner({ sites, trucks }: FiltersProps) {
<select <select
value={searchParams.get('truck_id') ?? ''} value={searchParams.get('truck_id') ?? ''}
onChange={e => updateParam('truck_id', e.target.value)} onChange={e => updateParam('truck_id', e.target.value)}
className="text-sm border border-divider px-2 py-1.5 focus:outline-none focus:ring-2 focus:ring-accent bg-surface" className="text-sm border border-gray-300 rounded-lg px-2 py-1.5 focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white"
> >
<option value="">All Trucks</option> <option value="">All Trucks</option>
{trucks.map(tk => <option key={tk.id} value={tk.id}>{tk.truck_no}</option>)} {trucks.map(tk => <option key={tk.id} value={tk.id}>{tk.truck_no}</option>)}
+16 -6
View File
@@ -1,7 +1,6 @@
'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
@@ -13,6 +12,15 @@ 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',
@@ -27,7 +35,7 @@ export function IncidentHeader({
canTriage, canInvestigate, canAddCapa, canTriage, canInvestigate, canAddCapa,
}: Props) { }: Props) {
return ( return (
<div className="sticky top-0 z-30 bg-surface border-b border-divider shadow-sm"> <div className="sticky top-0 z-30 bg-white border-b border-gray-200 shadow-sm">
<div className="max-w-3xl mx-auto px-4 py-3 flex items-center justify-between gap-4 flex-wrap"> <div className="max-w-3xl mx-auto px-4 py-3 flex items-center justify-between gap-4 flex-wrap">
<div className="flex items-center gap-3 min-w-0"> <div className="flex items-center gap-3 min-w-0">
<Link href={backHref} className="text-sm text-gray-500 hover:text-gray-700 shrink-0"> <Link href={backHref} className="text-sm text-gray-500 hover:text-gray-700 shrink-0">
@@ -37,13 +45,15 @@ 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="shrink-0"><StatusTag status={status}>{STATUS_LABELS[status] ?? status.replace(/_/g, ' ')}</StatusTag></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'}`}>
{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 && (
<Link <Link
href={`/hse/incidents/${incidentId}/triage`} href={`/hse/incidents/${incidentId}/triage`}
className="text-xs px-3 py-1.5 bg-accent text-white font-medium hover:bg-accent-600" className="text-xs px-3 py-1.5 bg-blue-600 text-white rounded-lg font-medium hover:bg-blue-700"
> >
Triage Triage
</Link> </Link>
@@ -51,7 +61,7 @@ export function IncidentHeader({
{canInvestigate && ( {canInvestigate && (
<Link <Link
href={`/hse/incidents/${incidentId}/investigation`} href={`/hse/incidents/${incidentId}/investigation`}
className="text-xs px-3 py-1.5 bg-accent text-white font-medium hover:bg-accent-600" className="text-xs px-3 py-1.5 bg-indigo-600 text-white rounded-lg font-medium hover:bg-indigo-700"
> >
Investigate Investigate
</Link> </Link>
@@ -59,7 +69,7 @@ export function IncidentHeader({
{canAddCapa && ( {canAddCapa && (
<Link <Link
href={`/hse/incidents/${incidentId}/capa/new`} href={`/hse/incidents/${incidentId}/capa/new`}
className="text-xs px-3 py-1.5 bg-accent text-white font-medium hover:bg-accent-600" className="text-xs px-3 py-1.5 bg-amber-600 text-white rounded-lg font-medium hover:bg-amber-700"
> >
Add CAPA Add CAPA
</Link> </Link>
+16 -8
View File
@@ -2,7 +2,6 @@
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',
@@ -15,7 +14,14 @@ const TYPE_LABELS: Record<string, string> = {
transport: 'Transport / Vehicle', transport: 'Transport / Vehicle',
} }
const STATUS_ORDER = ['reported', 'triaged', 'investigating', 'capa_pending', 'verification', 'closed'] as const 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',
}
export type Incident = { export type Incident = {
id: string id: string
@@ -60,12 +66,12 @@ export function IncidentList({ incidents, basePath }: Props) {
<input <input
type="search" type="search"
placeholder="Search ref, type, site…" placeholder="Search ref, type, site…"
className="border border-divider px-3 py-2 text-sm w-48 focus:outline-none focus:ring-2 focus:ring-accent" className="border border-gray-300 rounded-lg px-3 py-2 text-sm w-48 focus:outline-none focus:ring-2 focus:ring-blue-500"
value={search} value={search}
onChange={e => setSearch(e.target.value)} onChange={e => setSearch(e.target.value)}
/> />
<select <select
className="border border-divider px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-accent" className="border border-gray-300 rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"
value={typeFilter} value={typeFilter}
onChange={e => setTypeFilter(e.target.value)} onChange={e => setTypeFilter(e.target.value)}
> >
@@ -75,12 +81,12 @@ export function IncidentList({ incidents, basePath }: Props) {
))} ))}
</select> </select>
<select <select
className="border border-divider px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-accent" className="border border-gray-300 rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"
value={statusFilter} value={statusFilter}
onChange={e => setStatusFilter(e.target.value)} onChange={e => setStatusFilter(e.target.value)}
> >
<option value="">All statuses</option> <option value="">All statuses</option>
{STATUS_ORDER.map(s => ( {Object.keys(STATUS_COLORS).map(s => (
<option key={s} value={s}>{s.replace(/_/g, ' ')}</option> <option key={s} value={s}>{s.replace(/_/g, ' ')}</option>
))} ))}
</select> </select>
@@ -89,7 +95,7 @@ export function IncidentList({ incidents, basePath }: Props) {
{filtered.length === 0 ? ( {filtered.length === 0 ? (
<div className="text-center py-12 text-gray-500 text-sm">No incidents found</div> <div className="text-center py-12 text-gray-500 text-sm">No incidents found</div>
) : ( ) : (
<div className="divide-y divide-divider bg-surface shadow-sm overflow-hidden"> <div className="divide-y divide-gray-100 bg-white rounded-xl shadow-sm overflow-hidden">
{filtered.map(inc => ( {filtered.map(inc => (
<Link <Link
key={inc.id} key={inc.id}
@@ -101,7 +107,9 @@ 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>
<StatusTag status={inc.status}>{inc.status.replace(/_/g, ' ').toUpperCase()}</StatusTag> <span className={`text-xs px-2 py-0.5 rounded-full font-medium ${STATUS_COLORS[inc.status] ?? 'bg-gray-100 text-gray-700'}`}>
{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}
+19 -19
View File
@@ -136,7 +136,7 @@ export function InvestigationForm({ incidentId, existingInvestigationId }: Props
type="button" type="button"
onClick={getAiDraft} onClick={getAiDraft}
disabled={aiDraftLoading} disabled={aiDraftLoading}
className="bg-accent-100 text-accent-700 border border-accent-300 px-3 py-1.5 text-xs font-semibold disabled:opacity-50 hover:bg-accent-200" className="bg-purple-50 text-purple-700 border border-purple-300 rounded-lg px-3 py-1.5 text-xs font-semibold disabled:opacity-50 hover:bg-purple-100"
> >
{aiDraftLoading ? 'Drafting…' : 'Get AI Draft'} {aiDraftLoading ? 'Drafting…' : 'Get AI Draft'}
</button> </button>
@@ -148,10 +148,10 @@ export function InvestigationForm({ incidentId, existingInvestigationId }: Props
<button <button
key={m} type="button" key={m} type="button"
onClick={() => setMethod(m)} onClick={() => setMethod(m)}
className={`px-3 py-1.5 text-sm font-medium border ${ className={`px-3 py-1.5 rounded-lg text-sm font-medium border ${
method === m method === m
? 'bg-accent text-white border-accent' ? 'bg-blue-600 text-white border-blue-600'
: 'bg-surface text-gray-700 border-divider hover:border-accent' : 'bg-white text-gray-700 border-gray-300 hover:border-blue-400'
}`} }`}
> >
{m === 'five_why' ? '5-Why' : m === 'fishbone' ? 'Fishbone' : 'Other'} {m === 'five_why' ? '5-Why' : m === 'fishbone' ? 'Fishbone' : 'Other'}
@@ -164,25 +164,25 @@ export function InvestigationForm({ incidentId, existingInvestigationId }: Props
<div className="space-y-3"> <div className="space-y-3">
<p className="text-sm font-medium text-gray-700">5-Why Analysis</p> <p className="text-sm font-medium text-gray-700">5-Why Analysis</p>
{fiveWhy.map((step, i) => ( {fiveWhy.map((step, i) => (
<div key={i} className="border border-divider p-3 space-y-2"> <div key={i} className="border border-gray-200 rounded-lg p-3 space-y-2">
<label className="block text-xs text-gray-500">Why #{i + 1}</label> <label className="block text-xs text-gray-500">Why #{i + 1}</label>
<input <input
type="text" value={step.why} type="text" value={step.why}
onChange={e => updateWhyStep(i, 'why', e.target.value)} onChange={e => updateWhyStep(i, 'why', e.target.value)}
placeholder="Why did this happen?" placeholder="Why did this happen?"
className="w-full border border-divider px-2 py-1.5 text-sm" className="w-full rounded border border-gray-300 px-2 py-1.5 text-sm"
/> />
<textarea <textarea
value={step.answer} value={step.answer}
onChange={e => updateWhyStep(i, 'answer', e.target.value)} onChange={e => updateWhyStep(i, 'answer', e.target.value)}
rows={2} placeholder="Answer / finding…" rows={2} placeholder="Answer / finding…"
className="w-full border border-divider px-2 py-1.5 text-sm" className="w-full rounded border border-gray-300 px-2 py-1.5 text-sm"
/> />
</div> </div>
))} ))}
{fiveWhy.length < 5 && ( {fiveWhy.length < 5 && (
<button type="button" onClick={addWhyStep} <button type="button" onClick={addWhyStep}
className="text-sm text-accent-700 hover:underline"> className="text-sm text-blue-600 hover:underline">
+ Add another Why + Add another Why
</button> </button>
)} )}
@@ -193,7 +193,7 @@ export function InvestigationForm({ incidentId, existingInvestigationId }: Props
<div className="space-y-3"> <div className="space-y-3">
<p className="text-sm font-medium text-gray-700">Fishbone (Ishikawa) Analysis</p> <p className="text-sm font-medium text-gray-700">Fishbone (Ishikawa) Analysis</p>
{fishbone.map((cat, catIdx) => ( {fishbone.map((cat, catIdx) => (
<div key={cat.category} className="border border-divider p-3"> <div key={cat.category} className="border border-gray-200 rounded-lg p-3">
<p className="text-xs font-semibold text-gray-600 mb-2">{CATEGORY_LABELS[cat.category]}</p> <p className="text-xs font-semibold text-gray-600 mb-2">{CATEGORY_LABELS[cat.category]}</p>
{cat.causes.map((cause, causeIdx) => ( {cat.causes.map((cause, causeIdx) => (
<input <input
@@ -201,11 +201,11 @@ export function InvestigationForm({ incidentId, existingInvestigationId }: Props
type="text" value={cause} type="text" value={cause}
onChange={e => updateFishboneCause(catIdx, causeIdx, e.target.value)} onChange={e => updateFishboneCause(catIdx, causeIdx, e.target.value)}
placeholder="Contributing cause…" placeholder="Contributing cause…"
className="w-full border border-divider px-2 py-1.5 text-sm mb-1.5" className="w-full rounded border border-gray-300 px-2 py-1.5 text-sm mb-1.5"
/> />
))} ))}
<button type="button" onClick={() => addFishboneCause(catIdx)} <button type="button" onClick={() => addFishboneCause(catIdx)}
className="text-xs text-accent-700 hover:underline"> className="text-xs text-blue-600 hover:underline">
+ Add cause + Add cause
</button> </button>
</div> </div>
@@ -219,7 +219,7 @@ export function InvestigationForm({ incidentId, existingInvestigationId }: Props
<select <select
value={alcoholTest} value={alcoholTest}
onChange={e => setAlcoholTest(e.target.value)} onChange={e => setAlcoholTest(e.target.value)}
className="w-full border border-divider px-3 py-2 text-sm" className="w-full rounded-lg border border-gray-300 px-3 py-2 text-sm"
> >
<option value="">Not conducted</option> <option value="">Not conducted</option>
<option value="negative">Negative</option> <option value="negative">Negative</option>
@@ -233,7 +233,7 @@ export function InvestigationForm({ incidentId, existingInvestigationId }: Props
<select <select
value={urineTest} value={urineTest}
onChange={e => setUrineTest(e.target.value)} onChange={e => setUrineTest(e.target.value)}
className="w-full border border-divider px-3 py-2 text-sm" className="w-full rounded-lg border border-gray-300 px-3 py-2 text-sm"
> >
<option value="">Not conducted</option> <option value="">Not conducted</option>
<option value="negative">Negative</option> <option value="negative">Negative</option>
@@ -256,13 +256,13 @@ export function InvestigationForm({ incidentId, existingInvestigationId }: Props
value={ref} value={ref}
onChange={e => setWitnessRefs(witnessRefs.map((w, j) => (j === i ? e.target.value : w)))} onChange={e => setWitnessRefs(witnessRefs.map((w, j) => (j === i ? e.target.value : w)))}
placeholder="e.g. Ali bin Ahmad — statement dated 12/07/2026" placeholder="e.g. Ali bin Ahmad — statement dated 12/07/2026"
className="w-full border border-divider px-2 py-1.5 text-sm mb-1.5" className="w-full rounded border border-gray-300 px-2 py-1.5 text-sm mb-1.5"
/> />
))} ))}
<button <button
type="button" type="button"
onClick={() => setWitnessRefs([...witnessRefs, ''])} onClick={() => setWitnessRefs([...witnessRefs, ''])}
className="text-xs text-accent-700 hover:underline" className="text-xs text-blue-600 hover:underline"
> >
+ Add witness statement + Add witness statement
</button> </button>
@@ -274,7 +274,7 @@ export function InvestigationForm({ incidentId, existingInvestigationId }: Props
value={findingsText} value={findingsText}
onChange={e => setFindingsText(e.target.value)} onChange={e => setFindingsText(e.target.value)}
rows={3} rows={3}
className="w-full border border-divider px-3 py-2 text-sm" className="w-full rounded-lg border border-gray-300 px-3 py-2 text-sm"
placeholder="Describe the sequence of events and contributing factors…" placeholder="Describe the sequence of events and contributing factors…"
/> />
</div> </div>
@@ -285,7 +285,7 @@ export function InvestigationForm({ incidentId, existingInvestigationId }: Props
value={rootCause} value={rootCause}
onChange={e => setRootCause(e.target.value)} onChange={e => setRootCause(e.target.value)}
rows={2} rows={2}
className="w-full border border-divider px-3 py-2 text-sm" className="w-full rounded-lg border border-gray-300 px-3 py-2 text-sm"
placeholder="One-sentence root cause statement…" placeholder="One-sentence root cause statement…"
/> />
</div> </div>
@@ -293,7 +293,7 @@ export function InvestigationForm({ incidentId, existingInvestigationId }: Props
{!existingInvestigationId && ( {!existingInvestigationId && (
<label className="flex items-center gap-2 text-sm text-gray-700"> <label className="flex items-center gap-2 text-sm text-gray-700">
<input type="checkbox" checked={complete} onChange={e => setComplete(e.target.checked)} <input type="checkbox" checked={complete} onChange={e => setComplete(e.target.checked)}
className="border-divider text-accent-700" /> className="rounded border-gray-300 text-blue-600" />
Mark investigation complete (transitions incident to CAPA Pending) Mark investigation complete (transitions incident to CAPA Pending)
</label> </label>
)} )}
@@ -301,7 +301,7 @@ export function InvestigationForm({ incidentId, existingInvestigationId }: Props
{error && <p className="text-sm text-red-600">{error}</p>} {error && <p className="text-sm text-red-600">{error}</p>}
<button type="submit" disabled={saving} <button type="submit" disabled={saving}
className="w-full bg-accent text-white py-2 text-sm font-semibold disabled:opacity-50"> className="w-full bg-indigo-600 text-white rounded-lg py-2 text-sm font-semibold disabled:opacity-50">
{saving ? 'Saving…' : existingInvestigationId ? 'Update Investigation' : 'Start Investigation'} {saving ? 'Saving…' : existingInvestigationId ? 'Update Investigation' : 'Start Investigation'}
</button> </button>
</form> </form>
+7 -7
View File
@@ -35,15 +35,15 @@ export function InvestigationPanel({ investigation: inv }: Props) {
const investigatorName = inv.investigator?.name ?? inv.investigator?.email ?? 'Unknown' const investigatorName = inv.investigator?.name ?? inv.investigator?.email ?? 'Unknown'
return ( return (
<div className="mt-6 bg-surface shadow-sm border border-divider overflow-hidden"> <div className="mt-6 bg-white rounded-xl shadow-sm border border-gray-200 overflow-hidden">
<div className="flex items-center justify-between px-5 py-4 border-b border-divider"> <div className="flex items-center justify-between px-5 py-4 border-b border-gray-100">
<h2 className="text-sm font-semibold text-gray-900">Investigation</h2> <h2 className="text-sm font-semibold text-gray-900">Investigation</h2>
<div className="flex items-center gap-2"> <div className="flex items-center gap-2">
<span className="text-xs text-gray-500">{METHOD_LABELS[inv.method] ?? inv.method}</span> <span className="text-xs text-gray-500">{METHOD_LABELS[inv.method] ?? inv.method}</span>
<span className={`text-xs font-medium px-2 py-0.5 ${ <span className={`text-xs font-medium px-2 py-0.5 rounded-full ${
inv.completed_at inv.completed_at
? 'bg-neutral-100 text-ink' ? 'bg-green-100 text-green-700'
: 'bg-accent-100 text-accent-700' : 'bg-yellow-100 text-yellow-700'
}`}> }`}>
{inv.completed_at ? 'Completed' : 'In Progress'} {inv.completed_at ? 'Completed' : 'In Progress'}
</span> </span>
@@ -67,7 +67,7 @@ export function InvestigationPanel({ investigation: inv }: Props) {
<ol className="space-y-3"> <ol className="space-y-3">
{inv.five_why_steps.map((step, i) => ( {inv.five_why_steps.map((step, i) => (
<li key={i} className="flex gap-3"> <li key={i} className="flex gap-3">
<span className="flex-shrink-0 w-6 h-6 bg-accent-100 text-accent-700 text-xs font-bold flex items-center justify-center"> <span className="flex-shrink-0 w-6 h-6 rounded-full bg-blue-100 text-blue-700 text-xs font-bold flex items-center justify-center">
{i + 1} {i + 1}
</span> </span>
<div className="flex-1 min-w-0"> <div className="flex-1 min-w-0">
@@ -107,7 +107,7 @@ export function InvestigationPanel({ investigation: inv }: Props) {
{/* Root cause */} {/* Root cause */}
{inv.root_cause_summary && ( {inv.root_cause_summary && (
<div className="bg-red-50 border border-red-100 px-4 py-3"> <div className="bg-red-50 border border-red-100 rounded-lg px-4 py-3">
<h3 className="text-xs font-semibold text-red-600 uppercase tracking-wide mb-1">Root Cause</h3> <h3 className="text-xs font-semibold text-red-600 uppercase tracking-wide mb-1">Root Cause</h3>
<p className="text-sm text-gray-900 whitespace-pre-wrap">{inv.root_cause_summary}</p> <p className="text-sm text-gray-900 whitespace-pre-wrap">{inv.root_cause_summary}</p>
</div> </div>
+4 -4
View File
@@ -56,15 +56,15 @@ export function OfflineSync() {
if (pendingCount === 0) return null if (pendingCount === 0) return null
return ( return (
<div className="fixed bottom-4 left-4 right-4 bg-accent-100 border border-accent-300 p-3 flex items-center justify-between shadow-md z-50"> <div className="fixed bottom-4 left-4 right-4 bg-yellow-50 border border-yellow-300 rounded-lg p-3 flex items-center justify-between shadow-md z-50">
<span className="text-sm text-accent-700 font-medium"> <span className="text-sm text-yellow-800 font-medium">
{pendingCount} report{pendingCount > 1 ? 's' : ''} saved offline {pendingCount} report{pendingCount > 1 ? 's' : ''} saved offline
</span> </span>
<button <button
onClick={syncNow} onClick={syncNow}
disabled={syncing || !navigator.onLine} disabled={syncing || !navigator.onLine}
className="text-xs bg-accent text-white px-3 py-1.5 font-medium className="text-xs bg-yellow-600 text-white px-3 py-1.5 rounded font-medium
hover:bg-accent-600 disabled:opacity-50 disabled:cursor-not-allowed transition-colors" hover:bg-yellow-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors"
> >
{syncing ? 'Syncing…' : 'Sync now'} {syncing ? 'Syncing…' : 'Sync now'}
</button> </button>
+1 -1
View File
@@ -15,7 +15,7 @@ export function Pagination({ page, pageSize, total, href }: Props) {
disabled ? ( disabled ? (
<span className="px-3 py-1.5 text-sm text-gray-300">{label}</span> <span className="px-3 py-1.5 text-sm text-gray-300">{label}</span>
) : ( ) : (
<Link href={`${href}?page=${p}`} className="px-3 py-1.5 text-sm text-accent-700 hover:underline"> <Link href={`${href}?page=${p}`} className="px-3 py-1.5 text-sm text-blue-600 hover:underline">
{label} {label}
</Link> </Link>
) )
+24 -24
View File
@@ -73,7 +73,7 @@ export function ReportForm({ zoneToken, trucks, initialTruckId }: Props) {
value={(typeDetails[key] as string) ?? ''} value={(typeDetails[key] as string) ?? ''}
onChange={e => setDetail(key, e.target.value)} onChange={e => setDetail(key, e.target.value)}
placeholder={placeholder} placeholder={placeholder}
className="w-full border border-divider px-3 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-accent" className="w-full border border-gray-300 rounded-lg px-3 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"
/> />
</div> </div>
) )
@@ -82,7 +82,7 @@ export function ReportForm({ zoneToken, trucks, initialTruckId }: Props) {
<label className="flex items-center gap-3 cursor-pointer"> <label className="flex items-center gap-3 cursor-pointer">
<input <input
type="checkbox" type="checkbox"
className="w-4 h-4 text-accent-700" className="w-4 h-4 text-blue-600"
checked={Boolean(typeDetails[key])} checked={Boolean(typeDetails[key])}
onChange={e => setDetail(key, e.target.checked)} onChange={e => setDetail(key, e.target.checked)}
/> />
@@ -205,22 +205,22 @@ export function ReportForm({ zoneToken, trucks, initialTruckId }: Props) {
if (savedOffline) { if (savedOffline) {
return ( return (
<div className="bg-neutral-100 border border-divider p-5 text-sm text-ink"> <div className="bg-green-50 border border-green-200 rounded-xl p-5 text-sm text-green-700">
{t.savedOffline} {t.savedOffline}
</div> </div>
) )
} }
return ( return (
<form onSubmit={handleSubmit} className="space-y-5 bg-surface shadow-sm p-5"> <form onSubmit={handleSubmit} className="space-y-5 bg-white rounded-xl shadow-sm p-5">
{!isOnline && ( {!isOnline && (
<div className="bg-accent-100 border border-accent-300 p-3 text-sm text-accent-700"> <div className="bg-yellow-50 border border-yellow-200 rounded p-3 text-sm text-yellow-700">
{t.offlineBanner} {t.offlineBanner}
</div> </div>
)} )}
{error && ( {error && (
<div className="bg-red-50 border border-red-200 p-3 text-sm text-red-700"> <div className="bg-red-50 border border-red-200 rounded p-3 text-sm text-red-700">
{error} {error}
</div> </div>
)} )}
@@ -231,7 +231,7 @@ export function ReportForm({ zoneToken, trucks, initialTruckId }: Props) {
</label> </label>
<select <select
required required
className="w-full border border-divider px-3 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-accent" className="w-full border border-gray-300 rounded-lg px-3 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"
value={form.incident_type} value={form.incident_type}
onChange={e => { onChange={e => {
setForm(f => ({ ...f, incident_type: e.target.value as IncidentType, truck_id: '' })) setForm(f => ({ ...f, incident_type: e.target.value as IncidentType, truck_id: '' }))
@@ -246,26 +246,26 @@ export function ReportForm({ zoneToken, trucks, initialTruckId }: Props) {
</div> </div>
{form.incident_type === 'environmental' && ( {form.incident_type === 'environmental' && (
<div className="space-y-3 border border-divider p-3"> <div className="space-y-3 border border-gray-200 rounded-lg p-3">
{detailText('substance', tdLabels.substance, tdLabels.substancePlaceholder)} {detailText('substance', tdLabels.substance, tdLabels.substancePlaceholder)}
{detailText('estimated_volume', tdLabels.estimatedVolume, tdLabels.estimatedVolumePlaceholder)} {detailText('estimated_volume', tdLabels.estimatedVolume, tdLabels.estimatedVolumePlaceholder)}
{detailCheckbox('containment_deployed', tdLabels.containmentDeployed)} {detailCheckbox('containment_deployed', tdLabels.containmentDeployed)}
</div> </div>
)} )}
{form.incident_type === 'asset_damage' && ( {form.incident_type === 'asset_damage' && (
<div className="space-y-3 border border-divider p-3"> <div className="space-y-3 border border-gray-200 rounded-lg p-3">
{detailText('equipment_id', tdLabels.equipmentId, tdLabels.equipmentIdPlaceholder)} {detailText('equipment_id', tdLabels.equipmentId, tdLabels.equipmentIdPlaceholder)}
{detailCheckbox('loto_applied', tdLabels.lotoApplied)} {detailCheckbox('loto_applied', tdLabels.lotoApplied)}
</div> </div>
)} )}
{form.incident_type === 'security' && ( {form.incident_type === 'security' && (
<div className="space-y-3 border border-divider p-3"> <div className="space-y-3 border border-gray-200 rounded-lg p-3">
{detailText('persons_involved', tdLabels.personsInvolved, tdLabels.personsInvolvedPlaceholder)} {detailText('persons_involved', tdLabels.personsInvolved, tdLabels.personsInvolvedPlaceholder)}
{detailCheckbox('police_reported', tdLabels.policeReported)} {detailCheckbox('police_reported', tdLabels.policeReported)}
</div> </div>
)} )}
{form.incident_type === 'fire' && ( {form.incident_type === 'fire' && (
<div className="space-y-3 border border-divider p-3"> <div className="space-y-3 border border-gray-200 rounded-lg p-3">
{detailCheckbox('alarm_raised', tdLabels.alarmRaised)} {detailCheckbox('alarm_raised', tdLabels.alarmRaised)}
{detailCheckbox('fire_brigade_called', tdLabels.fireBrigadeCalled)} {detailCheckbox('fire_brigade_called', tdLabels.fireBrigadeCalled)}
</div> </div>
@@ -278,7 +278,7 @@ export function ReportForm({ zoneToken, trucks, initialTruckId }: Props) {
</label> </label>
<select <select
required required
className="w-full border border-divider px-3 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-accent" className="w-full border border-gray-300 rounded-lg px-3 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"
value={form.truck_id} value={form.truck_id}
onChange={e => setForm(f => ({ ...f, truck_id: e.target.value }))} onChange={e => setForm(f => ({ ...f, truck_id: e.target.value }))}
> >
@@ -301,31 +301,31 @@ export function ReportForm({ zoneToken, trucks, initialTruckId }: Props) {
minLength={10} minLength={10}
rows={4} rows={4}
placeholder={t.descriptionPlaceholder} placeholder={t.descriptionPlaceholder}
className="w-full border border-divider px-3 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-accent resize-none" className="w-full border border-gray-300 rounded-lg px-3 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 resize-none"
value={form.description} value={form.description}
onChange={e => setForm(f => ({ ...f, description: e.target.value }))} onChange={e => setForm(f => ({ ...f, description: e.target.value }))}
/> />
</div> </div>
{qualityCheck && !qualityCheck.passes && ( {qualityCheck && !qualityCheck.passes && (
<div className="bg-accent-100 border border-accent-300 p-3 space-y-2"> <div className="rounded-lg bg-amber-50 border border-amber-200 p-3 space-y-2">
<p className="text-xs font-semibold text-accent-700 uppercase tracking-wide"> <p className="text-xs font-semibold text-amber-700 uppercase tracking-wide">
{t.qualityScoreLabel.replace('{score}', String(qualityCheck.score))} {t.qualityScoreLabel.replace('{score}', String(qualityCheck.score))}
</p> </p>
<p className="text-sm text-accent-700">{qualityCheck.feedback}</p> <p className="text-sm text-amber-800">{qualityCheck.feedback}</p>
{qualityCheck.suggestions.length > 0 && ( {qualityCheck.suggestions.length > 0 && (
<ul className="list-disc list-inside space-y-1"> <ul className="list-disc list-inside space-y-1">
{qualityCheck.suggestions.map((s, i) => ( {qualityCheck.suggestions.map((s, i) => (
<li key={i} className="text-xs text-accent-700">{s}</li> <li key={i} className="text-xs text-amber-700">{s}</li>
))} ))}
</ul> </ul>
)} )}
<label className="flex items-center gap-2 text-xs text-accent-700 cursor-pointer mt-1"> <label className="flex items-center gap-2 text-xs text-amber-700 cursor-pointer mt-1">
<input <input
type="checkbox" type="checkbox"
checked={overrideQuality} checked={overrideQuality}
onChange={e => setOverrideQuality(e.target.checked)} onChange={e => setOverrideQuality(e.target.checked)}
className="border-accent-300 text-accent-700" className="rounded border-amber-300 text-amber-600"
/> />
{t.submitAnyway} {t.submitAnyway}
</label> </label>
@@ -336,7 +336,7 @@ export function ReportForm({ zoneToken, trucks, initialTruckId }: Props) {
<label className="flex items-center gap-3 cursor-pointer"> <label className="flex items-center gap-3 cursor-pointer">
<input <input
type="checkbox" type="checkbox"
className="w-4 h-4 text-accent-700" className="w-4 h-4 text-blue-600"
checked={form.injury_involved} checked={form.injury_involved}
onChange={e => setForm(f => ({ ...f, injury_involved: e.target.checked, medical_status: '' }))} onChange={e => setForm(f => ({ ...f, injury_involved: e.target.checked, medical_status: '' }))}
/> />
@@ -350,7 +350,7 @@ export function ReportForm({ zoneToken, trucks, initialTruckId }: Props) {
</label> </label>
<select <select
required={form.injury_involved} required={form.injury_involved}
className="w-full border border-divider px-3 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-accent" className="w-full border border-gray-300 rounded-lg px-3 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"
value={form.medical_status} value={form.medical_status}
onChange={e => setForm(f => ({ ...f, medical_status: e.target.value as MedicalStatus }))} onChange={e => setForm(f => ({ ...f, medical_status: e.target.value as MedicalStatus }))}
> >
@@ -365,7 +365,7 @@ export function ReportForm({ zoneToken, trucks, initialTruckId }: Props) {
<label className="flex items-center gap-3 cursor-pointer"> <label className="flex items-center gap-3 cursor-pointer">
<input <input
type="checkbox" type="checkbox"
className="w-4 h-4 text-accent-700" className="w-4 h-4 text-blue-600"
checked={form.asset_involved} checked={form.asset_involved}
onChange={e => setForm(f => ({ ...f, asset_involved: e.target.checked }))} onChange={e => setForm(f => ({ ...f, asset_involved: e.target.checked }))}
/> />
@@ -383,8 +383,8 @@ export function ReportForm({ zoneToken, trucks, initialTruckId }: Props) {
<button <button
type="submit" type="submit"
disabled={submitting || !form.incident_type || (form.incident_type === 'transport' && !form.truck_id)} disabled={submitting || !form.incident_type || (form.incident_type === 'transport' && !form.truck_id)}
className="w-full bg-accent text-white py-3 font-medium text-sm className="w-full bg-blue-600 text-white py-3 rounded-lg font-medium text-sm
hover:bg-accent-600 disabled:opacity-50 disabled:cursor-not-allowed transition-colors" hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors"
> >
{submitting ? t.submitting : t.submitButton} {submitting ? t.submitting : t.submitButton}
</button> </button>
@@ -43,7 +43,7 @@ export function SimilarIncidentsPanel({ incidentId }: Props) {
if (loading) { if (loading) {
return ( return (
<div className="mt-6 bg-surface shadow-sm p-5"> <div className="mt-6 bg-white rounded-xl shadow-sm p-5">
<p className="text-sm text-gray-400">Loading similar incidents…</p> <p className="text-sm text-gray-400">Loading similar incidents…</p>
</div> </div>
) )
@@ -51,7 +51,7 @@ export function SimilarIncidentsPanel({ incidentId }: Props) {
if (error || similar.length === 0) return null if (error || similar.length === 0) return null
return ( return (
<div className="mt-6 bg-surface shadow-sm p-5"> <div className="mt-6 bg-white rounded-xl shadow-sm p-5">
<h2 className="text-sm font-semibold text-gray-700 uppercase tracking-wide mb-3"> <h2 className="text-sm font-semibold text-gray-700 uppercase tracking-wide mb-3">
Similar Past Incidents Similar Past Incidents
</h2> </h2>
@@ -60,7 +60,7 @@ export function SimilarIncidentsPanel({ incidentId }: Props) {
<a <a
key={inc.id} key={inc.id}
href={`/hse/incidents/${inc.id}`} href={`/hse/incidents/${inc.id}`}
className="block border border-divider p-3 hover:border-accent hover:bg-neutral-100 transition-colors" className="block border border-gray-200 rounded-lg p-3 hover:border-blue-300 hover:bg-blue-50 transition-colors"
> >
<div className="flex items-center justify-between mb-1"> <div className="flex items-center justify-between mb-1">
<span className="text-xs font-medium text-gray-500"> <span className="text-xs font-medium text-gray-500">
+12 -12
View File
@@ -95,7 +95,7 @@ export function TriageForm({ incidentId, currentSeverity }: Props) {
<form onSubmit={handleSubmit} className="space-y-6"> <form onSubmit={handleSubmit} className="space-y-6">
<div> <div>
<label className="block text-sm font-medium text-gray-700 mb-2">Severity</label> <label className="block text-sm font-medium text-gray-700 mb-2">Severity</label>
<div className="flex border border-divider overflow-hidden divide-x divide-divider"> <div className="flex rounded-lg border border-gray-300 overflow-hidden divide-x divide-gray-300">
{([1, 2, 3, 4, 5] as const).map(v => ( {([1, 2, 3, 4, 5] as const).map(v => (
<button <button
key={v} key={v}
@@ -103,8 +103,8 @@ export function TriageForm({ incidentId, currentSeverity }: Props) {
onClick={() => setSeverity(v)} onClick={() => setSeverity(v)}
className={`flex-1 py-2 text-xs font-medium transition-colors ${ className={`flex-1 py-2 text-xs font-medium transition-colors ${
severity === v severity === v
? 'bg-accent text-white border-accent' ? 'bg-blue-600 text-white border-blue-600'
: 'bg-surface text-gray-700 hover:bg-gray-50' : 'bg-white text-gray-700 hover:bg-gray-50'
}`} }`}
> >
<span className="block font-bold">{v}</span> <span className="block font-bold">{v}</span>
@@ -126,7 +126,7 @@ export function TriageForm({ incidentId, currentSeverity }: Props) {
<input <input
type="checkbox" checked={value} type="checkbox" checked={value}
onChange={e => set(e.target.checked)} onChange={e => set(e.target.checked)}
className="border-divider text-accent-700" className="rounded border-gray-300 text-blue-600"
/> />
{label} {label}
</label> </label>
@@ -134,7 +134,7 @@ export function TriageForm({ incidentId, currentSeverity }: Props) {
</fieldset> </fieldset>
{dosh.reasons.length > 0 && ( {dosh.reasons.length > 0 && (
<div className="bg-red-50 border border-red-200 p-3 space-y-1"> <div className="rounded-lg bg-red-50 border border-red-200 p-3 space-y-1">
<p className="text-xs font-semibold text-red-700 uppercase tracking-wide">DOSH Reporting Required</p> <p className="text-xs font-semibold text-red-700 uppercase tracking-wide">DOSH Reporting Required</p>
{dosh.reasons.map(r => ( {dosh.reasons.map(r => (
<p key={r} className="text-xs text-red-600">{r}</p> <p key={r} className="text-xs text-red-600">{r}</p>
@@ -151,16 +151,16 @@ export function TriageForm({ incidentId, currentSeverity }: Props) {
value={triageNotes} value={triageNotes}
onChange={e => setTriageNotes(e.target.value)} onChange={e => setTriageNotes(e.target.value)}
rows={3} rows={3}
className="w-full border border-divider px-3 py-2 text-sm focus:ring-2 focus:ring-accent focus:border-transparent" className="w-full rounded-lg border border-gray-300 px-3 py-2 text-sm focus:ring-2 focus:ring-blue-500 focus:border-transparent"
placeholder="Initial assessment, immediate actions taken..." placeholder="Initial assessment, immediate actions taken..."
/> />
</div> </div>
{aiRationale && ( {aiRationale && (
<div className="bg-accent-100 border border-accent-300 p-3"> <div className="rounded-lg bg-purple-50 border border-purple-200 p-3">
<p className="text-xs font-semibold text-accent-700 mb-1">AI Suggestion Rationale</p> <p className="text-xs font-semibold text-purple-700 mb-1">AI Suggestion Rationale</p>
<p className="text-xs text-accent-700">{aiRationale}</p> <p className="text-xs text-purple-600">{aiRationale}</p>
<p className="text-xs text-accent-400 mt-1">Fields pre-filled — review before submitting.</p> <p className="text-xs text-purple-400 mt-1">Fields pre-filled — review before submitting.</p>
</div> </div>
)} )}
@@ -171,14 +171,14 @@ export function TriageForm({ incidentId, currentSeverity }: Props) {
type="button" type="button"
onClick={getAiSuggestion} onClick={getAiSuggestion}
disabled={aiLoading || saving} disabled={aiLoading || saving}
className="flex-1 bg-accent-100 text-accent-700 border border-accent-300 py-2 text-sm font-semibold disabled:opacity-50 hover:bg-accent-200" className="flex-1 bg-purple-50 text-purple-700 border border-purple-300 rounded-lg py-2 text-sm font-semibold disabled:opacity-50 hover:bg-purple-100"
> >
{aiLoading ? 'Getting suggestion…' : 'Get AI Suggestion'} {aiLoading ? 'Getting suggestion…' : 'Get AI Suggestion'}
</button> </button>
<button <button
type="submit" type="submit"
disabled={saving} disabled={saving}
className="flex-1 bg-accent text-white py-2 text-sm font-semibold disabled:opacity-50" className="flex-1 bg-blue-600 text-white rounded-lg py-2 text-sm font-semibold disabled:opacity-50"
> >
{saving ? 'Saving…' : 'Complete Triage'} {saving ? 'Saving…' : 'Complete Triage'}
</button> </button>
+1 -1
View File
@@ -33,7 +33,7 @@ export function LanguageSwitcher() {
value={current} value={current}
onChange={e => handleChange(e.target.value)} onChange={e => handleChange(e.target.value)}
aria-label="Select language" aria-label="Select language"
className="text-xs border border-divider px-2 py-1 bg-surface text-gray-700 focus:outline-none focus:ring-1 focus:ring-accent" className="text-xs border border-gray-300 rounded px-2 py-1 bg-white text-gray-700 focus:outline-none focus:ring-1 focus:ring-blue-500"
> >
{Object.entries(LOCALES).map(([code, label]) => ( {Object.entries(LOCALES).map(([code, label]) => (
<option key={code} value={code}>{label}</option> <option key={code} value={code}>{label}</option>
+89 -57
View File
@@ -2,17 +2,6 @@
import Link from 'next/link' import Link from 'next/link'
import { usePathname, useRouter } from 'next/navigation' import { usePathname, useRouter } from 'next/navigation'
import {
AlignLeft,
CircleCheck,
ClipboardList,
LayoutDashboard,
LogOut,
Plus,
Settings,
User,
Users,
} from 'lucide-react'
import { NotificationBell } from '@/components/notifications/bell' import { NotificationBell } from '@/components/notifications/bell'
interface NavItem { interface NavItem {
@@ -27,15 +16,52 @@ interface SidebarProps {
userEmail: string userEmail: string
} }
const IconGrid = () => <AlignLeft size={20} aria-hidden /> const IconGrid = () => (
const IconList = () => <ClipboardList size={20} aria-hidden /> <svg className="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
const IconCheck = () => <CircleCheck size={20} aria-hidden /> <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M4 6h16M4 12h16M4 18h7" />
const IconChart = () => <LayoutDashboard size={20} aria-hidden /> </svg>
const IconSettings = () => <Settings size={20} aria-hidden /> )
const IconUsers = () => <Users size={20} aria-hidden /> const IconList = () => (
const IconPlus = () => <Plus size={20} aria-hidden /> <svg className="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
const IconLogout = () => <LogOut size={16} aria-hidden /> <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2" />
const IconUser = () => <User size={16} aria-hidden /> </svg>
)
const IconCheck = () => (
<svg className="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" />
</svg>
)
const IconChart = () => (
<svg className="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z" />
</svg>
)
const IconSettings = () => (
<svg className="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z" />
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
</svg>
)
const IconUsers = () => (
<svg className="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M12 4.354a4 4 0 110 5.292M15 21H3v-1a6 6 0 0112 0v1zm0 0h6v-1a6 6 0 00-9-5.197M13 7a4 4 0 11-8 0 4 4 0 018 0z" />
</svg>
)
const IconPlus = () => (
<svg className="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M12 4v16m8-8H4" />
</svg>
)
const IconLogout = () => (
<svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M17 16l4-4m0 0l-4-4m4 4H7m6 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h4a3 3 0 013 3v1" />
</svg>
)
const IconUser = () => (
<svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z" />
</svg>
)
const NAV_ITEMS: Record<string, NavItem[]> = { const NAV_ITEMS: Record<string, NavItem[]> = {
reporter: [ reporter: [
@@ -68,12 +94,6 @@ const NAV_ITEMS: Record<string, NavItem[]> = {
], ],
} }
const EXACT_ROOTS = ['/reporter', '/supervisor', '/management', '/capa-owner', '/admin', '/report', '/account']
function isActivePath(href: string, pathname: string): boolean {
return EXACT_ROOTS.includes(href) ? pathname === href : pathname.startsWith(href)
}
function initials(name: string): string { function initials(name: string): string {
return name return name
.split(' ') .split(' ')
@@ -87,19 +107,23 @@ function useNavItems(role: string): NavItem[] {
return NAV_ITEMS[role] ?? NAV_ITEMS.reporter return NAV_ITEMS[role] ?? NAV_ITEMS.reporter
} }
const LINK_BASE = 'flex items-center gap-3 px-3 py-2 text-sm border-l-2 transition-colors'
const LINK_ACTIVE = 'border-accent text-accent-700 font-extrabold bg-accent-100/50'
const LINK_IDLE = 'border-transparent text-ink/70 font-medium hover:bg-ink/7 hover:text-ink'
function NavLink({ item, pathname }: { item: NavItem; pathname: string }) { function NavLink({ item, pathname }: { item: NavItem; pathname: string }) {
const active = isActivePath(item.href, pathname) // Exact match for root-level single-page roles, prefix match otherwise
const exactRoots = ['/reporter', '/supervisor', '/management', '/capa-owner', '/admin', '/report', '/account']
const isActive = exactRoots.includes(item.href)
? pathname === item.href
: pathname.startsWith(item.href)
return ( return (
<Link <Link
href={item.href} href={item.href}
aria-current={active ? 'page' : undefined} className={`flex items-center gap-3 px-3 py-2 rounded-lg text-sm font-medium transition-colors ${
className={`${LINK_BASE} ${active ? LINK_ACTIVE : LINK_IDLE}`} isActive
? 'bg-blue-50 text-blue-700'
: 'text-gray-600 hover:bg-gray-100 hover:text-gray-900'
}`}
> >
<span className={active ? 'text-accent-700' : 'text-ink/50'}>{item.icon}</span> <span className={isActive ? 'text-blue-600' : 'text-gray-400'}>{item.icon}</span>
{item.label} {item.label}
</Link> </Link>
) )
@@ -119,67 +143,74 @@ export function Sidebar({ role, userName, userEmail }: SidebarProps) {
const displayName = userName || userEmail || 'User' const displayName = userName || userEmail || 'User'
const roleLabel = role.replace(/_/g, ' ').replace(/\b\w/g, c => c.toUpperCase()) const roleLabel = role.replace(/_/g, ' ').replace(/\b\w/g, c => c.toUpperCase())
const accountActive = pathname === '/account'
return ( return (
<> <>
{/* Desktop sidebar */} {/* Desktop sidebar */}
<aside className="hidden sm:flex fixed left-0 top-0 h-full w-60 bg-ground border-r-2 border-divider flex-col z-40"> <aside className="hidden sm:flex fixed left-0 top-0 h-full w-60 bg-white border-r border-gray-200 flex-col z-40">
<div className="flex items-center justify-between px-4 py-4 border-b-2 border-divider"> {/* Header */}
<span className="text-lg font-extrabold tracking-tight text-ink">IMS</span> <div className="flex items-center justify-between px-4 py-4 border-b border-gray-100">
<span className="text-base font-bold text-gray-900 tracking-tight">IMS</span>
<NotificationBell /> <NotificationBell />
</div> </div>
<nav className="flex-1 overflow-y-auto py-3"> {/* Nav */}
<nav className="flex-1 overflow-y-auto px-3 py-3 space-y-1">
{items.map(item => ( {items.map(item => (
<NavLink key={item.href} item={item} pathname={pathname} /> <NavLink key={item.href} item={item} pathname={pathname} />
))} ))}
</nav> </nav>
<div className="border-t-2 border-divider py-3"> {/* User + logout */}
<div className="flex items-center gap-2 px-4 py-2 mb-1"> <div className="border-t border-gray-100 px-3 py-3">
<div className="w-8 h-8 rounded-full bg-accent flex items-center justify-center text-ground text-xs font-extrabold flex-shrink-0"> <div className="flex items-center gap-2 px-2 py-2 mb-1">
<div className="w-8 h-8 rounded-full bg-blue-600 flex items-center justify-center text-white text-xs font-bold flex-shrink-0">
{initials(displayName)} {initials(displayName)}
</div> </div>
<div className="min-w-0"> <div className="min-w-0">
<p className="text-sm font-extrabold text-ink truncate">{displayName}</p> <p className="text-sm font-medium text-gray-900 truncate">{displayName}</p>
<p className="text-xs text-ink/60 truncate">{roleLabel}</p> <p className="text-xs text-gray-500 truncate">{roleLabel}</p>
</div> </div>
</div> </div>
<Link <Link
href="/account" href="/account"
aria-current={accountActive ? 'page' : undefined} className={`flex items-center gap-2 w-full px-3 py-2 text-sm rounded-lg transition-colors ${
className={`${LINK_BASE} ${accountActive ? LINK_ACTIVE : LINK_IDLE}`} pathname === '/account'
? 'bg-blue-50 text-blue-700'
: 'text-gray-600 hover:bg-gray-100 hover:text-gray-900'
}`}
> >
<span className={accountActive ? 'text-accent-700' : 'text-ink/50'}> <span className={pathname === '/account' ? 'text-blue-600' : 'text-gray-400'}>
<IconUser /> <IconUser />
</span> </span>
Account Account
</Link> </Link>
<button <button
onClick={logout} onClick={logout}
className={`${LINK_BASE} ${LINK_IDLE} w-full text-left cursor-pointer`} className="flex items-center gap-2 w-full px-3 py-2 text-sm text-gray-600 hover:bg-gray-100 hover:text-gray-900 rounded-lg transition-colors"
> >
<span className="text-ink/50"><IconLogout /></span> <IconLogout />
Logout Logout
</button> </button>
<div className="mt-3 pt-3 border-t border-divider px-4"> <div className="mt-3 pt-3 border-t border-gray-100 px-2 text-center">
<p className="text-xs text-ink/50">v1.2.2</p> <p className="text-xs text-gray-400">v1.2.2</p>
</div> </div>
</div> </div>
</aside> </aside>
{/* Mobile bottom tab bar */} {/* Mobile bottom tab bar */}
<nav className="sm:hidden fixed bottom-0 left-0 right-0 bg-ground border-t-2 border-divider flex z-40 safe-area-pb"> <nav className="sm:hidden fixed bottom-0 left-0 right-0 bg-white border-t border-gray-200 flex z-40 safe-area-pb">
{mobileItems.map(item => { {mobileItems.map(item => {
const active = isActivePath(item.href, pathname) const exactRoots = ['/reporter', '/supervisor', '/management', '/capa-owner', '/admin', '/report', '/account']
const isActive = exactRoots.includes(item.href)
? pathname === item.href
: pathname.startsWith(item.href)
return ( return (
<Link <Link
key={item.href} key={item.href}
href={item.href} href={item.href}
aria-current={active ? 'page' : undefined} className={`flex-1 flex flex-col items-center gap-1 py-2 text-[10px] font-medium transition-colors ${
className={`flex-1 flex flex-col items-center gap-1 py-2 text-[10px] font-extrabold transition-colors ${ isActive ? 'text-blue-600' : 'text-gray-400'
active ? 'text-accent-700' : 'text-ink/55'
}`} }`}
> >
{item.icon} {item.icon}
@@ -187,10 +218,11 @@ export function Sidebar({ role, userName, userEmail }: SidebarProps) {
</Link> </Link>
) )
})} })}
{/* Mobile logout in "More" slot if room */}
{items.length <= 4 && ( {items.length <= 4 && (
<button <button
onClick={logout} onClick={logout}
className="flex-1 flex flex-col items-center gap-1 py-2 text-[10px] font-extrabold text-ink/55 cursor-pointer" className="flex-1 flex flex-col items-center gap-1 py-2 text-[10px] font-medium text-gray-400"
> >
<IconLogout /> <IconLogout />
<span className="leading-none">Logout</span> <span className="leading-none">Logout</span>
+7 -8
View File
@@ -2,7 +2,6 @@
import { useCallback, useEffect, useRef, useState } from 'react' import { useCallback, useEffect, useRef, useState } from 'react'
import Link from 'next/link' import Link from 'next/link'
import { Bell } from 'lucide-react'
type Notification = { type Notification = {
id: string id: string
@@ -63,22 +62,22 @@ export function NotificationBell() {
<button <button
onClick={() => setOpen(o => !o)} onClick={() => setOpen(o => !o)}
aria-label={`Notifications${unread > 0 ? ` (${unread} unread)` : ''}`} aria-label={`Notifications${unread > 0 ? ` (${unread} unread)` : ''}`}
className="relative bg-surface border border-divider w-10 h-10 flex items-center justify-center text-ink cursor-pointer transition-colors hover:bg-ink/7 active:bg-ink/15" className="relative bg-white rounded-full shadow-sm border border-gray-200 w-10 h-10 flex items-center justify-center hover:shadow-md transition-shadow"
> >
<Bell size={18} strokeWidth={2} aria-hidden /> <span className="text-lg" aria-hidden>🔔</span>
{unread > 0 && ( {unread > 0 && (
<span className="absolute -top-1 -right-1 bg-accent text-ground text-[10px] font-extrabold min-w-[18px] h-[18px] px-1 flex items-center justify-center"> <span className="absolute -top-1 -right-1 bg-red-600 text-white text-[10px] font-bold rounded-full min-w-[18px] h-[18px] px-1 flex items-center justify-center">
{unread > 99 ? '99+' : unread} {unread > 99 ? '99+' : unread}
</span> </span>
)} )}
</button> </button>
{open && ( {open && (
<div className="absolute right-0 mt-2 w-80 max-h-96 overflow-y-auto bg-surface shadow-lg border border-divider"> <div className="absolute right-0 mt-2 w-80 max-h-96 overflow-y-auto bg-white rounded-xl shadow-lg border border-gray-200">
<div className="flex items-center justify-between px-4 py-2 border-b-2 border-divider"> <div className="flex items-center justify-between px-4 py-2 border-b border-gray-100">
<span className="text-sm font-extrabold text-ink">Notifications</span> <span className="text-sm font-semibold text-gray-700">Notifications</span>
{unread > 0 && ( {unread > 0 && (
<button onClick={markAllRead} className="text-xs text-accent-700 hover:underline"> <button onClick={markAllRead} className="text-xs text-blue-600 hover:underline">
Mark all read Mark all read
</button> </button>
)} )}
+7 -7
View File
@@ -44,13 +44,13 @@ export function ApiKeyForm({ settings }: Props) {
{Object.keys(KEY_LABELS).map(key => { {Object.keys(KEY_LABELS).map(key => {
const status = settings[key] const status = settings[key]
return ( return (
<div key={key} className="bg-surface shadow-sm p-5"> <div key={key} className="bg-white rounded-xl shadow-sm p-5">
<div className="flex items-center justify-between mb-1"> <div className="flex items-center justify-between mb-1">
<label className="text-sm font-semibold text-gray-800">{KEY_LABELS[key]}</label> <label className="text-sm font-semibold text-gray-800">{KEY_LABELS[key]}</label>
<span className={`text-xs font-medium px-2 py-0.5 ${ <span className={`text-xs font-medium px-2 py-0.5 rounded-full ${
status?.set status?.set
? 'bg-neutral-100 text-ink' ? 'bg-green-100 text-green-700'
: 'bg-accent-100 text-accent-700' : 'bg-yellow-100 text-yellow-700'
}`}> }`}>
{status?.set ? 'Configured' : 'Not set'} {status?.set ? 'Configured' : 'Not set'}
</span> </span>
@@ -66,18 +66,18 @@ export function ApiKeyForm({ settings }: Props) {
value={values[key]} value={values[key]}
onChange={e => setValues(v => ({ ...v, [key]: e.target.value }))} onChange={e => setValues(v => ({ ...v, [key]: e.target.value }))}
placeholder={status?.set ? 'Enter new key to replace…' : 'Enter API key…'} placeholder={status?.set ? 'Enter new key to replace…' : 'Enter API key…'}
className="flex-1 border border-divider px-3 py-2 text-sm text-gray-900 placeholder-gray-500 focus:ring-2 focus:ring-accent focus:border-transparent font-mono" className="flex-1 border border-gray-300 rounded-lg px-3 py-2 text-sm text-gray-900 placeholder-gray-500 focus:ring-2 focus:ring-blue-500 focus:border-transparent font-mono"
/> />
<button <button
onClick={() => save(key)} onClick={() => save(key)}
disabled={saving[key] || !values[key]} disabled={saving[key] || !values[key]}
className="bg-accent text-white px-4 py-2 text-sm font-semibold disabled:opacity-50 hover:bg-accent-600" className="bg-blue-600 text-white rounded-lg px-4 py-2 text-sm font-semibold disabled:opacity-50 hover:bg-blue-700"
> >
{saving[key] ? 'Saving…' : 'Save'} {saving[key] ? 'Saving…' : 'Save'}
</button> </button>
</div> </div>
{results[key] === 'ok' && ( {results[key] === 'ok' && (
<p className="text-xs text-ink mt-2">Saved. Reload the page to confirm.</p> <p className="text-xs text-green-600 mt-2">Saved. Reload the page to confirm.</p>
)} )}
{results[key] === 'error' && ( {results[key] === 'error' && (
<p className="text-xs text-red-600 mt-2">Save failed. Check your permissions.</p> <p className="text-xs text-red-600 mt-2">Save failed. Check your permissions.</p>
-25
View File
@@ -1,25 +0,0 @@
import type { ButtonHTMLAttributes } from 'react'
import { cx } from './cx'
type Variant = 'primary' | 'secondary' | 'ghost' | 'icon'
const BASE =
'inline-flex items-center gap-1.5 text-left font-extrabold text-sm leading-tight ' +
'border border-transparent cursor-pointer transition-colors ' +
'disabled:opacity-45 disabled:cursor-not-allowed'
const VARIANTS: Record<Variant, string> = {
primary: 'justify-start bg-accent text-ground px-3.5 py-2 hover:bg-accent-600 active:bg-accent-700',
secondary: 'justify-start border-divider text-ink px-3.5 py-2 hover:bg-ink/7 active:bg-ink/15',
ghost: 'justify-start text-accent-700 px-1 py-2 hover:bg-accent/10 active:bg-accent/20',
icon: 'justify-center w-9 h-9 p-0 text-ink hover:bg-ink/7 active:bg-ink/15',
}
type Props = ButtonHTMLAttributes<HTMLButtonElement> & {
variant?: Variant
block?: boolean
}
export function Button({ variant = 'primary', block = false, className, type = 'button', ...rest }: Props) {
return <button type={type} className={cx(BASE, VARIANTS[variant], block && 'w-full', className)} {...rest} />
}
-22
View File
@@ -1,22 +0,0 @@
import type { ReactNode } from 'react'
export function Card({
kicker,
title,
meta,
children,
}: {
kicker?: ReactNode
title?: ReactNode
meta?: ReactNode
children?: ReactNode
}) {
return (
<div className="flex flex-col gap-2 p-3 bg-surface">
{kicker && <span className="text-[10px] tracking-[0.1em] uppercase text-accent-700">{kicker}</span>}
{title && <h3 className="text-[17px] leading-tight font-extrabold">{title}</h3>}
{children && <div className="flex-1 text-[13px] opacity-80">{children}</div>}
{meta && <div className="flex items-center gap-1.5 text-[11px] text-ink/50">{meta}</div>}
</div>
)
}
-2
View File
@@ -1,2 +0,0 @@
export const cx = (...parts: Array<string | false | null | undefined>): string =>
parts.filter(Boolean).join(' ')
-30
View File
@@ -1,30 +0,0 @@
import type { InputHTMLAttributes, ReactNode, SelectHTMLAttributes, TextareaHTMLAttributes } from 'react'
import { cx } from './cx'
export const INPUT_CLASS =
'w-full min-h-9 px-2.5 py-1.5 text-sm text-ink caret-accent bg-surface border border-divider ' +
'hover:border-ink/45 focus-visible:border-accent focus-visible:outline-offset-0 ' +
'disabled:opacity-45 disabled:cursor-not-allowed'
export function Field({ label, htmlFor, children }: { label: string; htmlFor: string; children: ReactNode }) {
return (
<div>
<label htmlFor={htmlFor} className="block text-xs mb-[5px] text-ink/70">
{label}
</label>
{children}
</div>
)
}
export function Input({ className, ...rest }: InputHTMLAttributes<HTMLInputElement>) {
return <input className={cx(INPUT_CLASS, className)} {...rest} />
}
export function Textarea({ className, ...rest }: TextareaHTMLAttributes<HTMLTextAreaElement>) {
return <textarea className={cx(INPUT_CLASS, 'min-h-[90px] resize-y', className)} {...rest} />
}
export function Select({ className, ...rest }: SelectHTMLAttributes<HTMLSelectElement>) {
return <select className={cx(INPUT_CLASS, className)} {...rest} />
}
+10 -12
View File
@@ -1,7 +1,6 @@
'use client' 'use client'
import { useEffect } from 'react' import { useEffect } from 'react'
import { X } from 'lucide-react'
interface ModalProps { interface ModalProps {
open: boolean open: boolean
@@ -26,21 +25,20 @@ export function Modal({ open, onClose, title, children, footer, width = 'md' }:
return ( return (
<div className="fixed inset-0 z-50 flex items-center justify-center p-4" role="dialog" aria-modal="true"> <div className="fixed inset-0 z-50 flex items-center justify-center p-4" role="dialog" aria-modal="true">
<div className="absolute inset-0 bg-neutral-900/50" onClick={onClose} /> <div className="absolute inset-0 bg-gray-900/50" onClick={onClose} />
<div className={`relative w-full ${maxW} bg-surface shadow-lg`}> <div className={`relative w-full ${maxW} bg-white rounded-2xl shadow-2xl`}>
<div className="flex items-center justify-between px-6 py-4 border-b-2 border-divider"> <div className="flex items-center justify-between px-6 py-4 border-b border-gray-100">
<h2 className="text-xl font-extrabold text-ink">{title}</h2> <h2 className="text-sm font-semibold text-gray-900">{title}</h2>
<button <button onClick={onClose} aria-label="Close"
onClick={onClose} className="text-gray-400 hover:text-gray-600 p-1 rounded-lg hover:bg-gray-100 transition-colors cursor-pointer">
aria-label="Close" <svg className="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2.5}>
className="inline-flex w-9 h-9 items-center justify-center text-ink cursor-pointer transition-colors hover:bg-ink/7 active:bg-ink/15" <path strokeLinecap="round" strokeLinejoin="round" d="M6 18 18 6M6 6l12 12" />
> </svg>
<X size={18} strokeWidth={2} aria-hidden />
</button> </button>
</div> </div>
<div className="px-6 py-5">{children}</div> <div className="px-6 py-5">{children}</div>
{footer && ( {footer && (
<div className="px-6 py-4 border-t border-divider flex justify-end gap-2"> <div className="px-6 py-4 border-t border-gray-100 flex justify-end gap-2">
{footer} {footer}
</div> </div>
)} )}
-72
View File
@@ -1,72 +0,0 @@
import type { ReactNode } from 'react'
import {
AlarmClock,
BadgeCheck,
Circle,
CircleAlert,
CircleCheck,
ClipboardList,
ListChecks,
Loader,
RotateCcw,
Search,
type LucideIcon,
} from 'lucide-react'
import { Tag, type TagVariant } from './tag'
const TONES: Record<string, TagVariant> = {
reported: 'accent',
triaged: 'outline',
investigating: 'outline',
capa_pending: 'outline',
verification: 'outline',
closed: 'neutral',
open: 'accent',
in_progress: 'outline',
overdue: 'accent',
pending_verification: 'outline',
verified: 'neutral',
reopened: 'accent',
}
const ICONS: Record<string, LucideIcon> = {
reported: CircleAlert,
triaged: ListChecks,
investigating: Search,
capa_pending: ClipboardList,
verification: BadgeCheck,
closed: CircleCheck,
open: Circle,
in_progress: Loader,
overdue: AlarmClock,
pending_verification: BadgeCheck,
verified: CircleCheck,
reopened: RotateCcw,
}
export function statusTone(status: string): TagVariant {
return TONES[status] ?? 'neutral'
}
function humanize(value: string): string {
return value
.split('_')
.map(w => (w === 'capa' ? 'CAPA' : w.charAt(0).toUpperCase() + w.slice(1)))
.join(' ')
}
export function StatusTag({ status, children }: { status: string; children?: ReactNode }) {
const Icon = ICONS[status]
return (
<Tag variant={statusTone(status)}>
{Icon && <Icon size={12} strokeWidth={2} aria-hidden />}
{children ?? humanize(status)}
</Tag>
)
}
const PRIORITY_TONES: Record<string, TagVariant> = { high: 'accent', med: 'outline', low: 'neutral' }
export function PriorityTag({ priority, children }: { priority: string; children?: ReactNode }) {
return <Tag variant={PRIORITY_TONES[priority] ?? 'neutral'}>{children ?? humanize(priority)}</Tag>
}
-5
View File
@@ -1,5 +0,0 @@
export const TABLE = 'w-full border-collapse text-sm'
export const TH =
'text-left text-[11px] uppercase tracking-[0.08em] text-ink/60 px-2 py-2 border-b-2 border-divider'
export const TR = 'hover:bg-ink/4'
export const TD = 'px-2 py-2 border-b border-divider'
-24
View File
@@ -1,24 +0,0 @@
import type { ReactNode } from 'react'
import { cx } from './cx'
export type TagVariant = 'accent' | 'neutral' | 'outline'
const VARIANTS: Record<TagVariant, string> = {
accent: 'bg-accent-100 text-accent-800',
neutral: 'bg-neutral-100 text-neutral-800',
outline: 'border border-accent text-accent-700',
}
export function Tag({ variant, children, className }: { variant: TagVariant; children: ReactNode; className?: string }) {
return (
<span
className={cx(
'inline-flex items-center gap-1 text-[11px] font-medium tracking-wide px-2.5 py-[3px] whitespace-nowrap',
VARIANTS[variant],
className,
)}
>
{children}
</span>
)
}
@@ -1,151 +0,0 @@
{
"plugins": [
"react",
"import"
],
"rules": {
"react/forbid-elements": [
"warn",
{
"forbid": []
}
],
"no-restricted-imports": [
"warn",
{
"patterns": []
}
],
"no-restricted-syntax": [
"warn",
{
"selector": "Literal[value=/#[0-9a-fA-F]{3,8}\\b/]",
"message": "Raw hex color — use a design-system color token via var()."
},
{
"selector": "Literal[value=/\\b\\d+px\\b/]",
"message": "Raw px value — use a design-system spacing token via var()."
},
{
"selector": "Literal[value=/font-family\\s*:\\s*(?!['\\\"]?(?:Archivo))/i]",
"message": "Font not provided by the design system. Available: Archivo."
}
]
},
"overrides": [
{
"files": [
"**/index.js"
],
"rules": {
"no-restricted-imports": "off"
}
}
],
"x-omelette": {
"components": {},
"tokens": [
"--color-accent",
"--color-accent-100",
"--color-accent-2",
"--color-accent-2-100",
"--color-accent-2-200",
"--color-accent-2-300",
"--color-accent-2-400",
"--color-accent-2-500",
"--color-accent-2-600",
"--color-accent-2-700",
"--color-accent-2-800",
"--color-accent-2-900",
"--color-accent-200",
"--color-accent-300",
"--color-accent-400",
"--color-accent-500",
"--color-accent-600",
"--color-accent-700",
"--color-accent-800",
"--color-accent-900",
"--color-bg",
"--color-divider",
"--color-neutral-100",
"--color-neutral-200",
"--color-neutral-300",
"--color-neutral-400",
"--color-neutral-500",
"--color-neutral-600",
"--color-neutral-700",
"--color-neutral-800",
"--color-neutral-900",
"--color-surface",
"--color-text",
"--font-body",
"--font-heading",
"--font-heading-weight",
"--radius-lg",
"--radius-md",
"--radius-sm",
"--shadow-lg",
"--shadow-md",
"--shadow-sm",
"--space-1",
"--space-2",
"--space-3",
"--space-4",
"--space-6",
"--space-8"
],
"tokenKinds": {
"--color-bg": "color",
"--color-surface": "color",
"--color-text": "font",
"--color-accent": "color",
"--color-accent-2": "color",
"--color-divider": "color",
"--color-neutral-100": "color",
"--color-neutral-200": "color",
"--color-neutral-300": "color",
"--color-neutral-400": "color",
"--color-neutral-500": "color",
"--color-neutral-600": "color",
"--color-neutral-700": "color",
"--color-neutral-800": "color",
"--color-neutral-900": "color",
"--color-accent-100": "color",
"--color-accent-200": "color",
"--color-accent-300": "color",
"--color-accent-400": "color",
"--color-accent-500": "color",
"--color-accent-600": "color",
"--color-accent-700": "color",
"--color-accent-800": "color",
"--color-accent-900": "color",
"--color-accent-2-100": "color",
"--color-accent-2-200": "color",
"--color-accent-2-300": "color",
"--color-accent-2-400": "color",
"--color-accent-2-500": "color",
"--color-accent-2-600": "color",
"--color-accent-2-700": "color",
"--color-accent-2-800": "color",
"--color-accent-2-900": "color",
"--font-heading": "font",
"--font-heading-weight": "font",
"--font-body": "font",
"--space-1": "spacing",
"--space-2": "spacing",
"--space-3": "spacing",
"--space-4": "spacing",
"--space-6": "spacing",
"--space-8": "spacing",
"--radius-sm": "radius",
"--radius-md": "radius",
"--radius-lg": "radius",
"--shadow-sm": "shadow",
"--shadow-md": "shadow",
"--shadow-lg": "shadow"
},
"fontFamilies": [
"Archivo"
]
}
}
@@ -1,11 +0,0 @@
/* @ds-bundle: {"format":4,"namespace":"Modernist_modern","components":[],"sourceHashes":{},"inlinedExternals":[],"unexposedExports":[]} */
(() => {
const __ds_ns = (window.Modernist_modern = window.Modernist_modern || {});
const __ds_scope = {};
(__ds_ns.__errors = __ds_ns.__errors || []);
})();
File diff suppressed because one or more lines are too long
@@ -1,81 +0,0 @@
# Modernist design system
Modernist is flat, architectural and set entirely in Archivo: a near-mono red on white, a visible modular grid, zero corner radius and strong 2px rules. Nothing floats and nothing is decorated — alignment and the strength of the dividers do all the organising, labels sit flush left (even inside buttons), and photography prints in pure black and white.
## How to use this
- Link the one stylesheet from every page — `<link rel="stylesheet" href="styles.css">` (adjust the relative path) — and take every color, font, spacing, radius and shadow from its variables (`var(--color-*)`, `var(--font-*)`, `var(--space-*)`, `var(--radius-*)`, `var(--shadow-*)`). Never hard-code a hex, a font name or a px value the tokens already carry.
- Build with the classes below rather than inventing parallel ones; the component pages are plain HTML, so view source and copy the markup.
- `templates/` holds starting points a consuming project can copy whole.
- The whole system was derived from `theme.json`. To change the look, edit the tokens at the top of `styles.css` — every page, the thumbnail and this guide read from them — and keep `theme.json` and the written guidance in step so they don't drift from what the CSS actually does.
## Direction
Modular grid layouts — content in equal-width cells, strong horizontal and vertical rhythm, visible structure. Use strong 2px dividers (`var(--color-divider)`) between major sections. Button labels are flush left — a button wider than its label starts the text at the left padding edge (trailing icon and all), never centered. Wrap hero and inline images in the `.grayscale` class — they print in pure black and white.
## Color
A light ground (`--color-bg` #f3f2f2) with `--color-text` #201e1d and a single accent #ec3013 (this is a mono scheme: no second accent was chosen — the `--color-accent-2-*` variables carry a machine-derived stand-in kept only so both sets resolve; treat them as one role). Each role carries a 100–900 tonal ramp (`--color-neutral-100` … `--color-accent-2-900`) generated in OKLCH on a shared perceptual lightness scale, so the same step of any ramp has the same visual weight. Use the light steps (100–300) for tinted fills, hovers and subtle borders, 500 as the role's base, and the dark steps (700–900) for text on tinted fills and for pressed states; prefer ramp steps over ad-hoc `color-mix()`. For elevation use `--shadow-sm/md/lg` (already tuned to the ground) rather than ad-hoc box-shadows.
## Type
Archivo for headings over Archivo for body text, loaded as `--font-heading` / `--font-body`. Density 1.00× and radius 0px are already baked into the `--space-*` / `--radius-*` scales — use the variables, not raw numbers.
## Icons
Use Lucide icons (https://lucide.dev) throughout.
## Interaction states
Interactive states are themed, never browser defaults: give every interactive element a `:hover` tint and a pressed state from the accent ramp (one step past the base — `--color-accent-600` on a light ground, `--color-accent-400` on a dark one, or a `color-mix()` tint for outlined/ghost variants), and style keyboard focus with `:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }` — never leave the default blue focus ring.
## Components
| Class | What it is | Shown in |
| --- | --- | --- |
| `.btn` with `.btn-primary`, `.btn-secondary`, `.btn-ghost`, `.btn-icon`, `.btn-block` | Actions — the primary is a solid accent fill | components/buttons.html |
| `.tag` with `.tag-accent`, `.tag-accent-2`, `.tag-neutral`, `.tag-outline` | Small labels tinted from the ramps (mono palette: accent-2 reads the same as accent) | components/buttons.html |
| `.field` + `label`, `.input`, `.radio` + `.dot`, `.seg` + `.seg-opt` | Form fields and choices on native elements — no script | components/forms.html |
| `.card` with `.card-kicker`, `.card-title`, `.card-body`, `.card-meta`; `.elev-sm/md/lg` | Surface-filled content cards; elevation utilities | components/cards.html |
| `.nav` + `.nav-brand` | The header bar | components/navigation.html |
| `.table` | Data tables with themed header and row rules | components/table.html |
| `.dialog-backdrop` + `.dialog` (+ `.dialog-title/-body/-actions`) | A modal at the top elevation | components/dialog.html |
| `.hr` | A strong 2px horizontal rule | foundations/layout.html |
| `.grayscale` | The image wrapper — every content photograph goes through it | foundations/image.html |
States are built in: hovers and pressed states come from the accent ramp, keyboard focus is the 2px accent `:focus-visible` ring, `::selection` is an accent tint, and disabled controls drop to 45% opacity. Don't restyle them per page. The accent-to-ground pair is tuned to at least 3:1 — enough for icons, large text and interface chrome, not for body copy — so for paragraph-size text in the accent use a deep ramp step (`--color-accent-700` on this ground) rather than the accent itself.
## Do
- Let the grid show: equal-width cells, strong horizontal rules between sections, visible structure.
- Keep everything flush left — headings, copy, and the labels inside wide buttons.
- Use the accent sparingly, for the primary action and small emphasis; the system is mostly ink on ground. The one place red runs as a field is the poster statement — the deck's section dividers and the landing's closing banner — where type stays display-grade and the accent carries the page.
- Print photographs in black and white with the `.grayscale` wrapper.
## Don't
- Do not round a corner anywhere — `--radius-md` is 0 on purpose.
- Do not center button labels or hero copy.
- Do not soften the rules into hairlines or drop them for whitespace.
- Do not tint or colorize imagery.
## Files
- `styles.css` — the only stylesheet: the token sheet (`:root` variables, ramps, base type) plus the component layer. Link it from every page.
- `readme.md` — this guide.
- `theme.json` — the parameters these files were derived from (a machine-readable record of the theme).
- `thumbnail.html` — the project cover (brand mark + swatches).
- `foundations/type.html` — the type scale and the heading/body pairing at real sizes.
- `foundations/color.html` — color roles and the 100-900 tonal ramps, with usage notes.
- `foundations/layout.html` — the spacing scale, the grid and how edges are drawn.
- `foundations/icons.html` — the icon set at interface sizes, inline and in buttons.
- `foundations/image.html` — how photographs and figures are treated.
- `components/buttons.html` — buttons, icon buttons and tags in every variant and state.
- `components/forms.html` — text fields, radios and the segmented control on native elements.
- `components/cards.html` — content cards and the elevation steps.
- `components/navigation.html` — the header bar pattern.
- `components/table.html` — a data table with the themed header and row rules.
- `components/dialog.html` — a modal over its backdrop at the top elevation.
- `theme.html` — the theme's parameters rendered as a reference sheet.
- `templates/landing/` — a starter page consuming the system the intended way (`index.html`, its `ds-base.js` loader, and the vendored `image-slot.js` its photograph mounts).
- `assets/photo.jpg` — the reference photograph the imagery page treats.
@@ -1,252 +0,0 @@
/* Modernist — design-system tokens and component classes. This file is the source of truth for the system's look; retune it here and see readme.md. */
@import url('https://fonts.googleapis.com/css2?family=Archivo:wght@400;600;800&display=swap');
:root {
--color-bg: #f3f2f2;
--color-surface: #eae9e9;
--color-text: #201e1d;
--color-accent: #ec3013;
--color-accent-2: #e15b47;
--color-divider: color-mix(in srgb, #201e1d 40%, transparent);
/* Tonal ramps — generated in OKLCH on one shared lightness scale, so the
same step of any role matches the others in visual value. */
--color-neutral-100: #f8f4f4;
--color-neutral-200: #eae7e7;
--color-neutral-300: #d7d3d3;
--color-neutral-400: #bab6b6;
--color-neutral-500: #9b9797;
--color-neutral-600: #7d7979;
--color-neutral-700: #605d5d;
--color-neutral-800: #444141;
--color-neutral-900: #2d2b2b;
--color-accent-100: #fff2ef;
--color-accent-200: #ffe0d9;
--color-accent-300: #ffc4b8;
--color-accent-400: #ff9783;
--color-accent-500: #ff563c;
--color-accent-600: #dd2b0f;
--color-accent-700: #ae1800;
--color-accent-800: #7c1405;
--color-accent-900: #4d170e;
--color-accent-2-100: #fff2ef;
--color-accent-2-200: #ffe0da;
--color-accent-2-300: #ffc4b9;
--color-accent-2-400: #ff9784;
--color-accent-2-500: #ef6853;
--color-accent-2-600: #c94b39;
--color-accent-2-700: #9e3526;
--color-accent-2-800: #71261b;
--color-accent-2-900: #471d16;
--font-heading: "Archivo", system-ui, sans-serif;
--font-heading-weight: 800;
--font-body: "Archivo", system-ui, sans-serif;
--space-1: 4.0px;
--space-2: 8.0px;
--space-3: 12.0px;
--space-4: 16.0px;
--space-6: 24.0px;
--space-8: 32.0px;
--radius-sm: 0px;
--radius-md: 0px;
--radius-lg: 0px;
/* Elevation — derived from the ground: soft ink-tinted shadows on a
light theme, a hairline edge + ambient darkness on a dark one. */
--shadow-sm: 0 1px 2px color-mix(in srgb, #2d2b2b 14%, transparent);
--shadow-md: 0 3px 10px color-mix(in srgb, #2d2b2b 16%, transparent);
--shadow-lg: 0 12px 32px color-mix(in srgb, #2d2b2b 22%, transparent);
}
body {
background: var(--color-bg);
color: var(--color-text);
font-family: var(--font-body);
}
h1, h2, h3, h4 { font-family: var(--font-heading); font-weight: var(--font-heading-weight); }
.grayscale{filter:grayscale(1) contrast(1.08)}
/* ══════════════════════════════════════════════════════════════════════════
Components — built with the tokens above. Plain CSS
on plain HTML: no JavaScript, no build step. Each class is documented in
readme.md and demonstrated in foundations/ and components/.
══════════════════════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; font-size: 15px; line-height: 1.55; font-weight: 400; }
h1, h2, h3, h4, h5, h6 {
font-family: var(--font-heading); font-weight: var(--font-heading-weight);
line-height: 1.12; letter-spacing: -0.015em; margin: 0 0 var(--space-2);
}
h1 { font-size: 42px; }
h2 { font-size: 32px; }
h3 { font-size: 25px; }
h4 { font-size: 20px; }
h5 { font-size: 16px; }
h6 { font-size: 13px; }
h6 { letter-spacing: 0.08em; text-transform: uppercase; }
p { margin: 0 0 var(--space-3); }
a { color: var(--color-accent); text-underline-offset: 3px; }
img { display: block; max-width: 100%; }
figure { margin: 0; }
figcaption {
font-size: 11px; margin-top: var(--space-1);
color: color-mix(in srgb, var(--color-text) 55%, transparent);
}
.text-muted { color: color-mix(in srgb, var(--color-text) 55%, transparent); }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }
::selection { background: color-mix(in srgb, var(--color-accent) 30%, transparent); }
/* — rules — */
.hr {
height: 2px; border: 0; margin: var(--space-4) 0;
background: var(--color-divider);
}
/* — buttons — */
.btn {
display: inline-flex; align-items: center; justify-content: center; gap: 6px;
cursor: pointer; text-decoration: none;
font-family: var(--font-heading); font-weight: var(--font-heading-weight);
font-size: 14px; line-height: 1.2; color: var(--color-text); /* matches the .input's 14px —
the pair sits side by side in sign-up rows */
background: transparent; border: 1px solid transparent;
padding: var(--space-2) calc(var(--space-3) * 1.2);
border-radius: var(--radius-md);
}
.btn svg { display: block; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--color-accent); color: var(--color-bg); }
.btn-primary:hover { background: var(--color-accent-600); }
.btn-primary:active { background: var(--color-accent-700); }
.btn-secondary { border-color: var(--color-divider); }
.btn-secondary:hover { background: color-mix(in srgb, var(--color-text) 7%, transparent); }
.btn-secondary:active { background: color-mix(in srgb, var(--color-text) 14%, transparent); }
.btn-ghost { color: var(--color-accent); padding-inline: var(--space-1); }
.btn-ghost:hover { background: color-mix(in srgb, var(--color-accent) 10%, transparent); }
.btn-ghost:active { background: color-mix(in srgb, var(--color-accent) 18%, transparent); }
.btn-icon { width: 36px; height: 36px; padding: 0; }
.btn-block { width: 100%; margin-top: var(--space-2); justify-content: flex-start; text-align: left; }
/* — forms — */
.field > label {
display: block; font-size: 12px; margin-bottom: 5px;
color: color-mix(in srgb, var(--color-text) 70%, transparent);
}
.input {
width: 100%; min-height: 36px; padding: 6px 10px; font: inherit;
font-size: 14px; color: var(--color-text); caret-color: var(--color-accent);
background: var(--color-surface);
border: 1px solid var(--color-divider); border-radius: var(--radius-md);
}
.input:hover { border-color: color-mix(in srgb, var(--color-text) 45%, transparent); }
.input:focus-visible { border-color: var(--color-accent); outline-offset: 0; }
textarea.input { min-height: 90px; resize: vertical; }
.radio { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; }
.radio input, .seg-opt input {
position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none;
}
.radio .dot {
width: 16px; height: 16px; flex: none; border-radius: 50%;
border: 1.5px solid var(--color-divider);
}
.radio:hover .dot { border-color: var(--color-accent); }
.radio input:checked + .dot {
border-color: var(--color-accent); background: var(--color-accent);
box-shadow: inset 0 0 0 4px var(--color-bg);
}
.radio input:focus-visible + .dot { outline: 2px solid var(--color-accent); outline-offset: 2px; }
.seg {
display: inline-flex; overflow: hidden;
border: 1px solid var(--color-divider); border-radius: var(--radius-md);
}
.seg-opt {
display: inline-flex; align-items: center; gap: 6px;
padding: 7px 12px; font-size: 13px; cursor: pointer;
}
.seg-opt + .seg-opt { border-left: 1px solid var(--color-divider); }
.seg-opt:has(input:checked) { background: var(--color-accent); color: var(--color-bg); }
.seg-opt:not(:has(input:checked)):hover { background: color-mix(in srgb, var(--color-text) 7%, transparent); }
.seg-opt:has(input:focus-visible) { outline: 2px solid var(--color-accent); outline-offset: -2px; }
/* — cards — */
.card {
display: flex; flex-direction: column; gap: var(--space-2);
padding: var(--space-3); border-radius: var(--radius-md); background: var(--color-surface);
}
.card-kicker { font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--color-accent); }
.card-title {
font-family: var(--font-heading); font-weight: var(--font-heading-weight);
font-size: 17px; line-height: 1.2;
}
.card-body { margin: 0; font-size: 13px; opacity: 0.8; flex: 1; }
.card-meta {
display: flex; align-items: center; gap: 6px; font-size: 11px;
color: color-mix(in srgb, var(--color-text) 50%, transparent);
}
.elev-sm { box-shadow: var(--shadow-sm); }
.elev-md { box-shadow: var(--shadow-md); }
.elev-lg { box-shadow: var(--shadow-lg); }
/* — tags — */
.tag {
display: inline-flex; align-items: center; font-size: 11px;
letter-spacing: 0.02em; padding: 3px 10px;
border-radius: calc(var(--radius-md) * 0.75);
}
.tag-accent { background: var(--color-accent-100); color: var(--color-accent-800); }
.tag-accent-2 { background: var(--color-accent-2-100); color: var(--color-accent-2-800); }
.tag-neutral { background: var(--color-neutral-100); color: var(--color-neutral-800); }
.tag-outline { border: 1px solid var(--color-accent); color: var(--color-accent); }
/* — navigation — */
.nav {
display: flex; align-items: center; gap: var(--space-4);
padding: var(--space-3) var(--space-4);
border-bottom: 2px solid var(--color-divider);
}
.nav-brand {
font-family: var(--font-heading); font-weight: var(--font-heading-weight);
font-size: 18px; margin-right: auto;
}
.nav a { color: inherit; text-decoration: none; font-size: 14px; }
.nav a:hover, .nav a[aria-current='page'] { color: var(--color-accent); }
/* — tables — */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
text-align: left; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase;
color: color-mix(in srgb, var(--color-text) 60%, transparent);
padding: var(--space-2); border-bottom: 2px solid var(--color-divider);
}
.table td {
padding: var(--space-2);
border-bottom: 1px solid var(--color-divider);
}
.table tbody tr:hover { background: color-mix(in srgb, var(--color-text) 4%, transparent); }
/* — dialog — */
.dialog-backdrop {
position: fixed; inset: 0; display: grid; place-items: center;
padding: var(--space-4);
background: color-mix(in srgb, var(--color-neutral-900) 50%, transparent);
}
.dialog {
width: min(440px, 100%); display: flex; flex-direction: column; gap: var(--space-3);
padding: var(--space-4); border-radius: var(--radius-lg);
background: var(--color-surface); box-shadow: var(--shadow-lg);
}
.dialog-title {
font-family: var(--font-heading); font-weight: var(--font-heading-weight);
font-size: 20px;
}
.dialog-body { font-size: 14px; opacity: 0.85; }
.dialog-actions { display: flex; justify-content: flex-end; gap: var(--space-2); margin-top: var(--space-2); }
File diff suppressed because it is too large Load Diff
@@ -1,117 +0,0 @@
# Modernist Design System Restyle
**Date:** 2026-09-30
**Status:** Approved
**Goal:** Restyle the whole IMS app to the Modernist design system in `design-system/_ds/modernist-*/`, and record the guidelines so future development follows them.
## Decisions
- **Governing source:** Modernist (`design-system/_ds/modernist-6062679c-a4aa-42a4-9043-28fea370dda9/readme.md` and `styles.css`). `design-system/IMS Admin.dc.html` (Geist, teal, 12px radius) is superseded and is not implemented. Its screen structure is out of scope for this pass.
- **Scope:** Whole app in one pass: tokens and base styles, shared shell, then every page (login, reporter, HSE, supervisor, management, capa-owner, admin).
- **Approach:** Remap Tailwind v4 tokens to Modernist so the existing utility classes restyle automatically, then add a thin set of shared components where token remapping leaves the markup structurally wrong.
## Current state
- Tailwind v4 (`@import "tailwindcss"` and `@theme inline` in `app/globals.css`), 62 TSX files with `className`.
- Utility usage: 522 `gray-*`, 120 `blue-*`, 219 `rounded*`, 57 `shadow*`.
- Semantic colors in use: red (errors, overdue), green (done, verified), purple, yellow, orange (workflow statuses, priorities).
- Font: Geist and Geist Mono via `next/font/google` in `app/layout.tsx`.
- Icons: inline SVG, `lucide-react` is not installed.
- Shared UI: `components/ui/modal.tsx` (rounded-2xl, gray-900/50 backdrop), `components/layout/sidebar.tsx`.
## Design
### 1. Tokens (`app/globals.css`)
Copy the Modernist `:root` variables verbatim from `styles.css` (colors, neutral and accent ramps, fonts, spacing, radius, shadows). Do not hard-code hex values elsewhere.
Expose them to Tailwind through `@theme`:
- `--color-gray-50…900` map to `--color-neutral-100…900` (nearest step). Existing `gray-*` classes then render on the Modernist neutral ramp.
- `--color-blue-50…900` map to `--color-accent-100…900`. Existing `blue-*` classes then render as the red accent (primary buttons, links, focus).
- `--radius-*` (`sm`, `md`, `lg`, `xl`, `2xl`, `3xl`) are set to `0`. `rounded-full` is left alone, so circular avatars and radio dots stay round.
- Shadows: remap `shadow-sm/md/lg` to `--shadow-sm/md/lg`. `shadow-xl` and `shadow-2xl` are replaced with `shadow-lg`.
- `--font-sans` and `--font-heading` are set to Archivo (400, 600, 800). Remove Geist, and Geist Mono stays only if monospace is used anywhere.
Base layer (from `styles.css`): body uses `--color-bg` and `--color-text` at 15px/1.55, headings use Archivo 800 with the Modernist scale, `a` uses the accent, `:focus-visible` is a 2px accent outline with 2px offset, `::selection` is an accent tint, disabled controls drop to 45% opacity. Remove the `prefers-color-scheme: dark` block: Modernist defines only a light ground.
Fix `app/globals.css` input colors (`#111827`, `#6b7280`) to use `--color-text` and a 55% text mix.
### 2. Shared components (`components/ui/`)
Each takes Modernist tokens only and carries the markup rules Tailwind remapping cannot:
| Component | Rules |
| --- | --- |
| `Button` (`primary`, `secondary`, `ghost`, `icon`, `block`) | Archivo 800 14px, flush-left label even when wide, primary is solid accent with `accent-600` hover and `accent-700` pressed. Secondary is a 1px divider border. |
| `Tag` (`accent`, `neutral`, `outline`) | 11px, 3px 10px padding, no radius. Used for statuses and priorities. |
| `Field` and `Input` | 12px label above, 36px min height, surface fill, 1px divider border, accent border on focus. |
| `Card` | Surface fill, 12px padding, no border, no radius, optional `kicker`, `title`, `meta`. |
| `DataTable` styles | Uppercase 11px header with a 2px divider under it, 1px row rules, 4% text-tint row hover. |
| `Modal` (existing) | Restyle to `.dialog`: surface fill, 0 radius, `--shadow-lg`, neutral-900/50 backdrop, title uses Archivo 800 20px, Lucide `X` for close. |
Existing pages keep their own markup where the remapped utilities already render correctly. Migrate a page to these components only when its markup needs a structural change (for example centered button labels, rounded chips, hairline dividers).
### 3. Shell
- **Sidebar:** flat surface, 2px right rule in `--color-divider`, brand in Archivo 800, nav items flush left with Lucide icons, active item in accent, version label kept at the bottom.
- **Mobile bottom nav:** 2px top rule, same active treatment.
- **Notification bell:** square button with a 1px divider border (was a round white button).
- **Section dividers:** use `.hr` (2px) between major sections, not whitespace or hairlines.
### 4. Icons
Install `lucide-react` and replace the inline SVGs in the sidebar, modal, nav, and buttons with Lucide equivalents. Default 16 to 20px, stroke 2.
### 5. Imagery
Add the `grayscale` class (`filter: grayscale(1) contrast(1.08)`) for decorative or brand photography only. Incident evidence photos and thumbnails stay in full color, because color can carry evidence (spill color, burns, signage). Decided 2026-09-30.
### 6. Status and priority colors (design decision)
Modernist is near-mono with one accent, so the current red, green, purple, yellow and orange status chips cannot all survive. Proposed mapping:
| Meaning | Treatment |
| --- | --- |
| Needs attention or overdue, open, reported, severity 4 to 5, errors | `tag-accent` (red tint), red text for inline errors |
| In progress (triaged, investigating, CAPA pending, verification) | `tag-outline` (accent outline) |
| Done (closed, verified, completed) | `tag-neutral` |
| Low priority or informational | `tag-neutral` |
Status is never conveyed by color alone: every tag keeps its text label, and the workflow states gain a Lucide icon. One central `StatusTag` and `PriorityTag` component replaces the scattered `STATUS_COLORS` and `PRIORITY_COLORS` maps (used in `capa-board.tsx`, `incident-list.tsx`, `incident-header.tsx`, `incident-detail.tsx`, and the reporter, supervisor and capa-owner pages).
### 7. Out of scope
- The IMS Admin mockup layouts (index tables with saved views, filter chips, bulk select).
- Dark mode.
- Data, API, auth or routing changes.
- Email templates and the generated PDFs (JKKP 6/7/8, incident report). They keep their own styling.
## Documentation and memory
- Add a "Design system" section to `CLAUDE.md`: Modernist is the source of truth, use tokens and never hard-code hex or px, 0 radius, flush-left labels, 2px rules, Lucide icons, `grayscale` imagery, status via `StatusTag` and `PriorityTag`.
- Save a memory file `ims-design-system.md` (type `reference`) pointing at `design-system/_ds/modernist-*/readme.md` and recording these rules and the status-color mapping, then add it to `MEMORY.md`.
## Testing and verification
- `next build` passes with no type errors. The vitest suite still passes. Only tests asserting old class names need updating.
- Run the app locally and check each role's pages in a browser: login, reporter report form and list, HSE inbox, incident detail, CAPA board, supervisor, management dashboard, admin users and settings. Check desktop and mobile widths.
- Grep gates after migration: no `rounded-(sm|md|lg|xl|2xl|3xl)` left in app/ or components/ apart from deliberate exceptions, no hard-coded hex in TSX, no `text-center` on button labels.
- Keyboard: every interactive element shows the 2px accent focus ring.
- Contrast: body copy in accent uses `accent-700`, not the accent itself (accent on ground is 3:1, so chrome only).
## Deployment
A build-only deploy per the IMS deployment procedure (`/srv/apps/ims/app`, never build on the server, keep `.next/BUILD_ID` and `.next/static` in place). No database changes.
## Risks
- **Remapping `blue-*` to red** can make unrelated blue uses (links, info banners) read as errors. Review every `blue-*` site (120 uses) and switch informational ones to neutral.
- **Status legibility:** removing green and purple makes states less scannable. Icons plus labels mitigate this, and the mapping above needs your sign-off.
- **Archivo 800 headings** are wider than Geist and can overflow narrow table headers and mobile nav labels. Check at 360px.
- **Visual diff is large** (62 files of class changes), so review in a browser, not only via the diff.
## Resolved decisions
1. Status mapping in section 6 is approved as written. Green is not kept for "closed/verified".
2. Evidence photos are exempt from grayscale (section 5).
+1 -1
View File
@@ -45,7 +45,7 @@ describe('analyzePdfsWithDeepSeek', () => {
const metadata = await analyzePdfsWithDeepSeek(pdfTexts) const metadata = await analyzePdfsWithDeepSeek(pdfTexts)
expect(metadata.description).toBeDefined() expect(metadata.description).toBeDefined()
expect(metadata.date).toBeDefined() expect(metadata.date).toBeDefined()
expect(metadata.location?.site).toBeDefined() expect(metadata.location.site).toBeDefined()
}) })
}) })
+2 -18
View File
@@ -16,7 +16,6 @@
"file-type": "^22.0.1", "file-type": "^22.0.1",
"idb": "^8.0.3", "idb": "^8.0.3",
"jose": "^6.2.4", "jose": "^6.2.4",
"lucide-react": "^1.49.0",
"next": "^16.3.7", "next": "^16.3.7",
"openai": "^6.46.0", "openai": "^6.46.0",
"pdf-lib": "^1.17.1", "pdf-lib": "^1.17.1",
@@ -3227,7 +3226,7 @@
"version": "19.2.17", "version": "19.2.17",
"resolved": "https://registry.npmjs.org/@types/react/-/react-19.2.17.tgz", "resolved": "https://registry.npmjs.org/@types/react/-/react-19.2.17.tgz",
"integrity": "sha512-MXfmqaVPEVgkBT/aY0aGCkRWWtByiYQXo3xdQ8r5RzuFrPiRn8Gar2tQdXSUQ2GKV3bkXckek89V8wQBY2Q/Aw==", "integrity": "sha512-MXfmqaVPEVgkBT/aY0aGCkRWWtByiYQXo3xdQ8r5RzuFrPiRn8Gar2tQdXSUQ2GKV3bkXckek89V8wQBY2Q/Aw==",
"devOptional": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"csstype": "^3.2.2" "csstype": "^3.2.2"
@@ -4682,7 +4681,7 @@
"version": "3.2.3", "version": "3.2.3",
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.3.tgz", "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.3.tgz",
"integrity": "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==", "integrity": "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==",
"devOptional": true, "dev": true,
"license": "MIT" "license": "MIT"
}, },
"node_modules/d": { "node_modules/d": {
@@ -8170,21 +8169,6 @@
"es5-ext": "~0.10.2" "es5-ext": "~0.10.2"
} }
}, },
"node_modules/lucide-react": {
"version": "1.49.0",
"resolved": "https://registry.npmjs.org/lucide-react/-/lucide-react-1.49.0.tgz",
"integrity": "sha512-ApfaNM4/7jBrVopqLJ84Jz8TMQ1Q1JeZ1PmKh25aeS3E1FTVcMkSh1bEQB7dfzdIrwXRP8p3z4AJjTIHHb5IIA==",
"license": "ISC",
"peerDependencies": {
"@types/react": "*",
"react": "^16.5.1 || ^17.0.0 || ^18.0.0 || ^19.0.0"
},
"peerDependenciesMeta": {
"@types/react": {
"optional": true
}
}
},
"node_modules/lz-string": { "node_modules/lz-string": {
"version": "1.5.0", "version": "1.5.0",
"resolved": "https://registry.npmjs.org/lz-string/-/lz-string-1.5.0.tgz", "resolved": "https://registry.npmjs.org/lz-string/-/lz-string-1.5.0.tgz",
+1 -3
View File
@@ -9,8 +9,7 @@
"lint": "eslint", "lint": "eslint",
"test": "vitest run", "test": "vitest run",
"test:watch": "vitest", "test:watch": "vitest",
"generate-qr": "tsx scripts/generate-qr.ts", "generate-qr": "tsx scripts/generate-qr.ts"
"check:design": "node scripts/check-design-gates.mjs"
}, },
"dependencies": { "dependencies": {
"@anthropic-ai/sdk": "^0.111.0", "@anthropic-ai/sdk": "^0.111.0",
@@ -21,7 +20,6 @@
"file-type": "^22.0.1", "file-type": "^22.0.1",
"idb": "^8.0.3", "idb": "^8.0.3",
"jose": "^6.2.4", "jose": "^6.2.4",
"lucide-react": "^1.49.0",
"next": "^16.3.7", "next": "^16.3.7",
"openai": "^6.46.0", "openai": "^6.46.0",
"pdf-lib": "^1.17.1", "pdf-lib": "^1.17.1",
-61
View File
@@ -1,61 +0,0 @@
import { readdirSync, readFileSync, statSync } from 'node:fs'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
// Files where a circular element is legitimate (avatar). Add others only with a reason.
export const ROUND_ALLOWED = ['components/layout/sidebar.tsx']
const RULES = [
{
rule: 'no-rounded',
re: /(?<=[\s"'`:{])(?:[\w-]+:)*rounded(?:-(?!full(?![\w-]))[\w]+)*(?=[\s"'`}])/,
},
{ rule: 'no-bg-white', re: /(?<![\w-])bg-white(?![\w-])/ },
{ rule: 'no-heavy-shadow', re: /(?<![\w-])shadow-(?:xl|2xl)(?![\w-])/ },
{
rule: 'off-palette',
re: /(?<![\w-])(?:bg|text|border|ring|from|to|via|divide|fill|stroke|outline)-(?:green|yellow|amber|orange|purple|indigo|teal|emerald|sky|cyan|pink|rose|violet|lime|fuchsia)-\d{2,3}/,
},
{ rule: 'no-hex', re: /(?<![&\w])#[0-9a-fA-F]{3,8}\b/ },
{ rule: 'no-centered-button', re: /<button[^>]*className=[^>]*(?<![\w-])text-center(?![\w-])/ },
]
export function findViolations(src, file) {
const out = []
const roundAllowed = ROUND_ALLOWED.includes(file)
src.split('\n').forEach((text, i) => {
const line = i + 1
for (const { rule, re } of RULES) {
if (re.test(text)) out.push({ file, line, rule, text: text.trim() })
}
if (!roundAllowed && /(?<=[\s"'`:{])(?:[\w-]+:)*rounded-full(?=[\s"'`}])/.test(text)) {
out.push({ file, line, rule: 'no-rounded-full', text: text.trim() })
}
})
return out
}
function walk(dir, files = []) {
for (const name of readdirSync(dir)) {
const full = path.join(dir, name)
if (statSync(full).isDirectory()) walk(full, files)
else if (full.endsWith('.tsx')) files.push(full)
}
return files
}
function main() {
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')
const all = []
for (const dir of ['app', 'components']) {
for (const abs of walk(path.join(root, dir))) {
const rel = path.relative(root, abs).split(path.sep).join('/')
all.push(...findViolations(readFileSync(abs, 'utf8'), rel))
}
}
for (const v of all) console.log(`${v.file}:${v.line} [${v.rule}] ${v.text}`)
console.log(all.length === 0 ? 'design gates: clean' : `design gates: ${all.length} violation(s)`)
process.exit(all.length === 0 ? 0 : 1)
}
if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) main()
-54
View File
@@ -1,54 +0,0 @@
import { readdirSync, readFileSync, writeFileSync, statSync } from 'node:fs'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
const CLASS_ATTR =
/className=(?:"[^"]*"|'[^']*'|\{"[^"]*"\}|\{'[^']*'\}|\{`(?:[^`\\]|\\.)*`\})/g
const ROUNDED =
/(?<![\w:-])(?:[\w-]+:)*rounded(?:-(?:t|b|l|r|tl|tr|bl|br|s|e))?(?:-(?:xs|sm|md|lg|xl|2xl|3xl|4xl|none))?(?![\w-])/g
function transformClassAttr(attr) {
let out = attr
out = out.replace(ROUNDED, '')
out = out.replace(/(?<![\w-])bg-white(?![\w-])/g, 'bg-surface')
out = out.replace(/(?<![\w-])border-gray-(?:100|200|300)(?![\w-])/g, 'border-divider')
out = out.replace(/(?<![\w-])divide-gray-(?:100|200|300)(?![\w-])/g, 'divide-divider')
out = out.replace(/(?<![\w-])shadow-(?:xl|2xl)(?![\w-])/g, 'shadow-lg')
out = out.replace(/(["'])([^"'`$]*)\1/g, (_, q, body) => q + body.trim().replace(/ {2,}/g, ' ') + q)
out = out.replace(/^(className=\{`)\s+/, '$1').replace(/\s+(`\})$/, '$1')
return out
}
export function transformSource(src) {
const next = src.replace(CLASS_ATTR, transformClassAttr)
return next.replace(/ className=(?:""|''|\{""\}|\{''\}|\{``\})/g, '')
}
function walk(dir, files = []) {
for (const name of readdirSync(dir)) {
const full = path.join(dir, name)
if (statSync(full).isDirectory()) walk(full, files)
else if (full.endsWith('.tsx')) files.push(full)
}
return files
}
function main() {
const dry = process.argv.includes('--dry')
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')
let changed = 0
for (const dir of ['app', 'components']) {
for (const file of walk(path.join(root, dir))) {
const before = readFileSync(file, 'utf8')
const after = transformSource(before)
if (after !== before) {
changed++
if (!dry) writeFileSync(file, after)
}
}
}
console.log(`${dry ? 'would change' : 'changed'} ${changed} files`)
}
if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) main()
+1 -1
View File
@@ -21,7 +21,7 @@ import { withUser } from '@/lib/db/with-user'
import { buildIncidentReportPdf } from '@/lib/pdf/incident-report' import { buildIncidentReportPdf } from '@/lib/pdf/incident-report'
import { NextRequest } from 'next/server' import { NextRequest } from 'next/server'
const mockSession = { sub: 'user-1', role: 'hse' as const, siteId: 'site-1', name: 'Test User' } const mockSession = { sub: 'user-1', role: 'hse' as const }
const MOCK_INCIDENT = { const MOCK_INCIDENT = {
id: 'inc-1', id: 'inc-1',
-41
View File
@@ -1,41 +0,0 @@
import { describe, it, expect, vi } from 'vitest'
import { render, screen } from '@testing-library/react'
vi.mock('next/navigation', () => ({
usePathname: () => '/hse/capa',
useRouter: () => ({ push: vi.fn(), refresh: vi.fn() }),
}))
vi.mock('@/components/notifications/bell', () => ({ NotificationBell: () => null }))
import { Sidebar } from '@/components/layout/sidebar'
describe('Sidebar (Modernist shell)', () => {
it('renders the role nav with Lucide icons instead of inline paths', () => {
const { container } = render(<Sidebar role="hse" userName="Ada Lovelace" userEmail="" />)
expect(screen.getAllByText('Dashboard').length).toBeGreaterThan(0)
expect(screen.getAllByText('CAPA').length).toBeGreaterThan(0)
expect(container.querySelectorAll('svg.lucide').length).toBeGreaterThan(4)
})
it('marks the active link in the accent with an aria-current', () => {
render(<Sidebar role="hse" userName="Ada" userEmail="" />)
const active = screen.getAllByRole('link', { name: /CAPA/ }).find(a => a.getAttribute('aria-current') === 'page')
expect(active).toBeTruthy()
expect(active?.className).toContain('text-accent-700')
expect(active?.className).toContain('border-accent')
})
it('is flat: a 2px divider rule, ground fill and no rounded corners except the avatar', () => {
const { container } = render(<Sidebar role="hse" userName="Ada" userEmail="" />)
const aside = container.querySelector('aside')
expect(aside?.className).toContain('border-r-2')
expect(aside?.className).toContain('bg-ground')
const rounded = container.innerHTML.match(/rounded[\w-]*/g) ?? []
expect(rounded.every(r => r === 'rounded-full')).toBe(true)
})
it('keeps the version label', () => {
render(<Sidebar role="hse" userName="Ada" userEmail="" />)
expect(screen.getByText('v1.2.2')).toBeTruthy()
})
})
-52
View File
@@ -1,52 +0,0 @@
import { describe, it, expect, vi } from 'vitest'
import { render, screen, fireEvent } from '@testing-library/react'
import { Modal } from '@/components/ui/modal'
describe('Modal (Modernist dialog)', () => {
it('renders nothing when closed', () => {
const { container } = render(
<Modal open={false} onClose={() => {}} title="T">
body
</Modal>,
)
expect(container.firstChild).toBeNull()
})
it('renders a dialog with title, body and footer on the surface fill', () => {
render(
<Modal open onClose={() => {}} title="Confirm" footer={<span>actions</span>}>
body text
</Modal>,
)
const dialog = screen.getByRole('dialog')
expect(dialog).toBeTruthy()
expect(screen.getByText('Confirm')).toBeTruthy()
expect(screen.getByText('body text')).toBeTruthy()
expect(screen.getByText('actions')).toBeTruthy()
expect(dialog.innerHTML).toContain('bg-surface')
expect(dialog.innerHTML).toContain('shadow-lg')
})
it('has no rounded corners and uses a 2px title rule', () => {
render(
<Modal open onClose={() => {}} title="T">
x
</Modal>,
)
const html = screen.getByRole('dialog').innerHTML
expect(html).not.toMatch(/rounded/)
expect(html).toContain('border-b-2')
})
it('closes from the X button and on Escape', () => {
const onClose = vi.fn()
render(
<Modal open onClose={onClose} title="T">
x
</Modal>,
)
fireEvent.click(screen.getByRole('button', { name: 'Close' }))
fireEvent.keyDown(document, { key: 'Escape' })
expect(onClose).toHaveBeenCalledTimes(2)
})
})
-132
View File
@@ -1,132 +0,0 @@
import { describe, it, expect } from 'vitest'
import { render, screen } from '@testing-library/react'
import { Button } from '@/components/ui/button'
import { Tag } from '@/components/ui/tag'
import { StatusTag, PriorityTag, statusTone } from '@/components/ui/status-tag'
import { Field, Input } from '@/components/ui/field'
import { Card } from '@/components/ui/card'
import { TABLE, TH, TR, TD } from '@/components/ui/table-styles'
describe('Button', () => {
it('renders a primary accent button that is type=button and flush left', () => {
render(<Button variant="primary">Save</Button>)
const btn = screen.getByRole('button', { name: 'Save' })
expect(btn.getAttribute('type')).toBe('button')
expect(btn.className).toContain('bg-accent')
expect(btn.className).toContain('justify-start')
expect(btn.className).not.toContain('justify-center')
})
it('block buttons span the row and stay flush left', () => {
render(<Button block>Go</Button>)
const btn = screen.getByRole('button', { name: 'Go' })
expect(btn.className).toContain('w-full')
expect(btn.className).toContain('justify-start')
})
it('icon buttons are square and centered', () => {
render(<Button variant="icon" aria-label="Close" />)
const btn = screen.getByRole('button', { name: 'Close' })
expect(btn.className).toContain('w-9')
expect(btn.className).toContain('justify-center')
expect(btn.className).not.toContain('justify-start')
})
it('never uses a rounded class', () => {
render(<Button variant="secondary">x</Button>)
expect(screen.getByRole('button').className).not.toMatch(/rounded/)
})
})
describe('Tag', () => {
it.each([
['accent', 'bg-accent-100'],
['neutral', 'bg-neutral-100'],
['outline', 'border-accent'],
] as const)('%s variant carries %s', (variant, cls) => {
render(<Tag variant={variant}>Label</Tag>)
expect(screen.getByText('Label').className).toContain(cls)
})
})
describe('statusTone', () => {
it.each([
['reported', 'accent'],
['triaged', 'outline'],
['investigating', 'outline'],
['capa_pending', 'outline'],
['verification', 'outline'],
['closed', 'neutral'],
['open', 'accent'],
['in_progress', 'outline'],
['overdue', 'accent'],
['pending_verification', 'outline'],
['verified', 'neutral'],
['reopened', 'accent'],
['something_else', 'neutral'],
])('%s maps to %s', (status, tone) => {
expect(statusTone(status)).toBe(tone)
})
})
describe('StatusTag', () => {
it('shows a humanized text label plus an icon, never color alone', () => {
const { container } = render(<StatusTag status="capa_pending" />)
expect(screen.getByText('CAPA Pending')).toBeTruthy()
expect(container.querySelector('svg')).not.toBeNull()
})
it('accepts a label override', () => {
render(<StatusTag status="overdue">Late</StatusTag>)
expect(screen.getByText('Late')).toBeTruthy()
})
})
describe('PriorityTag', () => {
it.each([
['high', 'bg-accent-100'],
['med', 'border-accent'],
['low', 'bg-neutral-100'],
])('%s priority uses %s', (priority, cls) => {
const { container } = render(<PriorityTag priority={priority} />)
expect(container.firstElementChild?.className).toContain(cls)
})
})
describe('Field and Input', () => {
it('associates the label with the input', () => {
render(
<Field label="Email" htmlFor="email">
<Input id="email" />
</Field>,
)
const input = screen.getByLabelText('Email')
expect(input.className).toContain('bg-surface')
expect(input.className).toContain('border-divider')
})
})
describe('Card', () => {
it('renders kicker, title, body and meta on the surface fill', () => {
const { container } = render(
<Card kicker="Open" title="Forklift" meta="Due Friday">
Body text
</Card>,
)
expect(screen.getByText('Open')).toBeTruthy()
expect(screen.getByText('Forklift')).toBeTruthy()
expect(screen.getByText('Body text')).toBeTruthy()
expect(screen.getByText('Due Friday')).toBeTruthy()
expect(container.firstElementChild?.className).toContain('bg-surface')
})
})
describe('table styles', () => {
it('uses a 2px header rule and 1px row rules', () => {
expect(TH).toContain('border-b-2')
expect(TH).toContain('border-divider')
expect(TD).toContain('border-b')
expect(TR).toContain('hover:bg-ink/4')
expect(TABLE).toContain('w-full')
})
})
-62
View File
@@ -1,62 +0,0 @@
import { describe, it, expect } from 'vitest'
import { readFileSync } from 'fs'
import path from 'path'
const css = readFileSync(path.resolve(__dirname, '../../app/globals.css'), 'utf8')
describe('Modernist tokens in globals.css', () => {
it.each([
['--color-bg', '#f3f2f2'],
['--color-surface', '#eae9e9'],
['--color-text', '#201e1d'],
['--color-accent', '#ec3013'],
['--color-accent-700', '#ae1800'],
['--color-neutral-900', '#2d2b2b'],
])('declares %s as %s', (name, value) => {
expect(css).toMatch(new RegExp(`${name}:\\s*${value}`, 'i'))
})
it.each(['xs', 'sm', 'md', 'lg', 'xl', '2xl', '3xl', '4xl'])('zeroes --radius-%s', size => {
expect(css).toMatch(new RegExp(`--radius-${size}:\\s*0px`))
})
it('zeroes the bare --radius used by the plain rounded class', () => {
expect(css).toMatch(/--radius:\s*0px/)
})
it('has no stray comment terminator before @theme', () => {
const head = css.slice(0, css.indexOf('@theme'))
expect(head.match(/\*\//g)?.length).toBe(head.match(/\/\*/g)?.length)
})
it('remaps the gray ramp onto the neutral ramp', () => {
expect(css).toMatch(/--color-gray-100:\s*var\(--color-neutral-200\)/)
expect(css).toMatch(/--color-gray-900:\s*var\(--color-text\)/)
})
it('remaps the blue ramp onto the accent ramp', () => {
expect(css).toMatch(/--color-blue-600:\s*var\(--color-accent\)/)
expect(css).toMatch(/--color-blue-700:\s*var\(--color-accent-700\)/)
})
it('remaps the red ramp onto the accent ramp, with body-size steps on accent-700', () => {
expect(css).toMatch(/--color-red-600:\s*var\(--color-accent-700\)/)
expect(css).toMatch(/--color-red-50:\s*var\(--color-accent-100\)/)
})
it('maps shadows onto the Modernist elevation tokens', () => {
expect(css).toMatch(/--shadow-2xl:\s*var\(--shadow-lg\)/)
})
it('uses Archivo through the next/font variable', () => {
expect(css).toMatch(/--font-sans:\s*var\(--font-archivo\)/)
})
it('has no dark mode block', () => {
expect(css).not.toContain('prefers-color-scheme')
})
it('styles keyboard focus with the 2px accent ring', () => {
expect(css).toMatch(/:focus-visible\s*\{[^}]*outline:\s*2px solid var\(--color-accent\)/)
})
})
-45
View File
@@ -1,45 +0,0 @@
import { describe, it, expect } from 'vitest'
import { findViolations, ROUND_ALLOWED } from '../../scripts/check-design-gates.mjs'
const rules = (src: string, file = 'components/x.tsx'): string[] =>
(findViolations(src, file) as Array<{ rule: string }>).map(v => v.rule)
describe('design gates', () => {
it('flags rounded corner classes', () => {
expect(rules('<div className="rounded-lg p-2" />')).toContain('no-rounded')
expect(rules('<div className="p-2 hover:rounded-md" />')).toContain('no-rounded')
})
it('flags rounded-full outside the allowlist and accepts it inside', () => {
expect(rules('<div className="rounded-full" />')).toContain('no-rounded-full')
expect(rules('<div className="rounded-full" />', ROUND_ALLOWED[0])).not.toContain('no-rounded-full')
})
it('flags off-palette colors but accepts remapped gray, blue and red', () => {
expect(rules('<p className="text-green-700" />')).toContain('off-palette')
expect(rules('<p className="bg-purple-100" />')).toContain('off-palette')
expect(rules('<p className="text-gray-500 text-blue-700 bg-red-50" />')).toEqual([])
})
it('flags hard-coded hex colors', () => {
expect(rules('<div style={{ color: "#ec3013" }} />')).toContain('no-hex')
expect(rules('<p>&#39;quoted&#39;</p>')).not.toContain('no-hex')
})
it('flags centered button labels', () => {
expect(rules('<button className="text-center px-2">x</button>')).toContain('no-centered-button')
})
it('flags leftovers the codemod should have replaced', () => {
expect(rules('<div className="bg-white shadow-2xl" />')).toEqual(expect.arrayContaining(['no-bg-white', 'no-heavy-shadow']))
})
it('reports file and 1-based line numbers', () => {
const v = findViolations('a\n<div className="rounded-md" />', 'components/y.tsx')
expect(v[0]).toMatchObject({ file: 'components/y.tsx', line: 2, rule: 'no-rounded' })
})
it('accepts clean on-system markup', () => {
expect(rules('<div className="bg-surface border border-divider p-4 text-ink shadow-sm" />')).toEqual([])
})
})
-55
View File
@@ -1,55 +0,0 @@
import { describe, it, expect } from 'vitest'
import { transformSource } from '../../scripts/modernist-codemod.mjs'
const t = (s: string): string => transformSource(s)
describe('modernist codemod', () => {
it('removes rounded-* sizes but keeps rounded-full', () => {
expect(t('<div className="rounded-xl p-4 rounded-full" />')).toBe('<div className="p-4 rounded-full" />')
expect(t('<div className="p-4 rounded" />')).toBe('<div className="p-4" />')
expect(t('<div className="rounded-t-lg border" />')).toBe('<div className="border" />')
})
it('removes variant-prefixed rounded classes whole', () => {
expect(t('<a className="hover:rounded-lg px-2" />')).toBe('<a className="px-2" />')
})
it('swaps bg-white for bg-surface, keeping variants and opacity', () => {
expect(t('<div className="bg-white p-2" />')).toBe('<div className="bg-surface p-2" />')
expect(t('<div className="hover:bg-white/80" />')).toBe('<div className="hover:bg-surface/80" />')
})
it('swaps light gray borders and dividers for the divider token', () => {
expect(t('<div className="border border-gray-200" />')).toBe('<div className="border border-divider" />')
expect(t('<ul className="divide-y divide-gray-100" />')).toBe('<ul className="divide-y divide-divider" />')
})
it('leaves dark gray borders alone', () => {
expect(t('<div className="border-gray-500" />')).toBe('<div className="border-gray-500" />')
})
it('swaps heavy shadows for shadow-lg', () => {
expect(t('<div className="shadow-2xl" />')).toBe('<div className="shadow-lg" />')
expect(t('<div className="shadow-xl" />')).toBe('<div className="shadow-lg" />')
expect(t('<div className="shadow-sm" />')).toBe('<div className="shadow-sm" />')
})
it('handles template literals with conditionals', () => {
const src = '<div className={`rounded-lg p-2 ${on ? \'bg-white rounded-md\' : \'bg-gray-50\'}`} />'
expect(t(src)).toBe('<div className={`p-2 ${on ? \'bg-surface\' : \'bg-gray-50\'}`} />')
})
it('drops a className that becomes empty', () => {
expect(t('<div className="rounded-lg" />')).toBe('<div />')
})
it('does not touch text outside className', () => {
const src = '<p>The corners are rounded and bg-white is a word.</p>'
expect(t(src)).toBe(src)
})
it('is idempotent', () => {
const once = t('<div className="rounded-xl bg-white border-gray-200 shadow-2xl" />')
expect(t(once)).toBe(once)
})
})
+12
View File
@@ -0,0 +1,12 @@
id,incident_id,root_cause_ref,description,owner_user_id,department,due_date,priority,status,completed_at,verified_by,verified_at,effectiveness_recheck_date,created_at,effectiveness_recheck_round,owner_notes
ebea1a0b-012d-4020-bedd-0fdd96964f8b,0f81a575-7fd8-4d3a-9686-15bcd0b5f0b6,poor handling,Safety Briefing,2fc47d6f-9123-4b43-8e0b-3074d025a21e,,2026-07-21,high,open,null,null,null,null,2026-07-21 11:03:45.751671+00,0,null
aabf7638-aa54-4093-a463-8ca9c02f6b6d,5e1c7d85-9988-48c8-8526-e971cd160ac5,unfit to work,safety briefing,11e15405-6c83-4483-9060-733660f424ad,,2026-07-21,high,closed,2026-07-21 11:31:25.844+00,11e15405-6c83-4483-9060-733660f424ad,2026-07-21 11:34:36.827+00,2026-08-20,2026-07-21 11:21:28.817757+00,0,null
4a48c2f0-6d5b-44a3-b2a0-5765909420ca,0f81a575-7fd8-4d3a-9686-15bcd0b5f0b6,poor handling,"Safety Briefing ",7b873070-9806-423e-b3a1-1817d4a3cc7e,,2026-07-21,high,closed,2026-07-22 12:01:50.802+00,11e15405-6c83-4483-9060-733660f424ad,2026-07-22 14:10:55.578+00,2026-08-21,2026-07-21 11:03:12.019957+00,0,null
8b405b2f-c084-46d4-a43e-46ab5a924dfa,5e1c7d85-9988-48c8-8526-e971cd160ac5,"Minimum supervision from PIC, Unfit to Work","Safety Briefing
MHE Refresher Training",8b4441d7-ef6b-49ea-94b1-28c8bbfb68cf,,2026-07-21,high,closed,2026-07-24 01:26:27.179+00,11e15405-6c83-4483-9060-733660f424ad,2026-07-24 05:06:21.863+00,2026-08-23,2026-07-21 07:58:49.92362+00,0,"Brief by : Safety Department
Date : 23/7/2026
Place: All warehouse except SC 11"
688470a9-8107-4284-a395-ea95ab1bdc7f,5e1c7d85-9988-48c8-8526-e971cd160ac5,"minimum supervision, unfit to work ","safety briefing
MHE Refresher training",11e15405-6c83-4483-9060-733660f424ad,,2026-07-23,high,closed,2026-07-24 05:06:05.654+00,11e15405-6c83-4483-9060-733660f424ad,2026-07-24 05:07:12.8+00,2026-08-23,2026-07-23 03:05:20.92003+00,0,"testing for new system update "
4656183f-722c-427f-82c4-dcb08335d9aa,dee6e6bb-b3a4-4767-8b9f-1dd3626c8f82,insufficient lighting,"inspection whole area to ensure sufficient lighting for worker to do job safely
change or service the spotlight to make sure it is working properly",11e15405-6c83-4483-9060-733660f424ad,,2026-07-24,high,open,null,null,null,null,2026-07-24 05:32:57.094077+00,0,null
1 id incident_id root_cause_ref description owner_user_id department due_date priority status completed_at verified_by verified_at effectiveness_recheck_date created_at effectiveness_recheck_round owner_notes
2 ebea1a0b-012d-4020-bedd-0fdd96964f8b 0f81a575-7fd8-4d3a-9686-15bcd0b5f0b6 poor handling Safety Briefing 2fc47d6f-9123-4b43-8e0b-3074d025a21e 2026-07-21 high open null null null null 2026-07-21 11:03:45.751671+00 0 null
3 aabf7638-aa54-4093-a463-8ca9c02f6b6d 5e1c7d85-9988-48c8-8526-e971cd160ac5 unfit to work safety briefing 11e15405-6c83-4483-9060-733660f424ad 2026-07-21 high closed 2026-07-21 11:31:25.844+00 11e15405-6c83-4483-9060-733660f424ad 2026-07-21 11:34:36.827+00 2026-08-20 2026-07-21 11:21:28.817757+00 0 null
4 4a48c2f0-6d5b-44a3-b2a0-5765909420ca 0f81a575-7fd8-4d3a-9686-15bcd0b5f0b6 poor handling Safety Briefing 7b873070-9806-423e-b3a1-1817d4a3cc7e 2026-07-21 high closed 2026-07-22 12:01:50.802+00 11e15405-6c83-4483-9060-733660f424ad 2026-07-22 14:10:55.578+00 2026-08-21 2026-07-21 11:03:12.019957+00 0 null
5 8b405b2f-c084-46d4-a43e-46ab5a924dfa 5e1c7d85-9988-48c8-8526-e971cd160ac5 Minimum supervision from PIC, Unfit to Work Safety Briefing MHE Refresher Training 8b4441d7-ef6b-49ea-94b1-28c8bbfb68cf 2026-07-21 high closed 2026-07-24 01:26:27.179+00 11e15405-6c83-4483-9060-733660f424ad 2026-07-24 05:06:21.863+00 2026-08-23 2026-07-21 07:58:49.92362+00 0 Brief by : Safety Department Date : 23/7/2026 Place: All warehouse except SC 11
6 688470a9-8107-4284-a395-ea95ab1bdc7f 5e1c7d85-9988-48c8-8526-e971cd160ac5 minimum supervision, unfit to work safety briefing MHE Refresher training 11e15405-6c83-4483-9060-733660f424ad 2026-07-23 high closed 2026-07-24 05:06:05.654+00 11e15405-6c83-4483-9060-733660f424ad 2026-07-24 05:07:12.8+00 2026-08-23 2026-07-23 03:05:20.92003+00 0 testing for new system update
7 4656183f-722c-427f-82c4-dcb08335d9aa dee6e6bb-b3a4-4767-8b9f-1dd3626c8f82 insufficient lighting inspection whole area to ensure sufficient lighting for worker to do job safely change or service the spotlight to make sure it is working properly 11e15405-6c83-4483-9060-733660f424ad 2026-07-24 high open null null null null 2026-07-24 05:32:57.094077+00 0 null
+8
View File
@@ -0,0 +1,8 @@
id,reference_no,incident_type,site_id,zone_id,reported_by,reported_at,description,severity,status,injury_involved,asset_involved,medical_status,lost_days,closed_at,created_at,is_fatality,is_serious_bodily_injury,is_dangerous_occurrence,is_occupational_disease,triage_notes,triaged_by,triaged_at,type_details,embedding,truck_id
0f81a575-7fd8-4d3a-9686-15bcd0b5f0b6,SC1-202607-0001,asset_damage,c244ec0a-d713-4f23-b2c7-cac3f6c2c19a,b5ac1078-4a49-4f9a-8be4-be59bb86824a,11e15405-6c83-4483-9060-733660f424ad,2026-07-14 02:59:33.578421+00,"Pada 6 Jun 2026, lebih kurang 6 petang, 1 forklift telah melanggar 1 kotak TV serial nombor HK0908 dan menyebabkan carton torn. barang dalam tidak mengalami kerosakan dan forklift dalam keadaan baik",1,investigating,false,false,null,null,null,2026-07-14 02:59:33.578421+00,false,false,false,false,"carton torn, this is operator error",11e15405-6c83-4483-9060-733660f424ad,2026-07-14 03:03:27.996+00,"{""equipment_id"":""FL 052""}",null,null
85c44b0b-5b4e-43a1-8e85-b64e8e510b3e,SC3-202607-0001,asset_damage,0c6e5030-be63-4c1b-ba4a-9eb01c2c392d,d352cb7f-dfca-4b6c-b3be-9209566ed74a,11e15405-6c83-4483-9060-733660f424ad,2026-07-14 03:52:41.932775+00,"Pada 2 april 2026, lebih kurang jam 4 petang, Abu terlanggar struktur racking lalu racking roboh. Setakat jam 4.30, sebanyak 3 baris racking roboh , jumlah kerosakan barang pelanggan masih belum dikenalpasti. Abu tidak mengalami sebarang kecederaan",4,investigating,false,true,null,null,null,2026-07-14 03:52:41.932775+00,false,false,true,false,need to secure the incident area immediately,11e15405-6c83-4483-9060-733660f424ad,2026-07-14 03:55:21.047+00,"{""equipment_id"":""RT A23"",""loto_applied"":true}",null,null
58e40574-738a-42ca-8478-1999963b2117,SC3-202607-0002,asset_damage,0c6e5030-be63-4c1b-ba4a-9eb01c2c392d,d352cb7f-dfca-4b6c-b3be-9209566ed74a,11e15405-6c83-4483-9060-733660f424ad,2026-07-14 07:45:56.883487+00,"2nd June 2026, 10.00 p.m, @Racking BA 320501 - Racking was collapsed due to a hit by RT (Ali, PIS123) during the picking tasks. By the time of PIC's arrival (Abu), 2 racking identified damaged and collapsed. No injury involved, however the cost of the goods damaged unidentified yet.",3,investigating,false,true,null,null,null,2026-07-14 07:45:56.883487+00,false,false,true,false,HSE arrived at the scene. Immediately clear the area for safety purpose,11e15405-6c83-4483-9060-733660f424ad,2026-07-14 07:47:25.267+00,"{""equipment_id"":""RT - A23""}",null,null
2abb27a1-f541-47de-8dd2-22d2a7902dc6,SC9-202607-0001,injury,f326a6ca-5b3c-4ea6-b1e5-8f73a5c3e54f,c921179e-0055-4c2c-be6d-80a48a8c89c2,11e15405-6c83-4483-9060-733660f424ad,2026-07-14 09:24:15.649656+00,"AT 08:00AM, A staff member called ALI ( ID : SGH888 ) has been injured by stepping on pallet nail on his left foot during picking at location AN at SC09. There weren't any damage for the pallet. We has been sent to nearest clinic for further medication",2,investigating,true,false,first_aid,null,null,2026-07-14 09:24:15.649656+00,false,false,false,false,"got mc for one day ",11e15405-6c83-4483-9060-733660f424ad,2026-07-14 09:25:44.752+00,null,null,null
bcc0f0a3-aa34-4152-b2e4-5a67d5720403,SC5-202607-0001,injury,3419dfd1-f705-4be4-8d63-9cde3b95c62e,02dbe610-5252-4f7d-bfa7-cf5255c9ce1f,11e15405-6c83-4483-9060-733660f424ad,2026-07-14 05:42:02.469274+00,"Pada 3 jun 2026, jam 4 petang, pemandu forklift terlanggar seorang pekerja dibahagian sisi badan kiri semasa menjalankan kerja unloading barang dari dalam kontena. pekerja yang dilanggar mengadu sakit bahagian badan kiri, PIC segera membawa pekerja tersebut ke hospital berdekatan. Operator forklift tersebut melarikan diri kerana khuatir dengan kejadian tersebut.",3,triaged,true,false,medical_treatment,null,null,2026-07-14 05:42:02.469274+00,false,false,false,false,null,11e15405-6c83-4483-9060-733660f424ad,2026-07-17 02:26:56.032+00,null,null,null
5e1c7d85-9988-48c8-8526-e971cd160ac5,SC1-202607-0002,asset_damage,c244ec0a-d713-4f23-b2c7-cac3f6c2c19a,b5ac1078-4a49-4f9a-8be4-be59bb86824a,11e15405-6c83-4483-9060-733660f424ad,2026-07-16 01:30:49.228419+00,"pada 2 jun 2026 , ali terlanggar sebuah aircond semasa menjalankan kerja unloading dari kontena ke staging. PIC datang ke tempat kejadian untuk mengawal situasi dengan mengalihkan barang ke tempat selamat dan ali direhatkan dari tugas forklift (MHE)",1,closed,false,true,null,null,2026-07-24 05:14:56.957+00,2026-07-16 01:30:49.228419+00,false,false,false,false,null,11e15405-6c83-4483-9060-733660f424ad,2026-07-16 01:32:37.163+00,"{""equipment_id"":""RT25""}",null,null
dee6e6bb-b3a4-4767-8b9f-1dd3626c8f82,SC3-202607-0003,asset_damage,0c6e5030-be63-4c1b-ba4a-9eb01c2c392d,d352cb7f-dfca-4b6c-b3be-9209566ed74a,11e15405-6c83-4483-9060-733660f424ad,2026-07-15 08:50:59.724576+00,"on 2 jun 2026, 10pm, ali hit racking then toppled. 2 item fall down during the time. PIC immediately comes to secure the scene.",4,investigating,false,true,null,null,null,2026-07-15 08:50:59.724576+00,false,false,false,false,"consider as high risk since involved structure ",11e15405-6c83-4483-9060-733660f424ad,2026-07-15 08:55:12.418+00,"{""equipment_id"":""RT 23"",""loto_applied"":true}",null,null
1 id reference_no incident_type site_id zone_id reported_by reported_at description severity status injury_involved asset_involved medical_status lost_days closed_at created_at is_fatality is_serious_bodily_injury is_dangerous_occurrence is_occupational_disease triage_notes triaged_by triaged_at type_details embedding truck_id
2 0f81a575-7fd8-4d3a-9686-15bcd0b5f0b6 SC1-202607-0001 asset_damage c244ec0a-d713-4f23-b2c7-cac3f6c2c19a b5ac1078-4a49-4f9a-8be4-be59bb86824a 11e15405-6c83-4483-9060-733660f424ad 2026-07-14 02:59:33.578421+00 Pada 6 Jun 2026, lebih kurang 6 petang, 1 forklift telah melanggar 1 kotak TV serial nombor HK0908 dan menyebabkan carton torn. barang dalam tidak mengalami kerosakan dan forklift dalam keadaan baik 1 investigating false false null null null 2026-07-14 02:59:33.578421+00 false false false false carton torn, this is operator error 11e15405-6c83-4483-9060-733660f424ad 2026-07-14 03:03:27.996+00 {"equipment_id":"FL 052"} null null
3 85c44b0b-5b4e-43a1-8e85-b64e8e510b3e SC3-202607-0001 asset_damage 0c6e5030-be63-4c1b-ba4a-9eb01c2c392d d352cb7f-dfca-4b6c-b3be-9209566ed74a 11e15405-6c83-4483-9060-733660f424ad 2026-07-14 03:52:41.932775+00 Pada 2 april 2026, lebih kurang jam 4 petang, Abu terlanggar struktur racking lalu racking roboh. Setakat jam 4.30, sebanyak 3 baris racking roboh , jumlah kerosakan barang pelanggan masih belum dikenalpasti. Abu tidak mengalami sebarang kecederaan 4 investigating false true null null null 2026-07-14 03:52:41.932775+00 false false true false need to secure the incident area immediately 11e15405-6c83-4483-9060-733660f424ad 2026-07-14 03:55:21.047+00 {"equipment_id":"RT A23","loto_applied":true} null null
4 58e40574-738a-42ca-8478-1999963b2117 SC3-202607-0002 asset_damage 0c6e5030-be63-4c1b-ba4a-9eb01c2c392d d352cb7f-dfca-4b6c-b3be-9209566ed74a 11e15405-6c83-4483-9060-733660f424ad 2026-07-14 07:45:56.883487+00 2nd June 2026, 10.00 p.m, @Racking BA 320501 - Racking was collapsed due to a hit by RT (Ali, PIS123) during the picking tasks. By the time of PIC's arrival (Abu), 2 racking identified damaged and collapsed. No injury involved, however the cost of the goods damaged unidentified yet. 3 investigating false true null null null 2026-07-14 07:45:56.883487+00 false false true false HSE arrived at the scene. Immediately clear the area for safety purpose 11e15405-6c83-4483-9060-733660f424ad 2026-07-14 07:47:25.267+00 {"equipment_id":"RT - A23"} null null
5 2abb27a1-f541-47de-8dd2-22d2a7902dc6 SC9-202607-0001 injury f326a6ca-5b3c-4ea6-b1e5-8f73a5c3e54f c921179e-0055-4c2c-be6d-80a48a8c89c2 11e15405-6c83-4483-9060-733660f424ad 2026-07-14 09:24:15.649656+00 AT 08:00AM, A staff member called ALI ( ID : SGH888 ) has been injured by stepping on pallet nail on his left foot during picking at location AN at SC09. There weren't any damage for the pallet. We has been sent to nearest clinic for further medication 2 investigating true false first_aid null null 2026-07-14 09:24:15.649656+00 false false false false got mc for one day 11e15405-6c83-4483-9060-733660f424ad 2026-07-14 09:25:44.752+00 null null null
6 bcc0f0a3-aa34-4152-b2e4-5a67d5720403 SC5-202607-0001 injury 3419dfd1-f705-4be4-8d63-9cde3b95c62e 02dbe610-5252-4f7d-bfa7-cf5255c9ce1f 11e15405-6c83-4483-9060-733660f424ad 2026-07-14 05:42:02.469274+00 Pada 3 jun 2026, jam 4 petang, pemandu forklift terlanggar seorang pekerja dibahagian sisi badan kiri semasa menjalankan kerja unloading barang dari dalam kontena. pekerja yang dilanggar mengadu sakit bahagian badan kiri, PIC segera membawa pekerja tersebut ke hospital berdekatan. Operator forklift tersebut melarikan diri kerana khuatir dengan kejadian tersebut. 3 triaged true false medical_treatment null null 2026-07-14 05:42:02.469274+00 false false false false null 11e15405-6c83-4483-9060-733660f424ad 2026-07-17 02:26:56.032+00 null null null
7 5e1c7d85-9988-48c8-8526-e971cd160ac5 SC1-202607-0002 asset_damage c244ec0a-d713-4f23-b2c7-cac3f6c2c19a b5ac1078-4a49-4f9a-8be4-be59bb86824a 11e15405-6c83-4483-9060-733660f424ad 2026-07-16 01:30:49.228419+00 pada 2 jun 2026 , ali terlanggar sebuah aircond semasa menjalankan kerja unloading dari kontena ke staging. PIC datang ke tempat kejadian untuk mengawal situasi dengan mengalihkan barang ke tempat selamat dan ali direhatkan dari tugas forklift (MHE) 1 closed false true null null 2026-07-24 05:14:56.957+00 2026-07-16 01:30:49.228419+00 false false false false null 11e15405-6c83-4483-9060-733660f424ad 2026-07-16 01:32:37.163+00 {"equipment_id":"RT25"} null null
8 dee6e6bb-b3a4-4767-8b9f-1dd3626c8f82 SC3-202607-0003 asset_damage 0c6e5030-be63-4c1b-ba4a-9eb01c2c392d d352cb7f-dfca-4b6c-b3be-9209566ed74a 11e15405-6c83-4483-9060-733660f424ad 2026-07-15 08:50:59.724576+00 on 2 jun 2026, 10pm, ali hit racking then toppled. 2 item fall down during the time. PIC immediately comes to secure the scene. 4 investigating false true null null null 2026-07-15 08:50:59.724576+00 false false false false consider as high risk since involved structure 11e15405-6c83-4483-9060-733660f424ad 2026-07-15 08:55:12.418+00 {"equipment_id":"RT 23","loto_applied":true} null null
+17
View File
@@ -0,0 +1,17 @@
id,incident_id,investigator_id,method,findings_text,root_cause_summary,alcohol_test_result,witness_statement_refs,completed_at,created_at,five_why_steps,fishbone_categories,urine_test_result
3883b700-f992-4f4f-a256-1b86934f32c5,0f81a575-7fd8-4d3a-9686-15bcd0b5f0b6,11e15405-6c83-4483-9060-733660f424ad,five_why,"1. 1. Implement mandatory quarterly forklift operator refresher training covering spatial awareness, load clearance, and zone discipline, with a practical assessment sign-off for each operator.
2. 2. Conduct a 5S+Safety audit across the OPS zone: install yellow/red floor marking tapes or painted lines to define minimum clearance zones around high-value/itemised stock (e.g., TV boxes), and erect protective barriers or bollards in high-risk stacking areas.
3. 3. Establish a formal near-miss and minor-damage reporting system (e.g., a simple WhatsApp-based or paper log) with a monthly review by the site supervisor to identify recurring patterns and trigger preventive actions before a more serious incident occurs.","The absence of a systematic HSE continuous improvement process—including regular operator refresher training, updated 5S/warehouse layout standards with clearance markings, and a near-miss reporting feedback loop—allowed an untrained behaviour (poor clearance judgment) to go uncorrected, resulting in a preventable collision with high-value goods.",negative,"[""Ali bin Abu - forklift driver - SGH . Dia mengaku bersalah kerana tidak nampak kotak tersebut semasa reverse untuk meletakkan barang yang unloading dari kontena ke staging inbound area""]",null,2026-07-14 03:14:59.037478+00,"[{""why"":""Why did the forklift collide with the TV box, causing a carton tear?"",""answer"":""The forklift operator misjudged the clearance distance while maneuvering near the TV box, causing the forklift tines or body to make contact with the carton.""},{""why"":""Why did the operator misjudge the clearance distance?"",""answer"":""The operator was not following proper spotting or lookout procedures, and the aisle/stacking area had no physical guides or marked safety zones to indicate minimum clearance from stored goods.""},{""why"":""Why were there no physical guides or marked safety zones for clearance?"",""answer"":""The warehouse layout did not include floor markings, barrier rails, or visual indicators for safe maneuvering distances in that specific stacking area, and there was no standardised process for auditing storage layout compliance.""},{""why"":""Why was the warehouse layout lacking proper markings and the operator not following safe procedures?"",""answer"":""There was no regular refresher training program for forklift operators focused on spatial awareness and zone discipline, and the facility's housekeeping and 5S standards had not been updated to include clearance safety requirements for high-value items.""},{""why"":""Why was there no refresher training and why were 5S standards not updated?"",""answer"":""Management had not prioritised periodic operator competency assessments or layout safety audits due to high operational pressure and a lack of a dedicated HSE feedback loop to capture near-misses and minor asset damage incidents for continuous improvement.""}]",null,null
47c322c2-1911-4b6d-a263-fb91b9ab0a62,85c44b0b-5b4e-43a1-8e85-b64e8e510b3e,11e15405-6c83-4483-9060-733660f424ad,five_why,"1. 1. Implement a Management of Change (MOC) procedure requiring HSE & Operations sign-off for any racking layout, stock density, or aisle width changes, including a mandatory racking zone risk assessment update before the change is approved.
2. 2. Install physical and tech-based controls in all MHE operating in racking zones: fit speed limiters/geo-fencing on all forklifts and reach trucks to cap speed at 5 km/h within 1 meter of any racking upright, plus install blue-spot safety lights and audible reverse alarms on all units.
3. 3. Conduct a compulsory refresher retraining for all MHE operators on safe racking aisle maneuvering, approved clearances, speed discipline, and the consequences of racking impact, with a hands-on practical assessment and sign-off by a certified trainer.","The root cause was the absence of a formal management-of-change (MOC) process for warehouse layout modifications, combined with inadequate MHE safety controls (speed limiters, alarms, clear signage) and insufficient operator awareness of safe maneuvering speeds in racking aisles, leading to a high-speed impact that caused a progressive racking collapse.",positive,"[""semasa disoal siasat, Abu berada dalam keadaan mabuk ( mata merah, berbau arak dan tidak boleh berdiri dengan betul ). DIa mengaku dia telah minum minuman keras sebelum datang kerja kerana ajakan rakannya.""]",null,2026-07-14 03:58:34.001168+00,"[{""why"":""Why did Abu hit the racking structure, causing it to collapse?"",""answer"":""Abu was operating a forklift (or reach truck) and misjudged the clearance while maneuvering in the racking aisle, making direct contact with the upright of the racking system.""},{""why"":""Why did Abu misjudge the clearance while maneuvering in the racking aisle?"",""answer"":""Abu may have been driving too fast for the aisle conditions, was distracted, or the racking aisle was narrower than required for the type of material handling equipment (MHE) being used.""},{""why"":""Why was Abu driving too fast or distracted, and why was the aisle clearance inadequate?"",""answer"":""There was no effective speed governor or geo-fencing system on the forklift, no clear signage indicating speed limits in racking zones, and operators are under pressure to meet tight operational KPIs (picking/put-away targets). Additionally, racking aisle width and layout were not reassessed after recent warehouse layout changes or stock density increases.""},{""why"":""Why was there no effective speed control, signage, or layout reassessment in place?"",""answer"":""The warehouse operations team had not conducted a recent risk assessment for the racking zone after layout changes, and MHE safety features (speed limiters, alarms, or aisle clearance markers) were not included in the preventive maintenance or safety inspection schedule.""},{""why"":""Why was the risk assessment not updated and MHE safety features not inspected regularly?"",""answer"":""There was no formal procedure requiring re-assessment of racking zone risks after layout or inventory density changes, and the HSE team was not notified of the modifications. Additionally, the MHE preventive maintenance checklist did not include verification of speed limiters or geo-fencing functionality.""}]",null,null
deb1c4f0-cf3c-4847-9718-c9748662f0a4,58e40574-738a-42ca-8478-1999963b2117,11e15405-6c83-4483-9060-733660f424ad,five_why,"Sleepy during that time due to take medicine before work start. ","operator negligence and unfit to work
PIC didnt supervisor his properly during briefing before work start",positive,"[""Ali - RT driver - PIS. He confess he was sleepy during that time. He didnt realize during that time he suddenly microsleep""]",null,2026-07-14 07:56:27.256602+00,[],null,null
64bc48a6-e6aa-4dad-ab9a-91c73bfaabad,2abb27a1-f541-47de-8dd2-22d2a7902dc6,11e15405-6c83-4483-9060-733660f424ad,five_why,"1. 1. Implement a Pre-Staging Pallet Inspection SOP: Mandate that all pallets entering the staging area must undergo a visual and tactile inspection (check for protruding nails, broken boards, and splinters) by the receiving or staging team before being released for picking. Use a simple checklist and colour-coded tags (green = safe, red = reject). Assign ownership to the Staging Team Leader.
2. 2. Introduce mandatory PPE reinforcement & provide puncture-resistant safety shoes: Reinforce the PPE policy requiring all warehouse staff to wear approved safety shoes with steel-toe caps and puncture-resistant soles. Conduct a toolbox talk within 48 hours. Consider procuring and subsidising appropriate safety footwear for all picking and staging staff.
3. 3. Establish a Hazard Identification and Near-Miss Reporting System: Roll out a simple digital or paper-based hazard reporting form (e.g., via WhatsApp group or notice board) for workers to report damaged pallets, protruding nails, or near-miss incidents. Ensure management reviews reports weekly and assigns corrective actions within 24 hours. Include this in the monthly HSE committee meeting agenda.","The absence of a formal pallet inspection SOP and lack of assigned ownership for pallet condition checks, driven by insufficient management priority on preventive safety controls and an inadequate hazard identification process, allowed a damaged pallet with a protruding nail to be staged in the picking area, resulting in a preventable foot injury to a worker.",null,[],null,2026-07-14 09:27:59.492206+00,"[{""why"":""Why did Ali step on a pallet nail and injure his left foot?"",""answer"":""Because a nail was protruding from a pallet located in the staging area at location AN, and Ali stepped on it while walking through the area during his picking task.""},{""why"":""Why was there a protruding nail on the pallet in the staging area?"",""answer"":""Because the pallet was not inspected or maintained before being placed in the staging area, and there is no routine pallet integrity check process before pallets are staged for picking operations.""},{""why"":""Why was there no routine pallet inspection process before staging pallets?"",""answer"":""Because the warehouse does not have a formal Pre-Staging Pallet Inspection Standard Operating Procedure (SOP), and the responsibility for checking pallet condition is not clearly assigned to any team or individual.""},{""why"":""Why is there no formal pallet inspection SOP or clear ownership for pallet condition checks?"",""answer"":""Because management has not prioritised pallet maintenance and inspection as a critical safety control, and existing resources are focused primarily on productivity metrics rather than preventive safety measures.""},{""why"":""Why has management not prioritised pallet inspection as a critical safety control despite the known risk of nail injuries?"",""answer"":""Because there is no systematic hazard identification and risk assessment (HIRARC) process that specifically addresses pallet-related foot injury hazards, and past near-misses or minor injuries were not formally reported or escalated to drive corrective action.""}]",null,null
71da7df7-110b-475e-a08a-8c1716ac7351,5e1c7d85-9988-48c8-8526-e971cd160ac5,11e15405-6c83-4483-9060-733660f424ad,five_why,"1. Conduct a HIRARC (Hazard Identification, Risk Assessment & Risk Control) for all MHE-operating zones including container unloading areas, with specific focus on fixed asset collision hazards, and implement identified controls such as physical barriers (e.g., bollards or guardrails) around fixed assets within 2 metres of MHE pathways.
2. Develop a Warehouse Layout Standard (based on MS 1722 or DOSH guidelines) that defines minimum clearances for MHE operations, designated MHE travel lanes, and exclusion zones around building infrastructure (columns, air conditioners, electrical panels). Mark these zones with high-visibility floor tape and signage.
3. Implement a pre-operation 'walk-around' inspection checklist for forklift operators that includes verification of clear path and awareness of fixed assets in the work area, and reinforce through weekly toolbox talks and a refresher training on safe MHE manoeuvring and spatial awareness.","The root cause is the absence of a systematic risk assessment and layout review process for the container unloading zone, leading to unprotected fixed assets (air conditioner) placed within the MHE operating envelope without physical barriers or designated exclusion zones.",positive,"[""ali mengaku dia telah ambil ubat batuk sebelum kerja menyebabkan dia mengantuk semasa bertugas""]",null,2026-07-16 01:35:43.588893+00,"[{""why"":""Why did Ali hit the air conditioner while unloading from the container to the staging area?"",""answer"":""Ali lost control or misjudged the distance while manoeuvring the forklift, causing it to collide with the air conditioning unit located near the unloading bay.""},{""why"":""Why did Ali lose control or misjudge the distance?"",""answer"":""The staging area near the container unloading bay had limited clearance, and the air conditioner was positioned within the forklift's operating zone without adequate physical barriers or markings.""},{""why"":""Why was the air conditioner placed in a location with limited clearance and no barriers?"",""answer"":""There was no designated exclusion zone or protective guarding for fixed assets (e.g., air conditioners) in the unloading area, and the layout did not account for forklift turning radius and load overhang.""},{""why"":""Why was there no designated exclusion zone or protective guarding for fixed assets in the unloading area?"",""answer"":""A formal risk assessment (HIRARC) had not been conducted for the container unloading zone to identify fixed asset collision hazards, and there was no standard layout plan defining safe distances between MHE pathways and building infrastructure.""},{""why"":""Why was the HIRARC for the unloading zone not conducted or updated?"",""answer"":""The site's asset protection programme did not include periodic workplace layout reviews for MHE operations, and there was no systematic process to identify and protect fixed assets in high-traffic operational zones.""}]",null,null
65035159-24d4-4081-a8da-80ffb6727816,dee6e6bb-b3a4-4767-8b9f-1dd3626c8f82,11e15405-6c83-4483-9060-733660f424ad,five_why,"- insufficient lighting
- limited sight due to higher level",the main issue due to broken spotlight was not handled before starting the job on that area makes the area was not safe to work,negative,"[""ali said he cant see the area clearly due to insufficient lighting on that area. He already raise up the issues to PIC, but no corrective action was taken. Plus, the item was on level 5, which make it harder for him to see clearly without sufficient lighting on higher level""]",null,2026-07-24 05:29:59.060352+00,"[{""why"":""Why did the incident happen?"",""answer"":""ali cant see clearly on level 5\n""},{""why"":""why ali cant see clearly on level 5 ?"",""answer"":""because the racking area was dark ""},{""why"":""why the racking area was dark ?"",""answer"":""due to the insufficient lighting in that area""},{""why"":""why insufficient lighting in that area?"",""answer"":""due to few spotlight was not functioning""}]",null,negative
1 id incident_id investigator_id method findings_text root_cause_summary alcohol_test_result witness_statement_refs completed_at created_at five_why_steps fishbone_categories urine_test_result
2 3883b700-f992-4f4f-a256-1b86934f32c5 0f81a575-7fd8-4d3a-9686-15bcd0b5f0b6 11e15405-6c83-4483-9060-733660f424ad five_why 1. 1. Implement mandatory quarterly forklift operator refresher training covering spatial awareness, load clearance, and zone discipline, with a practical assessment sign-off for each operator. 2. 2. Conduct a 5S+Safety audit across the OPS zone: install yellow/red floor marking tapes or painted lines to define minimum clearance zones around high-value/itemised stock (e.g., TV boxes), and erect protective barriers or bollards in high-risk stacking areas. 3. 3. Establish a formal near-miss and minor-damage reporting system (e.g., a simple WhatsApp-based or paper log) with a monthly review by the site supervisor to identify recurring patterns and trigger preventive actions before a more serious incident occurs. The absence of a systematic HSE continuous improvement process—including regular operator refresher training, updated 5S/warehouse layout standards with clearance markings, and a near-miss reporting feedback loop—allowed an untrained behaviour (poor clearance judgment) to go uncorrected, resulting in a preventable collision with high-value goods. negative ["Ali bin Abu - forklift driver - SGH . Dia mengaku bersalah kerana tidak nampak kotak tersebut semasa reverse untuk meletakkan barang yang unloading dari kontena ke staging inbound area"] null 2026-07-14 03:14:59.037478+00 [{"why":"Why did the forklift collide with the TV box, causing a carton tear?","answer":"The forklift operator misjudged the clearance distance while maneuvering near the TV box, causing the forklift tines or body to make contact with the carton."},{"why":"Why did the operator misjudge the clearance distance?","answer":"The operator was not following proper spotting or lookout procedures, and the aisle/stacking area had no physical guides or marked safety zones to indicate minimum clearance from stored goods."},{"why":"Why were there no physical guides or marked safety zones for clearance?","answer":"The warehouse layout did not include floor markings, barrier rails, or visual indicators for safe maneuvering distances in that specific stacking area, and there was no standardised process for auditing storage layout compliance."},{"why":"Why was the warehouse layout lacking proper markings and the operator not following safe procedures?","answer":"There was no regular refresher training program for forklift operators focused on spatial awareness and zone discipline, and the facility's housekeeping and 5S standards had not been updated to include clearance safety requirements for high-value items."},{"why":"Why was there no refresher training and why were 5S standards not updated?","answer":"Management had not prioritised periodic operator competency assessments or layout safety audits due to high operational pressure and a lack of a dedicated HSE feedback loop to capture near-misses and minor asset damage incidents for continuous improvement."}] null null
3 47c322c2-1911-4b6d-a263-fb91b9ab0a62 85c44b0b-5b4e-43a1-8e85-b64e8e510b3e 11e15405-6c83-4483-9060-733660f424ad five_why 1. 1. Implement a Management of Change (MOC) procedure requiring HSE & Operations sign-off for any racking layout, stock density, or aisle width changes, including a mandatory racking zone risk assessment update before the change is approved. 2. 2. Install physical and tech-based controls in all MHE operating in racking zones: fit speed limiters/geo-fencing on all forklifts and reach trucks to cap speed at 5 km/h within 1 meter of any racking upright, plus install blue-spot safety lights and audible reverse alarms on all units. 3. 3. Conduct a compulsory refresher retraining for all MHE operators on safe racking aisle maneuvering, approved clearances, speed discipline, and the consequences of racking impact, with a hands-on practical assessment and sign-off by a certified trainer. The root cause was the absence of a formal management-of-change (MOC) process for warehouse layout modifications, combined with inadequate MHE safety controls (speed limiters, alarms, clear signage) and insufficient operator awareness of safe maneuvering speeds in racking aisles, leading to a high-speed impact that caused a progressive racking collapse. positive ["semasa disoal siasat, Abu berada dalam keadaan mabuk ( mata merah, berbau arak dan tidak boleh berdiri dengan betul ). DIa mengaku dia telah minum minuman keras sebelum datang kerja kerana ajakan rakannya."] null 2026-07-14 03:58:34.001168+00 [{"why":"Why did Abu hit the racking structure, causing it to collapse?","answer":"Abu was operating a forklift (or reach truck) and misjudged the clearance while maneuvering in the racking aisle, making direct contact with the upright of the racking system."},{"why":"Why did Abu misjudge the clearance while maneuvering in the racking aisle?","answer":"Abu may have been driving too fast for the aisle conditions, was distracted, or the racking aisle was narrower than required for the type of material handling equipment (MHE) being used."},{"why":"Why was Abu driving too fast or distracted, and why was the aisle clearance inadequate?","answer":"There was no effective speed governor or geo-fencing system on the forklift, no clear signage indicating speed limits in racking zones, and operators are under pressure to meet tight operational KPIs (picking/put-away targets). Additionally, racking aisle width and layout were not reassessed after recent warehouse layout changes or stock density increases."},{"why":"Why was there no effective speed control, signage, or layout reassessment in place?","answer":"The warehouse operations team had not conducted a recent risk assessment for the racking zone after layout changes, and MHE safety features (speed limiters, alarms, or aisle clearance markers) were not included in the preventive maintenance or safety inspection schedule."},{"why":"Why was the risk assessment not updated and MHE safety features not inspected regularly?","answer":"There was no formal procedure requiring re-assessment of racking zone risks after layout or inventory density changes, and the HSE team was not notified of the modifications. Additionally, the MHE preventive maintenance checklist did not include verification of speed limiters or geo-fencing functionality."}] null null
4 deb1c4f0-cf3c-4847-9718-c9748662f0a4 58e40574-738a-42ca-8478-1999963b2117 11e15405-6c83-4483-9060-733660f424ad five_why Sleepy during that time due to take medicine before work start. operator negligence and unfit to work PIC didnt supervisor his properly during briefing before work start positive ["Ali - RT driver - PIS. He confess he was sleepy during that time. He didnt realize during that time he suddenly microsleep"] null 2026-07-14 07:56:27.256602+00 [] null null
5 64bc48a6-e6aa-4dad-ab9a-91c73bfaabad 2abb27a1-f541-47de-8dd2-22d2a7902dc6 11e15405-6c83-4483-9060-733660f424ad five_why 1. 1. Implement a Pre-Staging Pallet Inspection SOP: Mandate that all pallets entering the staging area must undergo a visual and tactile inspection (check for protruding nails, broken boards, and splinters) by the receiving or staging team before being released for picking. Use a simple checklist and colour-coded tags (green = safe, red = reject). Assign ownership to the Staging Team Leader. 2. 2. Introduce mandatory PPE reinforcement & provide puncture-resistant safety shoes: Reinforce the PPE policy requiring all warehouse staff to wear approved safety shoes with steel-toe caps and puncture-resistant soles. Conduct a toolbox talk within 48 hours. Consider procuring and subsidising appropriate safety footwear for all picking and staging staff. 3. 3. Establish a Hazard Identification and Near-Miss Reporting System: Roll out a simple digital or paper-based hazard reporting form (e.g., via WhatsApp group or notice board) for workers to report damaged pallets, protruding nails, or near-miss incidents. Ensure management reviews reports weekly and assigns corrective actions within 24 hours. Include this in the monthly HSE committee meeting agenda. The absence of a formal pallet inspection SOP and lack of assigned ownership for pallet condition checks, driven by insufficient management priority on preventive safety controls and an inadequate hazard identification process, allowed a damaged pallet with a protruding nail to be staged in the picking area, resulting in a preventable foot injury to a worker. null [] null 2026-07-14 09:27:59.492206+00 [{"why":"Why did Ali step on a pallet nail and injure his left foot?","answer":"Because a nail was protruding from a pallet located in the staging area at location AN, and Ali stepped on it while walking through the area during his picking task."},{"why":"Why was there a protruding nail on the pallet in the staging area?","answer":"Because the pallet was not inspected or maintained before being placed in the staging area, and there is no routine pallet integrity check process before pallets are staged for picking operations."},{"why":"Why was there no routine pallet inspection process before staging pallets?","answer":"Because the warehouse does not have a formal Pre-Staging Pallet Inspection Standard Operating Procedure (SOP), and the responsibility for checking pallet condition is not clearly assigned to any team or individual."},{"why":"Why is there no formal pallet inspection SOP or clear ownership for pallet condition checks?","answer":"Because management has not prioritised pallet maintenance and inspection as a critical safety control, and existing resources are focused primarily on productivity metrics rather than preventive safety measures."},{"why":"Why has management not prioritised pallet inspection as a critical safety control despite the known risk of nail injuries?","answer":"Because there is no systematic hazard identification and risk assessment (HIRARC) process that specifically addresses pallet-related foot injury hazards, and past near-misses or minor injuries were not formally reported or escalated to drive corrective action."}] null null
6 71da7df7-110b-475e-a08a-8c1716ac7351 5e1c7d85-9988-48c8-8526-e971cd160ac5 11e15405-6c83-4483-9060-733660f424ad five_why 1. Conduct a HIRARC (Hazard Identification, Risk Assessment & Risk Control) for all MHE-operating zones including container unloading areas, with specific focus on fixed asset collision hazards, and implement identified controls such as physical barriers (e.g., bollards or guardrails) around fixed assets within 2 metres of MHE pathways. 2. Develop a Warehouse Layout Standard (based on MS 1722 or DOSH guidelines) that defines minimum clearances for MHE operations, designated MHE travel lanes, and exclusion zones around building infrastructure (columns, air conditioners, electrical panels). Mark these zones with high-visibility floor tape and signage. 3. Implement a pre-operation 'walk-around' inspection checklist for forklift operators that includes verification of clear path and awareness of fixed assets in the work area, and reinforce through weekly toolbox talks and a refresher training on safe MHE manoeuvring and spatial awareness. The root cause is the absence of a systematic risk assessment and layout review process for the container unloading zone, leading to unprotected fixed assets (air conditioner) placed within the MHE operating envelope without physical barriers or designated exclusion zones. positive ["ali mengaku dia telah ambil ubat batuk sebelum kerja menyebabkan dia mengantuk semasa bertugas"] null 2026-07-16 01:35:43.588893+00 [{"why":"Why did Ali hit the air conditioner while unloading from the container to the staging area?","answer":"Ali lost control or misjudged the distance while manoeuvring the forklift, causing it to collide with the air conditioning unit located near the unloading bay."},{"why":"Why did Ali lose control or misjudge the distance?","answer":"The staging area near the container unloading bay had limited clearance, and the air conditioner was positioned within the forklift's operating zone without adequate physical barriers or markings."},{"why":"Why was the air conditioner placed in a location with limited clearance and no barriers?","answer":"There was no designated exclusion zone or protective guarding for fixed assets (e.g., air conditioners) in the unloading area, and the layout did not account for forklift turning radius and load overhang."},{"why":"Why was there no designated exclusion zone or protective guarding for fixed assets in the unloading area?","answer":"A formal risk assessment (HIRARC) had not been conducted for the container unloading zone to identify fixed asset collision hazards, and there was no standard layout plan defining safe distances between MHE pathways and building infrastructure."},{"why":"Why was the HIRARC for the unloading zone not conducted or updated?","answer":"The site's asset protection programme did not include periodic workplace layout reviews for MHE operations, and there was no systematic process to identify and protect fixed assets in high-traffic operational zones."}] null null
7 65035159-24d4-4081-a8da-80ffb6727816 dee6e6bb-b3a4-4767-8b9f-1dd3626c8f82 11e15405-6c83-4483-9060-733660f424ad five_why - insufficient lighting - limited sight due to higher level the main issue due to broken spotlight was not handled before starting the job on that area makes the area was not safe to work negative ["ali said he cant see the area clearly due to insufficient lighting on that area. He already raise up the issues to PIC, but no corrective action was taken. Plus, the item was on level 5, which make it harder for him to see clearly without sufficient lighting on higher level"] null 2026-07-24 05:29:59.060352+00 [{"why":"Why did the incident happen?","answer":"ali cant see clearly on level 5\n"},{"why":"why ali cant see clearly on level 5 ?","answer":"because the racking area was dark "},{"why":"why the racking area was dark ?","answer":"due to the insufficient lighting in that area"},{"why":"why insufficient lighting in that area?","answer":"due to few spotlight was not functioning"}] null negative
+17
View File
@@ -0,0 +1,17 @@
id,incident_id,investigator_id,method,findings_text,root_cause_summary,alcohol_test_result,completed_at,created_at,five_why_steps,fishbone_categories,urine_test_result
3883b700-f992-4f4f-a256-1b86934f32c5,0f81a575-7fd8-4d3a-9686-15bcd0b5f0b6,11e15405-6c83-4483-9060-733660f424ad,five_why,"1. 1. Implement mandatory quarterly forklift operator refresher training covering spatial awareness, load clearance, and zone discipline, with a practical assessment sign-off for each operator.
2. 2. Conduct a 5S+Safety audit across the OPS zone: install yellow/red floor marking tapes or painted lines to define minimum clearance zones around high-value/itemised stock (e.g., TV boxes), and erect protective barriers or bollards in high-risk stacking areas.
3. 3. Establish a formal near-miss and minor-damage reporting system (e.g., a simple WhatsApp-based or paper log) with a monthly review by the site supervisor to identify recurring patterns and trigger preventive actions before a more serious incident occurs.","The absence of a systematic HSE continuous improvement process—including regular operator refresher training, updated 5S/warehouse layout standards with clearance markings, and a near-miss reporting feedback loop—allowed an untrained behaviour (poor clearance judgment) to go uncorrected, resulting in a preventable collision with high-value goods.",negative,null,2026-07-14 03:14:59.037478+00,"[{""why"":""Why did the forklift collide with the TV box, causing a carton tear?"",""answer"":""The forklift operator misjudged the clearance distance while maneuvering near the TV box, causing the forklift tines or body to make contact with the carton.""},{""why"":""Why did the operator misjudge the clearance distance?"",""answer"":""The operator was not following proper spotting or lookout procedures, and the aisle/stacking area had no physical guides or marked safety zones to indicate minimum clearance from stored goods.""},{""why"":""Why were there no physical guides or marked safety zones for clearance?"",""answer"":""The warehouse layout did not include floor markings, barrier rails, or visual indicators for safe maneuvering distances in that specific stacking area, and there was no standardised process for auditing storage layout compliance.""},{""why"":""Why was the warehouse layout lacking proper markings and the operator not following safe procedures?"",""answer"":""There was no regular refresher training program for forklift operators focused on spatial awareness and zone discipline, and the facility's housekeeping and 5S standards had not been updated to include clearance safety requirements for high-value items.""},{""why"":""Why was there no refresher training and why were 5S standards not updated?"",""answer"":""Management had not prioritised periodic operator competency assessments or layout safety audits due to high operational pressure and a lack of a dedicated HSE feedback loop to capture near-misses and minor asset damage incidents for continuous improvement.""}]",null,null
47c322c2-1911-4b6d-a263-fb91b9ab0a62,85c44b0b-5b4e-43a1-8e85-b64e8e510b3e,11e15405-6c83-4483-9060-733660f424ad,five_why,"1. 1. Implement a Management of Change (MOC) procedure requiring HSE & Operations sign-off for any racking layout, stock density, or aisle width changes, including a mandatory racking zone risk assessment update before the change is approved.
2. 2. Install physical and tech-based controls in all MHE operating in racking zones: fit speed limiters/geo-fencing on all forklifts and reach trucks to cap speed at 5 km/h within 1 meter of any racking upright, plus install blue-spot safety lights and audible reverse alarms on all units.
3. 3. Conduct a compulsory refresher retraining for all MHE operators on safe racking aisle maneuvering, approved clearances, speed discipline, and the consequences of racking impact, with a hands-on practical assessment and sign-off by a certified trainer.","The root cause was the absence of a formal management-of-change (MOC) process for warehouse layout modifications, combined with inadequate MHE safety controls (speed limiters, alarms, clear signage) and insufficient operator awareness of safe maneuvering speeds in racking aisles, leading to a high-speed impact that caused a progressive racking collapse.",positive,null,2026-07-14 03:58:34.001168+00,"[{""why"":""Why did Abu hit the racking structure, causing it to collapse?"",""answer"":""Abu was operating a forklift (or reach truck) and misjudged the clearance while maneuvering in the racking aisle, making direct contact with the upright of the racking system.""},{""why"":""Why did Abu misjudge the clearance while maneuvering in the racking aisle?"",""answer"":""Abu may have been driving too fast for the aisle conditions, was distracted, or the racking aisle was narrower than required for the type of material handling equipment (MHE) being used.""},{""why"":""Why was Abu driving too fast or distracted, and why was the aisle clearance inadequate?"",""answer"":""There was no effective speed governor or geo-fencing system on the forklift, no clear signage indicating speed limits in racking zones, and operators are under pressure to meet tight operational KPIs (picking/put-away targets). Additionally, racking aisle width and layout were not reassessed after recent warehouse layout changes or stock density increases.""},{""why"":""Why was there no effective speed control, signage, or layout reassessment in place?"",""answer"":""The warehouse operations team had not conducted a recent risk assessment for the racking zone after layout changes, and MHE safety features (speed limiters, alarms, or aisle clearance markers) were not included in the preventive maintenance or safety inspection schedule.""},{""why"":""Why was the risk assessment not updated and MHE safety features not inspected regularly?"",""answer"":""There was no formal procedure requiring re-assessment of racking zone risks after layout or inventory density changes, and the HSE team was not notified of the modifications. Additionally, the MHE preventive maintenance checklist did not include verification of speed limiters or geo-fencing functionality.""}]",null,null
deb1c4f0-cf3c-4847-9718-c9748662f0a4,58e40574-738a-42ca-8478-1999963b2117,11e15405-6c83-4483-9060-733660f424ad,five_why,Sleepy during that time due to take medicine before work start. ,"operator negligence and unfit to work
PIC didnt supervisor his properly during briefing before work start",positive,null,2026-07-14 07:56:27.256602+00,[],null,null
64bc48a6-e6aa-4dad-ab9a-91c73bfaabad,2abb27a1-f541-47de-8dd2-22d2a7902dc6,11e15405-6c83-4483-9060-733660f424ad,five_why,"1. 1. Implement a Pre-Staging Pallet Inspection SOP: Mandate that all pallets entering the staging area must undergo a visual and tactile inspection (check for protruding nails, broken boards, and splinters) by the receiving or staging team before being released for picking. Use a simple checklist and colour-coded tags (green = safe, red = reject). Assign ownership to the Staging Team Leader.
2. 2. Introduce mandatory PPE reinforcement & provide puncture-resistant safety shoes: Reinforce the PPE policy requiring all warehouse staff to wear approved safety shoes with steel-toe caps and puncture-resistant soles. Conduct a toolbox talk within 48 hours. Consider procuring and subsidising appropriate safety footwear for all picking and staging staff.
3. 3. Establish a Hazard Identification and Near-Miss Reporting System: Roll out a simple digital or paper-based hazard reporting form (e.g., via WhatsApp group or notice board) for workers to report damaged pallets, protruding nails, or near-miss incidents. Ensure management reviews reports weekly and assigns corrective actions within 24 hours. Include this in the monthly HSE committee meeting agenda.","The absence of a formal pallet inspection SOP and lack of assigned ownership for pallet condition checks, driven by insufficient management priority on preventive safety controls and an inadequate hazard identification process, allowed a damaged pallet with a protruding nail to be staged in the picking area, resulting in a preventable foot injury to a worker.",null,null,2026-07-14 09:27:59.492206+00,"[{""why"":""Why did Ali step on a pallet nail and injure his left foot?"",""answer"":""Because a nail was protruding from a pallet located in the staging area at location AN, and Ali stepped on it while walking through the area during his picking task.""},{""why"":""Why was there a protruding nail on the pallet in the staging area?"",""answer"":""Because the pallet was not inspected or maintained before being placed in the staging area, and there is no routine pallet integrity check process before pallets are staged for picking operations.""},{""why"":""Why was there no routine pallet inspection process before staging pallets?"",""answer"":""Because the warehouse does not have a formal Pre-Staging Pallet Inspection Standard Operating Procedure (SOP), and the responsibility for checking pallet condition is not clearly assigned to any team or individual.""},{""why"":""Why is there no formal pallet inspection SOP or clear ownership for pallet condition checks?"",""answer"":""Because management has not prioritised pallet maintenance and inspection as a critical safety control, and existing resources are focused primarily on productivity metrics rather than preventive safety measures.""},{""why"":""Why has management not prioritised pallet inspection as a critical safety control despite the known risk of nail injuries?"",""answer"":""Because there is no systematic hazard identification and risk assessment (HIRARC) process that specifically addresses pallet-related foot injury hazards, and past near-misses or minor injuries were not formally reported or escalated to drive corrective action.""}]",null,null
71da7df7-110b-475e-a08a-8c1716ac7351,5e1c7d85-9988-48c8-8526-e971cd160ac5,11e15405-6c83-4483-9060-733660f424ad,five_why,"1. Conduct a HIRARC (Hazard Identification, Risk Assessment & Risk Control) for all MHE-operating zones including container unloading areas, with specific focus on fixed asset collision hazards, and implement identified controls such as physical barriers (e.g., bollards or guardrails) around fixed assets within 2 metres of MHE pathways.
2. Develop a Warehouse Layout Standard (based on MS 1722 or DOSH guidelines) that defines minimum clearances for MHE operations, designated MHE travel lanes, and exclusion zones around building infrastructure (columns, air conditioners, electrical panels). Mark these zones with high-visibility floor tape and signage.
3. Implement a pre-operation 'walk-around' inspection checklist for forklift operators that includes verification of clear path and awareness of fixed assets in the work area, and reinforce through weekly toolbox talks and a refresher training on safe MHE manoeuvring and spatial awareness.","The root cause is the absence of a systematic risk assessment and layout review process for the container unloading zone, leading to unprotected fixed assets (air conditioner) placed within the MHE operating envelope without physical barriers or designated exclusion zones.",positive,null,2026-07-16 01:35:43.588893+00,"[{""why"":""Why did Ali hit the air conditioner while unloading from the container to the staging area?"",""answer"":""Ali lost control or misjudged the distance while manoeuvring the forklift, causing it to collide with the air conditioning unit located near the unloading bay.""},{""why"":""Why did Ali lose control or misjudge the distance?"",""answer"":""The staging area near the container unloading bay had limited clearance, and the air conditioner was positioned within the forklift's operating zone without adequate physical barriers or markings.""},{""why"":""Why was the air conditioner placed in a location with limited clearance and no barriers?"",""answer"":""There was no designated exclusion zone or protective guarding for fixed assets (e.g., air conditioners) in the unloading area, and the layout did not account for forklift turning radius and load overhang.""},{""why"":""Why was there no designated exclusion zone or protective guarding for fixed assets in the unloading area?"",""answer"":""A formal risk assessment (HIRARC) had not been conducted for the container unloading zone to identify fixed asset collision hazards, and there was no standard layout plan defining safe distances between MHE pathways and building infrastructure.""},{""why"":""Why was the HIRARC for the unloading zone not conducted or updated?"",""answer"":""The site's asset protection programme did not include periodic workplace layout reviews for MHE operations, and there was no systematic process to identify and protect fixed assets in high-traffic operational zones.""}]",null,null
65035159-24d4-4081-a8da-80ffb6727816,dee6e6bb-b3a4-4767-8b9f-1dd3626c8f82,11e15405-6c83-4483-9060-733660f424ad,five_why,"- insufficient lighting
- limited sight due to higher level",the main issue due to broken spotlight was not handled before starting the job on that area makes the area was not safe to work,negative,null,2026-07-24 05:29:59.060352+00,"[{""why"":""Why did the incident happen?"",""answer"":""ali cant see clearly on level 5\n""},{""why"":""why ali cant see clearly on level 5 ?"",""answer"":""because the racking area was dark ""},{""why"":""why the racking area was dark ?"",""answer"":""due to the insufficient lighting in that area""},{""why"":""why insufficient lighting in that area?"",""answer"":""due to few spotlight was not functioning""}]",null,negative
1 id incident_id investigator_id method findings_text root_cause_summary alcohol_test_result completed_at created_at five_why_steps fishbone_categories urine_test_result
2 3883b700-f992-4f4f-a256-1b86934f32c5 0f81a575-7fd8-4d3a-9686-15bcd0b5f0b6 11e15405-6c83-4483-9060-733660f424ad five_why 1. 1. Implement mandatory quarterly forklift operator refresher training covering spatial awareness, load clearance, and zone discipline, with a practical assessment sign-off for each operator. 2. 2. Conduct a 5S+Safety audit across the OPS zone: install yellow/red floor marking tapes or painted lines to define minimum clearance zones around high-value/itemised stock (e.g., TV boxes), and erect protective barriers or bollards in high-risk stacking areas. 3. 3. Establish a formal near-miss and minor-damage reporting system (e.g., a simple WhatsApp-based or paper log) with a monthly review by the site supervisor to identify recurring patterns and trigger preventive actions before a more serious incident occurs. The absence of a systematic HSE continuous improvement process—including regular operator refresher training, updated 5S/warehouse layout standards with clearance markings, and a near-miss reporting feedback loop—allowed an untrained behaviour (poor clearance judgment) to go uncorrected, resulting in a preventable collision with high-value goods. negative null 2026-07-14 03:14:59.037478+00 [{"why":"Why did the forklift collide with the TV box, causing a carton tear?","answer":"The forklift operator misjudged the clearance distance while maneuvering near the TV box, causing the forklift tines or body to make contact with the carton."},{"why":"Why did the operator misjudge the clearance distance?","answer":"The operator was not following proper spotting or lookout procedures, and the aisle/stacking area had no physical guides or marked safety zones to indicate minimum clearance from stored goods."},{"why":"Why were there no physical guides or marked safety zones for clearance?","answer":"The warehouse layout did not include floor markings, barrier rails, or visual indicators for safe maneuvering distances in that specific stacking area, and there was no standardised process for auditing storage layout compliance."},{"why":"Why was the warehouse layout lacking proper markings and the operator not following safe procedures?","answer":"There was no regular refresher training program for forklift operators focused on spatial awareness and zone discipline, and the facility's housekeeping and 5S standards had not been updated to include clearance safety requirements for high-value items."},{"why":"Why was there no refresher training and why were 5S standards not updated?","answer":"Management had not prioritised periodic operator competency assessments or layout safety audits due to high operational pressure and a lack of a dedicated HSE feedback loop to capture near-misses and minor asset damage incidents for continuous improvement."}] null null
3 47c322c2-1911-4b6d-a263-fb91b9ab0a62 85c44b0b-5b4e-43a1-8e85-b64e8e510b3e 11e15405-6c83-4483-9060-733660f424ad five_why 1. 1. Implement a Management of Change (MOC) procedure requiring HSE & Operations sign-off for any racking layout, stock density, or aisle width changes, including a mandatory racking zone risk assessment update before the change is approved. 2. 2. Install physical and tech-based controls in all MHE operating in racking zones: fit speed limiters/geo-fencing on all forklifts and reach trucks to cap speed at 5 km/h within 1 meter of any racking upright, plus install blue-spot safety lights and audible reverse alarms on all units. 3. 3. Conduct a compulsory refresher retraining for all MHE operators on safe racking aisle maneuvering, approved clearances, speed discipline, and the consequences of racking impact, with a hands-on practical assessment and sign-off by a certified trainer. The root cause was the absence of a formal management-of-change (MOC) process for warehouse layout modifications, combined with inadequate MHE safety controls (speed limiters, alarms, clear signage) and insufficient operator awareness of safe maneuvering speeds in racking aisles, leading to a high-speed impact that caused a progressive racking collapse. positive null 2026-07-14 03:58:34.001168+00 [{"why":"Why did Abu hit the racking structure, causing it to collapse?","answer":"Abu was operating a forklift (or reach truck) and misjudged the clearance while maneuvering in the racking aisle, making direct contact with the upright of the racking system."},{"why":"Why did Abu misjudge the clearance while maneuvering in the racking aisle?","answer":"Abu may have been driving too fast for the aisle conditions, was distracted, or the racking aisle was narrower than required for the type of material handling equipment (MHE) being used."},{"why":"Why was Abu driving too fast or distracted, and why was the aisle clearance inadequate?","answer":"There was no effective speed governor or geo-fencing system on the forklift, no clear signage indicating speed limits in racking zones, and operators are under pressure to meet tight operational KPIs (picking/put-away targets). Additionally, racking aisle width and layout were not reassessed after recent warehouse layout changes or stock density increases."},{"why":"Why was there no effective speed control, signage, or layout reassessment in place?","answer":"The warehouse operations team had not conducted a recent risk assessment for the racking zone after layout changes, and MHE safety features (speed limiters, alarms, or aisle clearance markers) were not included in the preventive maintenance or safety inspection schedule."},{"why":"Why was the risk assessment not updated and MHE safety features not inspected regularly?","answer":"There was no formal procedure requiring re-assessment of racking zone risks after layout or inventory density changes, and the HSE team was not notified of the modifications. Additionally, the MHE preventive maintenance checklist did not include verification of speed limiters or geo-fencing functionality."}] null null
4 deb1c4f0-cf3c-4847-9718-c9748662f0a4 58e40574-738a-42ca-8478-1999963b2117 11e15405-6c83-4483-9060-733660f424ad five_why Sleepy during that time due to take medicine before work start. operator negligence and unfit to work PIC didnt supervisor his properly during briefing before work start positive null 2026-07-14 07:56:27.256602+00 [] null null
5 64bc48a6-e6aa-4dad-ab9a-91c73bfaabad 2abb27a1-f541-47de-8dd2-22d2a7902dc6 11e15405-6c83-4483-9060-733660f424ad five_why 1. 1. Implement a Pre-Staging Pallet Inspection SOP: Mandate that all pallets entering the staging area must undergo a visual and tactile inspection (check for protruding nails, broken boards, and splinters) by the receiving or staging team before being released for picking. Use a simple checklist and colour-coded tags (green = safe, red = reject). Assign ownership to the Staging Team Leader. 2. 2. Introduce mandatory PPE reinforcement & provide puncture-resistant safety shoes: Reinforce the PPE policy requiring all warehouse staff to wear approved safety shoes with steel-toe caps and puncture-resistant soles. Conduct a toolbox talk within 48 hours. Consider procuring and subsidising appropriate safety footwear for all picking and staging staff. 3. 3. Establish a Hazard Identification and Near-Miss Reporting System: Roll out a simple digital or paper-based hazard reporting form (e.g., via WhatsApp group or notice board) for workers to report damaged pallets, protruding nails, or near-miss incidents. Ensure management reviews reports weekly and assigns corrective actions within 24 hours. Include this in the monthly HSE committee meeting agenda. The absence of a formal pallet inspection SOP and lack of assigned ownership for pallet condition checks, driven by insufficient management priority on preventive safety controls and an inadequate hazard identification process, allowed a damaged pallet with a protruding nail to be staged in the picking area, resulting in a preventable foot injury to a worker. null null 2026-07-14 09:27:59.492206+00 [{"why":"Why did Ali step on a pallet nail and injure his left foot?","answer":"Because a nail was protruding from a pallet located in the staging area at location AN, and Ali stepped on it while walking through the area during his picking task."},{"why":"Why was there a protruding nail on the pallet in the staging area?","answer":"Because the pallet was not inspected or maintained before being placed in the staging area, and there is no routine pallet integrity check process before pallets are staged for picking operations."},{"why":"Why was there no routine pallet inspection process before staging pallets?","answer":"Because the warehouse does not have a formal Pre-Staging Pallet Inspection Standard Operating Procedure (SOP), and the responsibility for checking pallet condition is not clearly assigned to any team or individual."},{"why":"Why is there no formal pallet inspection SOP or clear ownership for pallet condition checks?","answer":"Because management has not prioritised pallet maintenance and inspection as a critical safety control, and existing resources are focused primarily on productivity metrics rather than preventive safety measures."},{"why":"Why has management not prioritised pallet inspection as a critical safety control despite the known risk of nail injuries?","answer":"Because there is no systematic hazard identification and risk assessment (HIRARC) process that specifically addresses pallet-related foot injury hazards, and past near-misses or minor injuries were not formally reported or escalated to drive corrective action."}] null null
6 71da7df7-110b-475e-a08a-8c1716ac7351 5e1c7d85-9988-48c8-8526-e971cd160ac5 11e15405-6c83-4483-9060-733660f424ad five_why 1. Conduct a HIRARC (Hazard Identification, Risk Assessment & Risk Control) for all MHE-operating zones including container unloading areas, with specific focus on fixed asset collision hazards, and implement identified controls such as physical barriers (e.g., bollards or guardrails) around fixed assets within 2 metres of MHE pathways. 2. Develop a Warehouse Layout Standard (based on MS 1722 or DOSH guidelines) that defines minimum clearances for MHE operations, designated MHE travel lanes, and exclusion zones around building infrastructure (columns, air conditioners, electrical panels). Mark these zones with high-visibility floor tape and signage. 3. Implement a pre-operation 'walk-around' inspection checklist for forklift operators that includes verification of clear path and awareness of fixed assets in the work area, and reinforce through weekly toolbox talks and a refresher training on safe MHE manoeuvring and spatial awareness. The root cause is the absence of a systematic risk assessment and layout review process for the container unloading zone, leading to unprotected fixed assets (air conditioner) placed within the MHE operating envelope without physical barriers or designated exclusion zones. positive null 2026-07-16 01:35:43.588893+00 [{"why":"Why did Ali hit the air conditioner while unloading from the container to the staging area?","answer":"Ali lost control or misjudged the distance while manoeuvring the forklift, causing it to collide with the air conditioning unit located near the unloading bay."},{"why":"Why did Ali lose control or misjudge the distance?","answer":"The staging area near the container unloading bay had limited clearance, and the air conditioner was positioned within the forklift's operating zone without adequate physical barriers or markings."},{"why":"Why was the air conditioner placed in a location with limited clearance and no barriers?","answer":"There was no designated exclusion zone or protective guarding for fixed assets (e.g., air conditioners) in the unloading area, and the layout did not account for forklift turning radius and load overhang."},{"why":"Why was there no designated exclusion zone or protective guarding for fixed assets in the unloading area?","answer":"A formal risk assessment (HIRARC) had not been conducted for the container unloading zone to identify fixed asset collision hazards, and there was no standard layout plan defining safe distances between MHE pathways and building infrastructure."},{"why":"Why was the HIRARC for the unloading zone not conducted or updated?","answer":"The site's asset protection programme did not include periodic workplace layout reviews for MHE operations, and there was no systematic process to identify and protect fixed assets in high-traffic operational zones."}] null null
7 65035159-24d4-4081-a8da-80ffb6727816 dee6e6bb-b3a4-4767-8b9f-1dd3626c8f82 11e15405-6c83-4483-9060-733660f424ad five_why - insufficient lighting - limited sight due to higher level the main issue due to broken spotlight was not handled before starting the job on that area makes the area was not safe to work negative null 2026-07-24 05:29:59.060352+00 [{"why":"Why did the incident happen?","answer":"ali cant see clearly on level 5\n"},{"why":"why ali cant see clearly on level 5 ?","answer":"because the racking area was dark "},{"why":"why the racking area was dark ?","answer":"due to the insufficient lighting in that area"},{"why":"why insufficient lighting in that area?","answer":"due to few spotlight was not functioning"}] null negative
+6
View File
@@ -0,0 +1,6 @@
id,name,email,phone,role,department,site_id,active,created_at
11e15405-6c83-4483-9060-733660f424ad,Admin,admin@ims.local,null,admin,null,null,true,2026-07-12 05:20:06.471419+00
39a0773b-86a2-4e3d-b3a5-4335bd3a9ee6,Test Admin,admin@ims-test.com,null,reporter,null,null,true,2026-07-09 22:30:17.135195+00
8b4441d7-ef6b-49ea-94b1-28c8bbfb68cf,Nurul Huda Safiah,huda@setia.com.my,null,capa_owner,null,c244ec0a-d713-4f23-b2c7-cac3f6c2c19a,true,2026-07-16 04:22:45.44713+00
2fc47d6f-9123-4b43-8e0b-3074d025a21e,Nurul Ain Athirah,athirah@setia.com.my,+60193357688,capa_owner,null,c244ec0a-d713-4f23-b2c7-cac3f6c2c19a,true,2026-07-20 06:35:17.362333+00
7b873070-9806-423e-b3a1-1817d4a3cc7e,yap,whyap79@gmail.com,null,capa_owner,null,c244ec0a-d713-4f23-b2c7-cac3f6c2c19a,true,2026-07-18 09:07:28.001432+00
1 id name email phone role department site_id active created_at
2 11e15405-6c83-4483-9060-733660f424ad Admin admin@ims.local null admin null null true 2026-07-12 05:20:06.471419+00
3 39a0773b-86a2-4e3d-b3a5-4335bd3a9ee6 Test Admin admin@ims-test.com null reporter null null true 2026-07-09 22:30:17.135195+00
4 8b4441d7-ef6b-49ea-94b1-28c8bbfb68cf Nurul Huda Safiah huda@setia.com.my null capa_owner null c244ec0a-d713-4f23-b2c7-cac3f6c2c19a true 2026-07-16 04:22:45.44713+00
5 2fc47d6f-9123-4b43-8e0b-3074d025a21e Nurul Ain Athirah athirah@setia.com.my +60193357688 capa_owner null c244ec0a-d713-4f23-b2c7-cac3f6c2c19a true 2026-07-20 06:35:17.362333+00
6 7b873070-9806-423e-b3a1-1817d4a3cc7e yap whyap79@gmail.com null capa_owner null c244ec0a-d713-4f23-b2c7-cac3f6c2c19a true 2026-07-18 09:07:28.001432+00