Compare commits
13
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
137780d013 | ||
|
|
c5a98eed06 | ||
|
|
ba9eeefe47 | ||
|
|
0b5020b3d0 | ||
|
|
e7416bf236 | ||
|
|
4411ed54b5 | ||
|
|
3a941a357b | ||
|
|
8701d24c6c | ||
|
|
106136e902 | ||
|
|
ef7f1c9660 | ||
|
|
bf178d5b8d | ||
|
|
38ccc44933 | ||
|
|
d2707ac3df |
@@ -51,3 +51,6 @@ graphify-out/
|
||||
|
||||
# iCloud sync conflict copies ("name 2.ext")
|
||||
* 2.*
|
||||
|
||||
# local scratch (data exports, deploy archives)
|
||||
tmp/
|
||||
|
||||
@@ -62,6 +62,21 @@ IMS/
|
||||
- `[[phases]]` — 4 phases + deliverables, current phase
|
||||
- `[[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
|
||||
When graphify-out/graph.json exists:
|
||||
- Run `graphify query "<question>"` before browsing source.
|
||||
|
||||
@@ -32,7 +32,7 @@ export default function ForgotPasswordPage() {
|
||||
<p className="text-sm text-gray-500">
|
||||
If an account exists for <strong>{email}</strong>, a password reset link has been sent.
|
||||
</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
|
||||
</Link>
|
||||
</div>
|
||||
@@ -57,19 +57,19 @@ export default function ForgotPasswordPage() {
|
||||
onChange={e => setEmail(e.target.value)}
|
||||
required
|
||||
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
|
||||
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"
|
||||
className="bg-accent hover:bg-accent-600 text-white font-medium py-2 disabled:opacity-50 transition-colors"
|
||||
>
|
||||
{loading ? 'Sending…' : 'Send reset link'}
|
||||
</button>
|
||||
|
||||
<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
|
||||
</Link>
|
||||
</p>
|
||||
|
||||
@@ -8,13 +8,13 @@ interface Props {
|
||||
export default async function LoginPage({ searchParams }: Props) {
|
||||
const { message } = await searchParams
|
||||
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' && (
|
||||
<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.
|
||||
</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 />
|
||||
</div>
|
||||
</main>
|
||||
|
||||
@@ -50,7 +50,7 @@ export default function ResetPasswordPage() {
|
||||
</div>
|
||||
|
||||
{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.includes('expired') && (
|
||||
<Link href="/forgot-password" className="underline">
|
||||
@@ -68,7 +68,7 @@ export default function ResetPasswordPage() {
|
||||
required
|
||||
minLength={8}
|
||||
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
|
||||
type="password"
|
||||
@@ -77,13 +77,13 @@ export default function ResetPasswordPage() {
|
||||
onChange={e => setConfirm(e.target.value)}
|
||||
required
|
||||
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
|
||||
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"
|
||||
className="bg-accent hover:bg-accent-600 text-white font-medium py-2 disabled:opacity-50 transition-colors"
|
||||
>
|
||||
{loading ? 'Saving…' : 'Set password'}
|
||||
</button>
|
||||
|
||||
@@ -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>
|
||||
</div>
|
||||
<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
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
@@ -9,6 +9,7 @@ import { eq, asc } from 'drizzle-orm'
|
||||
import { StatCard } from '@/components/dashboard/stat-card'
|
||||
import { CapaOwnerActions } from '@/components/capa/capa-owner-actions'
|
||||
import { CapaOwnerNotesForm } from '@/components/capa/capa-owner-notes-form'
|
||||
import { StatusTag } from '@/components/ui/status-tag'
|
||||
|
||||
const STATUS_LABELS: Record<string, string> = {
|
||||
open: 'Open',
|
||||
@@ -20,16 +21,6 @@ const STATUS_LABELS: Record<string, string> = {
|
||||
closed: 'Closed',
|
||||
}
|
||||
|
||||
const STATUS_COLORS: Record<string, string> = {
|
||||
open: 'bg-gray-100 text-gray-700',
|
||||
in_progress: 'bg-blue-100 text-blue-700',
|
||||
overdue: 'bg-red-100 text-red-700',
|
||||
pending_verification: 'bg-purple-100 text-purple-700',
|
||||
verified: 'bg-green-100 text-green-700',
|
||||
reopened: 'bg-orange-100 text-orange-700',
|
||||
closed: 'bg-gray-100 text-gray-500',
|
||||
}
|
||||
|
||||
export default async function CapaOwnerPage() {
|
||||
const session = await getSession()
|
||||
if (!session) redirect('/login')
|
||||
@@ -63,9 +54,9 @@ export default async function CapaOwnerPage() {
|
||||
const doneCount = rows.filter(c => ['verified', 'closed'].includes(c.status)).length
|
||||
|
||||
const PRIORITY_COLORS: Record<string, string> = {
|
||||
high: 'text-red-600 font-semibold',
|
||||
med: 'text-orange-500 font-medium',
|
||||
low: 'text-gray-400',
|
||||
high: 'text-accent-700 font-extrabold',
|
||||
med: 'text-accent-700 font-medium',
|
||||
low: 'text-ink/50',
|
||||
}
|
||||
|
||||
const activeRows = rows.filter(c => !['verified', 'closed'].includes(c.status))
|
||||
@@ -82,11 +73,11 @@ export default async function CapaOwnerPage() {
|
||||
</div>
|
||||
|
||||
{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>
|
||||
</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 => {
|
||||
const isOverdue = isCapaOverdue(capa)
|
||||
return (
|
||||
@@ -95,15 +86,13 @@ export default async function CapaOwnerPage() {
|
||||
<div className="flex-1 min-w-0">
|
||||
<p className="text-sm text-gray-800">{capa.description}</p>
|
||||
{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}
|
||||
</Link>
|
||||
)}
|
||||
</div>
|
||||
<div className="shrink-0 text-right space-y-1">
|
||||
<span className={`text-xs rounded-full px-2 py-0.5 ${STATUS_COLORS[capa.status] ?? 'bg-gray-100 text-gray-600'}`}>
|
||||
{STATUS_LABELS[capa.status] ?? capa.status}
|
||||
</span>
|
||||
<StatusTag status={capa.status}>{STATUS_LABELS[capa.status] ?? capa.status}</StatusTag>
|
||||
<p className={`text-xs ${isOverdue ? 'text-red-600 font-semibold' : 'text-gray-400'}`}>
|
||||
{capa.dueDate ? `Due ${new Date(capa.dueDate).toLocaleDateString('en-MY')}` : 'No due date'}
|
||||
</p>
|
||||
@@ -127,13 +116,11 @@ export default async function CapaOwnerPage() {
|
||||
{doneRows.length > 0 && (
|
||||
<div className="mt-6">
|
||||
<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 => (
|
||||
<div key={capa.id} className="p-4 flex items-center justify-between">
|
||||
<p className="text-sm text-gray-500 line-clamp-1">{capa.description}</p>
|
||||
<span className={`text-xs rounded-full px-2 py-0.5 ml-4 shrink-0 ${STATUS_COLORS[capa.status] ?? 'bg-gray-100'}`}>
|
||||
{STATUS_LABELS[capa.status] ?? capa.status}
|
||||
</span>
|
||||
<span className="shrink-0"><StatusTag status={capa.status}>{STATUS_LABELS[capa.status] ?? capa.status}</StatusTag></span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
@@ -10,17 +10,12 @@ import { aliasedTable } from 'drizzle-orm'
|
||||
import { VerifyForm } from '@/components/capa/verify-form'
|
||||
import { CloseCapaButton } from '@/components/capa/close-capa-button'
|
||||
import { CapaOwnerActions } from '@/components/capa/capa-owner-actions'
|
||||
import { PriorityTag } from '@/components/ui/status-tag'
|
||||
|
||||
interface Props {
|
||||
params: Promise<{ id: string }>
|
||||
}
|
||||
|
||||
const PRIORITY_BADGE: Record<string, string> = {
|
||||
low: 'bg-gray-100 text-gray-600',
|
||||
med: 'bg-yellow-100 text-yellow-700',
|
||||
high: 'bg-red-100 text-red-700',
|
||||
}
|
||||
|
||||
export default async function CapaDetailPage({ params }: Props) {
|
||||
const { id } = await params
|
||||
const session = await getSession()
|
||||
@@ -58,11 +53,11 @@ export default async function CapaDetailPage({ params }: Props) {
|
||||
|
||||
return (
|
||||
<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
|
||||
</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>
|
||||
<p className="text-xs text-gray-500 mb-1">
|
||||
@@ -70,9 +65,7 @@ export default async function CapaDetailPage({ params }: Props) {
|
||||
</p>
|
||||
<p className="text-gray-900 font-medium">{capa.description}</p>
|
||||
</div>
|
||||
<span className={`px-2 py-1 rounded text-xs font-semibold ${PRIORITY_BADGE[capa.priority] ?? ''}`}>
|
||||
{capa.priority}
|
||||
</span>
|
||||
<PriorityTag priority={capa.priority} />
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-2 gap-3 text-sm">
|
||||
|
||||
@@ -52,7 +52,7 @@ export default async function CapaListPage() {
|
||||
<main className="max-w-6xl mx-auto px-4 py-6">
|
||||
<div className="flex items-center justify-between mb-6">
|
||||
<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
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
@@ -165,17 +165,17 @@ export default async function HseDashboardPage({
|
||||
<div className="flex gap-3">
|
||||
<a
|
||||
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
|
||||
</a>
|
||||
<a
|
||||
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
|
||||
</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 →
|
||||
</Link>
|
||||
</div>
|
||||
@@ -187,8 +187,8 @@ export default async function HseDashboardPage({
|
||||
{(tab === 'overview') && (
|
||||
<>
|
||||
{now.getMonth() === 0 && (
|
||||
<div className="bg-amber-50 border border-amber-200 rounded-xl p-4 mb-6">
|
||||
<p className="text-sm text-amber-800">
|
||||
<div className="bg-accent-100 border border-accent-300 p-4 mb-6">
|
||||
<p className="text-sm text-accent-700">
|
||||
<strong>JKKP 8 annual register due:</strong> the {now.getFullYear() - 1} register must be
|
||||
submitted to DOSH before 31 January {now.getFullYear()}.{' '}
|
||||
<a href={`/api/reports/jkkp8?year=${now.getFullYear() - 1}`} className="underline font-medium">
|
||||
@@ -210,7 +210,7 @@ export default async function HseDashboardPage({
|
||||
/>
|
||||
</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">
|
||||
Leading vs Lagging — Last 30 Days
|
||||
</h2>
|
||||
@@ -218,18 +218,18 @@ export default async function HseDashboardPage({
|
||||
Leading: hazard + near-miss reports (predict risk) · Lagging: injuries (past harm)
|
||||
</p>
|
||||
<div className="flex gap-4">
|
||||
<div className="flex-1 text-center bg-blue-50 rounded-lg p-4">
|
||||
<p className="text-3xl font-bold text-blue-600">{leadingCount}</p>
|
||||
<p className="text-xs text-blue-700 mt-1">Leading (Hazards + Near Misses)</p>
|
||||
<div className="flex-1 text-center bg-neutral-100 p-4">
|
||||
<p className="text-3xl font-bold text-accent-700">{leadingCount}</p>
|
||||
<p className="text-xs text-accent-700 mt-1">Leading (Hazards + Near Misses)</p>
|
||||
</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-xs text-red-700 mt-1">Lagging (Injuries)</p>
|
||||
</div>
|
||||
{capaOnTimeRate !== null && (
|
||||
<div className="flex-1 text-center bg-green-50 rounded-lg p-4">
|
||||
<p className="text-3xl font-bold text-green-600">{capaOnTimeRate}%</p>
|
||||
<p className="text-xs text-green-700 mt-1">CAPA On-Time Rate</p>
|
||||
<div className="flex-1 text-center bg-neutral-100 p-4">
|
||||
<p className="text-3xl font-bold text-ink">{capaOnTimeRate}%</p>
|
||||
<p className="text-xs text-ink mt-1">CAPA On-Time Rate</p>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
@@ -240,7 +240,7 @@ export default async function HseDashboardPage({
|
||||
{/* Trends tab */}
|
||||
{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">
|
||||
Incident Trend — Last 12 Months
|
||||
</h2>
|
||||
@@ -253,7 +253,7 @@ export default async function HseDashboardPage({
|
||||
return (
|
||||
<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 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-gray-300" style={{ height: `${(Math.max(0, other) / monthlyMax) * 192}px` }} />
|
||||
</div>
|
||||
@@ -266,7 +266,7 @@ export default async function HseDashboardPage({
|
||||
</div>
|
||||
|
||||
{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>
|
||||
<ol className="space-y-2">
|
||||
{rootCauses.map((rc, i) => (
|
||||
@@ -288,7 +288,7 @@ export default async function HseDashboardPage({
|
||||
{tab === 'zones' && (
|
||||
<>
|
||||
{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">
|
||||
Zone Incident Heatmap — Last 90 Days
|
||||
</h2>
|
||||
@@ -296,9 +296,9 @@ export default async function HseDashboardPage({
|
||||
{by_zone.map(({ name, count }) => (
|
||||
<div key={name} className="flex items-center gap-3">
|
||||
<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
|
||||
className="h-3 rounded-full"
|
||||
className="h-3"
|
||||
style={{
|
||||
width: `${(count / zoneMax) * 100}%`,
|
||||
backgroundColor: `hsl(220, 70%, ${Math.max(30, 80 - Math.round((count / zoneMax) * 50))}%)`,
|
||||
@@ -312,15 +312,15 @@ export default async function HseDashboardPage({
|
||||
</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>
|
||||
<div className="space-y-2">
|
||||
{Object.entries(by_type).sort((a, b) => b[1] - a[1]).map(([type, count]) => (
|
||||
<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>
|
||||
<div className="flex-1 bg-gray-100 rounded-full h-2">
|
||||
<div className="flex-1 bg-gray-100 h-2">
|
||||
<div
|
||||
className="bg-blue-500 h-2 rounded-full"
|
||||
className="bg-accent h-2"
|
||||
style={{ width: total > 0 ? `${(count / total) * 100}%` : '0%' }}
|
||||
/>
|
||||
</div>
|
||||
@@ -333,7 +333,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-4">By Site</h2>
|
||||
<div className="space-y-2">
|
||||
{by_site.map(({ name, count }) => (
|
||||
|
||||
@@ -31,7 +31,7 @@ export default async function NewCapaPage({ params }: Props) {
|
||||
|
||||
return (
|
||||
<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
|
||||
</Link>
|
||||
<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 (
|
||||
<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
|
||||
</Link>
|
||||
<h1 className="text-xl font-bold text-gray-900 mb-1">Investigation Workspace</h1>
|
||||
|
||||
@@ -175,14 +175,14 @@ export default async function HseIncidentDetailPage({ params }: Props) {
|
||||
<a
|
||||
href={`/api/incidents/${id}/jkkp-pdf?form=jkkp6`}
|
||||
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)
|
||||
</a>
|
||||
<a
|
||||
href={`/api/incidents/${id}/jkkp-pdf?form=jkkp7`}
|
||||
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)
|
||||
</a>
|
||||
@@ -194,7 +194,7 @@ export default async function HseIncidentDetailPage({ params }: Props) {
|
||||
href={`/api/incidents/${id}/report-pdf`}
|
||||
target="_blank"
|
||||
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}>
|
||||
<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 (
|
||||
<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
|
||||
</Link>
|
||||
<h1 className="text-xl font-bold text-gray-900 mb-1">Triage Incident</h1>
|
||||
|
||||
@@ -13,12 +13,12 @@ export default async function HsePage() {
|
||||
<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>
|
||||
<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="font-semibold text-gray-900">Incident Inbox</div>
|
||||
<div className="text-xs text-gray-500 mt-1">View all incidents</div>
|
||||
</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="font-semibold text-gray-900">Dashboard</div>
|
||||
<div className="text-xs text-gray-500 mt-1">Stats & overview</div>
|
||||
|
||||
@@ -13,7 +13,7 @@ export default async function ProtectedLayout({
|
||||
if (!session) redirect('/login')
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-gray-50">
|
||||
<div className="min-h-screen bg-ground">
|
||||
<Sidebar
|
||||
role={session.role}
|
||||
userName={session.name}
|
||||
|
||||
@@ -88,7 +88,7 @@ export default async function ManagementPage() {
|
||||
|
||||
const SEVERITY_LABELS: Record<number, string> = { 1: 'Minor', 2: 'Low', 3: 'Moderate', 4: 'Serious', 5: 'Critical' }
|
||||
const SEVERITY_COLORS: Record<number, string> = {
|
||||
1: 'bg-green-400', 2: 'bg-yellow-400', 3: 'bg-orange-400', 4: 'bg-red-500', 5: 'bg-red-700',
|
||||
1: 'bg-neutral-300', 2: 'bg-neutral-500', 3: 'bg-accent-300', 4: 'bg-accent', 5: 'bg-accent-700',
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -97,7 +97,7 @@ export default async function ManagementPage() {
|
||||
<h1 className="text-2xl font-bold text-gray-900">Management Dashboard</h1>
|
||||
<a
|
||||
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
|
||||
</a>
|
||||
@@ -119,15 +119,15 @@ export default async function ManagementPage() {
|
||||
</div>
|
||||
|
||||
{/* 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>
|
||||
<p className="text-xs text-gray-400 mb-4">Leading: hazard + near-miss · Lagging: injuries</p>
|
||||
<div className="flex gap-6">
|
||||
<div className="flex-1 text-center bg-blue-50 rounded-lg p-4">
|
||||
<p className="text-3xl font-bold text-blue-600">{leadingCount}</p>
|
||||
<p className="text-xs text-blue-700 mt-1">Leading (Hazards + Near Misses)</p>
|
||||
<div className="flex-1 text-center bg-neutral-100 p-4">
|
||||
<p className="text-3xl font-bold text-accent-700">{leadingCount}</p>
|
||||
<p className="text-xs text-accent-700 mt-1">Leading (Hazards + Near Misses)</p>
|
||||
</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-xs text-red-700 mt-1">Lagging (Injuries)</p>
|
||||
</div>
|
||||
@@ -135,15 +135,15 @@ export default async function ManagementPage() {
|
||||
</div>
|
||||
|
||||
{/* 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>
|
||||
<div className="space-y-2">
|
||||
{([5, 4, 3, 2, 1] as const).map(sev => (
|
||||
<div key={sev} className="flex items-center gap-3">
|
||||
<span className="text-sm text-gray-600 w-24 shrink-0">{SEVERITY_LABELS[sev]}</span>
|
||||
<div className="flex-1 bg-gray-100 rounded-full h-3">
|
||||
<div className="flex-1 bg-gray-100 h-3">
|
||||
<div
|
||||
className={`h-3 rounded-full ${SEVERITY_COLORS[sev]}`}
|
||||
className={`h-3 ${SEVERITY_COLORS[sev]}`}
|
||||
style={{ width: severityMax > 0 ? `${(severityDist[sev] / severityMax) * 100}%` : '0%' }}
|
||||
/>
|
||||
</div>
|
||||
@@ -154,7 +154,7 @@ export default async function ManagementPage() {
|
||||
</div>
|
||||
|
||||
{/* 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>
|
||||
{by_site.length === 0 ? (
|
||||
<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 { incidents, sites, zones, capaActions } from '@/lib/db/schema'
|
||||
import { eq, and } from 'drizzle-orm'
|
||||
import { StatusTag } from '@/components/ui/status-tag'
|
||||
|
||||
const STATUS_LABELS: Record<string, string> = {
|
||||
reported: 'Reported', triaged: 'Triaged', investigating: 'Investigating',
|
||||
capa_pending: 'CAPA Pending', verification: 'Verification', closed: 'Closed',
|
||||
}
|
||||
const STATUS_COLORS: Record<string, string> = {
|
||||
reported: 'bg-gray-100 text-gray-600', triaged: 'bg-yellow-100 text-yellow-800',
|
||||
investigating: 'bg-blue-100 text-blue-700', capa_pending: 'bg-orange-100 text-orange-700',
|
||||
verification: 'bg-purple-100 text-purple-700', closed: 'bg-green-100 text-green-700',
|
||||
}
|
||||
|
||||
export default async function ReporterIncidentDetail({
|
||||
params,
|
||||
}: {
|
||||
@@ -65,18 +60,16 @@ export default async function ReporterIncidentDetail({
|
||||
return (
|
||||
<main className="max-w-2xl mx-auto px-4 py-6 space-y-4">
|
||||
<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 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>
|
||||
<h1 className="text-lg font-bold text-gray-900">{inc.referenceNo ?? inc.id.slice(0, 8)}</h1>
|
||||
<p className="text-sm text-gray-500 capitalize">{inc.incidentType?.replace(/_/g, ' ')}</p>
|
||||
</div>
|
||||
<span className={`text-xs rounded-full px-2 py-1 shrink-0 ${STATUS_COLORS[inc.status] ?? 'bg-gray-100 text-gray-600'}`}>
|
||||
{STATUS_LABELS[inc.status] ?? inc.status}
|
||||
</span>
|
||||
<span className="shrink-0"><StatusTag status={inc.status}>{STATUS_LABELS[inc.status] ?? inc.status}</StatusTag></span>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-2 gap-3 text-sm mb-4">
|
||||
@@ -98,7 +91,7 @@ export default async function ReporterIncidentDetail({
|
||||
</div>
|
||||
|
||||
{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-sm text-gray-800 whitespace-pre-line">{inc.description}</p>
|
||||
</div>
|
||||
@@ -106,15 +99,15 @@ export default async function ReporterIncidentDetail({
|
||||
</div>
|
||||
|
||||
{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>
|
||||
<div className="space-y-2">
|
||||
{capas.map(c => (
|
||||
<div key={c.id} className="flex items-start justify-between gap-3 text-sm">
|
||||
<p className="text-gray-700 flex-1">{c.description}</p>
|
||||
<span className={`text-xs rounded-full px-2 py-0.5 shrink-0 ${
|
||||
c.status === 'verified' ? 'bg-green-100 text-green-700' :
|
||||
c.status === 'pending_verification' ? 'bg-purple-100 text-purple-700' :
|
||||
<span className={`text-xs px-2 py-0.5 shrink-0 ${
|
||||
c.status === 'verified' ? 'bg-neutral-100 text-ink' :
|
||||
c.status === 'pending_verification' ? 'bg-accent-100 text-accent-700' :
|
||||
'bg-gray-100 text-gray-600'
|
||||
}`}>{c.status.replace(/_/g, ' ')}</span>
|
||||
</div>
|
||||
|
||||
@@ -6,6 +6,7 @@ import { redirect } from 'next/navigation'
|
||||
import { getSession } from '@/lib/auth/get-session'
|
||||
import { incidents, sites } from '@/lib/db/schema'
|
||||
import { eq, desc } from 'drizzle-orm'
|
||||
import { StatusTag } from '@/components/ui/status-tag'
|
||||
|
||||
const STATUS_LABELS: Record<string, string> = {
|
||||
reported: 'Reported',
|
||||
@@ -16,15 +17,6 @@ const STATUS_LABELS: Record<string, string> = {
|
||||
closed: 'Closed',
|
||||
}
|
||||
|
||||
const STATUS_COLORS: Record<string, string> = {
|
||||
reported: 'bg-gray-100 text-gray-600',
|
||||
triaged: 'bg-yellow-100 text-yellow-800',
|
||||
investigating: 'bg-blue-100 text-blue-700',
|
||||
capa_pending: 'bg-orange-100 text-orange-700',
|
||||
verification: 'bg-purple-100 text-purple-700',
|
||||
closed: 'bg-green-100 text-green-700',
|
||||
}
|
||||
|
||||
const TYPE_LABELS: Record<string, string> = {
|
||||
injury: 'Injury', near_miss: 'Near Miss', hazard: 'Hazard',
|
||||
asset_damage: 'Asset Damage', environmental: 'Environmental', security: 'Security', fire: 'Fire',
|
||||
@@ -62,34 +54,34 @@ export default async function ReporterPage() {
|
||||
</div>
|
||||
<Link
|
||||
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
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
<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-xs text-gray-500 mt-1">Total Submitted</p>
|
||||
</div>
|
||||
<div className="bg-white rounded-xl shadow-sm p-4 flex-1 text-center">
|
||||
<p className="text-2xl font-bold text-yellow-600">{openCount}</p>
|
||||
<div className="bg-surface shadow-sm p-4 flex-1 text-center">
|
||||
<p className="text-2xl font-bold text-accent-700">{openCount}</p>
|
||||
<p className="text-xs text-gray-500 mt-1">In Progress</p>
|
||||
</div>
|
||||
<div className="bg-white rounded-xl shadow-sm p-4 flex-1 text-center">
|
||||
<p className="text-2xl font-bold text-green-600">{closedCount}</p>
|
||||
<div className="bg-surface shadow-sm p-4 flex-1 text-center">
|
||||
<p className="text-2xl font-bold text-ink">{closedCount}</p>
|
||||
<p className="text-xs text-gray-500 mt-1">Closed</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{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>
|
||||
<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 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 => (
|
||||
<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">
|
||||
@@ -110,9 +102,7 @@ export default async function ReporterPage() {
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
<span className={`text-xs rounded-full px-2 py-0.5 shrink-0 ${STATUS_COLORS[inc.status] ?? 'bg-gray-100 text-gray-600'}`}>
|
||||
{STATUS_LABELS[inc.status] ?? inc.status}
|
||||
</span>
|
||||
<span className="shrink-0"><StatusTag status={inc.status}>{STATUS_LABELS[inc.status] ?? inc.status}</StatusTag></span>
|
||||
</div>
|
||||
</Link>
|
||||
))}
|
||||
|
||||
@@ -136,7 +136,7 @@ export default async function SupervisorIncidentDetailPage({ params }: Props) {
|
||||
|
||||
return (
|
||||
<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
|
||||
</Link>
|
||||
<IncidentDetail incident={incidentProp} />
|
||||
|
||||
@@ -8,6 +8,7 @@ import { incidents, sites, capaActions, users } from '@/lib/db/schema'
|
||||
import { eq, not, and, inArray, sql, desc } from 'drizzle-orm'
|
||||
import { aliasedTable } from 'drizzle-orm'
|
||||
import { StatCard } from '@/components/dashboard/stat-card'
|
||||
import { StatusTag } from '@/components/ui/status-tag'
|
||||
|
||||
const STATUS_LABELS: Record<string, string> = {
|
||||
reported: 'Reported',
|
||||
@@ -18,15 +19,6 @@ const STATUS_LABELS: Record<string, string> = {
|
||||
closed: 'Closed',
|
||||
}
|
||||
|
||||
const STATUS_COLORS: Record<string, string> = {
|
||||
reported: 'bg-gray-100 text-gray-700',
|
||||
triaged: 'bg-yellow-100 text-yellow-800',
|
||||
investigating: 'bg-blue-100 text-blue-700',
|
||||
capa_pending: 'bg-orange-100 text-orange-700',
|
||||
verification: 'bg-purple-100 text-purple-700',
|
||||
closed: 'bg-green-100 text-green-700',
|
||||
}
|
||||
|
||||
export default async function SupervisorPage() {
|
||||
const session = await getSession()
|
||||
if (!session) redirect('/login')
|
||||
@@ -119,7 +111,7 @@ export default async function SupervisorPage() {
|
||||
<h1 className="text-2xl font-bold text-gray-900">Supervisor Portal</h1>
|
||||
<p className="text-sm text-gray-500 mt-1">{siteName}</p>
|
||||
</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 →
|
||||
</Link>
|
||||
</div>
|
||||
@@ -133,7 +125,7 @@ export default async function SupervisorPage() {
|
||||
</div>
|
||||
|
||||
{/* 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>
|
||||
{openIncidents.length === 0 ? (
|
||||
<p className="text-sm text-gray-400">No open incidents.</p>
|
||||
@@ -143,15 +135,13 @@ export default async function SupervisorPage() {
|
||||
<Link
|
||||
key={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>
|
||||
<p className="text-sm font-medium text-gray-900">{inc.referenceNo ?? inc.id.slice(0, 8)}</p>
|
||||
<p className="text-xs text-gray-500">{TYPE_LABELS[inc.incidentType] ?? inc.incidentType}</p>
|
||||
</div>
|
||||
<span className={`text-xs rounded-full px-2 py-0.5 font-medium ${STATUS_COLORS[inc.status] ?? 'bg-gray-100 text-gray-700'}`}>
|
||||
{STATUS_LABELS[inc.status] ?? inc.status}
|
||||
</span>
|
||||
<StatusTag status={inc.status}>{STATUS_LABELS[inc.status] ?? inc.status}</StatusTag>
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
@@ -160,7 +150,7 @@ export default async function SupervisorPage() {
|
||||
|
||||
{/* Overdue CAPAs */}
|
||||
{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>
|
||||
<div className="space-y-2">
|
||||
{overdueCapas.map(capa => (
|
||||
|
||||
+155
-28
@@ -1,37 +1,164 @@
|
||||
@import "tailwindcss";
|
||||
|
||||
:root {
|
||||
--background: #ffffff;
|
||||
--foreground: #171717;
|
||||
/* Modernist tokens. Source of truth: the Modernist styles.css under design-system/_ds.
|
||||
Static emits every variable so plain CSS can use var(--color-*) too. */
|
||||
@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 {
|
||||
--color-background: var(--background);
|
||||
--color-foreground: var(--foreground);
|
||||
--font-sans: var(--font-geist-sans);
|
||||
--font-mono: var(--font-geist-mono);
|
||||
}
|
||||
@layer base {
|
||||
html {
|
||||
background: var(--color-bg);
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
:root {
|
||||
--background: #0a0a0a;
|
||||
--foreground: #ededed;
|
||||
body {
|
||||
background: var(--color-bg);
|
||||
color: var(--color-text);
|
||||
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 {
|
||||
background: var(--background);
|
||||
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 */
|
||||
.grayscale {
|
||||
filter: grayscale(1) contrast(1.08);
|
||||
}
|
||||
|
||||
+4
-9
@@ -1,16 +1,11 @@
|
||||
import type { Metadata } from 'next'
|
||||
import { Geist, Geist_Mono } from 'next/font/google'
|
||||
import { Archivo } from 'next/font/google'
|
||||
import './globals.css'
|
||||
import { I18nProvider } from '@/lib/i18n/context'
|
||||
import { getLocale, loadMessages } from '@/lib/i18n/server'
|
||||
|
||||
const geistSans = Geist({
|
||||
variable: '--font-geist-sans',
|
||||
subsets: ['latin'],
|
||||
})
|
||||
|
||||
const geistMono = Geist_Mono({
|
||||
variable: '--font-geist-mono',
|
||||
const archivo = Archivo({
|
||||
variable: '--font-archivo',
|
||||
subsets: ['latin'],
|
||||
})
|
||||
|
||||
@@ -30,7 +25,7 @@ export default async function RootLayout({
|
||||
return (
|
||||
<html
|
||||
lang={locale}
|
||||
className={`${geistSans.variable} ${geistMono.variable} h-full antialiased`}
|
||||
className={`${archivo.variable} h-full antialiased`}
|
||||
>
|
||||
<head>
|
||||
<link rel="manifest" href="/manifest.json" />
|
||||
|
||||
+1
-1
@@ -67,7 +67,7 @@ export default async function ReportPage({ searchParams }: Props) {
|
||||
{siteName ?? 'Unknown Site'} — {zoneName}
|
||||
</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>
|
||||
<ReportForm
|
||||
|
||||
@@ -10,7 +10,7 @@ export default async function ReportSuccessPage({ searchParams }: Props) {
|
||||
const { ref } = await searchParams
|
||||
return (
|
||||
<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>
|
||||
<h1 className="text-xl font-bold text-gray-900 mb-2">Report submitted</h1>
|
||||
{ref && (
|
||||
@@ -21,7 +21,7 @@ export default async function ReportSuccessPage({ searchParams }: Props) {
|
||||
<p className="text-sm text-gray-500 mb-6">
|
||||
The supervisor and HSE officer have been notified.
|
||||
</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
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
@@ -54,7 +54,7 @@ export default function ChangePasswordForm() {
|
||||
}
|
||||
|
||||
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>
|
||||
<form onSubmit={handleSubmit} className="space-y-4">
|
||||
<div>
|
||||
@@ -67,7 +67,7 @@ export default function ChangePasswordForm() {
|
||||
onChange={e => setCurrent(e.target.value)}
|
||||
disabled={loading}
|
||||
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>
|
||||
@@ -80,7 +80,7 @@ export default function ChangePasswordForm() {
|
||||
onChange={e => setNewPass(e.target.value)}
|
||||
disabled={loading}
|
||||
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>
|
||||
@@ -93,17 +93,17 @@ export default function ChangePasswordForm() {
|
||||
onChange={e => setConfirm(e.target.value)}
|
||||
disabled={loading}
|
||||
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>
|
||||
|
||||
{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
|
||||
type="submit"
|
||||
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'}
|
||||
</button>
|
||||
|
||||
@@ -25,20 +25,20 @@ export function AdminPanel({ users, sites, siteOptions, trucks }: Props) {
|
||||
|
||||
return (
|
||||
<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 => (
|
||||
<button
|
||||
key={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 ${
|
||||
tab === t.id
|
||||
? 'border-green-600 text-green-700'
|
||||
? 'border-accent text-ink'
|
||||
: 'border-transparent text-gray-500 hover:text-gray-700'
|
||||
}`}
|
||||
>
|
||||
{t.label}
|
||||
<span className={`ml-1.5 text-xs px-1.5 py-0.5 rounded-full ${
|
||||
tab === t.id ? 'bg-green-100 text-green-700' : 'bg-gray-100 text-gray-500'
|
||||
<span className={`ml-1.5 text-xs px-1.5 py-0.5 ${
|
||||
tab === t.id ? 'bg-neutral-100 text-ink' : 'bg-gray-100 text-gray-500'
|
||||
}`}>{t.count}</span>
|
||||
</button>
|
||||
))}
|
||||
|
||||
@@ -83,7 +83,7 @@ export function BulkImportForm() {
|
||||
if (stage === 'upload') {
|
||||
return (
|
||||
<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
|
||||
type="file"
|
||||
onChange={handleUpload}
|
||||
@@ -201,14 +201,14 @@ export function BulkImportForm() {
|
||||
<div className="flex gap-2">
|
||||
<button
|
||||
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
|
||||
</button>
|
||||
<button
|
||||
onClick={handleImport}
|
||||
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'}
|
||||
</button>
|
||||
@@ -220,9 +220,9 @@ export function BulkImportForm() {
|
||||
|
||||
return (
|
||||
<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>
|
||||
{message && <p className="text-green-600 text-sm">{message}</p>}
|
||||
{message && <p className="text-ink text-sm">{message}</p>}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
import { useState } from 'react'
|
||||
import { useRouter } from 'next/navigation'
|
||||
import { Modal } from '@/components/ui/modal'
|
||||
import { INPUT_CLASS as inp } from '@/components/ui/field'
|
||||
|
||||
export type SiteWithZones = {
|
||||
id: string
|
||||
@@ -16,7 +17,6 @@ interface Props {
|
||||
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'
|
||||
|
||||
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)
|
||||
|
||||
return (
|
||||
<div className="bg-white rounded-xl border border-gray-200 shadow-sm overflow-hidden">
|
||||
<div className="flex items-center justify-between px-5 py-4 border-b border-gray-100">
|
||||
<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-divider">
|
||||
<div>
|
||||
<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>
|
||||
</div>
|
||||
<div className="flex gap-2">
|
||||
<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}>
|
||||
<path strokeLinecap="round" strokeLinejoin="round" d="M12 4v16m8-8H4" />
|
||||
</svg>
|
||||
Add Zone
|
||||
</button>
|
||||
<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}>
|
||||
<path strokeLinecap="round" strokeLinejoin="round" d="M12 4v16m8-8H4" />
|
||||
</svg>
|
||||
@@ -118,10 +118,10 @@ export function SiteZoneManager({ sites }: Props) {
|
||||
<div className="flex items-center gap-2">
|
||||
<button disabled={busyId === site.id}
|
||||
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
|
||||
? 'bg-green-50 text-green-700 border-green-200 hover:bg-green-100'
|
||||
: 'bg-gray-50 text-gray-500 border-gray-200 hover:bg-gray-100'
|
||||
? 'bg-neutral-100 text-ink border-divider hover:bg-neutral-200'
|
||||
: 'bg-gray-50 text-gray-500 border-divider hover:bg-gray-100'
|
||||
}`}>
|
||||
{site.active ? 'Active' : 'Inactive'}
|
||||
</button>
|
||||
@@ -134,21 +134,21 @@ export function SiteZoneManager({ sites }: Props) {
|
||||
</div>
|
||||
|
||||
{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 => (
|
||||
<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>
|
||||
<div className="flex items-center gap-3">
|
||||
<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
|
||||
</a>
|
||||
<button disabled={busyId === z.id}
|
||||
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
|
||||
? 'bg-green-50 text-green-700 border-green-200 hover:bg-green-100'
|
||||
: 'bg-gray-50 text-gray-500 border-gray-200 hover:bg-gray-100'
|
||||
? 'bg-neutral-100 text-ink border-divider hover:bg-neutral-200'
|
||||
: 'bg-gray-50 text-gray-500 border-divider hover:bg-gray-100'
|
||||
}`}>
|
||||
{z.active ? 'Active' : 'Inactive'}
|
||||
</button>
|
||||
@@ -178,18 +178,18 @@ export function SiteZoneManager({ sites }: Props) {
|
||||
footer={
|
||||
<>
|
||||
<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
|
||||
</button>
|
||||
<button disabled={busy || !siteName.trim()}
|
||||
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'}
|
||||
</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>
|
||||
<label className={lbl} htmlFor="add-site-name">Site Name *</label>
|
||||
<input id="add-site-name" type="text" placeholder="e.g. Setia Warehouse KL"
|
||||
@@ -205,7 +205,7 @@ export function SiteZoneManager({ sites }: Props) {
|
||||
footer={
|
||||
<>
|
||||
<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
|
||||
</button>
|
||||
<button disabled={busy || !zoneName.trim() || !zoneSiteId}
|
||||
@@ -214,13 +214,13 @@ export function SiteZoneManager({ sites }: Props) {
|
||||
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'}
|
||||
</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>
|
||||
<label className={lbl} htmlFor="add-zone-site">Site *</label>
|
||||
@@ -243,12 +243,12 @@ export function SiteZoneManager({ sites }: Props) {
|
||||
footer={
|
||||
<>
|
||||
<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
|
||||
</button>
|
||||
<button disabled={!!(confirmDelete && busyId === confirmDelete.id)}
|
||||
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
|
||||
</button>
|
||||
</>
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
import { useState } from 'react'
|
||||
import { useRouter } from 'next/navigation'
|
||||
import { Modal } from '@/components/ui/modal'
|
||||
import { INPUT_CLASS as inp } from '@/components/ui/field'
|
||||
|
||||
export type Truck = {
|
||||
id: string
|
||||
@@ -15,7 +16,6 @@ interface Props {
|
||||
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'
|
||||
|
||||
export function TruckManager({ trucks }: Props) {
|
||||
@@ -83,14 +83,14 @@ export function TruckManager({ trucks }: Props) {
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="bg-white rounded-xl border border-gray-200 shadow-sm overflow-hidden">
|
||||
<div className="flex items-center justify-between px-5 py-4 border-b border-gray-100">
|
||||
<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-divider">
|
||||
<div>
|
||||
<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>
|
||||
</div>
|
||||
<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}>
|
||||
<path strokeLinecap="round" strokeLinejoin="round" d="M12 4v16m8-8H4" />
|
||||
</svg>
|
||||
@@ -109,15 +109,15 @@ export function TruckManager({ trucks }: Props) {
|
||||
</div>
|
||||
<div className="flex items-center gap-3">
|
||||
<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
|
||||
</a>
|
||||
<button disabled={busyId === tk.id}
|
||||
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
|
||||
? 'bg-green-50 text-green-700 border-green-200 hover:bg-green-100'
|
||||
: 'bg-gray-50 text-gray-500 border-gray-200 hover:bg-gray-100'
|
||||
? 'bg-neutral-100 text-ink border-divider hover:bg-neutral-200'
|
||||
: 'bg-gray-50 text-gray-500 border-divider hover:bg-gray-100'
|
||||
}`}>
|
||||
{tk.active ? 'Active' : 'Inactive'}
|
||||
</button>
|
||||
@@ -139,17 +139,17 @@ export function TruckManager({ trucks }: Props) {
|
||||
footer={
|
||||
<>
|
||||
<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
|
||||
</button>
|
||||
<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'}
|
||||
</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>
|
||||
<label className={lbl} htmlFor="add-truck-no">Truck Number *</label>
|
||||
@@ -173,12 +173,12 @@ export function TruckManager({ trucks }: Props) {
|
||||
footer={
|
||||
<>
|
||||
<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
|
||||
</button>
|
||||
<button disabled={busyId === confirmDelete?.id}
|
||||
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'}
|
||||
</button>
|
||||
</>
|
||||
|
||||
@@ -4,6 +4,7 @@ import { useState } from 'react'
|
||||
import { useRouter } from 'next/navigation'
|
||||
import { ALL_ROLES, type UserRole } from '@/lib/auth/roles'
|
||||
import { Modal } from '@/components/ui/modal'
|
||||
import { INPUT_CLASS as inp } from '@/components/ui/field'
|
||||
|
||||
export type AdminUser = {
|
||||
id: string
|
||||
@@ -24,7 +25,6 @@ interface Props {
|
||||
|
||||
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'
|
||||
|
||||
export function UserManager({ users, sites }: Props) {
|
||||
@@ -95,15 +95,15 @@ export function UserManager({ users, sites }: Props) {
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="bg-white rounded-xl border border-gray-200 shadow-sm overflow-hidden">
|
||||
<div className="flex items-center justify-between px-5 py-4 border-b border-gray-100">
|
||||
<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-divider">
|
||||
<div>
|
||||
<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>
|
||||
</div>
|
||||
<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}>
|
||||
<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">
|
||||
<select value={u.role} disabled={busyId === u.id}
|
||||
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>)}
|
||||
</select>
|
||||
</td>
|
||||
<td className="px-5 py-3">
|
||||
<select value={u.site_id ?? ''} disabled={busyId === u.id}
|
||||
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>
|
||||
{sites.map(s => <option key={s.id} value={s.id}>{s.name}</option>)}
|
||||
</select>
|
||||
@@ -149,10 +149,10 @@ export function UserManager({ users, sites }: Props) {
|
||||
<td className="px-5 py-3">
|
||||
<button disabled={busyId === u.id}
|
||||
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
|
||||
? 'bg-green-50 text-green-700 border-green-200 hover:bg-green-100'
|
||||
: 'bg-gray-50 text-gray-500 border-gray-200 hover:bg-gray-100'
|
||||
? 'bg-neutral-100 text-ink border-divider hover:bg-neutral-200'
|
||||
: 'bg-gray-50 text-gray-500 border-divider hover:bg-gray-100'
|
||||
}`}>
|
||||
{u.active ? 'Active' : 'Inactive'}
|
||||
</button>
|
||||
@@ -178,18 +178,18 @@ export function UserManager({ users, sites }: Props) {
|
||||
footer={
|
||||
<>
|
||||
<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
|
||||
</button>
|
||||
<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'}
|
||||
</button>
|
||||
</>
|
||||
}
|
||||
>
|
||||
<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>
|
||||
<label className={lbl} htmlFor="au-email">Email *</label>
|
||||
@@ -245,12 +245,12 @@ export function UserManager({ users, sites }: Props) {
|
||||
footer={
|
||||
<>
|
||||
<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
|
||||
</button>
|
||||
<button disabled={busyId === confirmDelete?.id}
|
||||
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'}
|
||||
</button>
|
||||
</>
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
import { useState } from 'react'
|
||||
import { useRouter } from 'next/navigation'
|
||||
import Link from 'next/link'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { Input } from '@/components/ui/field'
|
||||
|
||||
export function LoginForm() {
|
||||
const [email, setEmail] = useState('')
|
||||
@@ -37,44 +39,38 @@ export function LoginForm() {
|
||||
|
||||
return (
|
||||
<form onSubmit={handleSubmit} className="flex flex-col gap-4 w-full max-w-sm">
|
||||
<div className="text-center">
|
||||
<h1 className="text-2xl font-bold">IMS</h1>
|
||||
<p className="text-sm text-gray-500 mt-1">HSE Incident Management</p>
|
||||
<div className="pb-3 border-b-2 border-divider">
|
||||
<h1 className="text-3xl font-extrabold">IMS</h1>
|
||||
<p className="text-sm text-ink/60 mt-1">HSE Incident Management</p>
|
||||
</div>
|
||||
|
||||
{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}
|
||||
</p>
|
||||
)}
|
||||
|
||||
<input
|
||||
<Input
|
||||
type="email"
|
||||
placeholder="Email"
|
||||
value={email}
|
||||
onChange={(e) => setEmail(e.target.value)}
|
||||
required
|
||||
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"
|
||||
placeholder="Password"
|
||||
value={password}
|
||||
onChange={(e) => setPassword(e.target.value)}
|
||||
required
|
||||
autoComplete="current-password"
|
||||
className="border rounded-md px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"
|
||||
/>
|
||||
<button
|
||||
type="submit"
|
||||
disabled={loading}
|
||||
className="bg-blue-600 hover:bg-blue-700 text-white font-medium py-2 rounded-md disabled:opacity-50 transition-colors"
|
||||
>
|
||||
<Button type="submit" variant="primary" block disabled={loading}>
|
||||
{loading ? 'Signing in…' : 'Sign in'}
|
||||
</button>
|
||||
<p className="text-center text-sm text-gray-500">
|
||||
<Link href="/forgot-password" className="text-blue-600 hover:underline">
|
||||
</Button>
|
||||
<p className="text-sm text-ink/60">
|
||||
<Link href="/forgot-password" className="text-accent-700 hover:underline">
|
||||
Forgot password?
|
||||
</Link>
|
||||
</p>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
import { useState } from 'react'
|
||||
import Link from 'next/link'
|
||||
import { PriorityTag } from '@/components/ui/status-tag'
|
||||
|
||||
type CapaStatus = 'open' | 'in_progress' | 'overdue' | 'pending_verification' | 'verified' | 'reopened' | 'closed'
|
||||
|
||||
@@ -27,19 +28,14 @@ const STATUS_LABELS: Record<CapaStatus, string> = {
|
||||
reopened: 'Reopened',
|
||||
closed: 'Closed',
|
||||
}
|
||||
const STATUS_COLORS: Record<CapaStatus, string> = {
|
||||
open: 'bg-blue-50 border-blue-200',
|
||||
in_progress: 'bg-yellow-50 border-yellow-200',
|
||||
overdue: 'bg-red-50 border-red-200',
|
||||
pending_verification: 'bg-purple-50 border-purple-200',
|
||||
verified: 'bg-green-50 border-green-200',
|
||||
reopened: 'bg-orange-50 border-orange-200',
|
||||
closed: 'bg-gray-50 border-gray-200',
|
||||
}
|
||||
const PRIORITY_BADGE: Record<'low' | 'med' | 'high', string> = {
|
||||
low: 'bg-gray-100 text-gray-600',
|
||||
med: 'bg-yellow-100 text-yellow-700',
|
||||
high: 'bg-red-100 text-red-700',
|
||||
const COLUMN_BORDER: Record<CapaStatus, string> = {
|
||||
open: 'border-divider',
|
||||
in_progress: 'border-divider',
|
||||
overdue: 'border-accent',
|
||||
pending_verification: 'border-divider',
|
||||
verified: 'border-divider',
|
||||
reopened: 'border-accent',
|
||||
closed: 'border-divider',
|
||||
}
|
||||
|
||||
interface Props {
|
||||
@@ -58,7 +54,7 @@ export function CapaBoard({ capas }: Props) {
|
||||
return (
|
||||
<div>
|
||||
<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 className="overflow-x-auto">
|
||||
<table className="w-full text-sm">
|
||||
@@ -72,23 +68,21 @@ export function CapaBoard({ capas }: Props) {
|
||||
<th className="pb-2">Status</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody className="divide-y divide-gray-100">
|
||||
<tbody className="divide-y divide-divider">
|
||||
{capas.map(c => (
|
||||
<tr key={c.id}>
|
||||
<td className="py-2 pr-4 text-gray-500 text-xs">
|
||||
{(c.incidents as { reference_no: string | null } | null)?.reference_no ?? '—'}
|
||||
</td>
|
||||
<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}
|
||||
</Link>
|
||||
</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">
|
||||
<span className={`px-2 py-0.5 rounded text-xs font-medium ${PRIORITY_BADGE[c.priority]}`}>
|
||||
{c.priority}
|
||||
</span>
|
||||
<PriorityTag priority={c.priority} />
|
||||
</td>
|
||||
<td className="py-2 text-gray-600 text-xs">{STATUS_LABELS[c.status]}</td>
|
||||
</tr>
|
||||
@@ -103,22 +97,22 @@ export function CapaBoard({ capas }: Props) {
|
||||
return (
|
||||
<div>
|
||||
<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 className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4">
|
||||
{STATUS_ORDER.filter(s => s !== 'reopened').map(status => (
|
||||
<div key={status} className={`rounded-xl border p-4 ${STATUS_COLORS[status]}`}>
|
||||
<h3 className="text-xs font-semibold uppercase tracking-wide text-gray-600 mb-3">
|
||||
<div key={status} className={`border-2 p-4 bg-ground ${COLUMN_BORDER[status]}`}>
|
||||
<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})
|
||||
</h3>
|
||||
<div className="space-y-2 max-h-96 overflow-y-auto pr-2">
|
||||
{byStatus[status].map(c => (
|
||||
<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>
|
||||
<div className="flex items-center justify-between text-xs text-gray-500">
|
||||
<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>
|
||||
<p className="text-xs text-gray-400 mt-1">Due {c.due_date}</p>
|
||||
</Link>
|
||||
|
||||
@@ -77,7 +77,7 @@ export function CapaForm({ incidentId }: Props) {
|
||||
value={description}
|
||||
onChange={e => setDescription(e.target.value)}
|
||||
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?"
|
||||
/>
|
||||
</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>
|
||||
<input type="text" value={rootCauseRef}
|
||||
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" />
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<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
|
||||
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>
|
||||
{users.map(u => (
|
||||
<option key={u.id} value={u.id}>{u.name} ({u.department})</option>
|
||||
@@ -105,12 +105,12 @@ export function CapaForm({ incidentId }: Props) {
|
||||
<div>
|
||||
<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
|
||||
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>
|
||||
<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')}
|
||||
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="med">Medium</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>}
|
||||
|
||||
<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'}
|
||||
</button>
|
||||
</form>
|
||||
|
||||
@@ -36,7 +36,7 @@ export function CapaOwnerActions({ capaId, currentStatus }: Props) {
|
||||
<button
|
||||
onClick={() => updateStatus('in_progress')}
|
||||
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'}
|
||||
</button>
|
||||
@@ -48,7 +48,7 @@ export function CapaOwnerActions({ capaId, currentStatus }: Props) {
|
||||
<button
|
||||
onClick={() => updateStatus('pending_verification')}
|
||||
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'}
|
||||
</button>
|
||||
|
||||
@@ -39,18 +39,18 @@ export function CapaOwnerNotesForm({ capaId, initialNotes }: Props) {
|
||||
onChange={e => { setNotes(e.target.value); setSaved(false) }}
|
||||
rows={2}
|
||||
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>}
|
||||
<div className="flex items-center gap-2">
|
||||
<button
|
||||
onClick={handleSave}
|
||||
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'}
|
||||
</button>
|
||||
{saved && <span className="text-xs text-green-600">Saved</span>}
|
||||
{saved && <span className="text-xs text-ink">Saved</span>}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -31,7 +31,7 @@ export function CloseCapaButton({ capaId }: Props) {
|
||||
}
|
||||
|
||||
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>
|
||||
<p className="text-sm text-gray-600">
|
||||
This CAPA has been verified as effective. Close it to mark it fully resolved.
|
||||
@@ -40,7 +40,7 @@ export function CloseCapaButton({ capaId }: Props) {
|
||||
<button
|
||||
onClick={handleClose}
|
||||
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'}
|
||||
</button>
|
||||
|
||||
@@ -39,16 +39,16 @@ export function VerifyForm({ capaId }: Props) {
|
||||
}
|
||||
|
||||
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>
|
||||
<div className="flex gap-3">
|
||||
<button
|
||||
type="button"
|
||||
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'
|
||||
? 'bg-green-600 text-white border-green-600'
|
||||
: 'bg-white text-gray-700 border-gray-300 hover:border-green-500'
|
||||
? 'bg-accent text-white border-accent'
|
||||
: 'bg-surface text-gray-700 border-divider hover:border-accent'
|
||||
}`}
|
||||
>
|
||||
Verified — Effective
|
||||
@@ -56,10 +56,10 @@ export function VerifyForm({ capaId }: Props) {
|
||||
<button
|
||||
type="button"
|
||||
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'
|
||||
? 'bg-orange-600 text-white border-orange-600'
|
||||
: 'bg-white text-gray-700 border-gray-300 hover:border-orange-500'
|
||||
? 'bg-accent text-white border-accent'
|
||||
: 'bg-surface text-gray-700 border-divider hover:border-accent'
|
||||
}`}
|
||||
>
|
||||
Reopen — Ineffective
|
||||
@@ -72,7 +72,7 @@ export function VerifyForm({ capaId }: Props) {
|
||||
value={reopenReason}
|
||||
onChange={e => setReopenReason(e.target.value)}
|
||||
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…"
|
||||
/>
|
||||
</div>
|
||||
@@ -80,7 +80,7 @@ export function VerifyForm({ capaId }: Props) {
|
||||
{error && <p className="text-sm text-red-600">{error}</p>}
|
||||
{verdict && (
|
||||
<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'}
|
||||
</button>
|
||||
)}
|
||||
|
||||
@@ -15,15 +15,15 @@ function TabsInner({ activeTab }: { activeTab: string }) {
|
||||
const pathname = usePathname()
|
||||
|
||||
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 => (
|
||||
<button
|
||||
key={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 ${
|
||||
activeTab === tab.key
|
||||
? 'border-blue-600 text-blue-600'
|
||||
: 'border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300'
|
||||
? 'border-accent text-accent-700'
|
||||
: 'border-transparent text-gray-500 hover:text-gray-700 hover:border-divider'
|
||||
}`}
|
||||
>
|
||||
{tab.label}
|
||||
@@ -35,7 +35,7 @@ function TabsInner({ activeTab }: { activeTab: string }) {
|
||||
|
||||
export function DashboardTabs({ activeTab }: { activeTab: string }) {
|
||||
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} />
|
||||
</Suspense>
|
||||
)
|
||||
|
||||
@@ -11,9 +11,9 @@ type RiskFlag = {
|
||||
}
|
||||
|
||||
const LEVEL_COLORS: Record<RiskFlag['risk_level'], string> = {
|
||||
low: 'bg-yellow-50 text-yellow-700 border-yellow-200',
|
||||
medium: 'bg-orange-50 text-orange-700 border-orange-200',
|
||||
high: 'bg-red-50 text-red-700 border-red-200',
|
||||
low: 'bg-neutral-100 text-neutral-800 border-divider',
|
||||
medium: 'bg-ground text-accent-700 border-accent',
|
||||
high: 'bg-accent-100 text-accent-800 border-accent',
|
||||
}
|
||||
|
||||
export function RiskFlagsPanel() {
|
||||
@@ -43,7 +43,7 @@ export function RiskFlagsPanel() {
|
||||
}
|
||||
|
||||
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">
|
||||
<h2 className="text-sm font-semibold text-gray-700 uppercase tracking-wide">
|
||||
Rising-Risk Zones (AI)
|
||||
@@ -51,7 +51,7 @@ export function RiskFlagsPanel() {
|
||||
<button
|
||||
onClick={analyze}
|
||||
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'}
|
||||
</button>
|
||||
@@ -71,7 +71,7 @@ export function RiskFlagsPanel() {
|
||||
<p className="text-sm text-gray-700 mb-3">{summary}</p>
|
||||
<div className="space-y-2">
|
||||
{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">
|
||||
<span className="text-sm font-semibold">{f.zone} · {f.site}</span>
|
||||
<span className="text-xs font-bold uppercase">{f.risk_level}</span>
|
||||
|
||||
@@ -7,14 +7,14 @@ interface Props {
|
||||
|
||||
const ACCENT = {
|
||||
default: 'border-gray-200',
|
||||
green: 'border-green-400',
|
||||
yellow: 'border-yellow-400',
|
||||
green: 'border-divider',
|
||||
yellow: 'border-accent-300',
|
||||
red: 'border-red-400',
|
||||
}
|
||||
|
||||
export function StatCard({ label, value, sub, accent = 'default' }: Props) {
|
||||
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-3xl font-bold text-gray-900 mt-1">{value}</p>
|
||||
{sub && <p className="text-xs text-gray-400 mt-1">{sub}</p>}
|
||||
|
||||
@@ -78,7 +78,7 @@ export function ClosurePanel({ incidentId, status, canClose, canAddAddenda }: Pr
|
||||
<button
|
||||
onClick={closeIncident}
|
||||
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'}
|
||||
</button>
|
||||
@@ -89,7 +89,7 @@ export function ClosurePanel({ incidentId, status, canClose, canAddAddenda }: Pr
|
||||
}
|
||||
|
||||
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>
|
||||
<p className="text-xs text-gray-400 mb-3">
|
||||
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">
|
||||
{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-xs text-gray-400 mt-1">
|
||||
{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)}
|
||||
rows={3}
|
||||
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
|
||||
onClick={addAddendum}
|
||||
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'}
|
||||
</button>
|
||||
|
||||
@@ -34,7 +34,7 @@ export function EvidenceGallery({ files, stage }: Props) {
|
||||
href={file.file_url}
|
||||
target="_blank"
|
||||
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) ? (
|
||||
<img
|
||||
|
||||
@@ -57,8 +57,8 @@ export function FileUpload({ onFilesChange, disabled = false }: Props) {
|
||||
return (
|
||||
<div className="space-y-2">
|
||||
<div
|
||||
className={`border-2 border-dashed rounded-lg p-6 text-center cursor-pointer transition-colors
|
||||
${dragging ? 'border-blue-500 bg-blue-50' : 'border-gray-300 hover:border-gray-400'}
|
||||
className={`border-2 border-dashed p-6 text-center cursor-pointer transition-colors
|
||||
${dragging ? 'border-accent bg-accent-100' : 'border-divider hover:border-gray-400'}
|
||||
${disabled ? 'opacity-50 pointer-events-none' : ''}`}
|
||||
onClick={() => inputRef.current?.click()}
|
||||
onDragOver={e => { e.preventDefault(); setDragging(true) }}
|
||||
@@ -94,7 +94,7 @@ export function FileUpload({ onFilesChange, disabled = false }: Props) {
|
||||
{files.length > 0 && (
|
||||
<ul className="space-y-1">
|
||||
{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>
|
||||
<button
|
||||
type="button"
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { EvidenceGallery } from './evidence-gallery'
|
||||
import { StatusTag } from '@/components/ui/status-tag'
|
||||
|
||||
const TYPE_LABELS: Record<string, string> = {
|
||||
injury: 'Injury / Medical',
|
||||
@@ -11,15 +12,6 @@ const TYPE_LABELS: Record<string, string> = {
|
||||
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> = {
|
||||
none: 'None',
|
||||
first_aid: 'First Aid',
|
||||
@@ -72,7 +64,7 @@ export function IncidentDetail({ incident }: Props) {
|
||||
|
||||
return (
|
||||
<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>
|
||||
<h1 className="text-xl font-bold text-gray-900 font-mono">
|
||||
@@ -80,9 +72,7 @@ export function IncidentDetail({ incident }: Props) {
|
||||
</h1>
|
||||
<p className="text-sm text-gray-600 mt-0.5">{TYPE_LABELS[incident.incident_type] ?? incident.incident_type}</p>
|
||||
</div>
|
||||
<span className={`text-xs px-2.5 py-1 rounded-full font-medium ${STATUS_COLORS[incident.status] ?? 'bg-gray-100'}`}>
|
||||
{incident.status.replace(/_/g, ' ').toUpperCase()}
|
||||
</span>
|
||||
<StatusTag status={incident.status}>{incident.status.replace(/_/g, ' ').toUpperCase()}</StatusTag>
|
||||
</div>
|
||||
|
||||
<dl className="grid grid-cols-2 gap-4 sm:grid-cols-3">
|
||||
@@ -114,12 +104,12 @@ export function IncidentDetail({ incident }: Props) {
|
||||
</dl>
|
||||
</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>
|
||||
<p className="text-sm text-gray-800 leading-relaxed whitespace-pre-wrap">{incident.description}</p>
|
||||
</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">
|
||||
Evidence — Report Stage
|
||||
<span className="ml-2 text-gray-400 font-normal normal-case">
|
||||
|
||||
@@ -77,20 +77,20 @@ function FiltersInner({ sites, trucks }: FiltersProps) {
|
||||
placeholder="Search reference or description..."
|
||||
value={search}
|
||||
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>
|
||||
<select
|
||||
value={searchParams.get('status') ?? ''}
|
||||
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>)}
|
||||
</select>
|
||||
<select
|
||||
value={searchParams.get('type') ?? ''}
|
||||
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>)}
|
||||
</select>
|
||||
@@ -98,7 +98,7 @@ function FiltersInner({ sites, trucks }: FiltersProps) {
|
||||
<select
|
||||
value={searchParams.get('site_id') ?? ''}
|
||||
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>
|
||||
{sites.map(s => <option key={s.id} value={s.id}>{s.name}</option>)}
|
||||
@@ -108,7 +108,7 @@ function FiltersInner({ sites, trucks }: FiltersProps) {
|
||||
<select
|
||||
value={searchParams.get('truck_id') ?? ''}
|
||||
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>
|
||||
{trucks.map(tk => <option key={tk.id} value={tk.id}>{tk.truck_no}</option>)}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
'use client'
|
||||
|
||||
import Link from 'next/link'
|
||||
import { StatusTag } from '@/components/ui/status-tag'
|
||||
|
||||
interface Props {
|
||||
incidentId: string
|
||||
@@ -12,15 +13,6 @@ interface Props {
|
||||
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> = {
|
||||
reported: 'Reported',
|
||||
triaged: 'Triaged',
|
||||
@@ -35,7 +27,7 @@ export function IncidentHeader({
|
||||
canTriage, canInvestigate, canAddCapa,
|
||||
}: Props) {
|
||||
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="flex items-center gap-3 min-w-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">
|
||||
{referenceNo ?? 'Pending'}
|
||||
</span>
|
||||
<span className={`text-xs px-2 py-0.5 rounded-full font-medium shrink-0 ${STATUS_COLORS[status] ?? 'bg-gray-100 text-gray-800'}`}>
|
||||
{STATUS_LABELS[status] ?? status.replace(/_/g, ' ')}
|
||||
</span>
|
||||
<span className="shrink-0"><StatusTag status={status}>{STATUS_LABELS[status] ?? status.replace(/_/g, ' ')}</StatusTag></span>
|
||||
</div>
|
||||
<div className="flex gap-2 shrink-0">
|
||||
{canTriage && (
|
||||
<Link
|
||||
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
|
||||
</Link>
|
||||
@@ -61,7 +51,7 @@ export function IncidentHeader({
|
||||
{canInvestigate && (
|
||||
<Link
|
||||
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
|
||||
</Link>
|
||||
@@ -69,7 +59,7 @@ export function IncidentHeader({
|
||||
{canAddCapa && (
|
||||
<Link
|
||||
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
|
||||
</Link>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
import { useState } from 'react'
|
||||
import Link from 'next/link'
|
||||
import { StatusTag } from '@/components/ui/status-tag'
|
||||
|
||||
const TYPE_LABELS: Record<string, string> = {
|
||||
injury: 'Injury / Medical',
|
||||
@@ -14,14 +15,7 @@ const TYPE_LABELS: Record<string, string> = {
|
||||
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 STATUS_ORDER = ['reported', 'triaged', 'investigating', 'capa_pending', 'verification', 'closed'] as const
|
||||
|
||||
export type Incident = {
|
||||
id: string
|
||||
@@ -66,12 +60,12 @@ export function IncidentList({ incidents, basePath }: Props) {
|
||||
<input
|
||||
type="search"
|
||||
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}
|
||||
onChange={e => setSearch(e.target.value)}
|
||||
/>
|
||||
<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}
|
||||
onChange={e => setTypeFilter(e.target.value)}
|
||||
>
|
||||
@@ -81,12 +75,12 @@ export function IncidentList({ incidents, basePath }: Props) {
|
||||
))}
|
||||
</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}
|
||||
onChange={e => setStatusFilter(e.target.value)}
|
||||
>
|
||||
<option value="">All statuses</option>
|
||||
{Object.keys(STATUS_COLORS).map(s => (
|
||||
{STATUS_ORDER.map(s => (
|
||||
<option key={s} value={s}>{s.replace(/_/g, ' ')}</option>
|
||||
))}
|
||||
</select>
|
||||
@@ -95,7 +89,7 @@ export function IncidentList({ incidents, basePath }: Props) {
|
||||
{filtered.length === 0 ? (
|
||||
<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 => (
|
||||
<Link
|
||||
key={inc.id}
|
||||
@@ -107,9 +101,7 @@ export function IncidentList({ incidents, basePath }: Props) {
|
||||
<span className="font-mono text-sm font-semibold text-gray-900">
|
||||
{inc.reference_no ?? '—'}
|
||||
</span>
|
||||
<span className={`text-xs px-2 py-0.5 rounded-full font-medium ${STATUS_COLORS[inc.status] ?? 'bg-gray-100 text-gray-700'}`}>
|
||||
{inc.status.replace(/_/g, ' ').toUpperCase()}
|
||||
</span>
|
||||
<StatusTag status={inc.status}>{inc.status.replace(/_/g, ' ').toUpperCase()}</StatusTag>
|
||||
</div>
|
||||
<div className="text-sm text-gray-600">
|
||||
{TYPE_LABELS[inc.incident_type] ?? inc.incident_type}
|
||||
|
||||
@@ -136,7 +136,7 @@ export function InvestigationForm({ incidentId, existingInvestigationId }: Props
|
||||
type="button"
|
||||
onClick={getAiDraft}
|
||||
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'}
|
||||
</button>
|
||||
@@ -148,10 +148,10 @@ export function InvestigationForm({ incidentId, existingInvestigationId }: Props
|
||||
<button
|
||||
key={m} type="button"
|
||||
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
|
||||
? 'bg-blue-600 text-white border-blue-600'
|
||||
: 'bg-white text-gray-700 border-gray-300 hover:border-blue-400'
|
||||
? 'bg-accent text-white border-accent'
|
||||
: 'bg-surface text-gray-700 border-divider hover:border-accent'
|
||||
}`}
|
||||
>
|
||||
{m === 'five_why' ? '5-Why' : m === 'fishbone' ? 'Fishbone' : 'Other'}
|
||||
@@ -164,25 +164,25 @@ export function InvestigationForm({ incidentId, existingInvestigationId }: Props
|
||||
<div className="space-y-3">
|
||||
<p className="text-sm font-medium text-gray-700">5-Why Analysis</p>
|
||||
{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>
|
||||
<input
|
||||
type="text" value={step.why}
|
||||
onChange={e => updateWhyStep(i, 'why', e.target.value)}
|
||||
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
|
||||
value={step.answer}
|
||||
onChange={e => updateWhyStep(i, 'answer', e.target.value)}
|
||||
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>
|
||||
))}
|
||||
{fiveWhy.length < 5 && (
|
||||
<button type="button" onClick={addWhyStep}
|
||||
className="text-sm text-blue-600 hover:underline">
|
||||
className="text-sm text-accent-700 hover:underline">
|
||||
+ Add another Why
|
||||
</button>
|
||||
)}
|
||||
@@ -193,7 +193,7 @@ export function InvestigationForm({ incidentId, existingInvestigationId }: Props
|
||||
<div className="space-y-3">
|
||||
<p className="text-sm font-medium text-gray-700">Fishbone (Ishikawa) Analysis</p>
|
||||
{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>
|
||||
{cat.causes.map((cause, causeIdx) => (
|
||||
<input
|
||||
@@ -201,11 +201,11 @@ export function InvestigationForm({ incidentId, existingInvestigationId }: Props
|
||||
type="text" value={cause}
|
||||
onChange={e => updateFishboneCause(catIdx, causeIdx, e.target.value)}
|
||||
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)}
|
||||
className="text-xs text-blue-600 hover:underline">
|
||||
className="text-xs text-accent-700 hover:underline">
|
||||
+ Add cause
|
||||
</button>
|
||||
</div>
|
||||
@@ -219,7 +219,7 @@ export function InvestigationForm({ incidentId, existingInvestigationId }: Props
|
||||
<select
|
||||
value={alcoholTest}
|
||||
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="negative">Negative</option>
|
||||
@@ -233,7 +233,7 @@ export function InvestigationForm({ incidentId, existingInvestigationId }: Props
|
||||
<select
|
||||
value={urineTest}
|
||||
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="negative">Negative</option>
|
||||
@@ -256,13 +256,13 @@ export function InvestigationForm({ incidentId, existingInvestigationId }: Props
|
||||
value={ref}
|
||||
onChange={e => setWitnessRefs(witnessRefs.map((w, j) => (j === i ? e.target.value : w)))}
|
||||
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
|
||||
type="button"
|
||||
onClick={() => setWitnessRefs([...witnessRefs, ''])}
|
||||
className="text-xs text-blue-600 hover:underline"
|
||||
className="text-xs text-accent-700 hover:underline"
|
||||
>
|
||||
+ Add witness statement
|
||||
</button>
|
||||
@@ -274,7 +274,7 @@ export function InvestigationForm({ incidentId, existingInvestigationId }: Props
|
||||
value={findingsText}
|
||||
onChange={e => setFindingsText(e.target.value)}
|
||||
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…"
|
||||
/>
|
||||
</div>
|
||||
@@ -285,7 +285,7 @@ export function InvestigationForm({ incidentId, existingInvestigationId }: Props
|
||||
value={rootCause}
|
||||
onChange={e => setRootCause(e.target.value)}
|
||||
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…"
|
||||
/>
|
||||
</div>
|
||||
@@ -293,7 +293,7 @@ export function InvestigationForm({ incidentId, existingInvestigationId }: Props
|
||||
{!existingInvestigationId && (
|
||||
<label className="flex items-center gap-2 text-sm text-gray-700">
|
||||
<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)
|
||||
</label>
|
||||
)}
|
||||
@@ -301,7 +301,7 @@ export function InvestigationForm({ incidentId, existingInvestigationId }: Props
|
||||
{error && <p className="text-sm text-red-600">{error}</p>}
|
||||
|
||||
<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'}
|
||||
</button>
|
||||
</form>
|
||||
|
||||
@@ -35,15 +35,15 @@ export function InvestigationPanel({ investigation: inv }: Props) {
|
||||
const investigatorName = inv.investigator?.name ?? inv.investigator?.email ?? 'Unknown'
|
||||
|
||||
return (
|
||||
<div className="mt-6 bg-white rounded-xl shadow-sm border border-gray-200 overflow-hidden">
|
||||
<div className="flex items-center justify-between px-5 py-4 border-b border-gray-100">
|
||||
<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-divider">
|
||||
<h2 className="text-sm font-semibold text-gray-900">Investigation</h2>
|
||||
<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 font-medium px-2 py-0.5 rounded-full ${
|
||||
<span className={`text-xs font-medium px-2 py-0.5 ${
|
||||
inv.completed_at
|
||||
? 'bg-green-100 text-green-700'
|
||||
: 'bg-yellow-100 text-yellow-700'
|
||||
? 'bg-neutral-100 text-ink'
|
||||
: 'bg-accent-100 text-accent-700'
|
||||
}`}>
|
||||
{inv.completed_at ? 'Completed' : 'In Progress'}
|
||||
</span>
|
||||
@@ -67,7 +67,7 @@ export function InvestigationPanel({ investigation: inv }: Props) {
|
||||
<ol className="space-y-3">
|
||||
{inv.five_why_steps.map((step, i) => (
|
||||
<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}
|
||||
</span>
|
||||
<div className="flex-1 min-w-0">
|
||||
@@ -107,7 +107,7 @@ export function InvestigationPanel({ investigation: inv }: Props) {
|
||||
|
||||
{/* Root cause */}
|
||||
{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>
|
||||
<p className="text-sm text-gray-900 whitespace-pre-wrap">{inv.root_cause_summary}</p>
|
||||
</div>
|
||||
|
||||
@@ -56,15 +56,15 @@ export function OfflineSync() {
|
||||
if (pendingCount === 0) return null
|
||||
|
||||
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">
|
||||
<span className="text-sm text-yellow-800 font-medium">
|
||||
<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-accent-700 font-medium">
|
||||
{pendingCount} report{pendingCount > 1 ? 's' : ''} saved offline
|
||||
</span>
|
||||
<button
|
||||
onClick={syncNow}
|
||||
disabled={syncing || !navigator.onLine}
|
||||
className="text-xs bg-yellow-600 text-white px-3 py-1.5 rounded font-medium
|
||||
hover:bg-yellow-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors"
|
||||
className="text-xs bg-accent text-white px-3 py-1.5 font-medium
|
||||
hover:bg-accent-600 disabled:opacity-50 disabled:cursor-not-allowed transition-colors"
|
||||
>
|
||||
{syncing ? 'Syncing…' : 'Sync now'}
|
||||
</button>
|
||||
|
||||
@@ -15,7 +15,7 @@ export function Pagination({ page, pageSize, total, href }: Props) {
|
||||
disabled ? (
|
||||
<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}
|
||||
</Link>
|
||||
)
|
||||
|
||||
@@ -73,7 +73,7 @@ export function ReportForm({ zoneToken, trucks, initialTruckId }: Props) {
|
||||
value={(typeDetails[key] as string) ?? ''}
|
||||
onChange={e => setDetail(key, e.target.value)}
|
||||
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>
|
||||
)
|
||||
@@ -82,7 +82,7 @@ export function ReportForm({ zoneToken, trucks, initialTruckId }: Props) {
|
||||
<label className="flex items-center gap-3 cursor-pointer">
|
||||
<input
|
||||
type="checkbox"
|
||||
className="w-4 h-4 text-blue-600"
|
||||
className="w-4 h-4 text-accent-700"
|
||||
checked={Boolean(typeDetails[key])}
|
||||
onChange={e => setDetail(key, e.target.checked)}
|
||||
/>
|
||||
@@ -205,22 +205,22 @@ export function ReportForm({ zoneToken, trucks, initialTruckId }: Props) {
|
||||
|
||||
if (savedOffline) {
|
||||
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}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
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 && (
|
||||
<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}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{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}
|
||||
</div>
|
||||
)}
|
||||
@@ -231,7 +231,7 @@ export function ReportForm({ zoneToken, trucks, initialTruckId }: Props) {
|
||||
</label>
|
||||
<select
|
||||
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}
|
||||
onChange={e => {
|
||||
setForm(f => ({ ...f, incident_type: e.target.value as IncidentType, truck_id: '' }))
|
||||
@@ -246,26 +246,26 @@ export function ReportForm({ zoneToken, trucks, initialTruckId }: Props) {
|
||||
</div>
|
||||
|
||||
{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('estimated_volume', tdLabels.estimatedVolume, tdLabels.estimatedVolumePlaceholder)}
|
||||
{detailCheckbox('containment_deployed', tdLabels.containmentDeployed)}
|
||||
</div>
|
||||
)}
|
||||
{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)}
|
||||
{detailCheckbox('loto_applied', tdLabels.lotoApplied)}
|
||||
</div>
|
||||
)}
|
||||
{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)}
|
||||
{detailCheckbox('police_reported', tdLabels.policeReported)}
|
||||
</div>
|
||||
)}
|
||||
{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('fire_brigade_called', tdLabels.fireBrigadeCalled)}
|
||||
</div>
|
||||
@@ -278,7 +278,7 @@ export function ReportForm({ zoneToken, trucks, initialTruckId }: Props) {
|
||||
</label>
|
||||
<select
|
||||
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}
|
||||
onChange={e => setForm(f => ({ ...f, truck_id: e.target.value }))}
|
||||
>
|
||||
@@ -301,31 +301,31 @@ export function ReportForm({ zoneToken, trucks, initialTruckId }: Props) {
|
||||
minLength={10}
|
||||
rows={4}
|
||||
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}
|
||||
onChange={e => setForm(f => ({ ...f, description: e.target.value }))}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{qualityCheck && !qualityCheck.passes && (
|
||||
<div className="rounded-lg bg-amber-50 border border-amber-200 p-3 space-y-2">
|
||||
<p className="text-xs font-semibold text-amber-700 uppercase tracking-wide">
|
||||
<div className="bg-accent-100 border border-accent-300 p-3 space-y-2">
|
||||
<p className="text-xs font-semibold text-accent-700 uppercase tracking-wide">
|
||||
{t.qualityScoreLabel.replace('{score}', String(qualityCheck.score))}
|
||||
</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 && (
|
||||
<ul className="list-disc list-inside space-y-1">
|
||||
{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>
|
||||
)}
|
||||
<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
|
||||
type="checkbox"
|
||||
checked={overrideQuality}
|
||||
onChange={e => setOverrideQuality(e.target.checked)}
|
||||
className="rounded border-amber-300 text-amber-600"
|
||||
className="border-accent-300 text-accent-700"
|
||||
/>
|
||||
{t.submitAnyway}
|
||||
</label>
|
||||
@@ -336,7 +336,7 @@ export function ReportForm({ zoneToken, trucks, initialTruckId }: Props) {
|
||||
<label className="flex items-center gap-3 cursor-pointer">
|
||||
<input
|
||||
type="checkbox"
|
||||
className="w-4 h-4 text-blue-600"
|
||||
className="w-4 h-4 text-accent-700"
|
||||
checked={form.injury_involved}
|
||||
onChange={e => setForm(f => ({ ...f, injury_involved: e.target.checked, medical_status: '' }))}
|
||||
/>
|
||||
@@ -350,7 +350,7 @@ export function ReportForm({ zoneToken, trucks, initialTruckId }: Props) {
|
||||
</label>
|
||||
<select
|
||||
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}
|
||||
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">
|
||||
<input
|
||||
type="checkbox"
|
||||
className="w-4 h-4 text-blue-600"
|
||||
className="w-4 h-4 text-accent-700"
|
||||
checked={form.asset_involved}
|
||||
onChange={e => setForm(f => ({ ...f, asset_involved: e.target.checked }))}
|
||||
/>
|
||||
@@ -383,8 +383,8 @@ export function ReportForm({ zoneToken, trucks, initialTruckId }: Props) {
|
||||
<button
|
||||
type="submit"
|
||||
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
|
||||
hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors"
|
||||
className="w-full bg-accent text-white py-3 font-medium text-sm
|
||||
hover:bg-accent-600 disabled:opacity-50 disabled:cursor-not-allowed transition-colors"
|
||||
>
|
||||
{submitting ? t.submitting : t.submitButton}
|
||||
</button>
|
||||
|
||||
@@ -43,7 +43,7 @@ export function SimilarIncidentsPanel({ incidentId }: Props) {
|
||||
|
||||
if (loading) {
|
||||
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>
|
||||
</div>
|
||||
)
|
||||
@@ -51,7 +51,7 @@ export function SimilarIncidentsPanel({ incidentId }: Props) {
|
||||
if (error || similar.length === 0) return null
|
||||
|
||||
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">
|
||||
Similar Past Incidents
|
||||
</h2>
|
||||
@@ -60,7 +60,7 @@ export function SimilarIncidentsPanel({ incidentId }: Props) {
|
||||
<a
|
||||
key={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">
|
||||
<span className="text-xs font-medium text-gray-500">
|
||||
|
||||
@@ -95,7 +95,7 @@ export function TriageForm({ incidentId, currentSeverity }: Props) {
|
||||
<form onSubmit={handleSubmit} className="space-y-6">
|
||||
<div>
|
||||
<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 => (
|
||||
<button
|
||||
key={v}
|
||||
@@ -103,8 +103,8 @@ export function TriageForm({ incidentId, currentSeverity }: Props) {
|
||||
onClick={() => setSeverity(v)}
|
||||
className={`flex-1 py-2 text-xs font-medium transition-colors ${
|
||||
severity === v
|
||||
? 'bg-blue-600 text-white border-blue-600'
|
||||
: 'bg-white text-gray-700 hover:bg-gray-50'
|
||||
? 'bg-accent text-white border-accent'
|
||||
: 'bg-surface text-gray-700 hover:bg-gray-50'
|
||||
}`}
|
||||
>
|
||||
<span className="block font-bold">{v}</span>
|
||||
@@ -126,7 +126,7 @@ export function TriageForm({ incidentId, currentSeverity }: Props) {
|
||||
<input
|
||||
type="checkbox" checked={value}
|
||||
onChange={e => set(e.target.checked)}
|
||||
className="rounded border-gray-300 text-blue-600"
|
||||
className="border-divider text-accent-700"
|
||||
/>
|
||||
{label}
|
||||
</label>
|
||||
@@ -134,7 +134,7 @@ export function TriageForm({ incidentId, currentSeverity }: Props) {
|
||||
</fieldset>
|
||||
|
||||
{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>
|
||||
{dosh.reasons.map(r => (
|
||||
<p key={r} className="text-xs text-red-600">{r}</p>
|
||||
@@ -151,16 +151,16 @@ export function TriageForm({ incidentId, currentSeverity }: Props) {
|
||||
value={triageNotes}
|
||||
onChange={e => setTriageNotes(e.target.value)}
|
||||
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..."
|
||||
/>
|
||||
</div>
|
||||
|
||||
{aiRationale && (
|
||||
<div className="rounded-lg bg-purple-50 border border-purple-200 p-3">
|
||||
<p className="text-xs font-semibold text-purple-700 mb-1">AI Suggestion Rationale</p>
|
||||
<p className="text-xs text-purple-600">{aiRationale}</p>
|
||||
<p className="text-xs text-purple-400 mt-1">Fields pre-filled — review before submitting.</p>
|
||||
<div className="bg-accent-100 border border-accent-300 p-3">
|
||||
<p className="text-xs font-semibold text-accent-700 mb-1">AI Suggestion Rationale</p>
|
||||
<p className="text-xs text-accent-700">{aiRationale}</p>
|
||||
<p className="text-xs text-accent-400 mt-1">Fields pre-filled — review before submitting.</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -171,14 +171,14 @@ export function TriageForm({ incidentId, currentSeverity }: Props) {
|
||||
type="button"
|
||||
onClick={getAiSuggestion}
|
||||
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'}
|
||||
</button>
|
||||
<button
|
||||
type="submit"
|
||||
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'}
|
||||
</button>
|
||||
|
||||
@@ -33,7 +33,7 @@ export function LanguageSwitcher() {
|
||||
value={current}
|
||||
onChange={e => handleChange(e.target.value)}
|
||||
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]) => (
|
||||
<option key={code} value={code}>{label}</option>
|
||||
|
||||
@@ -2,6 +2,17 @@
|
||||
|
||||
import Link from 'next/link'
|
||||
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'
|
||||
|
||||
interface NavItem {
|
||||
@@ -16,52 +27,15 @@ interface SidebarProps {
|
||||
userEmail: string
|
||||
}
|
||||
|
||||
const IconGrid = () => (
|
||||
<svg className="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M4 6h16M4 12h16M4 18h7" />
|
||||
</svg>
|
||||
)
|
||||
const IconList = () => (
|
||||
<svg className="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<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" />
|
||||
</svg>
|
||||
)
|
||||
const IconCheck = () => (
|
||||
<svg className="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" />
|
||||
</svg>
|
||||
)
|
||||
const IconChart = () => (
|
||||
<svg className="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z" />
|
||||
</svg>
|
||||
)
|
||||
const IconSettings = () => (
|
||||
<svg className="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z" />
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
|
||||
</svg>
|
||||
)
|
||||
const IconUsers = () => (
|
||||
<svg className="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M12 4.354a4 4 0 110 5.292M15 21H3v-1a6 6 0 0112 0v1zm0 0h6v-1a6 6 0 00-9-5.197M13 7a4 4 0 11-8 0 4 4 0 018 0z" />
|
||||
</svg>
|
||||
)
|
||||
const IconPlus = () => (
|
||||
<svg className="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M12 4v16m8-8H4" />
|
||||
</svg>
|
||||
)
|
||||
const IconLogout = () => (
|
||||
<svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M17 16l4-4m0 0l-4-4m4 4H7m6 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h4a3 3 0 013 3v1" />
|
||||
</svg>
|
||||
)
|
||||
const IconUser = () => (
|
||||
<svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z" />
|
||||
</svg>
|
||||
)
|
||||
const IconGrid = () => <AlignLeft size={20} aria-hidden />
|
||||
const IconList = () => <ClipboardList size={20} aria-hidden />
|
||||
const IconCheck = () => <CircleCheck size={20} aria-hidden />
|
||||
const IconChart = () => <LayoutDashboard size={20} aria-hidden />
|
||||
const IconSettings = () => <Settings size={20} aria-hidden />
|
||||
const IconUsers = () => <Users size={20} aria-hidden />
|
||||
const IconPlus = () => <Plus size={20} aria-hidden />
|
||||
const IconLogout = () => <LogOut size={16} aria-hidden />
|
||||
const IconUser = () => <User size={16} aria-hidden />
|
||||
|
||||
const NAV_ITEMS: Record<string, NavItem[]> = {
|
||||
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 {
|
||||
return name
|
||||
.split(' ')
|
||||
@@ -107,23 +87,19 @@ function useNavItems(role: string): NavItem[] {
|
||||
return NAV_ITEMS[role] ?? NAV_ITEMS.reporter
|
||||
}
|
||||
|
||||
function NavLink({ item, pathname }: { item: NavItem; pathname: string }) {
|
||||
// Exact match for root-level single-page roles, prefix match otherwise
|
||||
const exactRoots = ['/reporter', '/supervisor', '/management', '/capa-owner', '/admin', '/report', '/account']
|
||||
const isActive = exactRoots.includes(item.href)
|
||||
? pathname === item.href
|
||||
: pathname.startsWith(item.href)
|
||||
const LINK_BASE = 'flex items-center gap-3 px-3 py-2 text-sm border-l-2 transition-colors'
|
||||
const LINK_ACTIVE = 'border-accent text-accent-700 font-extrabold bg-accent-100/50'
|
||||
const LINK_IDLE = 'border-transparent text-ink/70 font-medium hover:bg-ink/7 hover:text-ink'
|
||||
|
||||
function NavLink({ item, pathname }: { item: NavItem; pathname: string }) {
|
||||
const active = isActivePath(item.href, pathname)
|
||||
return (
|
||||
<Link
|
||||
href={item.href}
|
||||
className={`flex items-center gap-3 px-3 py-2 rounded-lg text-sm font-medium transition-colors ${
|
||||
isActive
|
||||
? 'bg-blue-50 text-blue-700'
|
||||
: 'text-gray-600 hover:bg-gray-100 hover:text-gray-900'
|
||||
}`}
|
||||
aria-current={active ? 'page' : undefined}
|
||||
className={`${LINK_BASE} ${active ? LINK_ACTIVE : LINK_IDLE}`}
|
||||
>
|
||||
<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}
|
||||
</Link>
|
||||
)
|
||||
@@ -143,74 +119,67 @@ export function Sidebar({ role, userName, userEmail }: SidebarProps) {
|
||||
|
||||
const displayName = userName || userEmail || 'User'
|
||||
const roleLabel = role.replace(/_/g, ' ').replace(/\b\w/g, c => c.toUpperCase())
|
||||
const accountActive = pathname === '/account'
|
||||
|
||||
return (
|
||||
<>
|
||||
{/* 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">
|
||||
{/* Header */}
|
||||
<div className="flex items-center justify-between px-4 py-4 border-b border-gray-100">
|
||||
<span className="text-base font-bold text-gray-900 tracking-tight">IMS</span>
|
||||
<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">
|
||||
<div className="flex items-center justify-between px-4 py-4 border-b-2 border-divider">
|
||||
<span className="text-lg font-extrabold tracking-tight text-ink">IMS</span>
|
||||
<NotificationBell />
|
||||
</div>
|
||||
|
||||
{/* Nav */}
|
||||
<nav className="flex-1 overflow-y-auto px-3 py-3 space-y-1">
|
||||
<nav className="flex-1 overflow-y-auto py-3">
|
||||
{items.map(item => (
|
||||
<NavLink key={item.href} item={item} pathname={pathname} />
|
||||
))}
|
||||
</nav>
|
||||
|
||||
{/* User + logout */}
|
||||
<div className="border-t border-gray-100 px-3 py-3">
|
||||
<div className="flex items-center gap-2 px-2 py-2 mb-1">
|
||||
<div className="w-8 h-8 rounded-full bg-blue-600 flex items-center justify-center text-white text-xs font-bold flex-shrink-0">
|
||||
<div className="border-t-2 border-divider py-3">
|
||||
<div className="flex items-center gap-2 px-4 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">
|
||||
{initials(displayName)}
|
||||
</div>
|
||||
<div className="min-w-0">
|
||||
<p className="text-sm font-medium text-gray-900 truncate">{displayName}</p>
|
||||
<p className="text-xs text-gray-500 truncate">{roleLabel}</p>
|
||||
<p className="text-sm font-extrabold text-ink truncate">{displayName}</p>
|
||||
<p className="text-xs text-ink/60 truncate">{roleLabel}</p>
|
||||
</div>
|
||||
</div>
|
||||
<Link
|
||||
href="/account"
|
||||
className={`flex items-center gap-2 w-full px-3 py-2 text-sm rounded-lg transition-colors ${
|
||||
pathname === '/account'
|
||||
? 'bg-blue-50 text-blue-700'
|
||||
: 'text-gray-600 hover:bg-gray-100 hover:text-gray-900'
|
||||
}`}
|
||||
aria-current={accountActive ? 'page' : undefined}
|
||||
className={`${LINK_BASE} ${accountActive ? LINK_ACTIVE : LINK_IDLE}`}
|
||||
>
|
||||
<span className={pathname === '/account' ? 'text-blue-600' : 'text-gray-400'}>
|
||||
<span className={accountActive ? 'text-accent-700' : 'text-ink/50'}>
|
||||
<IconUser />
|
||||
</span>
|
||||
Account
|
||||
</Link>
|
||||
<button
|
||||
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
|
||||
</button>
|
||||
<div className="mt-3 pt-3 border-t border-gray-100 px-2 text-center">
|
||||
<p className="text-xs text-gray-400">v1.2.2</p>
|
||||
<div className="mt-3 pt-3 border-t border-divider px-4">
|
||||
<p className="text-xs text-ink/50">v1.2.2</p>
|
||||
</div>
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
{/* 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 => {
|
||||
const exactRoots = ['/reporter', '/supervisor', '/management', '/capa-owner', '/admin', '/report', '/account']
|
||||
const isActive = exactRoots.includes(item.href)
|
||||
? pathname === item.href
|
||||
: pathname.startsWith(item.href)
|
||||
const active = isActivePath(item.href, pathname)
|
||||
return (
|
||||
<Link
|
||||
key={item.href}
|
||||
href={item.href}
|
||||
className={`flex-1 flex flex-col items-center gap-1 py-2 text-[10px] font-medium transition-colors ${
|
||||
isActive ? 'text-blue-600' : 'text-gray-400'
|
||||
aria-current={active ? 'page' : undefined}
|
||||
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}
|
||||
@@ -218,11 +187,10 @@ export function Sidebar({ role, userName, userEmail }: SidebarProps) {
|
||||
</Link>
|
||||
)
|
||||
})}
|
||||
{/* Mobile logout in "More" slot if room */}
|
||||
{items.length <= 4 && (
|
||||
<button
|
||||
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 />
|
||||
<span className="leading-none">Logout</span>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
import { useCallback, useEffect, useRef, useState } from 'react'
|
||||
import Link from 'next/link'
|
||||
import { Bell } from 'lucide-react'
|
||||
|
||||
type Notification = {
|
||||
id: string
|
||||
@@ -62,22 +63,22 @@ export function NotificationBell() {
|
||||
<button
|
||||
onClick={() => setOpen(o => !o)}
|
||||
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 && (
|
||||
<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}
|
||||
</span>
|
||||
)}
|
||||
</button>
|
||||
|
||||
{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="flex items-center justify-between px-4 py-2 border-b border-gray-100">
|
||||
<span className="text-sm font-semibold text-gray-700">Notifications</span>
|
||||
<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-2 border-divider">
|
||||
<span className="text-sm font-extrabold text-ink">Notifications</span>
|
||||
{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
|
||||
</button>
|
||||
)}
|
||||
|
||||
@@ -44,13 +44,13 @@ export function ApiKeyForm({ settings }: Props) {
|
||||
{Object.keys(KEY_LABELS).map(key => {
|
||||
const status = settings[key]
|
||||
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">
|
||||
<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
|
||||
? 'bg-green-100 text-green-700'
|
||||
: 'bg-yellow-100 text-yellow-700'
|
||||
? 'bg-neutral-100 text-ink'
|
||||
: 'bg-accent-100 text-accent-700'
|
||||
}`}>
|
||||
{status?.set ? 'Configured' : 'Not set'}
|
||||
</span>
|
||||
@@ -66,18 +66,18 @@ export function ApiKeyForm({ settings }: Props) {
|
||||
value={values[key]}
|
||||
onChange={e => setValues(v => ({ ...v, [key]: e.target.value }))}
|
||||
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
|
||||
onClick={() => save(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'}
|
||||
</button>
|
||||
</div>
|
||||
{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' && (
|
||||
<p className="text-xs text-red-600 mt-2">Save failed. Check your permissions.</p>
|
||||
|
||||
@@ -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} />
|
||||
}
|
||||
@@ -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>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
export const cx = (...parts: Array<string | false | null | undefined>): string =>
|
||||
parts.filter(Boolean).join(' ')
|
||||
@@ -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
@@ -1,6 +1,7 @@
|
||||
'use client'
|
||||
|
||||
import { useEffect } from 'react'
|
||||
import { X } from 'lucide-react'
|
||||
|
||||
interface ModalProps {
|
||||
open: boolean
|
||||
@@ -25,20 +26,21 @@ export function Modal({ open, onClose, title, children, footer, width = 'md' }:
|
||||
|
||||
return (
|
||||
<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={`relative w-full ${maxW} bg-white rounded-2xl shadow-2xl`}>
|
||||
<div className="flex items-center justify-between px-6 py-4 border-b border-gray-100">
|
||||
<h2 className="text-sm font-semibold text-gray-900">{title}</h2>
|
||||
<button onClick={onClose} aria-label="Close"
|
||||
className="text-gray-400 hover:text-gray-600 p-1 rounded-lg hover:bg-gray-100 transition-colors cursor-pointer">
|
||||
<svg className="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2.5}>
|
||||
<path strokeLinecap="round" strokeLinejoin="round" d="M6 18 18 6M6 6l12 12" />
|
||||
</svg>
|
||||
<div className="absolute inset-0 bg-neutral-900/50" onClick={onClose} />
|
||||
<div className={`relative w-full ${maxW} bg-surface shadow-lg`}>
|
||||
<div className="flex items-center justify-between px-6 py-4 border-b-2 border-divider">
|
||||
<h2 className="text-xl font-extrabold text-ink">{title}</h2>
|
||||
<button
|
||||
onClick={onClose}
|
||||
aria-label="Close"
|
||||
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"
|
||||
>
|
||||
<X size={18} strokeWidth={2} aria-hidden />
|
||||
</button>
|
||||
</div>
|
||||
<div className="px-6 py-5">{children}</div>
|
||||
{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}
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -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>
|
||||
}
|
||||
@@ -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'
|
||||
@@ -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>
|
||||
)
|
||||
}
|
||||
+151
@@ -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
@@ -0,0 +1,117 @@
|
||||
# Modernist Design System Restyle
|
||||
|
||||
**Date:** 2026-09-30
|
||||
**Status:** Approved
|
||||
**Goal:** Restyle the whole IMS app to the Modernist design system in `design-system/_ds/modernist-*/`, and record the guidelines so future development follows them.
|
||||
|
||||
## Decisions
|
||||
|
||||
- **Governing source:** Modernist (`design-system/_ds/modernist-6062679c-a4aa-42a4-9043-28fea370dda9/readme.md` and `styles.css`). `design-system/IMS Admin.dc.html` (Geist, teal, 12px radius) is superseded and is not implemented. Its screen structure is out of scope for this pass.
|
||||
- **Scope:** Whole app in one pass: tokens and base styles, shared shell, then every page (login, reporter, HSE, supervisor, management, capa-owner, admin).
|
||||
- **Approach:** Remap Tailwind v4 tokens to Modernist so the existing utility classes restyle automatically, then add a thin set of shared components where token remapping leaves the markup structurally wrong.
|
||||
|
||||
## Current state
|
||||
|
||||
- Tailwind v4 (`@import "tailwindcss"` and `@theme inline` in `app/globals.css`), 62 TSX files with `className`.
|
||||
- Utility usage: 522 `gray-*`, 120 `blue-*`, 219 `rounded*`, 57 `shadow*`.
|
||||
- Semantic colors in use: red (errors, overdue), green (done, verified), purple, yellow, orange (workflow statuses, priorities).
|
||||
- Font: Geist and Geist Mono via `next/font/google` in `app/layout.tsx`.
|
||||
- Icons: inline SVG, `lucide-react` is not installed.
|
||||
- Shared UI: `components/ui/modal.tsx` (rounded-2xl, gray-900/50 backdrop), `components/layout/sidebar.tsx`.
|
||||
|
||||
## Design
|
||||
|
||||
### 1. Tokens (`app/globals.css`)
|
||||
|
||||
Copy the Modernist `:root` variables verbatim from `styles.css` (colors, neutral and accent ramps, fonts, spacing, radius, shadows). Do not hard-code hex values elsewhere.
|
||||
|
||||
Expose them to Tailwind through `@theme`:
|
||||
|
||||
- `--color-gray-50…900` map to `--color-neutral-100…900` (nearest step). Existing `gray-*` classes then render on the Modernist neutral ramp.
|
||||
- `--color-blue-50…900` map to `--color-accent-100…900`. Existing `blue-*` classes then render as the red accent (primary buttons, links, focus).
|
||||
- `--radius-*` (`sm`, `md`, `lg`, `xl`, `2xl`, `3xl`) are set to `0`. `rounded-full` is left alone, so circular avatars and radio dots stay round.
|
||||
- Shadows: remap `shadow-sm/md/lg` to `--shadow-sm/md/lg`. `shadow-xl` and `shadow-2xl` are replaced with `shadow-lg`.
|
||||
- `--font-sans` and `--font-heading` are set to Archivo (400, 600, 800). Remove Geist, and Geist Mono stays only if monospace is used anywhere.
|
||||
|
||||
Base layer (from `styles.css`): body uses `--color-bg` and `--color-text` at 15px/1.55, headings use Archivo 800 with the Modernist scale, `a` uses the accent, `:focus-visible` is a 2px accent outline with 2px offset, `::selection` is an accent tint, disabled controls drop to 45% opacity. Remove the `prefers-color-scheme: dark` block: Modernist defines only a light ground.
|
||||
|
||||
Fix `app/globals.css` input colors (`#111827`, `#6b7280`) to use `--color-text` and a 55% text mix.
|
||||
|
||||
### 2. Shared components (`components/ui/`)
|
||||
|
||||
Each takes Modernist tokens only and carries the markup rules Tailwind remapping cannot:
|
||||
|
||||
| Component | Rules |
|
||||
| --- | --- |
|
||||
| `Button` (`primary`, `secondary`, `ghost`, `icon`, `block`) | Archivo 800 14px, flush-left label even when wide, primary is solid accent with `accent-600` hover and `accent-700` pressed. Secondary is a 1px divider border. |
|
||||
| `Tag` (`accent`, `neutral`, `outline`) | 11px, 3px 10px padding, no radius. Used for statuses and priorities. |
|
||||
| `Field` and `Input` | 12px label above, 36px min height, surface fill, 1px divider border, accent border on focus. |
|
||||
| `Card` | Surface fill, 12px padding, no border, no radius, optional `kicker`, `title`, `meta`. |
|
||||
| `DataTable` styles | Uppercase 11px header with a 2px divider under it, 1px row rules, 4% text-tint row hover. |
|
||||
| `Modal` (existing) | Restyle to `.dialog`: surface fill, 0 radius, `--shadow-lg`, neutral-900/50 backdrop, title uses Archivo 800 20px, Lucide `X` for close. |
|
||||
|
||||
Existing pages keep their own markup where the remapped utilities already render correctly. Migrate a page to these components only when its markup needs a structural change (for example centered button labels, rounded chips, hairline dividers).
|
||||
|
||||
### 3. Shell
|
||||
|
||||
- **Sidebar:** flat surface, 2px right rule in `--color-divider`, brand in Archivo 800, nav items flush left with Lucide icons, active item in accent, version label kept at the bottom.
|
||||
- **Mobile bottom nav:** 2px top rule, same active treatment.
|
||||
- **Notification bell:** square button with a 1px divider border (was a round white button).
|
||||
- **Section dividers:** use `.hr` (2px) between major sections, not whitespace or hairlines.
|
||||
|
||||
### 4. Icons
|
||||
|
||||
Install `lucide-react` and replace the inline SVGs in the sidebar, modal, nav, and buttons with Lucide equivalents. Default 16 to 20px, stroke 2.
|
||||
|
||||
### 5. Imagery
|
||||
|
||||
Add the `grayscale` class (`filter: grayscale(1) contrast(1.08)`) for decorative or brand photography only. Incident evidence photos and thumbnails stay in full color, because color can carry evidence (spill color, burns, signage). Decided 2026-09-30.
|
||||
|
||||
### 6. Status and priority colors (design decision)
|
||||
|
||||
Modernist is near-mono with one accent, so the current red, green, purple, yellow and orange status chips cannot all survive. Proposed mapping:
|
||||
|
||||
| Meaning | Treatment |
|
||||
| --- | --- |
|
||||
| Needs attention or overdue, open, reported, severity 4 to 5, errors | `tag-accent` (red tint), red text for inline errors |
|
||||
| In progress (triaged, investigating, CAPA pending, verification) | `tag-outline` (accent outline) |
|
||||
| Done (closed, verified, completed) | `tag-neutral` |
|
||||
| Low priority or informational | `tag-neutral` |
|
||||
|
||||
Status is never conveyed by color alone: every tag keeps its text label, and the workflow states gain a Lucide icon. One central `StatusTag` and `PriorityTag` component replaces the scattered `STATUS_COLORS` and `PRIORITY_COLORS` maps (used in `capa-board.tsx`, `incident-list.tsx`, `incident-header.tsx`, `incident-detail.tsx`, and the reporter, supervisor and capa-owner pages).
|
||||
|
||||
### 7. Out of scope
|
||||
|
||||
- The IMS Admin mockup layouts (index tables with saved views, filter chips, bulk select).
|
||||
- Dark mode.
|
||||
- Data, API, auth or routing changes.
|
||||
- Email templates and the generated PDFs (JKKP 6/7/8, incident report). They keep their own styling.
|
||||
|
||||
## Documentation and memory
|
||||
|
||||
- Add a "Design system" section to `CLAUDE.md`: Modernist is the source of truth, use tokens and never hard-code hex or px, 0 radius, flush-left labels, 2px rules, Lucide icons, `grayscale` imagery, status via `StatusTag` and `PriorityTag`.
|
||||
- Save a memory file `ims-design-system.md` (type `reference`) pointing at `design-system/_ds/modernist-*/readme.md` and recording these rules and the status-color mapping, then add it to `MEMORY.md`.
|
||||
|
||||
## Testing and verification
|
||||
|
||||
- `next build` passes with no type errors. The vitest suite still passes. Only tests asserting old class names need updating.
|
||||
- Run the app locally and check each role's pages in a browser: login, reporter report form and list, HSE inbox, incident detail, CAPA board, supervisor, management dashboard, admin users and settings. Check desktop and mobile widths.
|
||||
- Grep gates after migration: no `rounded-(sm|md|lg|xl|2xl|3xl)` left in app/ or components/ apart from deliberate exceptions, no hard-coded hex in TSX, no `text-center` on button labels.
|
||||
- Keyboard: every interactive element shows the 2px accent focus ring.
|
||||
- Contrast: body copy in accent uses `accent-700`, not the accent itself (accent on ground is 3:1, so chrome only).
|
||||
|
||||
## Deployment
|
||||
|
||||
A build-only deploy per the IMS deployment procedure (`/srv/apps/ims/app`, never build on the server, keep `.next/BUILD_ID` and `.next/static` in place). No database changes.
|
||||
|
||||
## Risks
|
||||
|
||||
- **Remapping `blue-*` to red** can make unrelated blue uses (links, info banners) read as errors. Review every `blue-*` site (120 uses) and switch informational ones to neutral.
|
||||
- **Status legibility:** removing green and purple makes states less scannable. Icons plus labels mitigate this, and the mapping above needs your sign-off.
|
||||
- **Archivo 800 headings** are wider than Geist and can overflow narrow table headers and mobile nav labels. Check at 360px.
|
||||
- **Visual diff is large** (62 files of class changes), so review in a browser, not only via the diff.
|
||||
|
||||
## Resolved decisions
|
||||
|
||||
1. Status mapping in section 6 is approved as written. Green is not kept for "closed/verified".
|
||||
2. Evidence photos are exempt from grayscale (section 5).
|
||||
@@ -45,7 +45,7 @@ describe('analyzePdfsWithDeepSeek', () => {
|
||||
const metadata = await analyzePdfsWithDeepSeek(pdfTexts)
|
||||
expect(metadata.description).toBeDefined()
|
||||
expect(metadata.date).toBeDefined()
|
||||
expect(metadata.location.site).toBeDefined()
|
||||
expect(metadata.location?.site).toBeDefined()
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
Generated
+18
-2
@@ -16,6 +16,7 @@
|
||||
"file-type": "^22.0.1",
|
||||
"idb": "^8.0.3",
|
||||
"jose": "^6.2.4",
|
||||
"lucide-react": "^1.49.0",
|
||||
"next": "^16.3.7",
|
||||
"openai": "^6.46.0",
|
||||
"pdf-lib": "^1.17.1",
|
||||
@@ -3226,7 +3227,7 @@
|
||||
"version": "19.2.17",
|
||||
"resolved": "https://registry.npmjs.org/@types/react/-/react-19.2.17.tgz",
|
||||
"integrity": "sha512-MXfmqaVPEVgkBT/aY0aGCkRWWtByiYQXo3xdQ8r5RzuFrPiRn8Gar2tQdXSUQ2GKV3bkXckek89V8wQBY2Q/Aw==",
|
||||
"dev": true,
|
||||
"devOptional": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"csstype": "^3.2.2"
|
||||
@@ -4681,7 +4682,7 @@
|
||||
"version": "3.2.3",
|
||||
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.3.tgz",
|
||||
"integrity": "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==",
|
||||
"dev": true,
|
||||
"devOptional": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/d": {
|
||||
@@ -8169,6 +8170,21 @@
|
||||
"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": {
|
||||
"version": "1.5.0",
|
||||
"resolved": "https://registry.npmjs.org/lz-string/-/lz-string-1.5.0.tgz",
|
||||
|
||||
+3
-1
@@ -9,7 +9,8 @@
|
||||
"lint": "eslint",
|
||||
"test": "vitest run",
|
||||
"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": {
|
||||
"@anthropic-ai/sdk": "^0.111.0",
|
||||
@@ -20,6 +21,7 @@
|
||||
"file-type": "^22.0.1",
|
||||
"idb": "^8.0.3",
|
||||
"jose": "^6.2.4",
|
||||
"lucide-react": "^1.49.0",
|
||||
"next": "^16.3.7",
|
||||
"openai": "^6.46.0",
|
||||
"pdf-lib": "^1.17.1",
|
||||
|
||||
@@ -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()
|
||||
@@ -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()
|
||||
@@ -21,7 +21,7 @@ import { withUser } from '@/lib/db/with-user'
|
||||
import { buildIncidentReportPdf } from '@/lib/pdf/incident-report'
|
||||
import { NextRequest } from 'next/server'
|
||||
|
||||
const mockSession = { sub: 'user-1', role: 'hse' as const }
|
||||
const mockSession = { sub: 'user-1', role: 'hse' as const, siteId: 'site-1', name: 'Test User' }
|
||||
|
||||
const MOCK_INCIDENT = {
|
||||
id: 'inc-1',
|
||||
|
||||
@@ -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()
|
||||
})
|
||||
})
|
||||
@@ -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)
|
||||
})
|
||||
})
|
||||
@@ -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')
|
||||
})
|
||||
})
|
||||
@@ -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\)/)
|
||||
})
|
||||
})
|
||||
@@ -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>'quoted'</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([])
|
||||
})
|
||||
})
|
||||
@@ -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)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user