10 Commits
Author SHA1 Message Date
adminandClaude Haiku 4.5 137780d013 docs(design): document Modernist design system and track its source
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-09-30 20:49:05 +08:00
adminandClaude Haiku 4.5 c5a98eed06 feat(design): sweep off-system styles and add the check:design gate
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-09-30 20:39:44 +08:00
adminandClaude Haiku 4.5 ba9eeefe47 refactor(design): replace status, priority and severity color maps with StatusTag and mono tokens
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-09-30 19:08:18 +08:00
adminandClaude Haiku 4.5 0b5020b3d0 feat(design): restyle shell with flat Modernist sidebar, mobile nav and bell
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-09-30 19:06:17 +08:00
adminandClaude Haiku 4.5 e7416bf236 feat(design): restyle Modal as a flat Modernist dialog
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-09-30 19:04:43 +08:00
adminandClaude Haiku 4.5 4411ed54b5 feat(design): add Modernist UI primitives (Button, Tag, StatusTag, Field, Card, table styles)
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-09-30 19:04:05 +08:00
adminandClaude Haiku 4.5 3a941a357b refactor(design): drop rounded classes, swap bg-white and gray borders for tokens
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-09-30 19:02:28 +08:00
adminandClaude Haiku 4.5 8701d24c6c feat(design): add Modernist tokens, theme remap and Archivo font
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-09-30 18:55:02 +08:00
adminandClaude Haiku 4.5 106136e902 docs: add Modernist design system restyle implementation plan
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015e81pY6swiKHQZDcN86CTD
2026-09-30 18:25:57 +08:00
adminandClaude Haiku 4.5 ef7f1c9660 docs: approve Modernist spec, resolve status and imagery decisions
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015e81pY6swiKHQZDcN86CTD
2026-09-30 18:09:04 +08:00
83 changed files with 3702 additions and 575 deletions
+15
View File
@@ -62,6 +62,21 @@ 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-blue-600 hover:underline"> <Link href="/login" className="text-sm text-accent-700 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-gray-300 rounded-md px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500" className="border border-divider px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-accent"
/> />
<button <button
type="submit" type="submit"
disabled={loading} disabled={loading}
className="bg-blue-600 hover:bg-blue-700 text-white font-medium py-2 rounded-md disabled:opacity-50 transition-colors" className="bg-accent hover:bg-accent-600 text-white font-medium py-2 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-blue-600 hover:underline"> <Link href="/login" className="text-accent-700 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-gray-50 p-4"> <main className="min-h-screen flex items-center justify-center bg-ground p-4">
{message === 'password_reset' && ( {message === 'password_reset' && (
<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"> <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">
Password updated — sign in with your new password. Password updated — sign in with your new password.
</div> </div>
)} )}
<div className="bg-white rounded-xl shadow-sm border p-8 w-full max-w-sm"> <div className="bg-surface border-2 border-divider 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 rounded px-3 py-2"> <p className="bg-red-50 border border-red-200 text-red-700 text-sm 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-gray-300 rounded-md px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500" className="border border-divider px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-accent"
/> />
<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-gray-300 rounded-md px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500" className="border border-divider px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-accent"
/> />
<button <button
type="submit" type="submit"
disabled={loading} disabled={loading}
className="bg-blue-600 hover:bg-blue-700 text-white font-medium py-2 rounded-md disabled:opacity-50 transition-colors" className="bg-accent hover:bg-accent-600 text-white font-medium py-2 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-green-600 text-white rounded-lg text-sm font-medium hover:bg-green-700"> <Link href="/bulk-import" className="px-4 py-2 bg-accent text-white text-sm font-medium hover:bg-accent-600">
Bulk Import Incidents Bulk Import Incidents
</Link> </Link>
</div> </div>
+10 -23
View File
@@ -9,6 +9,7 @@ import { eq, asc } from 'drizzle-orm'
import { StatCard } from '@/components/dashboard/stat-card' import { StatCard } from '@/components/dashboard/stat-card'
import { CapaOwnerActions } from '@/components/capa/capa-owner-actions' import { CapaOwnerActions } from '@/components/capa/capa-owner-actions'
import { CapaOwnerNotesForm } from '@/components/capa/capa-owner-notes-form' import { CapaOwnerNotesForm } from '@/components/capa/capa-owner-notes-form'
import { StatusTag } from '@/components/ui/status-tag'
const STATUS_LABELS: Record<string, string> = { const STATUS_LABELS: Record<string, string> = {
open: 'Open', open: 'Open',
@@ -20,16 +21,6 @@ const STATUS_LABELS: Record<string, string> = {
closed: 'Closed', closed: 'Closed',
} }
const STATUS_COLORS: Record<string, string> = {
open: 'bg-gray-100 text-gray-700',
in_progress: 'bg-blue-100 text-blue-700',
overdue: 'bg-red-100 text-red-700',
pending_verification: 'bg-purple-100 text-purple-700',
verified: 'bg-green-100 text-green-700',
reopened: 'bg-orange-100 text-orange-700',
closed: 'bg-gray-100 text-gray-500',
}
export default async function CapaOwnerPage() { export default async function CapaOwnerPage() {
const session = await getSession() const session = await getSession()
if (!session) redirect('/login') if (!session) redirect('/login')
@@ -63,9 +54,9 @@ export default async function CapaOwnerPage() {
const doneCount = rows.filter(c => ['verified', 'closed'].includes(c.status)).length const doneCount = rows.filter(c => ['verified', 'closed'].includes(c.status)).length
const PRIORITY_COLORS: Record<string, string> = { const PRIORITY_COLORS: Record<string, string> = {
high: 'text-red-600 font-semibold', high: 'text-accent-700 font-extrabold',
med: 'text-orange-500 font-medium', med: 'text-accent-700 font-medium',
low: 'text-gray-400', low: 'text-ink/50',
} }
const activeRows = rows.filter(c => !['verified', 'closed'].includes(c.status)) const activeRows = rows.filter(c => !['verified', 'closed'].includes(c.status))
@@ -82,11 +73,11 @@ export default async function CapaOwnerPage() {
</div> </div>
{activeRows.length === 0 ? ( {activeRows.length === 0 ? (
<div className="bg-white rounded-xl shadow-sm p-8 text-center"> <div className="bg-surface 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-white rounded-xl shadow-sm divide-y divide-gray-50"> <div className="bg-surface shadow-sm divide-y divide-gray-50">
{activeRows.map(capa => { {activeRows.map(capa => {
const isOverdue = isCapaOverdue(capa) const isOverdue = isCapaOverdue(capa)
return ( return (
@@ -95,15 +86,13 @@ 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-blue-600 hover:underline mt-0.5 inline-block"> <Link href={`/hse/incidents/${capa.incidentId}`} className="text-xs text-accent-700 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">
<span className={`text-xs rounded-full px-2 py-0.5 ${STATUS_COLORS[capa.status] ?? 'bg-gray-100 text-gray-600'}`}> <StatusTag status={capa.status}>{STATUS_LABELS[capa.status] ?? capa.status}</StatusTag>
{STATUS_LABELS[capa.status] ?? capa.status}
</span>
<p className={`text-xs ${isOverdue ? 'text-red-600 font-semibold' : 'text-gray-400'}`}> <p className={`text-xs ${isOverdue ? 'text-red-600 font-semibold' : 'text-gray-400'}`}>
{capa.dueDate ? `Due ${new Date(capa.dueDate).toLocaleDateString('en-MY')}` : 'No due date'} {capa.dueDate ? `Due ${new Date(capa.dueDate).toLocaleDateString('en-MY')}` : 'No due date'}
</p> </p>
@@ -127,13 +116,11 @@ 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-white rounded-xl shadow-sm divide-y divide-gray-50 opacity-60"> <div className="bg-surface 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={`text-xs rounded-full px-2 py-0.5 ml-4 shrink-0 ${STATUS_COLORS[capa.status] ?? 'bg-gray-100'}`}> <span className="shrink-0"><StatusTag status={capa.status}>{STATUS_LABELS[capa.status] ?? capa.status}</StatusTag></span>
{STATUS_LABELS[capa.status] ?? capa.status}
</span>
</div> </div>
))} ))}
</div> </div>
+4 -11
View File
@@ -10,17 +10,12 @@ import { aliasedTable } from 'drizzle-orm'
import { VerifyForm } from '@/components/capa/verify-form' import { VerifyForm } from '@/components/capa/verify-form'
import { CloseCapaButton } from '@/components/capa/close-capa-button' import { CloseCapaButton } from '@/components/capa/close-capa-button'
import { CapaOwnerActions } from '@/components/capa/capa-owner-actions' import { CapaOwnerActions } from '@/components/capa/capa-owner-actions'
import { PriorityTag } from '@/components/ui/status-tag'
interface Props { interface Props {
params: Promise<{ id: string }> params: Promise<{ id: string }>
} }
const PRIORITY_BADGE: Record<string, string> = {
low: 'bg-gray-100 text-gray-600',
med: 'bg-yellow-100 text-yellow-700',
high: 'bg-red-100 text-red-700',
}
export default async function CapaDetailPage({ params }: Props) { export default async function CapaDetailPage({ params }: Props) {
const { id } = await params const { id } = await params
const session = await getSession() const session = await getSession()
@@ -58,11 +53,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-blue-600 hover:underline mb-4 inline-block"> <Link href="/hse/capa" className="text-sm text-accent-700 hover:underline mb-4 inline-block">
← CAPA Board ← CAPA Board
</Link> </Link>
<div className="bg-white rounded-xl shadow-sm p-5 mb-4 space-y-4"> <div className="bg-surface 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">
@@ -70,9 +65,7 @@ export default async function CapaDetailPage({ params }: Props) {
</p> </p>
<p className="text-gray-900 font-medium">{capa.description}</p> <p className="text-gray-900 font-medium">{capa.description}</p>
</div> </div>
<span className={`px-2 py-1 rounded text-xs font-semibold ${PRIORITY_BADGE[capa.priority] ?? ''}`}> <PriorityTag priority={capa.priority} />
{capa.priority}
</span>
</div> </div>
<div className="grid grid-cols-2 gap-3 text-sm"> <div className="grid grid-cols-2 gap-3 text-sm">
+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-blue-600 hover:underline"> <Link href="/hse/incidents" className="text-sm text-accent-700 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-gray-200 rounded-lg px-3 py-1.5" className="text-sm text-gray-500 hover:text-gray-700 border border-divider 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-gray-200 rounded-lg px-3 py-1.5" className="text-sm text-gray-500 hover:text-gray-700 border border-divider px-3 py-1.5"
> >
JKKP 8 JKKP 8
</a> </a>
<Link href="/hse/incidents" className="text-sm text-blue-600 hover:underline"> <Link href="/hse/incidents" className="text-sm text-accent-700 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-amber-50 border border-amber-200 rounded-xl p-4 mb-6"> <div className="bg-accent-100 border border-accent-300 p-4 mb-6">
<p className="text-sm text-amber-800"> <p className="text-sm text-accent-700">
<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-white rounded-xl shadow-sm p-5"> <div className="bg-surface 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-blue-50 rounded-lg p-4"> <div className="flex-1 text-center bg-neutral-100 p-4">
<p className="text-3xl font-bold text-blue-600">{leadingCount}</p> <p className="text-3xl font-bold text-accent-700">{leadingCount}</p>
<p className="text-xs text-blue-700 mt-1">Leading (Hazards + Near Misses)</p> <p className="text-xs text-accent-700 mt-1">Leading (Hazards + Near Misses)</p>
</div> </div>
<div className="flex-1 text-center bg-red-50 rounded-lg p-4"> <div className="flex-1 text-center bg-red-50 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-green-50 rounded-lg p-4"> <div className="flex-1 text-center bg-neutral-100 p-4">
<p className="text-3xl font-bold text-green-600">{capaOnTimeRate}%</p> <p className="text-3xl font-bold text-ink">{capaOnTimeRate}%</p>
<p className="text-xs text-green-700 mt-1">CAPA On-Time Rate</p> <p className="text-xs text-ink 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-white rounded-xl shadow-sm p-5 mb-4"> <div className="bg-surface 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-blue-400" style={{ height: `${(m.leading / monthlyMax) * 192}px` }} /> <div className="w-full bg-accent-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-white rounded-xl shadow-sm p-5"> <div className="bg-surface 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-white rounded-xl shadow-sm p-5 mb-4"> <div className="bg-surface 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 rounded-full h-3"> <div className="flex-1 bg-gray-100 h-3">
<div <div
className="h-3 rounded-full" className="h-3"
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-white rounded-xl shadow-sm p-5 mb-4"> <div className="bg-surface 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 rounded-full h-2"> <div className="flex-1 bg-gray-100 h-2">
<div <div
className="bg-blue-500 h-2 rounded-full" className="bg-accent h-2"
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-white rounded-xl shadow-sm p-5"> <div className="bg-surface 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-blue-600 hover:underline mb-4 inline-block"> <Link href={`/hse/incidents/${id}`} className="text-sm text-accent-700 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-blue-600 hover:underline mb-4 inline-block"> <Link href={`/hse/incidents/${id}`} className="text-sm text-accent-700 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 rounded-lg px-4 py-2 text-sm font-semibold hover:bg-gray-900" className="inline-block bg-gray-800 text-white 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 rounded-lg px-4 py-2 text-sm font-semibold hover:bg-gray-700" className="inline-block bg-gray-600 text-white 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-green-600 text-white text-xs font-semibold rounded-lg hover:bg-green-700 transition-colors" 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"
> >
<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-blue-600 hover:underline mb-4 inline-block"> <Link href={`/hse/incidents/${id}`} className="text-sm text-accent-700 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-white rounded-xl shadow-sm p-5 hover:shadow-md transition-shadow border border-gray-100"> <Link href="/hse/incidents" className="bg-surface shadow-sm p-5 hover:shadow-md transition-shadow border border-divider">
<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-white rounded-xl shadow-sm p-5 hover:shadow-md transition-shadow border border-gray-100"> <Link href="/hse/dashboard" className="bg-surface shadow-sm p-5 hover:shadow-md transition-shadow border border-divider">
<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-gray-50"> <div className="min-h-screen bg-ground">
<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-green-400', 2: 'bg-yellow-400', 3: 'bg-orange-400', 4: 'bg-red-500', 5: 'bg-red-700', 1: 'bg-neutral-300', 2: 'bg-neutral-500', 3: 'bg-accent-300', 4: 'bg-accent', 5: 'bg-accent-700',
} }
return ( return (
@@ -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-gray-200 rounded-lg px-3 py-1.5" className="text-sm text-gray-500 hover:text-gray-700 border border-divider 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-white rounded-xl shadow-sm p-5 mb-4"> <div className="bg-surface 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-blue-50 rounded-lg p-4"> <div className="flex-1 text-center bg-neutral-100 p-4">
<p className="text-3xl font-bold text-blue-600">{leadingCount}</p> <p className="text-3xl font-bold text-accent-700">{leadingCount}</p>
<p className="text-xs text-blue-700 mt-1">Leading (Hazards + Near Misses)</p> <p className="text-xs text-accent-700 mt-1">Leading (Hazards + Near Misses)</p>
</div> </div>
<div className="flex-1 text-center bg-red-50 rounded-lg p-4"> <div className="flex-1 text-center bg-red-50 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-white rounded-xl shadow-sm p-5 mb-4"> <div className="bg-surface 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 rounded-full h-3"> <div className="flex-1 bg-gray-100 h-3">
<div <div
className={`h-3 rounded-full ${SEVERITY_COLORS[sev]}`} className={`h-3 ${SEVERITY_COLORS[sev]}`}
style={{ width: severityMax > 0 ? `${(severityDist[sev] / severityMax) * 100}%` : '0%' }} style={{ width: severityMax > 0 ? `${(severityDist[sev] / severityMax) * 100}%` : '0%' }}
/> />
</div> </div>
@@ -154,7 +154,7 @@ export default async function ManagementPage() {
</div> </div>
{/* Site comparison */} {/* Site comparison */}
<div className="bg-white rounded-xl shadow-sm p-5"> <div className="bg-surface 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,17 +6,12 @@ import { redirect, notFound } from 'next/navigation'
import { getSession } from '@/lib/auth/get-session' import { getSession } from '@/lib/auth/get-session'
import { incidents, sites, zones, capaActions } from '@/lib/db/schema' import { incidents, sites, zones, capaActions } from '@/lib/db/schema'
import { eq, and } from 'drizzle-orm' import { eq, and } from 'drizzle-orm'
import { StatusTag } from '@/components/ui/status-tag'
const STATUS_LABELS: Record<string, string> = { const STATUS_LABELS: Record<string, string> = {
reported: 'Reported', triaged: 'Triaged', investigating: 'Investigating', reported: 'Reported', triaged: 'Triaged', investigating: 'Investigating',
capa_pending: 'CAPA Pending', verification: 'Verification', closed: 'Closed', capa_pending: 'CAPA Pending', verification: 'Verification', closed: 'Closed',
} }
const STATUS_COLORS: Record<string, string> = {
reported: 'bg-gray-100 text-gray-600', triaged: 'bg-yellow-100 text-yellow-800',
investigating: 'bg-blue-100 text-blue-700', capa_pending: 'bg-orange-100 text-orange-700',
verification: 'bg-purple-100 text-purple-700', closed: 'bg-green-100 text-green-700',
}
export default async function ReporterIncidentDetail({ export default async function ReporterIncidentDetail({
params, params,
}: { }: {
@@ -65,18 +60,16 @@ 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-blue-600 hover:underline">← My Reports</Link> <Link href="/reporter" className="text-sm text-accent-700 hover:underline">← My Reports</Link>
</div> </div>
<div className="bg-white rounded-xl shadow-sm p-5"> <div className="bg-surface 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={`text-xs rounded-full px-2 py-1 shrink-0 ${STATUS_COLORS[inc.status] ?? 'bg-gray-100 text-gray-600'}`}> <span className="shrink-0"><StatusTag status={inc.status}>{STATUS_LABELS[inc.status] ?? inc.status}</StatusTag></span>
{STATUS_LABELS[inc.status] ?? inc.status}
</span>
</div> </div>
<div className="grid grid-cols-2 gap-3 text-sm mb-4"> <div className="grid grid-cols-2 gap-3 text-sm mb-4">
@@ -98,7 +91,7 @@ export default async function ReporterIncidentDetail({
</div> </div>
{inc.description && ( {inc.description && (
<div className="border-t border-gray-100 pt-4"> <div className="border-t border-divider 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>
@@ -106,15 +99,15 @@ export default async function ReporterIncidentDetail({
</div> </div>
{capas.length > 0 && ( {capas.length > 0 && (
<div className="bg-white rounded-xl shadow-sm p-5"> <div className="bg-surface 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 rounded-full px-2 py-0.5 shrink-0 ${ <span className={`text-xs px-2 py-0.5 shrink-0 ${
c.status === 'verified' ? 'bg-green-100 text-green-700' : c.status === 'verified' ? 'bg-neutral-100 text-ink' :
c.status === 'pending_verification' ? 'bg-purple-100 text-purple-700' : c.status === 'pending_verification' ? 'bg-accent-100 text-accent-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>
+11 -21
View File
@@ -6,6 +6,7 @@ import { redirect } from 'next/navigation'
import { getSession } from '@/lib/auth/get-session' import { getSession } from '@/lib/auth/get-session'
import { incidents, sites } from '@/lib/db/schema' import { incidents, sites } from '@/lib/db/schema'
import { eq, desc } from 'drizzle-orm' import { eq, desc } from 'drizzle-orm'
import { StatusTag } from '@/components/ui/status-tag'
const STATUS_LABELS: Record<string, string> = { const STATUS_LABELS: Record<string, string> = {
reported: 'Reported', reported: 'Reported',
@@ -16,15 +17,6 @@ const STATUS_LABELS: Record<string, string> = {
closed: 'Closed', closed: 'Closed',
} }
const STATUS_COLORS: Record<string, string> = {
reported: 'bg-gray-100 text-gray-600',
triaged: 'bg-yellow-100 text-yellow-800',
investigating: 'bg-blue-100 text-blue-700',
capa_pending: 'bg-orange-100 text-orange-700',
verification: 'bg-purple-100 text-purple-700',
closed: 'bg-green-100 text-green-700',
}
const TYPE_LABELS: Record<string, string> = { const TYPE_LABELS: Record<string, string> = {
injury: 'Injury', near_miss: 'Near Miss', hazard: 'Hazard', injury: 'Injury', near_miss: 'Near Miss', hazard: 'Hazard',
asset_damage: 'Asset Damage', environmental: 'Environmental', security: 'Security', fire: 'Fire', asset_damage: 'Asset Damage', environmental: 'Environmental', security: 'Security', fire: 'Fire',
@@ -62,34 +54,34 @@ export default async function ReporterPage() {
</div> </div>
<Link <Link
href="/report" href="/report"
className="bg-blue-600 text-white rounded-lg px-4 py-2 text-sm font-semibold hover:bg-blue-700" className="bg-accent text-white px-4 py-2 text-sm font-semibold hover:bg-accent-600"
> >
+ 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-white rounded-xl shadow-sm p-4 flex-1 text-center"> <div className="bg-surface 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-white rounded-xl shadow-sm p-4 flex-1 text-center"> <div className="bg-surface shadow-sm p-4 flex-1 text-center">
<p className="text-2xl font-bold text-yellow-600">{openCount}</p> <p className="text-2xl font-bold text-accent-700">{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-white rounded-xl shadow-sm p-4 flex-1 text-center"> <div className="bg-surface shadow-sm p-4 flex-1 text-center">
<p className="text-2xl font-bold text-green-600">{closedCount}</p> <p className="text-2xl font-bold text-ink">{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-white rounded-xl shadow-sm p-8 text-center"> <div className="bg-surface 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-blue-600 text-sm hover:underline">Submit your first report →</Link> <Link href="/report" className="text-accent-700 text-sm hover:underline">Submit your first report →</Link>
</div> </div>
) : ( ) : (
<div className="bg-white rounded-xl shadow-sm divide-y divide-gray-50"> <div className="bg-surface 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">
@@ -110,9 +102,7 @@ export default async function ReporterPage() {
</p> </p>
)} )}
</div> </div>
<span className={`text-xs rounded-full px-2 py-0.5 shrink-0 ${STATUS_COLORS[inc.status] ?? 'bg-gray-100 text-gray-600'}`}> <span className="shrink-0"><StatusTag status={inc.status}>{STATUS_LABELS[inc.status] ?? inc.status}</StatusTag></span>
{STATUS_LABELS[inc.status] ?? inc.status}
</span>
</div> </div>
</Link> </Link>
))} ))}
@@ -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-blue-600 hover:underline mb-4 inline-block"> <Link href="/supervisor/incidents" className="text-sm text-accent-700 hover:underline mb-4 inline-block">
← Back to inbox ← Back to inbox
</Link> </Link>
<IncidentDetail incident={incidentProp} /> <IncidentDetail incident={incidentProp} />
+6 -16
View File
@@ -8,6 +8,7 @@ import { incidents, sites, capaActions, users } from '@/lib/db/schema'
import { eq, not, and, inArray, sql, desc } from 'drizzle-orm' import { eq, not, and, inArray, sql, desc } from 'drizzle-orm'
import { aliasedTable } from 'drizzle-orm' import { aliasedTable } from 'drizzle-orm'
import { StatCard } from '@/components/dashboard/stat-card' import { StatCard } from '@/components/dashboard/stat-card'
import { StatusTag } from '@/components/ui/status-tag'
const STATUS_LABELS: Record<string, string> = { const STATUS_LABELS: Record<string, string> = {
reported: 'Reported', reported: 'Reported',
@@ -18,15 +19,6 @@ const STATUS_LABELS: Record<string, string> = {
closed: 'Closed', closed: 'Closed',
} }
const STATUS_COLORS: Record<string, string> = {
reported: 'bg-gray-100 text-gray-700',
triaged: 'bg-yellow-100 text-yellow-800',
investigating: 'bg-blue-100 text-blue-700',
capa_pending: 'bg-orange-100 text-orange-700',
verification: 'bg-purple-100 text-purple-700',
closed: 'bg-green-100 text-green-700',
}
export default async function SupervisorPage() { export default async function SupervisorPage() {
const session = await getSession() const session = await getSession()
if (!session) redirect('/login') if (!session) redirect('/login')
@@ -119,7 +111,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-blue-600 hover:underline"> <Link href="/supervisor/incidents" className="text-sm text-accent-700 hover:underline">
All incidents → All incidents →
</Link> </Link>
</div> </div>
@@ -133,7 +125,7 @@ export default async function SupervisorPage() {
</div> </div>
{/* Open incidents */} {/* Open incidents */}
<div className="bg-white rounded-xl shadow-sm p-5 mb-4"> <div className="bg-surface 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>
@@ -143,15 +135,13 @@ 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 rounded" className="flex items-center justify-between py-2 border-b border-gray-50 last:border-0 hover:bg-gray-50 -mx-2 px-2"
> >
<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>
<span className={`text-xs rounded-full px-2 py-0.5 font-medium ${STATUS_COLORS[inc.status] ?? 'bg-gray-100 text-gray-700'}`}> <StatusTag status={inc.status}>{STATUS_LABELS[inc.status] ?? inc.status}</StatusTag>
{STATUS_LABELS[inc.status] ?? inc.status}
</span>
</Link> </Link>
))} ))}
</div> </div>
@@ -160,7 +150,7 @@ export default async function SupervisorPage() {
{/* Overdue CAPAs */} {/* Overdue CAPAs */}
{overdueCount > 0 && ( {overdueCount > 0 && (
<div className="bg-white rounded-xl shadow-sm p-5"> <div className="bg-surface 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 => (
+155 -28
View File
@@ -1,37 +1,164 @@
@import "tailwindcss"; @import "tailwindcss";
:root { /* Modernist tokens. Source of truth: the Modernist styles.css under design-system/_ds.
--background: #ffffff; Static emits every variable so plain CSS can use var(--color-*) too. */
--foreground: #171717; @theme static {
--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;
} }
@theme inline { @layer base {
--color-background: var(--background); html {
--color-foreground: var(--foreground); background: var(--color-bg);
--font-sans: var(--font-geist-sans); }
--font-mono: var(--font-geist-mono);
}
@media (prefers-color-scheme: dark) { body {
:root { background: var(--color-bg);
--background: #0a0a0a; color: var(--color-text);
--foreground: #ededed; font-family: var(--font-sans);
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,
textarea,
select {
color: var(--color-text);
}
input::placeholder,
textarea::placeholder {
color: color-mix(in srgb, var(--color-text) 55%, transparent);
}
button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
opacity: 0.45;
cursor: not-allowed;
} }
} }
body { .grayscale {
background: var(--background); filter: grayscale(1) contrast(1.08);
color: var(--foreground);
font-family: Arial, Helvetica, sans-serif;
}
input,
textarea,
select {
color: #111827; /* gray-900 — dark typed text */
}
input::placeholder,
textarea::placeholder {
color: #6b7280; /* gray-500 — readable placeholder */
} }
+4 -9
View File
@@ -1,16 +1,11 @@
import type { Metadata } from 'next' import type { Metadata } from 'next'
import { Geist, Geist_Mono } from 'next/font/google' import { Archivo } 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 geistSans = Geist({ const archivo = Archivo({
variable: '--font-geist-sans', variable: '--font-archivo',
subsets: ['latin'],
})
const geistMono = Geist_Mono({
variable: '--font-geist-mono',
subsets: ['latin'], subsets: ['latin'],
}) })
@@ -30,7 +25,7 @@ export default async function RootLayout({
return ( return (
<html <html
lang={locale} lang={locale}
className={`${geistSans.variable} ${geistMono.variable} h-full antialiased`} className={`${archivo.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-amber-600 mt-1">No zone detected — zone will not be recorded</p> <p className="text-sm text-accent-700 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-white rounded-xl shadow-sm p-8 max-w-sm w-full text-center"> <div className="bg-surface 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-blue-600 hover:underline"> <Link href="/report" className="text-sm text-accent-700 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-white rounded-xl shadow-sm p-5"> <div className="bg-surface 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-gray-300 rounded-lg px-3 py-2 text-sm focus:ring-2 focus:ring-blue-500 focus:border-transparent disabled:opacity-50" className="w-full border border-divider px-3 py-2 text-sm focus:ring-2 focus:ring-accent 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-gray-300 rounded-lg px-3 py-2 text-sm focus:ring-2 focus:ring-blue-500 focus:border-transparent disabled:opacity-50" className="w-full border border-divider px-3 py-2 text-sm focus:ring-2 focus:ring-accent 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-gray-300 rounded-lg px-3 py-2 text-sm focus:ring-2 focus:ring-blue-500 focus:border-transparent disabled:opacity-50" className="w-full border border-divider px-3 py-2 text-sm focus:ring-2 focus:ring-accent 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-green-600 mt-1">Password changed successfully.</p>} {success && <p className="text-xs text-ink mt-1">Password changed successfully.</p>}
<button <button
type="submit" type="submit"
disabled={loading} disabled={loading}
className="bg-blue-600 text-white rounded-lg px-4 py-2 text-sm font-semibold disabled:opacity-50 hover:bg-blue-700" className="bg-accent text-white px-4 py-2 text-sm font-semibold disabled:opacity-50 hover:bg-accent-600"
> >
{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-gray-200 mb-6"> <div className="flex gap-1 border-b border-divider 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-green-600 text-green-700' ? 'border-accent text-ink'
: '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 rounded-full ${ <span className={`ml-1.5 text-xs px-1.5 py-0.5 ${
tab === t.id ? 'bg-green-100 text-green-700' : 'bg-gray-100 text-gray-500' tab === t.id ? 'bg-neutral-100 text-ink' : '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 rounded border-2 border-dashed border-gray-300 p-6 text-center hover:bg-gray-50"> <label className="block cursor-pointer border-2 border-dashed border-divider 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 rounded" className="px-4 py-2 text-gray-600 hover:bg-gray-100"
> >
Back Back
</button> </button>
<button <button
onClick={handleImport} onClick={handleImport}
disabled={!canImport || loading} disabled={!canImport || loading}
className="px-4 py-2 bg-blue-600 text-white rounded disabled:opacity-50 disabled:cursor-not-allowed" className="px-4 py-2 bg-accent text-white 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-green-600">✓ Import Complete</h3> <h3 className="font-bold text-ink">✓ Import Complete</h3>
<p>{folders.length} incidents created</p> <p>{folders.length} incidents created</p>
{message && <p className="text-green-600 text-sm">{message}</p>} {message && <p className="text-ink text-sm">{message}</p>}
</div> </div>
) )
} }
+21 -21
View File
@@ -3,6 +3,7 @@
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
@@ -16,7 +17,6 @@ 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-white rounded-xl border border-gray-200 shadow-sm overflow-hidden"> <div className="bg-surface border border-divider shadow-sm overflow-hidden">
<div className="flex items-center justify-between px-5 py-4 border-b border-gray-100"> <div className="flex items-center justify-between px-5 py-4 border-b border-divider">
<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 rounded-lg 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 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-green-600 text-white text-xs font-semibold rounded-lg hover:bg-green-700 transition-colors cursor-pointer"> 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">
<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 rounded-full border transition-colors cursor-pointer disabled:opacity-50 ${ className={`text-xs font-medium px-2.5 py-1 border transition-colors cursor-pointer disabled:opacity-50 ${
site.active site.active
? 'bg-green-50 text-green-700 border-green-200 hover:bg-green-100' ? 'bg-neutral-100 text-ink border-divider hover:bg-neutral-200'
: 'bg-gray-50 text-gray-500 border-gray-200 hover:bg-gray-100' : 'bg-gray-50 text-gray-500 border-divider 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-gray-100"> <ul className="mt-3 space-y-1.5 pl-3 border-l-2 border-divider">
{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-blue-600 hover:underline cursor-pointer"> className="text-xs text-accent-700 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 rounded-full border transition-colors cursor-pointer disabled:opacity-50 ${ className={`text-xs font-medium px-2 py-0.5 border transition-colors cursor-pointer disabled:opacity-50 ${
z.active z.active
? 'bg-green-50 text-green-700 border-green-200 hover:bg-green-100' ? 'bg-neutral-100 text-ink border-divider hover:bg-neutral-200'
: 'bg-gray-50 text-gray-500 border-gray-200 hover:bg-gray-100' : 'bg-gray-50 text-gray-500 border-divider 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 rounded-lg border border-gray-300 text-gray-700 hover:bg-gray-50 cursor-pointer transition-colors"> className="px-4 py-2 text-sm font-medium border border-divider 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-green-600 text-white text-sm font-semibold rounded-lg hover:bg-green-700 disabled:opacity-50 cursor-pointer transition-colors"> className="px-4 py-2 bg-accent text-white text-sm font-semibold hover:bg-accent-600 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 rounded-lg mb-3">{error}</p>} {error && <p className="text-xs text-red-600 bg-red-50 px-3 py-2 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 rounded-lg border border-gray-300 text-gray-700 hover:bg-gray-50 cursor-pointer transition-colors"> className="px-4 py-2 text-sm font-medium border border-divider 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-green-600 text-white text-sm font-semibold rounded-lg hover:bg-green-700 disabled:opacity-50 cursor-pointer transition-colors"> className="px-4 py-2 bg-accent text-white text-sm font-semibold hover:bg-accent-600 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 rounded-lg mb-3">{error}</p>} {error && <p className="text-xs text-red-600 bg-red-50 px-3 py-2 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 rounded-lg border border-gray-300 text-gray-700 hover:bg-gray-50 cursor-pointer transition-colors"> className="px-4 py-2 text-sm font-medium border border-divider 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 rounded-lg 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 hover:bg-red-700 disabled:opacity-50 cursor-pointer transition-colors">
Delete Delete
</button> </button>
</> </>
+13 -13
View File
@@ -3,6 +3,7 @@
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
@@ -15,7 +16,6 @@ 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-white rounded-xl border border-gray-200 shadow-sm overflow-hidden"> <div className="bg-surface border border-divider shadow-sm overflow-hidden">
<div className="flex items-center justify-between px-5 py-4 border-b border-gray-100"> <div className="flex items-center justify-between px-5 py-4 border-b border-divider">
<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-green-600 text-white text-xs font-semibold rounded-lg hover:bg-green-700 transition-colors cursor-pointer"> 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">
<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-blue-600 hover:underline cursor-pointer"> className="text-xs text-accent-700 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 rounded-full border transition-colors cursor-pointer disabled:opacity-50 ${ className={`text-xs font-medium px-2.5 py-1 border transition-colors cursor-pointer disabled:opacity-50 ${
tk.active tk.active
? 'bg-green-50 text-green-700 border-green-200 hover:bg-green-100' ? 'bg-neutral-100 text-ink border-divider hover:bg-neutral-200'
: 'bg-gray-50 text-gray-500 border-gray-200 hover:bg-gray-100' : 'bg-gray-50 text-gray-500 border-divider 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 rounded-lg border border-gray-300 text-gray-700 hover:bg-gray-50 cursor-pointer transition-colors"> className="px-4 py-2 text-sm font-medium border border-divider 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-green-600 text-white text-sm font-semibold rounded-lg hover:bg-green-700 disabled:opacity-50 cursor-pointer transition-colors"> className="px-4 py-2 bg-accent text-white text-sm font-semibold hover:bg-accent-600 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 rounded-lg mb-3">{error}</p>} {error && <p className="text-xs text-red-600 bg-red-50 px-3 py-2 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 rounded-lg border border-gray-300 text-gray-700 hover:bg-gray-50 cursor-pointer transition-colors"> className="px-4 py-2 text-sm font-medium border border-divider 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 rounded-lg 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 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,6 +4,7 @@ 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
@@ -24,7 +25,6 @@ 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-white rounded-xl border border-gray-200 shadow-sm overflow-hidden"> <div className="bg-surface border border-divider shadow-sm overflow-hidden">
<div className="flex items-center justify-between px-5 py-4 border-b border-gray-100"> <div className="flex items-center justify-between px-5 py-4 border-b border-divider">
<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-green-600 text-white text-xs font-semibold rounded-lg hover:bg-green-700 transition-colors cursor-pointer" 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"
> >
<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-gray-200 rounded-lg px-2 py-1 text-xs focus:outline-none focus:ring-1 focus:ring-green-500 cursor-pointer"> className="border border-divider px-2 py-1 text-xs focus:outline-none focus:ring-1 focus:ring-accent 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-gray-200 rounded-lg px-2 py-1 text-xs focus:outline-none focus:ring-1 focus:ring-green-500 cursor-pointer"> className="border border-divider px-2 py-1 text-xs focus:outline-none focus:ring-1 focus:ring-accent 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 rounded-full font-medium border transition-colors cursor-pointer ${ className={`text-xs px-2.5 py-1 font-medium border transition-colors cursor-pointer ${
u.active u.active
? 'bg-green-50 text-green-700 border-green-200 hover:bg-green-100' ? 'bg-neutral-100 text-ink border-divider hover:bg-neutral-200'
: 'bg-gray-50 text-gray-500 border-gray-200 hover:bg-gray-100' : 'bg-gray-50 text-gray-500 border-divider 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 rounded-lg border border-gray-300 text-gray-700 hover:bg-gray-50 cursor-pointer transition-colors"> className="px-4 py-2 text-sm font-medium border border-divider 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-green-600 text-white text-sm font-semibold rounded-lg hover:bg-green-700 disabled:opacity-50 cursor-pointer transition-colors"> className="px-4 py-2 bg-accent text-white text-sm font-semibold hover:bg-accent-600 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 rounded-lg">{error}</p>} {error && <p className="text-xs text-red-600 bg-red-50 px-3 py-2">{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 rounded-lg border border-gray-300 text-gray-700 hover:bg-gray-50 cursor-pointer transition-colors"> className="px-4 py-2 text-sm font-medium border border-divider 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 rounded-lg 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 hover:bg-red-700 disabled:opacity-50 cursor-pointer transition-colors">
{busyId === confirmDelete?.id ? 'Deleting…' : 'Delete'} {busyId === confirmDelete?.id ? 'Deleting…' : 'Delete'}
</button> </button>
</> </>
+12 -16
View File
@@ -4,6 +4,8 @@
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('')
@@ -37,44 +39,38 @@ 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="text-center"> <div className="pb-3 border-b-2 border-divider">
<h1 className="text-2xl font-bold">IMS</h1> <h1 className="text-3xl font-extrabold">IMS</h1>
<p className="text-sm text-gray-500 mt-1">HSE Incident Management</p> <p className="text-sm text-ink/60 mt-1">HSE Incident Management</p>
</div> </div>
{error && ( {error && (
<p className="bg-red-50 border border-red-200 text-red-700 text-sm rounded px-3 py-2"> <p className="bg-accent-100 border border-accent text-accent-800 text-sm 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 <Button type="submit" variant="primary" block disabled={loading}>
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-center text-sm text-gray-500"> <p className="text-sm text-ink/60">
<Link href="/forgot-password" className="text-blue-600 hover:underline"> <Link href="/forgot-password" className="text-accent-700 hover:underline">
Forgot password? Forgot password?
</Link> </Link>
</p> </p>
+18 -24
View File
@@ -2,6 +2,7 @@
import { useState } from 'react' import { useState } from 'react'
import Link from 'next/link' import Link from 'next/link'
import { PriorityTag } from '@/components/ui/status-tag'
type CapaStatus = 'open' | 'in_progress' | 'overdue' | 'pending_verification' | 'verified' | 'reopened' | 'closed' type CapaStatus = 'open' | 'in_progress' | 'overdue' | 'pending_verification' | 'verified' | 'reopened' | 'closed'
@@ -27,19 +28,14 @@ const STATUS_LABELS: Record<CapaStatus, string> = {
reopened: 'Reopened', reopened: 'Reopened',
closed: 'Closed', closed: 'Closed',
} }
const STATUS_COLORS: Record<CapaStatus, string> = { const COLUMN_BORDER: Record<CapaStatus, string> = {
open: 'bg-blue-50 border-blue-200', open: 'border-divider',
in_progress: 'bg-yellow-50 border-yellow-200', in_progress: 'border-divider',
overdue: 'bg-red-50 border-red-200', overdue: 'border-accent',
pending_verification: 'bg-purple-50 border-purple-200', pending_verification: 'border-divider',
verified: 'bg-green-50 border-green-200', verified: 'border-divider',
reopened: 'bg-orange-50 border-orange-200', reopened: 'border-accent',
closed: 'bg-gray-50 border-gray-200', closed: 'border-divider',
}
const PRIORITY_BADGE: Record<'low' | 'med' | 'high', string> = {
low: 'bg-gray-100 text-gray-600',
med: 'bg-yellow-100 text-yellow-700',
high: 'bg-red-100 text-red-700',
} }
interface Props { interface Props {
@@ -58,7 +54,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-blue-600 hover:underline">Board view</button> <button onClick={() => setView('board')} className="text-sm text-accent-700 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">
@@ -72,23 +68,21 @@ 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-gray-100"> <tbody className="divide-y divide-divider">
{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-blue-600 hover:underline line-clamp-2"> <Link href={`/hse/capa/${c.id}`} className="text-accent-700 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">
<span className={`px-2 py-0.5 rounded text-xs font-medium ${PRIORITY_BADGE[c.priority]}`}> <PriorityTag priority={c.priority} />
{c.priority}
</span>
</td> </td>
<td className="py-2 text-gray-600 text-xs">{STATUS_LABELS[c.status]}</td> <td className="py-2 text-gray-600 text-xs">{STATUS_LABELS[c.status]}</td>
</tr> </tr>
@@ -103,22 +97,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-blue-600 hover:underline">Table view</button> <button onClick={() => setView('table')} className="text-sm text-accent-700 hover:underline">Table view</button>
</div> </div>
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4"> <div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4">
{STATUS_ORDER.filter(s => s !== 'reopened').map(status => ( {STATUS_ORDER.filter(s => s !== 'reopened').map(status => (
<div key={status} className={`rounded-xl border p-4 ${STATUS_COLORS[status]}`}> <div key={status} className={`border-2 p-4 bg-ground ${COLUMN_BORDER[status]}`}>
<h3 className="text-xs font-semibold uppercase tracking-wide text-gray-600 mb-3"> <h3 className="text-xs font-extrabold uppercase tracking-wide text-ink/70 mb-3 pb-2 border-b-2 border-divider">
{STATUS_LABELS[status]} ({byStatus[status].length}) {STATUS_LABELS[status]} ({byStatus[status].length})
</h3> </h3>
<div className="space-y-2 max-h-96 overflow-y-auto pr-2"> <div className="space-y-2 max-h-96 overflow-y-auto pr-2">
{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-white rounded-lg p-3 shadow-sm hover:shadow-md transition-shadow border border-gray-100"> className="block bg-surface p-3 shadow-sm hover:shadow-md transition-shadow border border-divider">
<p className="text-sm text-gray-800 line-clamp-2 mb-1">{c.description}</p> <p className="text-sm text-gray-800 line-clamp-2 mb-1">{c.description}</p>
<div className="flex items-center justify-between text-xs text-gray-500"> <div className="flex items-center justify-between text-xs text-gray-500">
<span>{(c.owner as { name: string } | null)?.name ?? '—'}</span> <span>{(c.owner as { name: string } | null)?.name ?? '—'}</span>
<span className={`px-1.5 py-0.5 rounded ${PRIORITY_BADGE[c.priority]}`}>{c.priority}</span> <PriorityTag priority={c.priority} />
</div> </div>
<p className="text-xs text-gray-400 mt-1">Due {c.due_date}</p> <p className="text-xs text-gray-400 mt-1">Due {c.due_date}</p>
</Link> </Link>
+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 rounded-lg border border-gray-300 px-3 py-2 text-sm" className="w-full border border-divider 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 rounded-lg border border-gray-300 px-3 py-2 text-sm" className="w-full border border-divider 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 rounded-lg border border-gray-300 px-3 py-2 text-sm"> className="w-full border border-divider 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 rounded-lg border border-gray-300 px-3 py-2 text-sm" /> className="w-full border border-divider 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 rounded-lg border border-gray-300 px-3 py-2 text-sm"> className="w-full border border-divider 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-amber-600 text-white rounded-lg py-2 text-sm font-semibold disabled:opacity-50"> className="w-full bg-accent text-white 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-gray-300 rounded-md hover:bg-gray-50 disabled:opacity-50" className="text-sm px-3 py-1.5 border border-divider 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-blue-600 text-white rounded-md hover:bg-blue-700 disabled:opacity-50" className="text-sm px-3 py-1.5 bg-accent text-white hover:bg-accent-600 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 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" 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"
/> />
{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 rounded-md hover:bg-gray-700 disabled:opacity-50" className="text-xs px-3 py-1 bg-gray-800 text-white hover:bg-gray-700 disabled:opacity-50"
> >
{saving ? 'Saving…' : 'Save Notes'} {saving ? 'Saving…' : 'Save Notes'}
</button> </button>
{saved && <span className="text-xs text-green-600">Saved</span>} {saved && <span className="text-xs text-ink">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-gray-200 rounded-xl p-5 space-y-3 bg-green-50"> <div className="border border-divider p-5 space-y-3 bg-neutral-100">
<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-green-700 text-white rounded-lg py-2 text-sm font-semibold hover:bg-green-800 disabled:opacity-50" className="w-full bg-accent text-white py-2 text-sm font-semibold hover:bg-accent-700 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-gray-200 rounded-xl p-5 space-y-4 bg-purple-50"> <form onSubmit={handleSubmit} className="border border-divider p-5 space-y-4 bg-accent-100">
<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 rounded-lg text-sm font-medium border ${ className={`flex-1 py-2 text-sm font-medium border ${
verdict === 'verified' verdict === 'verified'
? 'bg-green-600 text-white border-green-600' ? 'bg-accent text-white border-accent'
: 'bg-white text-gray-700 border-gray-300 hover:border-green-500' : 'bg-surface text-gray-700 border-divider hover:border-accent'
}`} }`}
> >
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 rounded-lg text-sm font-medium border ${ className={`flex-1 py-2 text-sm font-medium border ${
verdict === 'reopened' verdict === 'reopened'
? 'bg-orange-600 text-white border-orange-600' ? 'bg-accent text-white border-accent'
: 'bg-white text-gray-700 border-gray-300 hover:border-orange-500' : 'bg-surface text-gray-700 border-divider hover:border-accent'
}`} }`}
> >
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 rounded-lg border border-gray-300 px-3 py-2 text-sm" className="w-full border border-divider 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 rounded-lg py-2 text-sm font-semibold disabled:opacity-50"> className="w-full bg-gray-900 text-white 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-gray-200 mb-6 overflow-x-auto -mx-4 px-4"> <div className="flex border-b border-divider 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-blue-600 text-blue-600' ? 'border-accent text-accent-700'
: 'border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300' : 'border-transparent text-gray-500 hover:text-gray-700 hover:border-divider'
}`} }`}
> >
{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-gray-200" />}> <Suspense fallback={<div className="h-11 mb-6 border-b border-divider" />}>
<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-yellow-50 text-yellow-700 border-yellow-200', low: 'bg-neutral-100 text-neutral-800 border-divider',
medium: 'bg-orange-50 text-orange-700 border-orange-200', medium: 'bg-ground text-accent-700 border-accent',
high: 'bg-red-50 text-red-700 border-red-200', high: 'bg-accent-100 text-accent-800 border-accent',
} }
export function RiskFlagsPanel() { export function RiskFlagsPanel() {
@@ -43,7 +43,7 @@ export function RiskFlagsPanel() {
} }
return ( return (
<div className="bg-white rounded-xl shadow-sm p-5 mb-4"> <div className="bg-surface 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-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" 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"
> >
{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 rounded-lg p-3 ${LEVEL_COLORS[f.risk_level]}`}> <div key={`${f.site}-${f.zone}`} className={`border 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-green-400', green: 'border-divider',
yellow: 'border-yellow-400', yellow: 'border-accent-300',
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-white rounded-xl shadow-sm p-5 border-t-4 ${ACCENT[accent]}`}> <div className={`bg-surface 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-green-700 text-white rounded-lg px-4 py-2 text-sm font-semibold hover:bg-green-800 disabled:opacity-50" className="bg-accent text-white px-4 py-2 text-sm font-semibold hover:bg-accent-700 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-white rounded-xl shadow-sm p-5"> <div className="mt-6 bg-surface 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-gray-100 rounded-lg p-3"> <li key={a.id} className="border border-divider 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-gray-200 rounded-lg p-2 text-sm" className="w-full border border-divider 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 rounded-lg px-4 py-2 text-sm font-semibold hover:bg-gray-900 disabled:opacity-50" className="mt-2 bg-gray-800 text-white 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 rounded-lg overflow-hidden bg-gray-100 aspect-square hover:opacity-90 transition-opacity" className="block 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 rounded-lg p-6 text-center cursor-pointer transition-colors className={`border-2 border-dashed p-6 text-center cursor-pointer transition-colors
${dragging ? 'border-blue-500 bg-blue-50' : 'border-gray-300 hover:border-gray-400'} ${dragging ? 'border-accent bg-accent-100' : 'border-divider 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 rounded px-3 py-2 text-sm"> <li key={i} className="flex items-center justify-between bg-gray-50 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"
+5 -15
View File
@@ -1,4 +1,5 @@
import { EvidenceGallery } from './evidence-gallery' import { EvidenceGallery } from './evidence-gallery'
import { StatusTag } from '@/components/ui/status-tag'
const TYPE_LABELS: Record<string, string> = { const TYPE_LABELS: Record<string, string> = {
injury: 'Injury / Medical', injury: 'Injury / Medical',
@@ -11,15 +12,6 @@ const TYPE_LABELS: Record<string, string> = {
transport: 'Transport / Vehicle', transport: 'Transport / Vehicle',
} }
const STATUS_COLORS: Record<string, string> = {
reported: 'bg-yellow-100 text-yellow-800',
triaged: 'bg-blue-100 text-blue-800',
investigating: 'bg-purple-100 text-purple-800',
capa_pending: 'bg-orange-100 text-orange-800',
verification: 'bg-indigo-100 text-indigo-800',
closed: 'bg-green-100 text-green-800',
}
const MEDICAL_LABELS: Record<string, string> = { const MEDICAL_LABELS: Record<string, string> = {
none: 'None', none: 'None',
first_aid: 'First Aid', first_aid: 'First Aid',
@@ -72,7 +64,7 @@ export function IncidentDetail({ incident }: Props) {
return ( return (
<div className="space-y-6"> <div className="space-y-6">
<div className="bg-white rounded-xl shadow-sm p-5"> <div className="bg-surface 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">
@@ -80,9 +72,7 @@ export function IncidentDetail({ incident }: Props) {
</h1> </h1>
<p className="text-sm text-gray-600 mt-0.5">{TYPE_LABELS[incident.incident_type] ?? incident.incident_type}</p> <p className="text-sm text-gray-600 mt-0.5">{TYPE_LABELS[incident.incident_type] ?? incident.incident_type}</p>
</div> </div>
<span className={`text-xs px-2.5 py-1 rounded-full font-medium ${STATUS_COLORS[incident.status] ?? 'bg-gray-100'}`}> <StatusTag status={incident.status}>{incident.status.replace(/_/g, ' ').toUpperCase()}</StatusTag>
{incident.status.replace(/_/g, ' ').toUpperCase()}
</span>
</div> </div>
<dl className="grid grid-cols-2 gap-4 sm:grid-cols-3"> <dl className="grid grid-cols-2 gap-4 sm:grid-cols-3">
@@ -114,12 +104,12 @@ export function IncidentDetail({ incident }: Props) {
</dl> </dl>
</div> </div>
<div className="bg-white rounded-xl shadow-sm p-5"> <div className="bg-surface 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-white rounded-xl shadow-sm p-5"> <div className="bg-surface 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-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500" className="w-full pl-8 pr-3 py-1.5 text-sm border border-divider focus:outline-none focus:ring-2 focus:ring-accent"
/> />
</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-gray-300 rounded-lg px-2 py-1.5 focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white" className="text-sm border border-divider px-2 py-1.5 focus:outline-none focus:ring-2 focus:ring-accent bg-surface"
> >
{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-gray-300 rounded-lg px-2 py-1.5 focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white" className="text-sm border border-divider px-2 py-1.5 focus:outline-none focus:ring-2 focus:ring-accent bg-surface"
> >
{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-gray-300 rounded-lg px-2 py-1.5 focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white" className="text-sm border border-divider px-2 py-1.5 focus:outline-none focus:ring-2 focus:ring-accent bg-surface"
> >
<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-gray-300 rounded-lg px-2 py-1.5 focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white" className="text-sm border border-divider px-2 py-1.5 focus:outline-none focus:ring-2 focus:ring-accent bg-surface"
> >
<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>)}
+6 -16
View File
@@ -1,6 +1,7 @@
'use client' 'use client'
import Link from 'next/link' import Link from 'next/link'
import { StatusTag } from '@/components/ui/status-tag'
interface Props { interface Props {
incidentId: string incidentId: string
@@ -12,15 +13,6 @@ interface Props {
canAddCapa?: boolean canAddCapa?: boolean
} }
const STATUS_COLORS: Record<string, string> = {
reported: 'bg-yellow-100 text-yellow-800',
triaged: 'bg-blue-100 text-blue-800',
investigating: 'bg-purple-100 text-purple-800',
capa_pending: 'bg-orange-100 text-orange-800',
verification: 'bg-indigo-100 text-indigo-800',
closed: 'bg-green-100 text-green-800',
}
const STATUS_LABELS: Record<string, string> = { const STATUS_LABELS: Record<string, string> = {
reported: 'Reported', reported: 'Reported',
triaged: 'Triaged', triaged: 'Triaged',
@@ -35,7 +27,7 @@ export function IncidentHeader({
canTriage, canInvestigate, canAddCapa, canTriage, canInvestigate, canAddCapa,
}: Props) { }: Props) {
return ( return (
<div className="sticky top-0 z-30 bg-white border-b border-gray-200 shadow-sm"> <div className="sticky top-0 z-30 bg-surface border-b border-divider 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">
@@ -45,15 +37,13 @@ export function IncidentHeader({
<span className="text-sm font-mono font-semibold text-gray-900 truncate"> <span className="text-sm font-mono font-semibold text-gray-900 truncate">
{referenceNo ?? 'Pending'} {referenceNo ?? 'Pending'}
</span> </span>
<span className={`text-xs px-2 py-0.5 rounded-full font-medium shrink-0 ${STATUS_COLORS[status] ?? 'bg-gray-100 text-gray-800'}`}> <span className="shrink-0"><StatusTag status={status}>{STATUS_LABELS[status] ?? status.replace(/_/g, ' ')}</StatusTag></span>
{STATUS_LABELS[status] ?? status.replace(/_/g, ' ')}
</span>
</div> </div>
<div className="flex gap-2 shrink-0"> <div className="flex gap-2 shrink-0">
{canTriage && ( {canTriage && (
<Link <Link
href={`/hse/incidents/${incidentId}/triage`} href={`/hse/incidents/${incidentId}/triage`}
className="text-xs px-3 py-1.5 bg-blue-600 text-white rounded-lg font-medium hover:bg-blue-700" className="text-xs px-3 py-1.5 bg-accent text-white font-medium hover:bg-accent-600"
> >
Triage Triage
</Link> </Link>
@@ -61,7 +51,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-indigo-600 text-white rounded-lg font-medium hover:bg-indigo-700" className="text-xs px-3 py-1.5 bg-accent text-white font-medium hover:bg-accent-600"
> >
Investigate Investigate
</Link> </Link>
@@ -69,7 +59,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-amber-600 text-white rounded-lg font-medium hover:bg-amber-700" className="text-xs px-3 py-1.5 bg-accent text-white font-medium hover:bg-accent-600"
> >
Add CAPA Add CAPA
</Link> </Link>
+8 -16
View File
@@ -2,6 +2,7 @@
import { useState } from 'react' import { useState } from 'react'
import Link from 'next/link' import Link from 'next/link'
import { StatusTag } from '@/components/ui/status-tag'
const TYPE_LABELS: Record<string, string> = { const TYPE_LABELS: Record<string, string> = {
injury: 'Injury / Medical', injury: 'Injury / Medical',
@@ -14,14 +15,7 @@ const TYPE_LABELS: Record<string, string> = {
transport: 'Transport / Vehicle', transport: 'Transport / Vehicle',
} }
const STATUS_COLORS: Record<string, string> = { const STATUS_ORDER = ['reported', 'triaged', 'investigating', 'capa_pending', 'verification', 'closed'] as const
reported: 'bg-yellow-100 text-yellow-800',
triaged: 'bg-blue-100 text-blue-800',
investigating: 'bg-purple-100 text-purple-800',
capa_pending: 'bg-orange-100 text-orange-800',
verification: 'bg-indigo-100 text-indigo-800',
closed: 'bg-green-100 text-green-800',
}
export type Incident = { export type Incident = {
id: string id: string
@@ -66,12 +60,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-gray-300 rounded-lg px-3 py-2 text-sm w-48 focus:outline-none focus:ring-2 focus:ring-blue-500" className="border border-divider px-3 py-2 text-sm w-48 focus:outline-none focus:ring-2 focus:ring-accent"
value={search} value={search}
onChange={e => setSearch(e.target.value)} onChange={e => setSearch(e.target.value)}
/> />
<select <select
className="border border-gray-300 rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500" className="border border-divider px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-accent"
value={typeFilter} value={typeFilter}
onChange={e => setTypeFilter(e.target.value)} onChange={e => setTypeFilter(e.target.value)}
> >
@@ -81,12 +75,12 @@ export function IncidentList({ incidents, basePath }: Props) {
))} ))}
</select> </select>
<select <select
className="border border-gray-300 rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500" className="border border-divider px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-accent"
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>
{Object.keys(STATUS_COLORS).map(s => ( {STATUS_ORDER.map(s => (
<option key={s} value={s}>{s.replace(/_/g, ' ')}</option> <option key={s} value={s}>{s.replace(/_/g, ' ')}</option>
))} ))}
</select> </select>
@@ -95,7 +89,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-gray-100 bg-white rounded-xl shadow-sm overflow-hidden"> <div className="divide-y divide-divider bg-surface shadow-sm overflow-hidden">
{filtered.map(inc => ( {filtered.map(inc => (
<Link <Link
key={inc.id} key={inc.id}
@@ -107,9 +101,7 @@ export function IncidentList({ incidents, basePath }: Props) {
<span className="font-mono text-sm font-semibold text-gray-900"> <span className="font-mono text-sm font-semibold text-gray-900">
{inc.reference_no ?? '—'} {inc.reference_no ?? '—'}
</span> </span>
<span className={`text-xs px-2 py-0.5 rounded-full font-medium ${STATUS_COLORS[inc.status] ?? 'bg-gray-100 text-gray-700'}`}> <StatusTag status={inc.status}>{inc.status.replace(/_/g, ' ').toUpperCase()}</StatusTag>
{inc.status.replace(/_/g, ' ').toUpperCase()}
</span>
</div> </div>
<div className="text-sm text-gray-600"> <div className="text-sm text-gray-600">
{TYPE_LABELS[inc.incident_type] ?? inc.incident_type} {TYPE_LABELS[inc.incident_type] ?? inc.incident_type}
+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-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" 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"
> >
{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 rounded-lg text-sm font-medium border ${ className={`px-3 py-1.5 text-sm font-medium border ${
method === m method === m
? 'bg-blue-600 text-white border-blue-600' ? 'bg-accent text-white border-accent'
: 'bg-white text-gray-700 border-gray-300 hover:border-blue-400' : 'bg-surface text-gray-700 border-divider hover:border-accent'
}`} }`}
> >
{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-gray-200 rounded-lg p-3 space-y-2"> <div key={i} className="border border-divider 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 rounded border border-gray-300 px-2 py-1.5 text-sm" className="w-full border border-divider 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 rounded border border-gray-300 px-2 py-1.5 text-sm" className="w-full border border-divider 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-blue-600 hover:underline"> className="text-sm text-accent-700 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-gray-200 rounded-lg p-3"> <div key={cat.category} className="border border-divider 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 rounded border border-gray-300 px-2 py-1.5 text-sm mb-1.5" className="w-full border border-divider 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-blue-600 hover:underline"> className="text-xs text-accent-700 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 rounded-lg border border-gray-300 px-3 py-2 text-sm" className="w-full border border-divider 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 rounded-lg border border-gray-300 px-3 py-2 text-sm" className="w-full border border-divider 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 rounded border border-gray-300 px-2 py-1.5 text-sm mb-1.5" className="w-full border border-divider 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-blue-600 hover:underline" className="text-xs text-accent-700 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 rounded-lg border border-gray-300 px-3 py-2 text-sm" className="w-full border border-divider 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 rounded-lg border border-gray-300 px-3 py-2 text-sm" className="w-full border border-divider 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="rounded border-gray-300 text-blue-600" /> className="border-divider text-accent-700" />
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-indigo-600 text-white rounded-lg py-2 text-sm font-semibold disabled:opacity-50"> className="w-full bg-accent text-white 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-white rounded-xl shadow-sm border border-gray-200 overflow-hidden"> <div className="mt-6 bg-surface shadow-sm border border-divider overflow-hidden">
<div className="flex items-center justify-between px-5 py-4 border-b border-gray-100"> <div className="flex items-center justify-between px-5 py-4 border-b border-divider">
<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 rounded-full ${ <span className={`text-xs font-medium px-2 py-0.5 ${
inv.completed_at inv.completed_at
? 'bg-green-100 text-green-700' ? 'bg-neutral-100 text-ink'
: 'bg-yellow-100 text-yellow-700' : 'bg-accent-100 text-accent-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 rounded-full bg-blue-100 text-blue-700 text-xs font-bold flex items-center justify-center"> <span className="flex-shrink-0 w-6 h-6 bg-accent-100 text-accent-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 rounded-lg px-4 py-3"> <div className="bg-red-50 border border-red-100 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-yellow-50 border border-yellow-300 rounded-lg p-3 flex items-center justify-between shadow-md z-50"> <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">
<span className="text-sm text-yellow-800 font-medium"> <span className="text-sm text-accent-700 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-yellow-600 text-white px-3 py-1.5 rounded font-medium className="text-xs bg-accent text-white px-3 py-1.5 font-medium
hover:bg-yellow-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors" hover:bg-accent-600 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-blue-600 hover:underline"> <Link href={`${href}?page=${p}`} className="px-3 py-1.5 text-sm text-accent-700 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-gray-300 rounded-lg px-3 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500" className="w-full border border-divider px-3 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-accent"
/> />
</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-blue-600" className="w-4 h-4 text-accent-700"
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-green-50 border border-green-200 rounded-xl p-5 text-sm text-green-700"> <div className="bg-neutral-100 border border-divider p-5 text-sm text-ink">
{t.savedOffline} {t.savedOffline}
</div> </div>
) )
} }
return ( return (
<form onSubmit={handleSubmit} className="space-y-5 bg-white rounded-xl shadow-sm p-5"> <form onSubmit={handleSubmit} className="space-y-5 bg-surface shadow-sm p-5">
{!isOnline && ( {!isOnline && (
<div className="bg-yellow-50 border border-yellow-200 rounded p-3 text-sm text-yellow-700"> <div className="bg-accent-100 border border-accent-300 p-3 text-sm text-accent-700">
{t.offlineBanner} {t.offlineBanner}
</div> </div>
)} )}
{error && ( {error && (
<div className="bg-red-50 border border-red-200 rounded p-3 text-sm text-red-700"> <div className="bg-red-50 border border-red-200 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-gray-300 rounded-lg px-3 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500" className="w-full border border-divider px-3 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-accent"
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-gray-200 rounded-lg p-3"> <div className="space-y-3 border border-divider 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-gray-200 rounded-lg p-3"> <div className="space-y-3 border border-divider 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-gray-200 rounded-lg p-3"> <div className="space-y-3 border border-divider 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-gray-200 rounded-lg p-3"> <div className="space-y-3 border border-divider 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-gray-300 rounded-lg px-3 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500" className="w-full border border-divider px-3 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-accent"
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-gray-300 rounded-lg px-3 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 resize-none" className="w-full border border-divider px-3 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-accent 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="rounded-lg bg-amber-50 border border-amber-200 p-3 space-y-2"> <div className="bg-accent-100 border border-accent-300 p-3 space-y-2">
<p className="text-xs font-semibold text-amber-700 uppercase tracking-wide"> <p className="text-xs font-semibold text-accent-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-amber-800">{qualityCheck.feedback}</p> <p className="text-sm text-accent-700">{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-amber-700">{s}</li> <li key={i} className="text-xs text-accent-700">{s}</li>
))} ))}
</ul> </ul>
)} )}
<label className="flex items-center gap-2 text-xs text-amber-700 cursor-pointer mt-1"> <label className="flex items-center gap-2 text-xs text-accent-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="rounded border-amber-300 text-amber-600" className="border-accent-300 text-accent-700"
/> />
{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-blue-600" className="w-4 h-4 text-accent-700"
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-gray-300 rounded-lg px-3 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500" className="w-full border border-divider px-3 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-accent"
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-blue-600" className="w-4 h-4 text-accent-700"
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-blue-600 text-white py-3 rounded-lg font-medium text-sm className="w-full bg-accent text-white py-3 font-medium text-sm
hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors" hover:bg-accent-600 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-white rounded-xl shadow-sm p-5"> <div className="mt-6 bg-surface 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-white rounded-xl shadow-sm p-5"> <div className="mt-6 bg-surface 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-gray-200 rounded-lg p-3 hover:border-blue-300 hover:bg-blue-50 transition-colors" className="block border border-divider p-3 hover:border-accent hover:bg-neutral-100 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 rounded-lg border border-gray-300 overflow-hidden divide-x divide-gray-300"> <div className="flex border border-divider overflow-hidden divide-x divide-divider">
{([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-blue-600 text-white border-blue-600' ? 'bg-accent text-white border-accent'
: 'bg-white text-gray-700 hover:bg-gray-50' : 'bg-surface 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="rounded border-gray-300 text-blue-600" className="border-divider text-accent-700"
/> />
{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="rounded-lg bg-red-50 border border-red-200 p-3 space-y-1"> <div className="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 rounded-lg border border-gray-300 px-3 py-2 text-sm focus:ring-2 focus:ring-blue-500 focus:border-transparent" className="w-full border border-divider px-3 py-2 text-sm focus:ring-2 focus:ring-accent focus:border-transparent"
placeholder="Initial assessment, immediate actions taken..." placeholder="Initial assessment, immediate actions taken..."
/> />
</div> </div>
{aiRationale && ( {aiRationale && (
<div className="rounded-lg bg-purple-50 border border-purple-200 p-3"> <div className="bg-accent-100 border border-accent-300 p-3">
<p className="text-xs font-semibold text-purple-700 mb-1">AI Suggestion Rationale</p> <p className="text-xs font-semibold text-accent-700 mb-1">AI Suggestion Rationale</p>
<p className="text-xs text-purple-600">{aiRationale}</p> <p className="text-xs text-accent-700">{aiRationale}</p>
<p className="text-xs text-purple-400 mt-1">Fields pre-filled — review before submitting.</p> <p className="text-xs text-accent-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-purple-50 text-purple-700 border border-purple-300 rounded-lg py-2 text-sm font-semibold disabled:opacity-50 hover:bg-purple-100" 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"
> >
{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-blue-600 text-white rounded-lg py-2 text-sm font-semibold disabled:opacity-50" className="flex-1 bg-accent text-white 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-gray-300 rounded px-2 py-1 bg-white text-gray-700 focus:outline-none focus:ring-1 focus:ring-blue-500" className="text-xs border border-divider px-2 py-1 bg-surface text-gray-700 focus:outline-none focus:ring-1 focus:ring-accent"
> >
{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>
+57 -89
View File
@@ -2,6 +2,17 @@
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 {
@@ -16,52 +27,15 @@ interface SidebarProps {
userEmail: string userEmail: string
} }
const IconGrid = () => ( const IconGrid = () => <AlignLeft size={20} aria-hidden />
<svg className="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"> const IconList = () => <ClipboardList size={20} aria-hidden />
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M4 6h16M4 12h16M4 18h7" /> const IconCheck = () => <CircleCheck size={20} aria-hidden />
</svg> const IconChart = () => <LayoutDashboard size={20} aria-hidden />
) const IconSettings = () => <Settings size={20} aria-hidden />
const IconList = () => ( const IconUsers = () => <Users size={20} aria-hidden />
<svg className="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"> const IconPlus = () => <Plus size={20} 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 IconLogout = () => <LogOut size={16} aria-hidden />
</svg> const IconUser = () => <User size={16} aria-hidden />
)
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: [
@@ -94,6 +68,12 @@ 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(' ')
@@ -107,23 +87,19 @@ function useNavItems(role: string): NavItem[] {
return NAV_ITEMS[role] ?? NAV_ITEMS.reporter return NAV_ITEMS[role] ?? NAV_ITEMS.reporter
} }
function NavLink({ item, pathname }: { item: NavItem; pathname: string }) { const LINK_BASE = 'flex items-center gap-3 px-3 py-2 text-sm border-l-2 transition-colors'
// Exact match for root-level single-page roles, prefix match otherwise const LINK_ACTIVE = 'border-accent text-accent-700 font-extrabold bg-accent-100/50'
const exactRoots = ['/reporter', '/supervisor', '/management', '/capa-owner', '/admin', '/report', '/account'] const LINK_IDLE = 'border-transparent text-ink/70 font-medium hover:bg-ink/7 hover:text-ink'
const isActive = exactRoots.includes(item.href)
? pathname === item.href
: pathname.startsWith(item.href)
function NavLink({ item, pathname }: { item: NavItem; pathname: string }) {
const active = isActivePath(item.href, pathname)
return ( return (
<Link <Link
href={item.href} href={item.href}
className={`flex items-center gap-3 px-3 py-2 rounded-lg text-sm font-medium transition-colors ${ aria-current={active ? 'page' : undefined}
isActive className={`${LINK_BASE} ${active ? LINK_ACTIVE : LINK_IDLE}`}
? 'bg-blue-50 text-blue-700'
: 'text-gray-600 hover:bg-gray-100 hover:text-gray-900'
}`}
> >
<span className={isActive ? 'text-blue-600' : 'text-gray-400'}>{item.icon}</span> <span className={active ? 'text-accent-700' : 'text-ink/50'}>{item.icon}</span>
{item.label} {item.label}
</Link> </Link>
) )
@@ -143,74 +119,67 @@ 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-white border-r border-gray-200 flex-col z-40"> <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">
{/* Header */} <div className="flex items-center justify-between px-4 py-4 border-b-2 border-divider">
<div className="flex items-center justify-between px-4 py-4 border-b border-gray-100"> <span className="text-lg font-extrabold tracking-tight text-ink">IMS</span>
<span className="text-base font-bold text-gray-900 tracking-tight">IMS</span>
<NotificationBell /> <NotificationBell />
</div> </div>
{/* Nav */} <nav className="flex-1 overflow-y-auto py-3">
<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>
{/* User + logout */} <div className="border-t-2 border-divider py-3">
<div className="border-t border-gray-100 px-3 py-3"> <div className="flex items-center gap-2 px-4 py-2 mb-1">
<div className="flex items-center gap-2 px-2 py-2 mb-1"> <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="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-medium text-gray-900 truncate">{displayName}</p> <p className="text-sm font-extrabold text-ink truncate">{displayName}</p>
<p className="text-xs text-gray-500 truncate">{roleLabel}</p> <p className="text-xs text-ink/60 truncate">{roleLabel}</p>
</div> </div>
</div> </div>
<Link <Link
href="/account" href="/account"
className={`flex items-center gap-2 w-full px-3 py-2 text-sm rounded-lg transition-colors ${ aria-current={accountActive ? 'page' : undefined}
pathname === '/account' className={`${LINK_BASE} ${accountActive ? LINK_ACTIVE : LINK_IDLE}`}
? 'bg-blue-50 text-blue-700'
: 'text-gray-600 hover:bg-gray-100 hover:text-gray-900'
}`}
> >
<span className={pathname === '/account' ? 'text-blue-600' : 'text-gray-400'}> <span className={accountActive ? 'text-accent-700' : 'text-ink/50'}>
<IconUser /> <IconUser />
</span> </span>
Account Account
</Link> </Link>
<button <button
onClick={logout} onClick={logout}
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" className={`${LINK_BASE} ${LINK_IDLE} w-full text-left cursor-pointer`}
> >
<IconLogout /> <span className="text-ink/50"><IconLogout /></span>
Logout Logout
</button> </button>
<div className="mt-3 pt-3 border-t border-gray-100 px-2 text-center"> <div className="mt-3 pt-3 border-t border-divider px-4">
<p className="text-xs text-gray-400">v1.2.2</p> <p className="text-xs text-ink/50">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-white border-t border-gray-200 flex z-40 safe-area-pb"> <nav className="sm:hidden fixed bottom-0 left-0 right-0 bg-ground border-t-2 border-divider flex z-40 safe-area-pb">
{mobileItems.map(item => { {mobileItems.map(item => {
const exactRoots = ['/reporter', '/supervisor', '/management', '/capa-owner', '/admin', '/report', '/account'] const active = isActivePath(item.href, pathname)
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}
className={`flex-1 flex flex-col items-center gap-1 py-2 text-[10px] font-medium transition-colors ${ aria-current={active ? 'page' : undefined}
isActive ? 'text-blue-600' : 'text-gray-400' className={`flex-1 flex flex-col items-center gap-1 py-2 text-[10px] font-extrabold transition-colors ${
active ? 'text-accent-700' : 'text-ink/55'
}`} }`}
> >
{item.icon} {item.icon}
@@ -218,11 +187,10 @@ 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-medium text-gray-400" className="flex-1 flex flex-col items-center gap-1 py-2 text-[10px] font-extrabold text-ink/55 cursor-pointer"
> >
<IconLogout /> <IconLogout />
<span className="leading-none">Logout</span> <span className="leading-none">Logout</span>
+8 -7
View File
@@ -2,6 +2,7 @@
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
@@ -62,22 +63,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-white rounded-full shadow-sm border border-gray-200 w-10 h-10 flex items-center justify-center hover:shadow-md transition-shadow" 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"
> >
<span className="text-lg" aria-hidden>🔔</span> <Bell size={18} strokeWidth={2} aria-hidden />
{unread > 0 && ( {unread > 0 && (
<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"> <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">
{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-white rounded-xl shadow-lg border border-gray-200"> <div className="absolute right-0 mt-2 w-80 max-h-96 overflow-y-auto bg-surface shadow-lg border border-divider">
<div className="flex items-center justify-between px-4 py-2 border-b border-gray-100"> <div className="flex items-center justify-between px-4 py-2 border-b-2 border-divider">
<span className="text-sm font-semibold text-gray-700">Notifications</span> <span className="text-sm font-extrabold text-ink">Notifications</span>
{unread > 0 && ( {unread > 0 && (
<button onClick={markAllRead} className="text-xs text-blue-600 hover:underline"> <button onClick={markAllRead} className="text-xs text-accent-700 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-white rounded-xl shadow-sm p-5"> <div key={key} className="bg-surface 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 rounded-full ${ <span className={`text-xs font-medium px-2 py-0.5 ${
status?.set status?.set
? 'bg-green-100 text-green-700' ? 'bg-neutral-100 text-ink'
: 'bg-yellow-100 text-yellow-700' : 'bg-accent-100 text-accent-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-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" 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"
/> />
<button <button
onClick={() => save(key)} onClick={() => save(key)}
disabled={saving[key] || !values[key]} disabled={saving[key] || !values[key]}
className="bg-blue-600 text-white rounded-lg px-4 py-2 text-sm font-semibold disabled:opacity-50 hover:bg-blue-700" className="bg-accent text-white px-4 py-2 text-sm font-semibold disabled:opacity-50 hover:bg-accent-600"
> >
{saving[key] ? 'Saving…' : 'Save'} {saving[key] ? 'Saving…' : 'Save'}
</button> </button>
</div> </div>
{results[key] === 'ok' && ( {results[key] === 'ok' && (
<p className="text-xs text-green-600 mt-2">Saved. Reload the page to confirm.</p> <p className="text-xs text-ink 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
@@ -0,0 +1,25 @@
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
@@ -0,0 +1,22 @@
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
@@ -0,0 +1,2 @@
export const cx = (...parts: Array<string | false | null | undefined>): string =>
parts.filter(Boolean).join(' ')
+30
View File
@@ -0,0 +1,30 @@
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} />
}
+12 -10
View File
@@ -1,6 +1,7 @@
'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
@@ -25,20 +26,21 @@ 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-gray-900/50" onClick={onClose} /> <div className="absolute inset-0 bg-neutral-900/50" onClick={onClose} />
<div className={`relative w-full ${maxW} bg-white rounded-2xl shadow-2xl`}> <div className={`relative w-full ${maxW} bg-surface shadow-lg`}>
<div className="flex items-center justify-between px-6 py-4 border-b border-gray-100"> <div className="flex items-center justify-between px-6 py-4 border-b-2 border-divider">
<h2 className="text-sm font-semibold text-gray-900">{title}</h2> <h2 className="text-xl font-extrabold text-ink">{title}</h2>
<button onClick={onClose} aria-label="Close" <button
className="text-gray-400 hover:text-gray-600 p-1 rounded-lg hover:bg-gray-100 transition-colors cursor-pointer"> onClick={onClose}
<svg className="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2.5}> aria-label="Close"
<path strokeLinecap="round" strokeLinejoin="round" d="M6 18 18 6M6 6l12 12" /> 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"
</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-gray-100 flex justify-end gap-2"> <div className="px-6 py-4 border-t border-divider flex justify-end gap-2">
{footer} {footer}
</div> </div>
)} )}
+72
View File
@@ -0,0 +1,72 @@
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
@@ -0,0 +1,5 @@
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
@@ -0,0 +1,24 @@
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>
)
}
@@ -0,0 +1,151 @@
{
"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"
]
}
}
@@ -0,0 +1,11 @@
/* @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
@@ -0,0 +1,81 @@
# 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.
@@ -0,0 +1,252 @@
/* 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,7 +1,7 @@
# Modernist Design System Restyle # Modernist Design System Restyle
**Date:** 2026-09-30 **Date:** 2026-09-30
**Status:** Draft, awaiting user review **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. **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 ## Decisions
@@ -65,7 +65,7 @@ Install `lucide-react` and replace the inline SVGs in the sidebar, modal, nav, a
### 5. Imagery ### 5. Imagery
Wrap evidence thumbnails and any content photographs in a `grayscale` class (`filter: grayscale(1) contrast(1.08)`). Exception: photos that document an incident where color carries evidence. Open question below. 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) ### 6. Status and priority colors (design decision)
@@ -111,7 +111,7 @@ A build-only deploy per the IMS deployment procedure (`/srv/apps/ims/app`, never
- **Archivo 800 headings** are wider than Geist and can overflow narrow table headers and mobile nav labels. Check at 360px. - **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. - **Visual diff is large** (62 files of class changes), so review in a browser, not only via the diff.
## Open questions ## Resolved decisions
1. Is the status mapping in section 6 acceptable, or should green be kept as a second semantic color for "closed/verified"? 1. Status mapping in section 6 is approved as written. Green is not kept for "closed/verified".
2. Should incident evidence photos be forced to grayscale, or exempted because color can carry evidence? 2. Evidence photos are exempt from grayscale (section 5).
+18 -2
View File
@@ -16,6 +16,7 @@
"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",
@@ -3226,7 +3227,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==",
"dev": true, "devOptional": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"csstype": "^3.2.2" "csstype": "^3.2.2"
@@ -4681,7 +4682,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==",
"dev": true, "devOptional": true,
"license": "MIT" "license": "MIT"
}, },
"node_modules/d": { "node_modules/d": {
@@ -8169,6 +8170,21 @@
"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",
+3 -1
View File
@@ -9,7 +9,8 @@
"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",
@@ -20,6 +21,7 @@
"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
@@ -0,0 +1,61 @@
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
@@ -0,0 +1,54 @@
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()
+41
View File
@@ -0,0 +1,41 @@
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
@@ -0,0 +1,52 @@
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
@@ -0,0 +1,132 @@
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
@@ -0,0 +1,62 @@
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
@@ -0,0 +1,45 @@
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
@@ -0,0 +1,55 @@
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)
})
})