refactor(design): drop rounded classes, swap bg-white and gray borders for tokens
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -57,13 +57,13 @@ export default function ForgotPasswordPage() {
|
|||||||
onChange={e => setEmail(e.target.value)}
|
onChange={e => setEmail(e.target.value)}
|
||||||
required
|
required
|
||||||
autoComplete="email"
|
autoComplete="email"
|
||||||
className="border border-gray-300 rounded-md px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"
|
className="border border-divider px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
type="submit"
|
type="submit"
|
||||||
disabled={loading}
|
disabled={loading}
|
||||||
className="bg-blue-600 hover:bg-blue-700 text-white font-medium py-2 rounded-md disabled:opacity-50 transition-colors"
|
className="bg-blue-600 hover:bg-blue-700 text-white font-medium py-2 disabled:opacity-50 transition-colors"
|
||||||
>
|
>
|
||||||
{loading ? 'Sending…' : 'Send reset link'}
|
{loading ? 'Sending…' : 'Send reset link'}
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -10,11 +10,11 @@ export default async function LoginPage({ searchParams }: Props) {
|
|||||||
return (
|
return (
|
||||||
<main className="min-h-screen flex items-center justify-center bg-gray-50 p-4">
|
<main className="min-h-screen flex items-center justify-center bg-gray-50 p-4">
|
||||||
{message === 'password_reset' && (
|
{message === 'password_reset' && (
|
||||||
<div className="fixed top-4 left-1/2 -translate-x-1/2 bg-green-50 border border-green-200 text-green-700 text-sm rounded px-4 py-2 shadow">
|
<div className="fixed top-4 left-1/2 -translate-x-1/2 bg-green-50 border border-green-200 text-green-700 text-sm px-4 py-2 shadow">
|
||||||
Password updated — sign in with your new password.
|
Password updated — sign in with your new password.
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<div className="bg-white rounded-xl shadow-sm border p-8 w-full max-w-sm">
|
<div className="bg-surface shadow-sm border p-8 w-full max-w-sm">
|
||||||
<LoginForm />
|
<LoginForm />
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ export default function ResetPasswordPage() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{error && (
|
{error && (
|
||||||
<p className="bg-red-50 border border-red-200 text-red-700 text-sm rounded px-3 py-2">
|
<p className="bg-red-50 border border-red-200 text-red-700 text-sm px-3 py-2">
|
||||||
{error}{' '}
|
{error}{' '}
|
||||||
{error.includes('expired') && (
|
{error.includes('expired') && (
|
||||||
<Link href="/forgot-password" className="underline">
|
<Link href="/forgot-password" className="underline">
|
||||||
@@ -68,7 +68,7 @@ export default function ResetPasswordPage() {
|
|||||||
required
|
required
|
||||||
minLength={8}
|
minLength={8}
|
||||||
autoComplete="new-password"
|
autoComplete="new-password"
|
||||||
className="border border-gray-300 rounded-md px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"
|
className="border border-divider px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"
|
||||||
/>
|
/>
|
||||||
<input
|
<input
|
||||||
type="password"
|
type="password"
|
||||||
@@ -77,13 +77,13 @@ export default function ResetPasswordPage() {
|
|||||||
onChange={e => setConfirm(e.target.value)}
|
onChange={e => setConfirm(e.target.value)}
|
||||||
required
|
required
|
||||||
autoComplete="new-password"
|
autoComplete="new-password"
|
||||||
className="border border-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-blue-500"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
type="submit"
|
type="submit"
|
||||||
disabled={loading}
|
disabled={loading}
|
||||||
className="bg-blue-600 hover:bg-blue-700 text-white font-medium py-2 rounded-md disabled:opacity-50 transition-colors"
|
className="bg-blue-600 hover:bg-blue-700 text-white font-medium py-2 disabled:opacity-50 transition-colors"
|
||||||
>
|
>
|
||||||
{loading ? 'Saving…' : 'Set password'}
|
{loading ? 'Saving…' : 'Set password'}
|
||||||
</button>
|
</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>
|
<p className="text-sm text-gray-500 mt-0.5">Manage users, sites, zones, and trucks</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="mb-6 flex gap-3">
|
<div className="mb-6 flex gap-3">
|
||||||
<Link href="/bulk-import" className="px-4 py-2 bg-green-600 text-white rounded-lg text-sm font-medium hover:bg-green-700">
|
<Link href="/bulk-import" className="px-4 py-2 bg-green-600 text-white text-sm font-medium hover:bg-green-700">
|
||||||
Bulk Import Incidents
|
Bulk Import Incidents
|
||||||
</Link>
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -82,11 +82,11 @@ export default async function CapaOwnerPage() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{activeRows.length === 0 ? (
|
{activeRows.length === 0 ? (
|
||||||
<div className="bg-white rounded-xl shadow-sm p-8 text-center">
|
<div className="bg-surface shadow-sm p-8 text-center">
|
||||||
<p className="text-gray-400 text-sm">No active CAPAs assigned to you.</p>
|
<p className="text-gray-400 text-sm">No active CAPAs assigned to you.</p>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div className="bg-white rounded-xl shadow-sm divide-y divide-gray-50">
|
<div className="bg-surface shadow-sm divide-y divide-gray-50">
|
||||||
{activeRows.map(capa => {
|
{activeRows.map(capa => {
|
||||||
const isOverdue = isCapaOverdue(capa)
|
const isOverdue = isCapaOverdue(capa)
|
||||||
return (
|
return (
|
||||||
@@ -127,7 +127,7 @@ export default async function CapaOwnerPage() {
|
|||||||
{doneRows.length > 0 && (
|
{doneRows.length > 0 && (
|
||||||
<div className="mt-6">
|
<div className="mt-6">
|
||||||
<h2 className="text-xs font-semibold text-gray-400 uppercase tracking-wide mb-2">Completed ({doneCount})</h2>
|
<h2 className="text-xs font-semibold text-gray-400 uppercase tracking-wide mb-2">Completed ({doneCount})</h2>
|
||||||
<div className="bg-white rounded-xl shadow-sm divide-y divide-gray-50 opacity-60">
|
<div className="bg-surface shadow-sm divide-y divide-gray-50 opacity-60">
|
||||||
{doneRows.map(capa => (
|
{doneRows.map(capa => (
|
||||||
<div key={capa.id} className="p-4 flex items-center justify-between">
|
<div key={capa.id} className="p-4 flex items-center justify-between">
|
||||||
<p className="text-sm text-gray-500 line-clamp-1">{capa.description}</p>
|
<p className="text-sm text-gray-500 line-clamp-1">{capa.description}</p>
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ export default async function CapaDetailPage({ params }: Props) {
|
|||||||
← CAPA Board
|
← CAPA Board
|
||||||
</Link>
|
</Link>
|
||||||
|
|
||||||
<div className="bg-white rounded-xl shadow-sm p-5 mb-4 space-y-4">
|
<div className="bg-surface shadow-sm p-5 mb-4 space-y-4">
|
||||||
<div className="flex items-start justify-between">
|
<div className="flex items-start justify-between">
|
||||||
<div>
|
<div>
|
||||||
<p className="text-xs text-gray-500 mb-1">
|
<p className="text-xs text-gray-500 mb-1">
|
||||||
@@ -70,7 +70,7 @@ export default async function CapaDetailPage({ params }: Props) {
|
|||||||
</p>
|
</p>
|
||||||
<p className="text-gray-900 font-medium">{capa.description}</p>
|
<p className="text-gray-900 font-medium">{capa.description}</p>
|
||||||
</div>
|
</div>
|
||||||
<span className={`px-2 py-1 rounded text-xs font-semibold ${PRIORITY_BADGE[capa.priority] ?? ''}`}>
|
<span className={`px-2 py-1 text-xs font-semibold ${PRIORITY_BADGE[capa.priority] ?? ''}`}>
|
||||||
{capa.priority}
|
{capa.priority}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -165,13 +165,13 @@ export default async function HseDashboardPage({
|
|||||||
<div className="flex gap-3">
|
<div className="flex gap-3">
|
||||||
<a
|
<a
|
||||||
href="/api/dashboard/export?role=hse"
|
href="/api/dashboard/export?role=hse"
|
||||||
className="text-sm text-gray-500 hover:text-gray-700 border border-gray-200 rounded-lg px-3 py-1.5"
|
className="text-sm text-gray-500 hover:text-gray-700 border border-divider px-3 py-1.5"
|
||||||
>
|
>
|
||||||
Export CSV
|
Export CSV
|
||||||
</a>
|
</a>
|
||||||
<a
|
<a
|
||||||
href={`/api/reports/jkkp8?year=${now.getFullYear()}`}
|
href={`/api/reports/jkkp8?year=${now.getFullYear()}`}
|
||||||
className="text-sm text-gray-500 hover:text-gray-700 border border-gray-200 rounded-lg px-3 py-1.5"
|
className="text-sm text-gray-500 hover:text-gray-700 border border-divider px-3 py-1.5"
|
||||||
>
|
>
|
||||||
JKKP 8
|
JKKP 8
|
||||||
</a>
|
</a>
|
||||||
@@ -187,7 +187,7 @@ export default async function HseDashboardPage({
|
|||||||
{(tab === 'overview') && (
|
{(tab === 'overview') && (
|
||||||
<>
|
<>
|
||||||
{now.getMonth() === 0 && (
|
{now.getMonth() === 0 && (
|
||||||
<div className="bg-amber-50 border border-amber-200 rounded-xl p-4 mb-6">
|
<div className="bg-amber-50 border border-amber-200 p-4 mb-6">
|
||||||
<p className="text-sm text-amber-800">
|
<p className="text-sm text-amber-800">
|
||||||
<strong>JKKP 8 annual register due:</strong> the {now.getFullYear() - 1} register must be
|
<strong>JKKP 8 annual register due:</strong> the {now.getFullYear() - 1} register must be
|
||||||
submitted to DOSH before 31 January {now.getFullYear()}.{' '}
|
submitted to DOSH before 31 January {now.getFullYear()}.{' '}
|
||||||
@@ -210,7 +210,7 @@ export default async function HseDashboardPage({
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="bg-white rounded-xl shadow-sm p-5">
|
<div className="bg-surface shadow-sm p-5">
|
||||||
<h2 className="text-sm font-semibold text-gray-900 mb-1">
|
<h2 className="text-sm font-semibold text-gray-900 mb-1">
|
||||||
Leading vs Lagging — Last 30 Days
|
Leading vs Lagging — Last 30 Days
|
||||||
</h2>
|
</h2>
|
||||||
@@ -218,16 +218,16 @@ export default async function HseDashboardPage({
|
|||||||
Leading: hazard + near-miss reports (predict risk) · Lagging: injuries (past harm)
|
Leading: hazard + near-miss reports (predict risk) · Lagging: injuries (past harm)
|
||||||
</p>
|
</p>
|
||||||
<div className="flex gap-4">
|
<div className="flex gap-4">
|
||||||
<div className="flex-1 text-center bg-blue-50 rounded-lg p-4">
|
<div className="flex-1 text-center bg-blue-50 p-4">
|
||||||
<p className="text-3xl font-bold text-blue-600">{leadingCount}</p>
|
<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>
|
<p className="text-xs text-blue-700 mt-1">Leading (Hazards + Near Misses)</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex-1 text-center bg-red-50 rounded-lg p-4">
|
<div className="flex-1 text-center bg-red-50 p-4">
|
||||||
<p className="text-3xl font-bold text-red-600">{laggingCount}</p>
|
<p className="text-3xl font-bold text-red-600">{laggingCount}</p>
|
||||||
<p className="text-xs text-red-700 mt-1">Lagging (Injuries)</p>
|
<p className="text-xs text-red-700 mt-1">Lagging (Injuries)</p>
|
||||||
</div>
|
</div>
|
||||||
{capaOnTimeRate !== null && (
|
{capaOnTimeRate !== null && (
|
||||||
<div className="flex-1 text-center bg-green-50 rounded-lg p-4">
|
<div className="flex-1 text-center bg-green-50 p-4">
|
||||||
<p className="text-3xl font-bold text-green-600">{capaOnTimeRate}%</p>
|
<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>
|
<p className="text-xs text-green-700 mt-1">CAPA On-Time Rate</p>
|
||||||
</div>
|
</div>
|
||||||
@@ -240,7 +240,7 @@ export default async function HseDashboardPage({
|
|||||||
{/* Trends tab */}
|
{/* Trends tab */}
|
||||||
{tab === 'trends' && (
|
{tab === 'trends' && (
|
||||||
<>
|
<>
|
||||||
<div className="bg-white rounded-xl shadow-sm p-5 mb-4">
|
<div className="bg-surface shadow-sm p-5 mb-4">
|
||||||
<h2 className="text-sm font-semibold text-gray-900 mb-1">
|
<h2 className="text-sm font-semibold text-gray-900 mb-1">
|
||||||
Incident Trend — Last 12 Months
|
Incident Trend — Last 12 Months
|
||||||
</h2>
|
</h2>
|
||||||
@@ -266,7 +266,7 @@ export default async function HseDashboardPage({
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{rootCauses.length > 0 && (
|
{rootCauses.length > 0 && (
|
||||||
<div className="bg-white rounded-xl shadow-sm p-5">
|
<div className="bg-surface shadow-sm p-5">
|
||||||
<h2 className="text-sm font-semibold text-gray-900 mb-4">Top Root Causes</h2>
|
<h2 className="text-sm font-semibold text-gray-900 mb-4">Top Root Causes</h2>
|
||||||
<ol className="space-y-2">
|
<ol className="space-y-2">
|
||||||
{rootCauses.map((rc, i) => (
|
{rootCauses.map((rc, i) => (
|
||||||
@@ -288,7 +288,7 @@ export default async function HseDashboardPage({
|
|||||||
{tab === 'zones' && (
|
{tab === 'zones' && (
|
||||||
<>
|
<>
|
||||||
{by_zone.length > 0 && (
|
{by_zone.length > 0 && (
|
||||||
<div className="bg-white rounded-xl shadow-sm p-5 mb-4">
|
<div className="bg-surface shadow-sm p-5 mb-4">
|
||||||
<h2 className="text-sm font-semibold text-gray-900 mb-4">
|
<h2 className="text-sm font-semibold text-gray-900 mb-4">
|
||||||
Zone Incident Heatmap — Last 90 Days
|
Zone Incident Heatmap — Last 90 Days
|
||||||
</h2>
|
</h2>
|
||||||
@@ -312,7 +312,7 @@ export default async function HseDashboardPage({
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<div className="bg-white rounded-xl shadow-sm p-5 mb-4">
|
<div className="bg-surface shadow-sm p-5 mb-4">
|
||||||
<h2 className="text-sm font-semibold text-gray-900 mb-4">By Incident Type</h2>
|
<h2 className="text-sm font-semibold text-gray-900 mb-4">By Incident Type</h2>
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
{Object.entries(by_type).sort((a, b) => b[1] - a[1]).map(([type, count]) => (
|
{Object.entries(by_type).sort((a, b) => b[1] - a[1]).map(([type, count]) => (
|
||||||
@@ -333,7 +333,7 @@ export default async function HseDashboardPage({
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="bg-white rounded-xl shadow-sm p-5">
|
<div className="bg-surface shadow-sm p-5">
|
||||||
<h2 className="text-sm font-semibold text-gray-900 mb-4">By Site</h2>
|
<h2 className="text-sm font-semibold text-gray-900 mb-4">By Site</h2>
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
{by_site.map(({ name, count }) => (
|
{by_site.map(({ name, count }) => (
|
||||||
|
|||||||
@@ -175,14 +175,14 @@ export default async function HseIncidentDetailPage({ params }: Props) {
|
|||||||
<a
|
<a
|
||||||
href={`/api/incidents/${id}/jkkp-pdf?form=jkkp6`}
|
href={`/api/incidents/${id}/jkkp-pdf?form=jkkp6`}
|
||||||
target="_blank"
|
target="_blank"
|
||||||
className="inline-block bg-gray-800 text-white rounded-lg px-4 py-2 text-sm font-semibold hover:bg-gray-900"
|
className="inline-block bg-gray-800 text-white px-4 py-2 text-sm font-semibold hover:bg-gray-900"
|
||||||
>
|
>
|
||||||
Download JKKP 6 (PDF)
|
Download JKKP 6 (PDF)
|
||||||
</a>
|
</a>
|
||||||
<a
|
<a
|
||||||
href={`/api/incidents/${id}/jkkp-pdf?form=jkkp7`}
|
href={`/api/incidents/${id}/jkkp-pdf?form=jkkp7`}
|
||||||
target="_blank"
|
target="_blank"
|
||||||
className="inline-block bg-gray-600 text-white rounded-lg px-4 py-2 text-sm font-semibold hover:bg-gray-700"
|
className="inline-block bg-gray-600 text-white px-4 py-2 text-sm font-semibold hover:bg-gray-700"
|
||||||
>
|
>
|
||||||
Download JKKP 7 (PDF)
|
Download JKKP 7 (PDF)
|
||||||
</a>
|
</a>
|
||||||
@@ -194,7 +194,7 @@ export default async function HseIncidentDetailPage({ params }: Props) {
|
|||||||
href={`/api/incidents/${id}/report-pdf`}
|
href={`/api/incidents/${id}/report-pdf`}
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
className="flex items-center gap-1.5 px-3 py-1.5 bg-green-600 text-white text-xs font-semibold rounded-lg hover:bg-green-700 transition-colors"
|
className="flex items-center gap-1.5 px-3 py-1.5 bg-green-600 text-white text-xs font-semibold hover:bg-green-700 transition-colors"
|
||||||
>
|
>
|
||||||
<svg className="w-3.5 h-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2}>
|
<svg className="w-3.5 h-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2}>
|
||||||
<path strokeLinecap="round" strokeLinejoin="round" d="M12 10v6m0 0l-3-3m3 3l3-3m2 8H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" />
|
<path strokeLinecap="round" strokeLinejoin="round" d="M12 10v6m0 0l-3-3m3 3l3-3m2 8H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" />
|
||||||
|
|||||||
@@ -13,12 +13,12 @@ export default async function HsePage() {
|
|||||||
<h1 className="text-2xl font-bold text-gray-900 mb-1">HSE Officer Portal</h1>
|
<h1 className="text-2xl font-bold text-gray-900 mb-1">HSE Officer Portal</h1>
|
||||||
<p className="text-gray-500 text-sm mb-8">Welcome, {session.name}</p>
|
<p className="text-gray-500 text-sm mb-8">Welcome, {session.name}</p>
|
||||||
<div className="grid grid-cols-2 gap-4 sm:grid-cols-3">
|
<div className="grid grid-cols-2 gap-4 sm:grid-cols-3">
|
||||||
<Link href="/hse/incidents" className="bg-white rounded-xl shadow-sm p-5 hover:shadow-md transition-shadow border border-gray-100">
|
<Link href="/hse/incidents" className="bg-surface shadow-sm p-5 hover:shadow-md transition-shadow border border-divider">
|
||||||
<div className="text-2xl mb-2">📋</div>
|
<div className="text-2xl mb-2">📋</div>
|
||||||
<div className="font-semibold text-gray-900">Incident Inbox</div>
|
<div className="font-semibold text-gray-900">Incident Inbox</div>
|
||||||
<div className="text-xs text-gray-500 mt-1">View all incidents</div>
|
<div className="text-xs text-gray-500 mt-1">View all incidents</div>
|
||||||
</Link>
|
</Link>
|
||||||
<Link href="/hse/dashboard" className="bg-white rounded-xl shadow-sm p-5 hover:shadow-md transition-shadow border border-gray-100">
|
<Link href="/hse/dashboard" className="bg-surface shadow-sm p-5 hover:shadow-md transition-shadow border border-divider">
|
||||||
<div className="text-2xl mb-2">📊</div>
|
<div className="text-2xl mb-2">📊</div>
|
||||||
<div className="font-semibold text-gray-900">Dashboard</div>
|
<div className="font-semibold text-gray-900">Dashboard</div>
|
||||||
<div className="text-xs text-gray-500 mt-1">Stats & overview</div>
|
<div className="text-xs text-gray-500 mt-1">Stats & overview</div>
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ export default async function ManagementPage() {
|
|||||||
<h1 className="text-2xl font-bold text-gray-900">Management Dashboard</h1>
|
<h1 className="text-2xl font-bold text-gray-900">Management Dashboard</h1>
|
||||||
<a
|
<a
|
||||||
href="/api/dashboard/export?role=management"
|
href="/api/dashboard/export?role=management"
|
||||||
className="text-sm text-gray-500 hover:text-gray-700 border border-gray-200 rounded-lg px-3 py-1.5"
|
className="text-sm text-gray-500 hover:text-gray-700 border border-divider px-3 py-1.5"
|
||||||
>
|
>
|
||||||
Export CSV
|
Export CSV
|
||||||
</a>
|
</a>
|
||||||
@@ -119,15 +119,15 @@ export default async function ManagementPage() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Leading vs lagging */}
|
{/* Leading vs lagging */}
|
||||||
<div className="bg-white rounded-xl shadow-sm p-5 mb-4">
|
<div className="bg-surface shadow-sm p-5 mb-4">
|
||||||
<h2 className="text-sm font-semibold text-gray-700 uppercase tracking-wide mb-1">Leading vs Lagging — Last 30 Days</h2>
|
<h2 className="text-sm font-semibold text-gray-700 uppercase tracking-wide mb-1">Leading vs Lagging — Last 30 Days</h2>
|
||||||
<p className="text-xs text-gray-400 mb-4">Leading: hazard + near-miss · Lagging: injuries</p>
|
<p className="text-xs text-gray-400 mb-4">Leading: hazard + near-miss · Lagging: injuries</p>
|
||||||
<div className="flex gap-6">
|
<div className="flex gap-6">
|
||||||
<div className="flex-1 text-center bg-blue-50 rounded-lg p-4">
|
<div className="flex-1 text-center bg-blue-50 p-4">
|
||||||
<p className="text-3xl font-bold text-blue-600">{leadingCount}</p>
|
<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>
|
<p className="text-xs text-blue-700 mt-1">Leading (Hazards + Near Misses)</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex-1 text-center bg-red-50 rounded-lg p-4">
|
<div className="flex-1 text-center bg-red-50 p-4">
|
||||||
<p className="text-3xl font-bold text-red-600">{laggingCount}</p>
|
<p className="text-3xl font-bold text-red-600">{laggingCount}</p>
|
||||||
<p className="text-xs text-red-700 mt-1">Lagging (Injuries)</p>
|
<p className="text-xs text-red-700 mt-1">Lagging (Injuries)</p>
|
||||||
</div>
|
</div>
|
||||||
@@ -135,7 +135,7 @@ export default async function ManagementPage() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Severity distribution */}
|
{/* Severity distribution */}
|
||||||
<div className="bg-white rounded-xl shadow-sm p-5 mb-4">
|
<div className="bg-surface shadow-sm p-5 mb-4">
|
||||||
<h2 className="text-sm font-semibold text-gray-700 uppercase tracking-wide mb-4">Severity Distribution (All Time)</h2>
|
<h2 className="text-sm font-semibold text-gray-700 uppercase tracking-wide mb-4">Severity Distribution (All Time)</h2>
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
{([5, 4, 3, 2, 1] as const).map(sev => (
|
{([5, 4, 3, 2, 1] as const).map(sev => (
|
||||||
@@ -154,7 +154,7 @@ export default async function ManagementPage() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Site comparison */}
|
{/* Site comparison */}
|
||||||
<div className="bg-white rounded-xl shadow-sm p-5">
|
<div className="bg-surface shadow-sm p-5">
|
||||||
<h2 className="text-sm font-semibold text-gray-700 uppercase tracking-wide mb-4">Incidents by Site</h2>
|
<h2 className="text-sm font-semibold text-gray-700 uppercase tracking-wide mb-4">Incidents by Site</h2>
|
||||||
{by_site.length === 0 ? (
|
{by_site.length === 0 ? (
|
||||||
<p className="text-sm text-gray-400">No data</p>
|
<p className="text-sm text-gray-400">No data</p>
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ export default async function ReporterIncidentDetail({
|
|||||||
<Link href="/reporter" className="text-sm text-blue-600 hover:underline">← My Reports</Link>
|
<Link href="/reporter" className="text-sm text-blue-600 hover:underline">← My Reports</Link>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="bg-white rounded-xl shadow-sm p-5">
|
<div className="bg-surface shadow-sm p-5">
|
||||||
<div className="flex items-start justify-between gap-3 mb-4">
|
<div className="flex items-start justify-between gap-3 mb-4">
|
||||||
<div>
|
<div>
|
||||||
<h1 className="text-lg font-bold text-gray-900">{inc.referenceNo ?? inc.id.slice(0, 8)}</h1>
|
<h1 className="text-lg font-bold text-gray-900">{inc.referenceNo ?? inc.id.slice(0, 8)}</h1>
|
||||||
@@ -98,7 +98,7 @@ export default async function ReporterIncidentDetail({
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{inc.description && (
|
{inc.description && (
|
||||||
<div className="border-t border-gray-100 pt-4">
|
<div className="border-t border-divider pt-4">
|
||||||
<p className="text-xs text-gray-500 mb-1">Description</p>
|
<p className="text-xs text-gray-500 mb-1">Description</p>
|
||||||
<p className="text-sm text-gray-800 whitespace-pre-line">{inc.description}</p>
|
<p className="text-sm text-gray-800 whitespace-pre-line">{inc.description}</p>
|
||||||
</div>
|
</div>
|
||||||
@@ -106,17 +106,17 @@ export default async function ReporterIncidentDetail({
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{capas.length > 0 && (
|
{capas.length > 0 && (
|
||||||
<div className="bg-white rounded-xl shadow-sm p-5">
|
<div className="bg-surface shadow-sm p-5">
|
||||||
<h2 className="text-sm font-semibold text-gray-900 mb-3">Corrective Actions ({capas.length})</h2>
|
<h2 className="text-sm font-semibold text-gray-900 mb-3">Corrective Actions ({capas.length})</h2>
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
{capas.map(c => (
|
{capas.map(c => (
|
||||||
<div key={c.id} className="flex items-start justify-between gap-3 text-sm">
|
<div key={c.id} className="flex items-start justify-between gap-3 text-sm">
|
||||||
<p className="text-gray-700 flex-1">{c.description}</p>
|
<p className="text-gray-700 flex-1">{c.description}</p>
|
||||||
<span className={`text-xs rounded-full px-2 py-0.5 shrink-0 ${
|
<span className={`text-xs rounded-full px-2 py-0.5 shrink-0 ${
|
||||||
c.status === 'verified' ? 'bg-green-100 text-green-700' :
|
c.status === 'verified' ? 'bg-green-100 text-green-700' :
|
||||||
c.status === 'pending_verification' ? 'bg-purple-100 text-purple-700' :
|
c.status === 'pending_verification' ? 'bg-purple-100 text-purple-700' :
|
||||||
'bg-gray-100 text-gray-600'
|
'bg-gray-100 text-gray-600'
|
||||||
}`}>{c.status.replace(/_/g, ' ')}</span>
|
}`}>{c.status.replace(/_/g, ' ')}</span>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -62,34 +62,34 @@ export default async function ReporterPage() {
|
|||||||
</div>
|
</div>
|
||||||
<Link
|
<Link
|
||||||
href="/report"
|
href="/report"
|
||||||
className="bg-blue-600 text-white rounded-lg px-4 py-2 text-sm font-semibold hover:bg-blue-700"
|
className="bg-blue-600 text-white px-4 py-2 text-sm font-semibold hover:bg-blue-700"
|
||||||
>
|
>
|
||||||
+ New Report
|
+ New Report
|
||||||
</Link>
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex gap-4 mb-6 text-sm">
|
<div className="flex gap-4 mb-6 text-sm">
|
||||||
<div className="bg-white rounded-xl shadow-sm p-4 flex-1 text-center">
|
<div className="bg-surface shadow-sm p-4 flex-1 text-center">
|
||||||
<p className="text-2xl font-bold text-gray-900">{rows.length}</p>
|
<p className="text-2xl font-bold text-gray-900">{rows.length}</p>
|
||||||
<p className="text-xs text-gray-500 mt-1">Total Submitted</p>
|
<p className="text-xs text-gray-500 mt-1">Total Submitted</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="bg-white rounded-xl shadow-sm p-4 flex-1 text-center">
|
<div className="bg-surface shadow-sm p-4 flex-1 text-center">
|
||||||
<p className="text-2xl font-bold text-yellow-600">{openCount}</p>
|
<p className="text-2xl font-bold text-yellow-600">{openCount}</p>
|
||||||
<p className="text-xs text-gray-500 mt-1">In Progress</p>
|
<p className="text-xs text-gray-500 mt-1">In Progress</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="bg-white rounded-xl shadow-sm p-4 flex-1 text-center">
|
<div className="bg-surface shadow-sm p-4 flex-1 text-center">
|
||||||
<p className="text-2xl font-bold text-green-600">{closedCount}</p>
|
<p className="text-2xl font-bold text-green-600">{closedCount}</p>
|
||||||
<p className="text-xs text-gray-500 mt-1">Closed</p>
|
<p className="text-xs text-gray-500 mt-1">Closed</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{rows.length === 0 ? (
|
{rows.length === 0 ? (
|
||||||
<div className="bg-white rounded-xl shadow-sm p-8 text-center">
|
<div className="bg-surface shadow-sm p-8 text-center">
|
||||||
<p className="text-gray-400 text-sm mb-4">No incidents reported yet.</p>
|
<p className="text-gray-400 text-sm mb-4">No incidents reported yet.</p>
|
||||||
<Link href="/report" className="text-blue-600 text-sm hover:underline">Submit your first report →</Link>
|
<Link href="/report" className="text-blue-600 text-sm hover:underline">Submit your first report →</Link>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div className="bg-white rounded-xl shadow-sm divide-y divide-gray-50">
|
<div className="bg-surface shadow-sm divide-y divide-gray-50">
|
||||||
{rows.map(inc => (
|
{rows.map(inc => (
|
||||||
<Link key={inc.id} href={`/reporter/incidents/${inc.id}`} className="block p-4 cursor-pointer hover:bg-gray-50 transition-colors">
|
<Link key={inc.id} href={`/reporter/incidents/${inc.id}`} className="block p-4 cursor-pointer hover:bg-gray-50 transition-colors">
|
||||||
<div className="flex items-start justify-between gap-3">
|
<div className="flex items-start justify-between gap-3">
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ export default async function SupervisorPage() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Open incidents */}
|
{/* Open incidents */}
|
||||||
<div className="bg-white rounded-xl shadow-sm p-5 mb-4">
|
<div className="bg-surface shadow-sm p-5 mb-4">
|
||||||
<h2 className="text-sm font-semibold text-gray-700 uppercase tracking-wide mb-4">Open Incidents</h2>
|
<h2 className="text-sm font-semibold text-gray-700 uppercase tracking-wide mb-4">Open Incidents</h2>
|
||||||
{openIncidents.length === 0 ? (
|
{openIncidents.length === 0 ? (
|
||||||
<p className="text-sm text-gray-400">No open incidents.</p>
|
<p className="text-sm text-gray-400">No open incidents.</p>
|
||||||
@@ -143,7 +143,7 @@ export default async function SupervisorPage() {
|
|||||||
<Link
|
<Link
|
||||||
key={inc.id}
|
key={inc.id}
|
||||||
href={`/supervisor/incidents/${inc.id}`}
|
href={`/supervisor/incidents/${inc.id}`}
|
||||||
className="flex items-center justify-between py-2 border-b border-gray-50 last:border-0 hover:bg-gray-50 -mx-2 px-2 rounded"
|
className="flex items-center justify-between py-2 border-b border-gray-50 last:border-0 hover:bg-gray-50 -mx-2 px-2"
|
||||||
>
|
>
|
||||||
<div>
|
<div>
|
||||||
<p className="text-sm font-medium text-gray-900">{inc.referenceNo ?? inc.id.slice(0, 8)}</p>
|
<p className="text-sm font-medium text-gray-900">{inc.referenceNo ?? inc.id.slice(0, 8)}</p>
|
||||||
@@ -160,7 +160,7 @@ export default async function SupervisorPage() {
|
|||||||
|
|
||||||
{/* Overdue CAPAs */}
|
{/* Overdue CAPAs */}
|
||||||
{overdueCount > 0 && (
|
{overdueCount > 0 && (
|
||||||
<div className="bg-white rounded-xl shadow-sm p-5">
|
<div className="bg-surface shadow-sm p-5">
|
||||||
<h2 className="text-sm font-semibold text-red-600 uppercase tracking-wide mb-4">Overdue CAPAs</h2>
|
<h2 className="text-sm font-semibold text-red-600 uppercase tracking-wide mb-4">Overdue CAPAs</h2>
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
{overdueCapas.map(capa => (
|
{overdueCapas.map(capa => (
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ export default async function ReportSuccessPage({ searchParams }: Props) {
|
|||||||
const { ref } = await searchParams
|
const { ref } = await searchParams
|
||||||
return (
|
return (
|
||||||
<main className="min-h-screen bg-gray-50 flex items-center justify-center px-4">
|
<main className="min-h-screen bg-gray-50 flex items-center justify-center px-4">
|
||||||
<div className="bg-white rounded-xl shadow-sm p-8 max-w-sm w-full text-center">
|
<div className="bg-surface shadow-sm p-8 max-w-sm w-full text-center">
|
||||||
<div className="text-4xl mb-4">✓</div>
|
<div className="text-4xl mb-4">✓</div>
|
||||||
<h1 className="text-xl font-bold text-gray-900 mb-2">Report submitted</h1>
|
<h1 className="text-xl font-bold text-gray-900 mb-2">Report submitted</h1>
|
||||||
{ref && (
|
{ref && (
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ export default function ChangePasswordForm() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="bg-white rounded-xl shadow-sm p-5">
|
<div className="bg-surface shadow-sm p-5">
|
||||||
<h2 className="text-base font-semibold text-gray-900 mb-4">Change Password</h2>
|
<h2 className="text-base font-semibold text-gray-900 mb-4">Change Password</h2>
|
||||||
<form onSubmit={handleSubmit} className="space-y-4">
|
<form onSubmit={handleSubmit} className="space-y-4">
|
||||||
<div>
|
<div>
|
||||||
@@ -67,7 +67,7 @@ export default function ChangePasswordForm() {
|
|||||||
onChange={e => setCurrent(e.target.value)}
|
onChange={e => setCurrent(e.target.value)}
|
||||||
disabled={loading}
|
disabled={loading}
|
||||||
autoComplete="current-password"
|
autoComplete="current-password"
|
||||||
className="w-full border border-gray-300 rounded-lg px-3 py-2 text-sm focus:ring-2 focus:ring-blue-500 focus:border-transparent disabled:opacity-50"
|
className="w-full border border-divider px-3 py-2 text-sm focus:ring-2 focus:ring-blue-500 focus:border-transparent disabled:opacity-50"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
@@ -80,7 +80,7 @@ export default function ChangePasswordForm() {
|
|||||||
onChange={e => setNewPass(e.target.value)}
|
onChange={e => setNewPass(e.target.value)}
|
||||||
disabled={loading}
|
disabled={loading}
|
||||||
autoComplete="new-password"
|
autoComplete="new-password"
|
||||||
className="w-full border border-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-blue-500 focus:border-transparent disabled:opacity-50"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
@@ -93,7 +93,7 @@ export default function ChangePasswordForm() {
|
|||||||
onChange={e => setConfirm(e.target.value)}
|
onChange={e => setConfirm(e.target.value)}
|
||||||
disabled={loading}
|
disabled={loading}
|
||||||
autoComplete="new-password"
|
autoComplete="new-password"
|
||||||
className="w-full border border-gray-300 rounded-lg px-3 py-2 text-sm focus:ring-2 focus:ring-blue-500 focus:border-transparent disabled:opacity-50"
|
className="w-full border border-divider px-3 py-2 text-sm focus:ring-2 focus:ring-blue-500 focus:border-transparent disabled:opacity-50"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -103,7 +103,7 @@ export default function ChangePasswordForm() {
|
|||||||
<button
|
<button
|
||||||
type="submit"
|
type="submit"
|
||||||
disabled={loading}
|
disabled={loading}
|
||||||
className="bg-blue-600 text-white rounded-lg px-4 py-2 text-sm font-semibold disabled:opacity-50 hover:bg-blue-700"
|
className="bg-blue-600 text-white px-4 py-2 text-sm font-semibold disabled:opacity-50 hover:bg-blue-700"
|
||||||
>
|
>
|
||||||
{loading ? 'Saving…' : 'Update Password'}
|
{loading ? 'Saving…' : 'Update Password'}
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -25,21 +25,21 @@ export function AdminPanel({ users, sites, siteOptions, trucks }: Props) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<div className="flex gap-1 border-b border-gray-200 mb-6">
|
<div className="flex gap-1 border-b border-divider mb-6">
|
||||||
{tabs.map(t => (
|
{tabs.map(t => (
|
||||||
<button
|
<button
|
||||||
key={t.id}
|
key={t.id}
|
||||||
onClick={() => setTab(t.id)}
|
onClick={() => setTab(t.id)}
|
||||||
className={`px-4 py-2.5 text-sm font-medium border-b-2 -mb-px transition-colors cursor-pointer ${
|
className={`px-4 py-2.5 text-sm font-medium border-b-2 -mb-px transition-colors cursor-pointer ${
|
||||||
tab === t.id
|
tab === t.id
|
||||||
? 'border-green-600 text-green-700'
|
? 'border-green-600 text-green-700'
|
||||||
: 'border-transparent text-gray-500 hover:text-gray-700'
|
: 'border-transparent text-gray-500 hover:text-gray-700'
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
{t.label}
|
{t.label}
|
||||||
<span className={`ml-1.5 text-xs px-1.5 py-0.5 rounded-full ${
|
<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'
|
tab === t.id ? 'bg-green-100 text-green-700' : 'bg-gray-100 text-gray-500'
|
||||||
}`}>{t.count}</span>
|
}`}>{t.count}</span>
|
||||||
</button>
|
</button>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ export function BulkImportForm() {
|
|||||||
if (stage === 'upload') {
|
if (stage === 'upload') {
|
||||||
return (
|
return (
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
<label className="block cursor-pointer rounded border-2 border-dashed border-gray-300 p-6 text-center hover:bg-gray-50">
|
<label className="block cursor-pointer border-2 border-dashed border-divider p-6 text-center hover:bg-gray-50">
|
||||||
<input
|
<input
|
||||||
type="file"
|
type="file"
|
||||||
onChange={handleUpload}
|
onChange={handleUpload}
|
||||||
@@ -201,14 +201,14 @@ export function BulkImportForm() {
|
|||||||
<div className="flex gap-2">
|
<div className="flex gap-2">
|
||||||
<button
|
<button
|
||||||
onClick={() => setStage('upload')}
|
onClick={() => setStage('upload')}
|
||||||
className="px-4 py-2 text-gray-600 hover:bg-gray-100 rounded"
|
className="px-4 py-2 text-gray-600 hover:bg-gray-100"
|
||||||
>
|
>
|
||||||
Back
|
Back
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
onClick={handleImport}
|
onClick={handleImport}
|
||||||
disabled={!canImport || loading}
|
disabled={!canImport || loading}
|
||||||
className="px-4 py-2 bg-blue-600 text-white rounded disabled:opacity-50 disabled:cursor-not-allowed"
|
className="px-4 py-2 bg-blue-600 text-white disabled:opacity-50 disabled:cursor-not-allowed"
|
||||||
>
|
>
|
||||||
{loading ? 'Importing...' : 'Import All'}
|
{loading ? 'Importing...' : 'Import All'}
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ interface Props {
|
|||||||
sites: SiteWithZones[]
|
sites: SiteWithZones[]
|
||||||
}
|
}
|
||||||
|
|
||||||
const inp = 'w-full border border-gray-300 rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-green-500 focus:border-green-500'
|
const inp = 'w-full border border-gray-300 px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-green-500 focus:border-green-500'
|
||||||
const lbl = 'block text-xs font-medium text-gray-600 mb-1'
|
const lbl = 'block text-xs font-medium text-gray-600 mb-1'
|
||||||
|
|
||||||
type DeleteTarget = { kind: 'site'; id: string; name: string } | { kind: 'zone'; id: string; name: string }
|
type DeleteTarget = { kind: 'site'; id: string; name: string } | { kind: 'zone'; id: string; name: string }
|
||||||
@@ -81,22 +81,22 @@ export function SiteZoneManager({ sites }: Props) {
|
|||||||
const totalZones = sites.reduce((n, s) => n + s.zones.length, 0)
|
const totalZones = sites.reduce((n, s) => n + s.zones.length, 0)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="bg-white rounded-xl border border-gray-200 shadow-sm overflow-hidden">
|
<div className="bg-surface border border-divider shadow-sm overflow-hidden">
|
||||||
<div className="flex items-center justify-between px-5 py-4 border-b border-gray-100">
|
<div className="flex items-center justify-between px-5 py-4 border-b border-divider">
|
||||||
<div>
|
<div>
|
||||||
<h2 className="text-sm font-semibold text-gray-900">Sites & Zones</h2>
|
<h2 className="text-sm font-semibold text-gray-900">Sites & Zones</h2>
|
||||||
<p className="text-xs text-gray-400 mt-0.5">{sites.length} site{sites.length !== 1 ? 's' : ''} · {totalZones} zone{totalZones !== 1 ? 's' : ''}</p>
|
<p className="text-xs text-gray-400 mt-0.5">{sites.length} site{sites.length !== 1 ? 's' : ''} · {totalZones} zone{totalZones !== 1 ? 's' : ''}</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex gap-2">
|
<div className="flex gap-2">
|
||||||
<button onClick={() => { setShowAddZone(true); setError(null) }}
|
<button onClick={() => { setShowAddZone(true); setError(null) }}
|
||||||
className="flex items-center gap-1.5 px-3 py-1.5 bg-gray-100 text-gray-700 text-xs font-semibold rounded-lg hover:bg-gray-200 transition-colors cursor-pointer">
|
className="flex items-center gap-1.5 px-3 py-1.5 bg-gray-100 text-gray-700 text-xs font-semibold hover:bg-gray-200 transition-colors cursor-pointer">
|
||||||
<svg className="w-3.5 h-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2.5}>
|
<svg className="w-3.5 h-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2.5}>
|
||||||
<path strokeLinecap="round" strokeLinejoin="round" d="M12 4v16m8-8H4" />
|
<path strokeLinecap="round" strokeLinejoin="round" d="M12 4v16m8-8H4" />
|
||||||
</svg>
|
</svg>
|
||||||
Add Zone
|
Add Zone
|
||||||
</button>
|
</button>
|
||||||
<button onClick={() => { setShowAddSite(true); setError(null) }}
|
<button onClick={() => { setShowAddSite(true); setError(null) }}
|
||||||
className="flex items-center gap-1.5 px-3 py-1.5 bg-green-600 text-white text-xs font-semibold rounded-lg hover:bg-green-700 transition-colors cursor-pointer">
|
className="flex items-center gap-1.5 px-3 py-1.5 bg-green-600 text-white text-xs font-semibold hover:bg-green-700 transition-colors cursor-pointer">
|
||||||
<svg className="w-3.5 h-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2.5}>
|
<svg className="w-3.5 h-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2.5}>
|
||||||
<path strokeLinecap="round" strokeLinejoin="round" d="M12 4v16m8-8H4" />
|
<path strokeLinecap="round" strokeLinejoin="round" d="M12 4v16m8-8H4" />
|
||||||
</svg>
|
</svg>
|
||||||
@@ -119,10 +119,10 @@ export function SiteZoneManager({ sites }: Props) {
|
|||||||
<button disabled={busyId === site.id}
|
<button disabled={busyId === site.id}
|
||||||
onClick={() => send('PATCH', { kind: 'site', id: site.id, active: !site.active })}
|
onClick={() => send('PATCH', { kind: 'site', id: site.id, active: !site.active })}
|
||||||
className={`text-xs font-medium px-2.5 py-1 rounded-full border transition-colors cursor-pointer disabled:opacity-50 ${
|
className={`text-xs font-medium px-2.5 py-1 rounded-full border transition-colors cursor-pointer disabled:opacity-50 ${
|
||||||
site.active
|
site.active
|
||||||
? 'bg-green-50 text-green-700 border-green-200 hover:bg-green-100'
|
? 'bg-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-gray-50 text-gray-500 border-divider hover:bg-gray-100'
|
||||||
}`}>
|
}`}>
|
||||||
{site.active ? 'Active' : 'Inactive'}
|
{site.active ? 'Active' : 'Inactive'}
|
||||||
</button>
|
</button>
|
||||||
<button disabled={busyId === site.id}
|
<button disabled={busyId === site.id}
|
||||||
@@ -134,7 +134,7 @@ export function SiteZoneManager({ sites }: Props) {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{site.zones.length > 0 && (
|
{site.zones.length > 0 && (
|
||||||
<ul className="mt-3 space-y-1.5 pl-3 border-l-2 border-gray-100">
|
<ul className="mt-3 space-y-1.5 pl-3 border-l-2 border-divider">
|
||||||
{site.zones.map(z => (
|
{site.zones.map(z => (
|
||||||
<li key={z.id} className={`flex items-center justify-between ${!z.active ? 'opacity-50' : ''}`}>
|
<li key={z.id} className={`flex items-center justify-between ${!z.active ? 'opacity-50' : ''}`}>
|
||||||
<span className="text-xs text-gray-700 font-medium">{z.name}</span>
|
<span className="text-xs text-gray-700 font-medium">{z.name}</span>
|
||||||
@@ -146,10 +146,10 @@ export function SiteZoneManager({ sites }: Props) {
|
|||||||
<button disabled={busyId === z.id}
|
<button disabled={busyId === z.id}
|
||||||
onClick={() => send('PATCH', { kind: 'zone', id: z.id, active: !z.active })}
|
onClick={() => send('PATCH', { kind: 'zone', id: z.id, active: !z.active })}
|
||||||
className={`text-xs font-medium px-2 py-0.5 rounded-full border transition-colors cursor-pointer disabled:opacity-50 ${
|
className={`text-xs font-medium px-2 py-0.5 rounded-full border transition-colors cursor-pointer disabled:opacity-50 ${
|
||||||
z.active
|
z.active
|
||||||
? 'bg-green-50 text-green-700 border-green-200 hover:bg-green-100'
|
? 'bg-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-gray-50 text-gray-500 border-divider hover:bg-gray-100'
|
||||||
}`}>
|
}`}>
|
||||||
{z.active ? 'Active' : 'Inactive'}
|
{z.active ? 'Active' : 'Inactive'}
|
||||||
</button>
|
</button>
|
||||||
<button disabled={busyId === z.id}
|
<button disabled={busyId === z.id}
|
||||||
@@ -178,18 +178,18 @@ export function SiteZoneManager({ sites }: Props) {
|
|||||||
footer={
|
footer={
|
||||||
<>
|
<>
|
||||||
<button onClick={() => { setShowAddSite(false); setSiteName(''); setError(null) }}
|
<button onClick={() => { setShowAddSite(false); setSiteName(''); setError(null) }}
|
||||||
className="px-4 py-2 text-sm font-medium rounded-lg border border-gray-300 text-gray-700 hover:bg-gray-50 cursor-pointer transition-colors">
|
className="px-4 py-2 text-sm font-medium border border-divider text-gray-700 hover:bg-gray-50 cursor-pointer transition-colors">
|
||||||
Cancel
|
Cancel
|
||||||
</button>
|
</button>
|
||||||
<button disabled={busy || !siteName.trim()}
|
<button disabled={busy || !siteName.trim()}
|
||||||
onClick={async () => { if (await post({ kind: 'site', name: siteName })) { setSiteName(''); setShowAddSite(false) } }}
|
onClick={async () => { if (await post({ kind: 'site', name: siteName })) { setSiteName(''); setShowAddSite(false) } }}
|
||||||
className="px-4 py-2 bg-green-600 text-white text-sm font-semibold rounded-lg hover:bg-green-700 disabled:opacity-50 cursor-pointer transition-colors">
|
className="px-4 py-2 bg-green-600 text-white text-sm font-semibold hover:bg-green-700 disabled:opacity-50 cursor-pointer transition-colors">
|
||||||
{busy ? 'Adding…' : 'Add Site'}
|
{busy ? 'Adding…' : 'Add Site'}
|
||||||
</button>
|
</button>
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{error && <p className="text-xs text-red-600 bg-red-50 px-3 py-2 rounded-lg mb-3">{error}</p>}
|
{error && <p className="text-xs text-red-600 bg-red-50 px-3 py-2 mb-3">{error}</p>}
|
||||||
<div>
|
<div>
|
||||||
<label className={lbl} htmlFor="add-site-name">Site Name *</label>
|
<label className={lbl} htmlFor="add-site-name">Site Name *</label>
|
||||||
<input id="add-site-name" type="text" placeholder="e.g. Setia Warehouse KL"
|
<input id="add-site-name" type="text" placeholder="e.g. Setia Warehouse KL"
|
||||||
@@ -205,7 +205,7 @@ export function SiteZoneManager({ sites }: Props) {
|
|||||||
footer={
|
footer={
|
||||||
<>
|
<>
|
||||||
<button onClick={() => { setShowAddZone(false); setZoneName(''); setZoneSiteId(''); setError(null) }}
|
<button onClick={() => { setShowAddZone(false); setZoneName(''); setZoneSiteId(''); setError(null) }}
|
||||||
className="px-4 py-2 text-sm font-medium rounded-lg border border-gray-300 text-gray-700 hover:bg-gray-50 cursor-pointer transition-colors">
|
className="px-4 py-2 text-sm font-medium border border-divider text-gray-700 hover:bg-gray-50 cursor-pointer transition-colors">
|
||||||
Cancel
|
Cancel
|
||||||
</button>
|
</button>
|
||||||
<button disabled={busy || !zoneName.trim() || !zoneSiteId}
|
<button disabled={busy || !zoneName.trim() || !zoneSiteId}
|
||||||
@@ -214,13 +214,13 @@ export function SiteZoneManager({ sites }: Props) {
|
|||||||
setZoneName(''); setZoneSiteId(''); setShowAddZone(false)
|
setZoneName(''); setZoneSiteId(''); setShowAddZone(false)
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
className="px-4 py-2 bg-green-600 text-white text-sm font-semibold rounded-lg hover:bg-green-700 disabled:opacity-50 cursor-pointer transition-colors">
|
className="px-4 py-2 bg-green-600 text-white text-sm font-semibold hover:bg-green-700 disabled:opacity-50 cursor-pointer transition-colors">
|
||||||
{busy ? 'Adding…' : 'Add Zone'}
|
{busy ? 'Adding…' : 'Add Zone'}
|
||||||
</button>
|
</button>
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{error && <p className="text-xs text-red-600 bg-red-50 px-3 py-2 rounded-lg mb-3">{error}</p>}
|
{error && <p className="text-xs text-red-600 bg-red-50 px-3 py-2 mb-3">{error}</p>}
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
<div>
|
<div>
|
||||||
<label className={lbl} htmlFor="add-zone-site">Site *</label>
|
<label className={lbl} htmlFor="add-zone-site">Site *</label>
|
||||||
@@ -243,12 +243,12 @@ export function SiteZoneManager({ sites }: Props) {
|
|||||||
footer={
|
footer={
|
||||||
<>
|
<>
|
||||||
<button onClick={() => setConfirmDelete(null)}
|
<button onClick={() => setConfirmDelete(null)}
|
||||||
className="px-4 py-2 text-sm font-medium rounded-lg border border-gray-300 text-gray-700 hover:bg-gray-50 cursor-pointer transition-colors">
|
className="px-4 py-2 text-sm font-medium border border-divider text-gray-700 hover:bg-gray-50 cursor-pointer transition-colors">
|
||||||
Cancel
|
Cancel
|
||||||
</button>
|
</button>
|
||||||
<button disabled={!!(confirmDelete && busyId === confirmDelete.id)}
|
<button disabled={!!(confirmDelete && busyId === confirmDelete.id)}
|
||||||
onClick={() => confirmDelete && handleDelete(confirmDelete)}
|
onClick={() => confirmDelete && handleDelete(confirmDelete)}
|
||||||
className="px-4 py-2 bg-red-600 text-white text-sm font-semibold rounded-lg hover:bg-red-700 disabled:opacity-50 cursor-pointer transition-colors">
|
className="px-4 py-2 bg-red-600 text-white text-sm font-semibold hover:bg-red-700 disabled:opacity-50 cursor-pointer transition-colors">
|
||||||
Delete
|
Delete
|
||||||
</button>
|
</button>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ interface Props {
|
|||||||
trucks: Truck[]
|
trucks: Truck[]
|
||||||
}
|
}
|
||||||
|
|
||||||
const inp = 'w-full border border-gray-300 rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-green-500 focus:border-green-500'
|
const inp = 'w-full border border-gray-300 px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-green-500 focus:border-green-500'
|
||||||
const lbl = 'block text-xs font-medium text-gray-600 mb-1'
|
const lbl = 'block text-xs font-medium text-gray-600 mb-1'
|
||||||
|
|
||||||
export function TruckManager({ trucks }: Props) {
|
export function TruckManager({ trucks }: Props) {
|
||||||
@@ -83,14 +83,14 @@ export function TruckManager({ trucks }: Props) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="bg-white rounded-xl border border-gray-200 shadow-sm overflow-hidden">
|
<div className="bg-surface border border-divider shadow-sm overflow-hidden">
|
||||||
<div className="flex items-center justify-between px-5 py-4 border-b border-gray-100">
|
<div className="flex items-center justify-between px-5 py-4 border-b border-divider">
|
||||||
<div>
|
<div>
|
||||||
<h2 className="text-sm font-semibold text-gray-900">Trucks</h2>
|
<h2 className="text-sm font-semibold text-gray-900">Trucks</h2>
|
||||||
<p className="text-xs text-gray-400 mt-0.5">{trucks.length} vehicle{trucks.length !== 1 ? 's' : ''}</p>
|
<p className="text-xs text-gray-400 mt-0.5">{trucks.length} vehicle{trucks.length !== 1 ? 's' : ''}</p>
|
||||||
</div>
|
</div>
|
||||||
<button onClick={() => { setShowAdd(true); setError(null) }}
|
<button onClick={() => { setShowAdd(true); setError(null) }}
|
||||||
className="flex items-center gap-1.5 px-3 py-1.5 bg-green-600 text-white text-xs font-semibold rounded-lg hover:bg-green-700 transition-colors cursor-pointer">
|
className="flex items-center gap-1.5 px-3 py-1.5 bg-green-600 text-white text-xs font-semibold hover:bg-green-700 transition-colors cursor-pointer">
|
||||||
<svg className="w-3.5 h-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2.5}>
|
<svg className="w-3.5 h-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2.5}>
|
||||||
<path strokeLinecap="round" strokeLinejoin="round" d="M12 4v16m8-8H4" />
|
<path strokeLinecap="round" strokeLinejoin="round" d="M12 4v16m8-8H4" />
|
||||||
</svg>
|
</svg>
|
||||||
@@ -115,10 +115,10 @@ export function TruckManager({ trucks }: Props) {
|
|||||||
<button disabled={busyId === tk.id}
|
<button disabled={busyId === tk.id}
|
||||||
onClick={() => send('PATCH', { id: tk.id, active: !tk.active })}
|
onClick={() => send('PATCH', { id: tk.id, active: !tk.active })}
|
||||||
className={`text-xs font-medium px-2.5 py-1 rounded-full border transition-colors cursor-pointer disabled:opacity-50 ${
|
className={`text-xs font-medium px-2.5 py-1 rounded-full border transition-colors cursor-pointer disabled:opacity-50 ${
|
||||||
tk.active
|
tk.active
|
||||||
? 'bg-green-50 text-green-700 border-green-200 hover:bg-green-100'
|
? 'bg-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-gray-50 text-gray-500 border-divider hover:bg-gray-100'
|
||||||
}`}>
|
}`}>
|
||||||
{tk.active ? 'Active' : 'Inactive'}
|
{tk.active ? 'Active' : 'Inactive'}
|
||||||
</button>
|
</button>
|
||||||
<button disabled={busyId === tk.id} onClick={() => setConfirmDelete(tk)}
|
<button disabled={busyId === tk.id} onClick={() => setConfirmDelete(tk)}
|
||||||
@@ -139,17 +139,17 @@ export function TruckManager({ trucks }: Props) {
|
|||||||
footer={
|
footer={
|
||||||
<>
|
<>
|
||||||
<button onClick={() => { setShowAdd(false); setTruckNo(''); setCarrier(''); setError(null) }}
|
<button onClick={() => { setShowAdd(false); setTruckNo(''); setCarrier(''); setError(null) }}
|
||||||
className="px-4 py-2 text-sm font-medium rounded-lg border border-gray-300 text-gray-700 hover:bg-gray-50 cursor-pointer transition-colors">
|
className="px-4 py-2 text-sm font-medium border border-divider text-gray-700 hover:bg-gray-50 cursor-pointer transition-colors">
|
||||||
Cancel
|
Cancel
|
||||||
</button>
|
</button>
|
||||||
<button disabled={submitting || !truckNo.trim()} onClick={handleAdd}
|
<button disabled={submitting || !truckNo.trim()} onClick={handleAdd}
|
||||||
className="px-4 py-2 bg-green-600 text-white text-sm font-semibold rounded-lg hover:bg-green-700 disabled:opacity-50 cursor-pointer transition-colors">
|
className="px-4 py-2 bg-green-600 text-white text-sm font-semibold hover:bg-green-700 disabled:opacity-50 cursor-pointer transition-colors">
|
||||||
{submitting ? 'Adding…' : 'Add Truck'}
|
{submitting ? 'Adding…' : 'Add Truck'}
|
||||||
</button>
|
</button>
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{error && <p className="text-xs text-red-600 bg-red-50 px-3 py-2 rounded-lg mb-3">{error}</p>}
|
{error && <p className="text-xs text-red-600 bg-red-50 px-3 py-2 mb-3">{error}</p>}
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
<div>
|
<div>
|
||||||
<label className={lbl} htmlFor="add-truck-no">Truck Number *</label>
|
<label className={lbl} htmlFor="add-truck-no">Truck Number *</label>
|
||||||
@@ -173,12 +173,12 @@ export function TruckManager({ trucks }: Props) {
|
|||||||
footer={
|
footer={
|
||||||
<>
|
<>
|
||||||
<button onClick={() => setConfirmDelete(null)}
|
<button onClick={() => setConfirmDelete(null)}
|
||||||
className="px-4 py-2 text-sm font-medium rounded-lg border border-gray-300 text-gray-700 hover:bg-gray-50 cursor-pointer transition-colors">
|
className="px-4 py-2 text-sm font-medium border border-divider text-gray-700 hover:bg-gray-50 cursor-pointer transition-colors">
|
||||||
Cancel
|
Cancel
|
||||||
</button>
|
</button>
|
||||||
<button disabled={busyId === confirmDelete?.id}
|
<button disabled={busyId === confirmDelete?.id}
|
||||||
onClick={() => confirmDelete && handleDelete(confirmDelete)}
|
onClick={() => confirmDelete && handleDelete(confirmDelete)}
|
||||||
className="px-4 py-2 bg-red-600 text-white text-sm font-semibold rounded-lg hover:bg-red-700 disabled:opacity-50 cursor-pointer transition-colors">
|
className="px-4 py-2 bg-red-600 text-white text-sm font-semibold hover:bg-red-700 disabled:opacity-50 cursor-pointer transition-colors">
|
||||||
{busyId === confirmDelete?.id ? 'Deleting…' : 'Delete'}
|
{busyId === confirmDelete?.id ? 'Deleting…' : 'Delete'}
|
||||||
</button>
|
</button>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ interface Props {
|
|||||||
|
|
||||||
const EMPTY = { email: '', name: '', phone: '', role: 'reporter' as UserRole, site_id: '', password: '' }
|
const EMPTY = { email: '', name: '', phone: '', role: 'reporter' as UserRole, site_id: '', password: '' }
|
||||||
|
|
||||||
const inp = 'w-full border border-gray-300 rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-green-500 focus:border-green-500'
|
const inp = 'w-full border border-gray-300 px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-green-500 focus:border-green-500'
|
||||||
const lbl = 'block text-xs font-medium text-gray-600 mb-1'
|
const lbl = 'block text-xs font-medium text-gray-600 mb-1'
|
||||||
|
|
||||||
export function UserManager({ users, sites }: Props) {
|
export function UserManager({ users, sites }: Props) {
|
||||||
@@ -95,15 +95,15 @@ export function UserManager({ users, sites }: Props) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="bg-white rounded-xl border border-gray-200 shadow-sm overflow-hidden">
|
<div className="bg-surface border border-divider shadow-sm overflow-hidden">
|
||||||
<div className="flex items-center justify-between px-5 py-4 border-b border-gray-100">
|
<div className="flex items-center justify-between px-5 py-4 border-b border-divider">
|
||||||
<div>
|
<div>
|
||||||
<h2 className="text-sm font-semibold text-gray-900">Users</h2>
|
<h2 className="text-sm font-semibold text-gray-900">Users</h2>
|
||||||
<p className="text-xs text-gray-400 mt-0.5">{users.length} account{users.length !== 1 ? 's' : ''}</p>
|
<p className="text-xs text-gray-400 mt-0.5">{users.length} account{users.length !== 1 ? 's' : ''}</p>
|
||||||
</div>
|
</div>
|
||||||
<button
|
<button
|
||||||
onClick={() => { setShowAdd(true); setError(null) }}
|
onClick={() => { setShowAdd(true); setError(null) }}
|
||||||
className="flex items-center gap-1.5 px-3 py-1.5 bg-green-600 text-white text-xs font-semibold rounded-lg hover:bg-green-700 transition-colors cursor-pointer"
|
className="flex items-center gap-1.5 px-3 py-1.5 bg-green-600 text-white text-xs font-semibold hover:bg-green-700 transition-colors cursor-pointer"
|
||||||
>
|
>
|
||||||
<svg className="w-3.5 h-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2.5}>
|
<svg className="w-3.5 h-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2.5}>
|
||||||
<path strokeLinecap="round" strokeLinejoin="round" d="M12 4v16m8-8H4" />
|
<path strokeLinecap="round" strokeLinejoin="round" d="M12 4v16m8-8H4" />
|
||||||
@@ -134,14 +134,14 @@ export function UserManager({ users, sites }: Props) {
|
|||||||
<td className="px-5 py-3">
|
<td className="px-5 py-3">
|
||||||
<select value={u.role} disabled={busyId === u.id}
|
<select value={u.role} disabled={busyId === u.id}
|
||||||
onChange={e => patchUser(u.id, { role: e.target.value })}
|
onChange={e => patchUser(u.id, { role: e.target.value })}
|
||||||
className="border border-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-green-500 cursor-pointer">
|
||||||
{ALL_ROLES.map(r => <option key={r} value={r}>{r.replace(/_/g, ' ')}</option>)}
|
{ALL_ROLES.map(r => <option key={r} value={r}>{r.replace(/_/g, ' ')}</option>)}
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
<td className="px-5 py-3">
|
<td className="px-5 py-3">
|
||||||
<select value={u.site_id ?? ''} disabled={busyId === u.id}
|
<select value={u.site_id ?? ''} disabled={busyId === u.id}
|
||||||
onChange={e => patchUser(u.id, { site_id: e.target.value || null })}
|
onChange={e => patchUser(u.id, { site_id: e.target.value || null })}
|
||||||
className="border border-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-green-500 cursor-pointer">
|
||||||
<option value="">No site</option>
|
<option value="">No site</option>
|
||||||
{sites.map(s => <option key={s.id} value={s.id}>{s.name}</option>)}
|
{sites.map(s => <option key={s.id} value={s.id}>{s.name}</option>)}
|
||||||
</select>
|
</select>
|
||||||
@@ -150,10 +150,10 @@ export function UserManager({ users, sites }: Props) {
|
|||||||
<button disabled={busyId === u.id}
|
<button disabled={busyId === u.id}
|
||||||
onClick={() => patchUser(u.id, { active: !u.active })}
|
onClick={() => patchUser(u.id, { active: !u.active })}
|
||||||
className={`text-xs px-2.5 py-1 rounded-full font-medium border transition-colors cursor-pointer ${
|
className={`text-xs px-2.5 py-1 rounded-full font-medium border transition-colors cursor-pointer ${
|
||||||
u.active
|
u.active
|
||||||
? 'bg-green-50 text-green-700 border-green-200 hover:bg-green-100'
|
? 'bg-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-gray-50 text-gray-500 border-divider hover:bg-gray-100'
|
||||||
}`}>
|
}`}>
|
||||||
{u.active ? 'Active' : 'Inactive'}
|
{u.active ? 'Active' : 'Inactive'}
|
||||||
</button>
|
</button>
|
||||||
</td>
|
</td>
|
||||||
@@ -178,18 +178,18 @@ export function UserManager({ users, sites }: Props) {
|
|||||||
footer={
|
footer={
|
||||||
<>
|
<>
|
||||||
<button type="button" onClick={() => { setShowAdd(false); setForm(EMPTY); setError(null) }}
|
<button type="button" onClick={() => { setShowAdd(false); setForm(EMPTY); setError(null) }}
|
||||||
className="px-4 py-2 text-sm font-medium rounded-lg border border-gray-300 text-gray-700 hover:bg-gray-50 cursor-pointer transition-colors">
|
className="px-4 py-2 text-sm font-medium border border-divider text-gray-700 hover:bg-gray-50 cursor-pointer transition-colors">
|
||||||
Cancel
|
Cancel
|
||||||
</button>
|
</button>
|
||||||
<button form="add-user-form" type="submit" disabled={submitting}
|
<button form="add-user-form" type="submit" disabled={submitting}
|
||||||
className="px-4 py-2 bg-green-600 text-white text-sm font-semibold rounded-lg hover:bg-green-700 disabled:opacity-50 cursor-pointer transition-colors">
|
className="px-4 py-2 bg-green-600 text-white text-sm font-semibold hover:bg-green-700 disabled:opacity-50 cursor-pointer transition-colors">
|
||||||
{submitting ? 'Adding…' : 'Add User'}
|
{submitting ? 'Adding…' : 'Add User'}
|
||||||
</button>
|
</button>
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<form id="add-user-form" onSubmit={handleSubmit} className="space-y-4">
|
<form id="add-user-form" onSubmit={handleSubmit} className="space-y-4">
|
||||||
{error && <p className="text-xs text-red-600 bg-red-50 px-3 py-2 rounded-lg">{error}</p>}
|
{error && <p className="text-xs text-red-600 bg-red-50 px-3 py-2">{error}</p>}
|
||||||
<div className="grid grid-cols-2 gap-3">
|
<div className="grid grid-cols-2 gap-3">
|
||||||
<div>
|
<div>
|
||||||
<label className={lbl} htmlFor="au-email">Email *</label>
|
<label className={lbl} htmlFor="au-email">Email *</label>
|
||||||
@@ -245,12 +245,12 @@ export function UserManager({ users, sites }: Props) {
|
|||||||
footer={
|
footer={
|
||||||
<>
|
<>
|
||||||
<button onClick={() => setConfirmDelete(null)}
|
<button onClick={() => setConfirmDelete(null)}
|
||||||
className="px-4 py-2 text-sm font-medium rounded-lg border border-gray-300 text-gray-700 hover:bg-gray-50 cursor-pointer transition-colors">
|
className="px-4 py-2 text-sm font-medium border border-divider text-gray-700 hover:bg-gray-50 cursor-pointer transition-colors">
|
||||||
Cancel
|
Cancel
|
||||||
</button>
|
</button>
|
||||||
<button disabled={busyId === confirmDelete?.id}
|
<button disabled={busyId === confirmDelete?.id}
|
||||||
onClick={() => confirmDelete && deleteUser(confirmDelete)}
|
onClick={() => confirmDelete && deleteUser(confirmDelete)}
|
||||||
className="px-4 py-2 bg-red-600 text-white text-sm font-semibold rounded-lg hover:bg-red-700 disabled:opacity-50 cursor-pointer transition-colors">
|
className="px-4 py-2 bg-red-600 text-white text-sm font-semibold hover:bg-red-700 disabled:opacity-50 cursor-pointer transition-colors">
|
||||||
{busyId === confirmDelete?.id ? 'Deleting…' : 'Delete'}
|
{busyId === confirmDelete?.id ? 'Deleting…' : 'Delete'}
|
||||||
</button>
|
</button>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ export function LoginForm() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{error && (
|
{error && (
|
||||||
<p className="bg-red-50 border border-red-200 text-red-700 text-sm rounded px-3 py-2">
|
<p className="bg-red-50 border border-red-200 text-red-700 text-sm px-3 py-2">
|
||||||
{error}
|
{error}
|
||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
@@ -55,7 +55,7 @@ export function LoginForm() {
|
|||||||
onChange={(e) => setEmail(e.target.value)}
|
onChange={(e) => setEmail(e.target.value)}
|
||||||
required
|
required
|
||||||
autoComplete="email"
|
autoComplete="email"
|
||||||
className="border rounded-md px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"
|
className="border px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"
|
||||||
/>
|
/>
|
||||||
<input
|
<input
|
||||||
type="password"
|
type="password"
|
||||||
@@ -64,12 +64,12 @@ export function LoginForm() {
|
|||||||
onChange={(e) => setPassword(e.target.value)}
|
onChange={(e) => setPassword(e.target.value)}
|
||||||
required
|
required
|
||||||
autoComplete="current-password"
|
autoComplete="current-password"
|
||||||
className="border rounded-md px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"
|
className="border px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"
|
||||||
/>
|
/>
|
||||||
<button
|
<button
|
||||||
type="submit"
|
type="submit"
|
||||||
disabled={loading}
|
disabled={loading}
|
||||||
className="bg-blue-600 hover:bg-blue-700 text-white font-medium py-2 rounded-md disabled:opacity-50 transition-colors"
|
className="bg-blue-600 hover:bg-blue-700 text-white font-medium py-2 disabled:opacity-50 transition-colors"
|
||||||
>
|
>
|
||||||
{loading ? 'Signing in…' : 'Sign in'}
|
{loading ? 'Signing in…' : 'Sign in'}
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ export function CapaBoard({ capas }: Props) {
|
|||||||
<th className="pb-2">Status</th>
|
<th className="pb-2">Status</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody className="divide-y divide-gray-100">
|
<tbody className="divide-y divide-divider">
|
||||||
{capas.map(c => (
|
{capas.map(c => (
|
||||||
<tr key={c.id}>
|
<tr key={c.id}>
|
||||||
<td className="py-2 pr-4 text-gray-500 text-xs">
|
<td className="py-2 pr-4 text-gray-500 text-xs">
|
||||||
@@ -86,7 +86,7 @@ export function CapaBoard({ capas }: Props) {
|
|||||||
<td className="py-2 pr-4 text-gray-600">{(c.owner as { name: string } | null)?.name ?? '—'}</td>
|
<td className="py-2 pr-4 text-gray-600">{(c.owner as { name: string } | null)?.name ?? '—'}</td>
|
||||||
<td className="py-2 pr-4 text-gray-600">{c.due_date}</td>
|
<td className="py-2 pr-4 text-gray-600">{c.due_date}</td>
|
||||||
<td className="py-2 pr-4">
|
<td className="py-2 pr-4">
|
||||||
<span className={`px-2 py-0.5 rounded text-xs font-medium ${PRIORITY_BADGE[c.priority]}`}>
|
<span className={`px-2 py-0.5 text-xs font-medium ${PRIORITY_BADGE[c.priority]}`}>
|
||||||
{c.priority}
|
{c.priority}
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
@@ -107,18 +107,18 @@ export function CapaBoard({ capas }: Props) {
|
|||||||
</div>
|
</div>
|
||||||
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4">
|
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4">
|
||||||
{STATUS_ORDER.filter(s => s !== 'reopened').map(status => (
|
{STATUS_ORDER.filter(s => s !== 'reopened').map(status => (
|
||||||
<div key={status} className={`rounded-xl border p-4 ${STATUS_COLORS[status]}`}>
|
<div key={status} className={`border p-4 ${STATUS_COLORS[status]}`}>
|
||||||
<h3 className="text-xs font-semibold uppercase tracking-wide text-gray-600 mb-3">
|
<h3 className="text-xs font-semibold uppercase tracking-wide text-gray-600 mb-3">
|
||||||
{STATUS_LABELS[status]} ({byStatus[status].length})
|
{STATUS_LABELS[status]} ({byStatus[status].length})
|
||||||
</h3>
|
</h3>
|
||||||
<div className="space-y-2 max-h-96 overflow-y-auto pr-2">
|
<div className="space-y-2 max-h-96 overflow-y-auto pr-2">
|
||||||
{byStatus[status].map(c => (
|
{byStatus[status].map(c => (
|
||||||
<Link key={c.id} href={`/hse/capa/${c.id}`}
|
<Link key={c.id} href={`/hse/capa/${c.id}`}
|
||||||
className="block bg-white rounded-lg p-3 shadow-sm hover:shadow-md transition-shadow border border-gray-100">
|
className="block bg-surface p-3 shadow-sm hover:shadow-md transition-shadow border border-divider">
|
||||||
<p className="text-sm text-gray-800 line-clamp-2 mb-1">{c.description}</p>
|
<p className="text-sm text-gray-800 line-clamp-2 mb-1">{c.description}</p>
|
||||||
<div className="flex items-center justify-between text-xs text-gray-500">
|
<div className="flex items-center justify-between text-xs text-gray-500">
|
||||||
<span>{(c.owner as { name: string } | null)?.name ?? '—'}</span>
|
<span>{(c.owner as { name: string } | null)?.name ?? '—'}</span>
|
||||||
<span className={`px-1.5 py-0.5 rounded ${PRIORITY_BADGE[c.priority]}`}>{c.priority}</span>
|
<span className={`px-1.5 py-0.5 ${PRIORITY_BADGE[c.priority]}`}>{c.priority}</span>
|
||||||
</div>
|
</div>
|
||||||
<p className="text-xs text-gray-400 mt-1">Due {c.due_date}</p>
|
<p className="text-xs text-gray-400 mt-1">Due {c.due_date}</p>
|
||||||
</Link>
|
</Link>
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ export function CapaForm({ incidentId }: Props) {
|
|||||||
value={description}
|
value={description}
|
||||||
onChange={e => setDescription(e.target.value)}
|
onChange={e => setDescription(e.target.value)}
|
||||||
rows={3} required
|
rows={3} required
|
||||||
className="w-full rounded-lg border border-gray-300 px-3 py-2 text-sm"
|
className="w-full border border-divider px-3 py-2 text-sm"
|
||||||
placeholder="What corrective action will be taken?"
|
placeholder="What corrective action will be taken?"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -86,14 +86,14 @@ export function CapaForm({ incidentId }: Props) {
|
|||||||
<label className="block text-sm font-medium text-gray-700 mb-1">Root Cause Reference</label>
|
<label className="block text-sm font-medium text-gray-700 mb-1">Root Cause Reference</label>
|
||||||
<input type="text" value={rootCauseRef}
|
<input type="text" value={rootCauseRef}
|
||||||
onChange={e => setRootCauseRef(e.target.value)}
|
onChange={e => setRootCauseRef(e.target.value)}
|
||||||
className="w-full rounded-lg border border-gray-300 px-3 py-2 text-sm"
|
className="w-full border border-divider px-3 py-2 text-sm"
|
||||||
placeholder="e.g. Why #3 — inadequate training" />
|
placeholder="e.g. Why #3 — inadequate training" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<label className="block text-sm font-medium text-gray-700 mb-1">Assigned To *</label>
|
<label className="block text-sm font-medium text-gray-700 mb-1">Assigned To *</label>
|
||||||
<select value={ownerId} onChange={e => handleOwnerChange(e.target.value)} required
|
<select value={ownerId} onChange={e => handleOwnerChange(e.target.value)} required
|
||||||
className="w-full rounded-lg border border-gray-300 px-3 py-2 text-sm">
|
className="w-full border border-divider px-3 py-2 text-sm">
|
||||||
<option value="">Select owner…</option>
|
<option value="">Select owner…</option>
|
||||||
{users.map(u => (
|
{users.map(u => (
|
||||||
<option key={u.id} value={u.id}>{u.name} ({u.department})</option>
|
<option key={u.id} value={u.id}>{u.name} ({u.department})</option>
|
||||||
@@ -105,12 +105,12 @@ export function CapaForm({ incidentId }: Props) {
|
|||||||
<div>
|
<div>
|
||||||
<label className="block text-sm font-medium text-gray-700 mb-1">Due Date *</label>
|
<label className="block text-sm font-medium text-gray-700 mb-1">Due Date *</label>
|
||||||
<input type="date" value={dueDate} onChange={e => setDueDate(e.target.value)} required
|
<input type="date" value={dueDate} onChange={e => setDueDate(e.target.value)} required
|
||||||
className="w-full rounded-lg border border-gray-300 px-3 py-2 text-sm" />
|
className="w-full border border-divider px-3 py-2 text-sm" />
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label className="block text-sm font-medium text-gray-700 mb-1">Priority</label>
|
<label className="block text-sm font-medium text-gray-700 mb-1">Priority</label>
|
||||||
<select value={priority} onChange={e => setPriority(e.target.value as 'low' | 'med' | 'high')}
|
<select value={priority} onChange={e => setPriority(e.target.value as 'low' | 'med' | 'high')}
|
||||||
className="w-full rounded-lg border border-gray-300 px-3 py-2 text-sm">
|
className="w-full border border-divider px-3 py-2 text-sm">
|
||||||
<option value="low">Low</option>
|
<option value="low">Low</option>
|
||||||
<option value="med">Medium</option>
|
<option value="med">Medium</option>
|
||||||
<option value="high">High</option>
|
<option value="high">High</option>
|
||||||
@@ -121,7 +121,7 @@ export function CapaForm({ incidentId }: Props) {
|
|||||||
{error && <p className="text-sm text-red-600">{error}</p>}
|
{error && <p className="text-sm text-red-600">{error}</p>}
|
||||||
|
|
||||||
<button type="submit" disabled={saving}
|
<button type="submit" disabled={saving}
|
||||||
className="w-full bg-amber-600 text-white rounded-lg py-2 text-sm font-semibold disabled:opacity-50">
|
className="w-full bg-amber-600 text-white py-2 text-sm font-semibold disabled:opacity-50">
|
||||||
{saving ? 'Creating…' : 'Create CAPA Action'}
|
{saving ? 'Creating…' : 'Create CAPA Action'}
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ export function CapaOwnerActions({ capaId, currentStatus }: Props) {
|
|||||||
<button
|
<button
|
||||||
onClick={() => updateStatus('in_progress')}
|
onClick={() => updateStatus('in_progress')}
|
||||||
disabled={loading}
|
disabled={loading}
|
||||||
className="text-sm px-3 py-1.5 border border-gray-300 rounded-md hover:bg-gray-50 disabled:opacity-50"
|
className="text-sm px-3 py-1.5 border border-divider hover:bg-gray-50 disabled:opacity-50"
|
||||||
>
|
>
|
||||||
{loading ? '…' : 'Mark In Progress'}
|
{loading ? '…' : 'Mark In Progress'}
|
||||||
</button>
|
</button>
|
||||||
@@ -48,7 +48,7 @@ export function CapaOwnerActions({ capaId, currentStatus }: Props) {
|
|||||||
<button
|
<button
|
||||||
onClick={() => updateStatus('pending_verification')}
|
onClick={() => updateStatus('pending_verification')}
|
||||||
disabled={loading}
|
disabled={loading}
|
||||||
className="text-sm px-3 py-1.5 bg-blue-600 text-white rounded-md hover:bg-blue-700 disabled:opacity-50"
|
className="text-sm px-3 py-1.5 bg-blue-600 text-white hover:bg-blue-700 disabled:opacity-50"
|
||||||
>
|
>
|
||||||
{loading ? '…' : 'Submit for Verification'}
|
{loading ? '…' : 'Submit for Verification'}
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -39,14 +39,14 @@ export function CapaOwnerNotesForm({ capaId, initialNotes }: Props) {
|
|||||||
onChange={e => { setNotes(e.target.value); setSaved(false) }}
|
onChange={e => { setNotes(e.target.value); setSaved(false) }}
|
||||||
rows={2}
|
rows={2}
|
||||||
placeholder="Add any notes or updates for this action…"
|
placeholder="Add any notes or updates for this action…"
|
||||||
className="w-full rounded-md border border-gray-200 px-3 py-2 text-sm text-gray-800 resize-none focus:outline-none focus:ring-2 focus:ring-blue-500"
|
className="w-full border border-divider px-3 py-2 text-sm text-gray-800 resize-none focus:outline-none focus:ring-2 focus:ring-blue-500"
|
||||||
/>
|
/>
|
||||||
{error && <p className="text-xs text-red-600">{error}</p>}
|
{error && <p className="text-xs text-red-600">{error}</p>}
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<button
|
<button
|
||||||
onClick={handleSave}
|
onClick={handleSave}
|
||||||
disabled={saving}
|
disabled={saving}
|
||||||
className="text-xs px-3 py-1 bg-gray-800 text-white rounded-md hover:bg-gray-700 disabled:opacity-50"
|
className="text-xs px-3 py-1 bg-gray-800 text-white hover:bg-gray-700 disabled:opacity-50"
|
||||||
>
|
>
|
||||||
{saving ? 'Saving…' : 'Save Notes'}
|
{saving ? 'Saving…' : 'Save Notes'}
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ export function CloseCapaButton({ capaId }: Props) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="border border-gray-200 rounded-xl p-5 space-y-3 bg-green-50">
|
<div className="border border-divider p-5 space-y-3 bg-green-50">
|
||||||
<h3 className="text-sm font-semibold text-gray-800">Close CAPA</h3>
|
<h3 className="text-sm font-semibold text-gray-800">Close CAPA</h3>
|
||||||
<p className="text-sm text-gray-600">
|
<p className="text-sm text-gray-600">
|
||||||
This CAPA has been verified as effective. Close it to mark it fully resolved.
|
This CAPA has been verified as effective. Close it to mark it fully resolved.
|
||||||
@@ -40,7 +40,7 @@ export function CloseCapaButton({ capaId }: Props) {
|
|||||||
<button
|
<button
|
||||||
onClick={handleClose}
|
onClick={handleClose}
|
||||||
disabled={loading}
|
disabled={loading}
|
||||||
className="w-full bg-green-700 text-white rounded-lg py-2 text-sm font-semibold hover:bg-green-800 disabled:opacity-50"
|
className="w-full bg-green-700 text-white py-2 text-sm font-semibold hover:bg-green-800 disabled:opacity-50"
|
||||||
>
|
>
|
||||||
{loading ? 'Closing…' : 'Close CAPA'}
|
{loading ? 'Closing…' : 'Close CAPA'}
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -39,28 +39,28 @@ export function VerifyForm({ capaId }: Props) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<form onSubmit={handleSubmit} className="border border-gray-200 rounded-xl p-5 space-y-4 bg-purple-50">
|
<form onSubmit={handleSubmit} className="border border-divider p-5 space-y-4 bg-purple-50">
|
||||||
<h3 className="text-sm font-semibold text-gray-800">HSE Verification</h3>
|
<h3 className="text-sm font-semibold text-gray-800">HSE Verification</h3>
|
||||||
<div className="flex gap-3">
|
<div className="flex gap-3">
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() => setVerdict('verified')}
|
onClick={() => setVerdict('verified')}
|
||||||
className={`flex-1 py-2 rounded-lg text-sm font-medium border ${
|
className={`flex-1 py-2 text-sm font-medium border ${
|
||||||
verdict === 'verified'
|
verdict === 'verified'
|
||||||
? 'bg-green-600 text-white border-green-600'
|
? 'bg-green-600 text-white border-green-600'
|
||||||
: 'bg-white text-gray-700 border-gray-300 hover:border-green-500'
|
: 'bg-surface text-gray-700 border-divider hover:border-green-500'
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
Verified — Effective
|
Verified — Effective
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() => setVerdict('reopened')}
|
onClick={() => setVerdict('reopened')}
|
||||||
className={`flex-1 py-2 rounded-lg text-sm font-medium border ${
|
className={`flex-1 py-2 text-sm font-medium border ${
|
||||||
verdict === 'reopened'
|
verdict === 'reopened'
|
||||||
? 'bg-orange-600 text-white border-orange-600'
|
? 'bg-orange-600 text-white border-orange-600'
|
||||||
: 'bg-white text-gray-700 border-gray-300 hover:border-orange-500'
|
: 'bg-surface text-gray-700 border-divider hover:border-orange-500'
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
Reopen — Ineffective
|
Reopen — Ineffective
|
||||||
</button>
|
</button>
|
||||||
@@ -72,7 +72,7 @@ export function VerifyForm({ capaId }: Props) {
|
|||||||
value={reopenReason}
|
value={reopenReason}
|
||||||
onChange={e => setReopenReason(e.target.value)}
|
onChange={e => setReopenReason(e.target.value)}
|
||||||
rows={2} required
|
rows={2} required
|
||||||
className="w-full rounded-lg border border-gray-300 px-3 py-2 text-sm"
|
className="w-full border border-divider px-3 py-2 text-sm"
|
||||||
placeholder="Describe why the corrective action did not resolve the root cause…"
|
placeholder="Describe why the corrective action did not resolve the root cause…"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -80,7 +80,7 @@ export function VerifyForm({ capaId }: Props) {
|
|||||||
{error && <p className="text-sm text-red-600">{error}</p>}
|
{error && <p className="text-sm text-red-600">{error}</p>}
|
||||||
{verdict && (
|
{verdict && (
|
||||||
<button type="submit" disabled={saving}
|
<button type="submit" disabled={saving}
|
||||||
className="w-full bg-gray-900 text-white rounded-lg py-2 text-sm font-semibold disabled:opacity-50">
|
className="w-full bg-gray-900 text-white py-2 text-sm font-semibold disabled:opacity-50">
|
||||||
{saving ? 'Saving…' : 'Submit Verification'}
|
{saving ? 'Saving…' : 'Submit Verification'}
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -15,16 +15,16 @@ function TabsInner({ activeTab }: { activeTab: string }) {
|
|||||||
const pathname = usePathname()
|
const pathname = usePathname()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex border-b border-gray-200 mb-6 overflow-x-auto -mx-4 px-4">
|
<div className="flex border-b border-divider mb-6 overflow-x-auto -mx-4 px-4">
|
||||||
{TABS.map(tab => (
|
{TABS.map(tab => (
|
||||||
<button
|
<button
|
||||||
key={tab.key}
|
key={tab.key}
|
||||||
onClick={() => router.replace(`${pathname}?tab=${tab.key}`)}
|
onClick={() => router.replace(`${pathname}?tab=${tab.key}`)}
|
||||||
className={`px-4 py-2.5 text-sm font-medium whitespace-nowrap border-b-2 transition-colors ${
|
className={`px-4 py-2.5 text-sm font-medium whitespace-nowrap border-b-2 transition-colors ${
|
||||||
activeTab === tab.key
|
activeTab === tab.key
|
||||||
? 'border-blue-600 text-blue-600'
|
? 'border-blue-600 text-blue-600'
|
||||||
: 'border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300'
|
: 'border-transparent text-gray-500 hover:text-gray-700 hover:border-divider'
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
{tab.label}
|
{tab.label}
|
||||||
</button>
|
</button>
|
||||||
@@ -35,7 +35,7 @@ function TabsInner({ activeTab }: { activeTab: string }) {
|
|||||||
|
|
||||||
export function DashboardTabs({ activeTab }: { activeTab: string }) {
|
export function DashboardTabs({ activeTab }: { activeTab: string }) {
|
||||||
return (
|
return (
|
||||||
<Suspense fallback={<div className="h-11 mb-6 border-b border-gray-200" />}>
|
<Suspense fallback={<div className="h-11 mb-6 border-b border-divider" />}>
|
||||||
<TabsInner activeTab={activeTab} />
|
<TabsInner activeTab={activeTab} />
|
||||||
</Suspense>
|
</Suspense>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ export function RiskFlagsPanel() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="bg-white rounded-xl shadow-sm p-5 mb-4">
|
<div className="bg-surface shadow-sm p-5 mb-4">
|
||||||
<div className="flex items-center justify-between mb-1">
|
<div className="flex items-center justify-between mb-1">
|
||||||
<h2 className="text-sm font-semibold text-gray-700 uppercase tracking-wide">
|
<h2 className="text-sm font-semibold text-gray-700 uppercase tracking-wide">
|
||||||
Rising-Risk Zones (AI)
|
Rising-Risk Zones (AI)
|
||||||
@@ -51,7 +51,7 @@ export function RiskFlagsPanel() {
|
|||||||
<button
|
<button
|
||||||
onClick={analyze}
|
onClick={analyze}
|
||||||
disabled={loading}
|
disabled={loading}
|
||||||
className="bg-purple-50 text-purple-700 border border-purple-300 rounded-lg px-3 py-1.5 text-xs font-semibold disabled:opacity-50 hover:bg-purple-100"
|
className="bg-purple-50 text-purple-700 border border-purple-300 px-3 py-1.5 text-xs font-semibold disabled:opacity-50 hover:bg-purple-100"
|
||||||
>
|
>
|
||||||
{loading ? 'Analyzing…' : flags ? 'Re-analyze' : 'Analyze 90-Day Risk'}
|
{loading ? 'Analyzing…' : flags ? 'Re-analyze' : 'Analyze 90-Day Risk'}
|
||||||
</button>
|
</button>
|
||||||
@@ -71,7 +71,7 @@ export function RiskFlagsPanel() {
|
|||||||
<p className="text-sm text-gray-700 mb-3">{summary}</p>
|
<p className="text-sm text-gray-700 mb-3">{summary}</p>
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
{flags.map(f => (
|
{flags.map(f => (
|
||||||
<div key={`${f.site}-${f.zone}`} className={`border rounded-lg p-3 ${LEVEL_COLORS[f.risk_level]}`}>
|
<div key={`${f.site}-${f.zone}`} className={`border p-3 ${LEVEL_COLORS[f.risk_level]}`}>
|
||||||
<div className="flex items-center justify-between mb-1">
|
<div className="flex items-center justify-between mb-1">
|
||||||
<span className="text-sm font-semibold">{f.zone} · {f.site}</span>
|
<span className="text-sm font-semibold">{f.zone} · {f.site}</span>
|
||||||
<span className="text-xs font-bold uppercase">{f.risk_level}</span>
|
<span className="text-xs font-bold uppercase">{f.risk_level}</span>
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ const ACCENT = {
|
|||||||
|
|
||||||
export function StatCard({ label, value, sub, accent = 'default' }: Props) {
|
export function StatCard({ label, value, sub, accent = 'default' }: Props) {
|
||||||
return (
|
return (
|
||||||
<div className={`bg-white rounded-xl shadow-sm p-5 border-t-4 ${ACCENT[accent]}`}>
|
<div className={`bg-surface shadow-sm p-5 border-t-4 ${ACCENT[accent]}`}>
|
||||||
<p className="text-xs text-gray-500 uppercase tracking-wide font-medium">{label}</p>
|
<p className="text-xs text-gray-500 uppercase tracking-wide font-medium">{label}</p>
|
||||||
<p className="text-3xl font-bold text-gray-900 mt-1">{value}</p>
|
<p className="text-3xl font-bold text-gray-900 mt-1">{value}</p>
|
||||||
{sub && <p className="text-xs text-gray-400 mt-1">{sub}</p>}
|
{sub && <p className="text-xs text-gray-400 mt-1">{sub}</p>}
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ export function ClosurePanel({ incidentId, status, canClose, canAddAddenda }: Pr
|
|||||||
<button
|
<button
|
||||||
onClick={closeIncident}
|
onClick={closeIncident}
|
||||||
disabled={busy}
|
disabled={busy}
|
||||||
className="bg-green-700 text-white rounded-lg px-4 py-2 text-sm font-semibold hover:bg-green-800 disabled:opacity-50"
|
className="bg-green-700 text-white px-4 py-2 text-sm font-semibold hover:bg-green-800 disabled:opacity-50"
|
||||||
>
|
>
|
||||||
{busy ? 'Closing…' : 'Close Incident'}
|
{busy ? 'Closing…' : 'Close Incident'}
|
||||||
</button>
|
</button>
|
||||||
@@ -89,7 +89,7 @@ export function ClosurePanel({ incidentId, status, canClose, canAddAddenda }: Pr
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="mt-6 bg-white rounded-xl shadow-sm p-5">
|
<div className="mt-6 bg-surface shadow-sm p-5">
|
||||||
<h2 className="text-sm font-semibold text-gray-700 uppercase tracking-wide mb-1">Addenda</h2>
|
<h2 className="text-sm font-semibold text-gray-700 uppercase tracking-wide mb-1">Addenda</h2>
|
||||||
<p className="text-xs text-gray-400 mb-3">
|
<p className="text-xs text-gray-400 mb-3">
|
||||||
This incident is closed and locked. New information is recorded as addenda.
|
This incident is closed and locked. New information is recorded as addenda.
|
||||||
@@ -99,7 +99,7 @@ export function ClosurePanel({ incidentId, status, canClose, canAddAddenda }: Pr
|
|||||||
) : (
|
) : (
|
||||||
<ul className="space-y-3">
|
<ul className="space-y-3">
|
||||||
{addenda.map(a => (
|
{addenda.map(a => (
|
||||||
<li key={a.id} className="border border-gray-100 rounded-lg p-3">
|
<li key={a.id} className="border border-divider p-3">
|
||||||
<p className="text-sm text-gray-800 whitespace-pre-wrap">{a.body}</p>
|
<p className="text-sm text-gray-800 whitespace-pre-wrap">{a.body}</p>
|
||||||
<p className="text-xs text-gray-400 mt-1">
|
<p className="text-xs text-gray-400 mt-1">
|
||||||
{a.author?.name ?? 'Unknown'} · {new Date(a.created_at).toLocaleString('en-MY', { timeZone: 'Asia/Kuala_Lumpur' })}
|
{a.author?.name ?? 'Unknown'} · {new Date(a.created_at).toLocaleString('en-MY', { timeZone: 'Asia/Kuala_Lumpur' })}
|
||||||
@@ -115,12 +115,12 @@ export function ClosurePanel({ incidentId, status, canClose, canAddAddenda }: Pr
|
|||||||
onChange={e => setDraft(e.target.value)}
|
onChange={e => setDraft(e.target.value)}
|
||||||
rows={3}
|
rows={3}
|
||||||
placeholder="Add an addendum…"
|
placeholder="Add an addendum…"
|
||||||
className="w-full border border-gray-200 rounded-lg p-2 text-sm"
|
className="w-full border border-divider p-2 text-sm"
|
||||||
/>
|
/>
|
||||||
<button
|
<button
|
||||||
onClick={addAddendum}
|
onClick={addAddendum}
|
||||||
disabled={busy || !draft.trim()}
|
disabled={busy || !draft.trim()}
|
||||||
className="mt-2 bg-gray-800 text-white rounded-lg px-4 py-2 text-sm font-semibold hover:bg-gray-900 disabled:opacity-50"
|
className="mt-2 bg-gray-800 text-white px-4 py-2 text-sm font-semibold hover:bg-gray-900 disabled:opacity-50"
|
||||||
>
|
>
|
||||||
{busy ? 'Saving…' : 'Add Addendum'}
|
{busy ? 'Saving…' : 'Add Addendum'}
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ export function EvidenceGallery({ files, stage }: Props) {
|
|||||||
href={file.file_url}
|
href={file.file_url}
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
className="block rounded-lg overflow-hidden bg-gray-100 aspect-square hover:opacity-90 transition-opacity"
|
className="block overflow-hidden bg-gray-100 aspect-square hover:opacity-90 transition-opacity"
|
||||||
>
|
>
|
||||||
{isImage(file.file_type) ? (
|
{isImage(file.file_type) ? (
|
||||||
<img
|
<img
|
||||||
|
|||||||
@@ -57,9 +57,9 @@ export function FileUpload({ onFilesChange, disabled = false }: Props) {
|
|||||||
return (
|
return (
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
<div
|
<div
|
||||||
className={`border-2 border-dashed rounded-lg p-6 text-center cursor-pointer transition-colors
|
className={`border-2 border-dashed p-6 text-center cursor-pointer transition-colors
|
||||||
${dragging ? 'border-blue-500 bg-blue-50' : 'border-gray-300 hover:border-gray-400'}
|
${dragging ? 'border-blue-500 bg-blue-50' : 'border-divider hover:border-gray-400'}
|
||||||
${disabled ? 'opacity-50 pointer-events-none' : ''}`}
|
${disabled ? 'opacity-50 pointer-events-none' : ''}`}
|
||||||
onClick={() => inputRef.current?.click()}
|
onClick={() => inputRef.current?.click()}
|
||||||
onDragOver={e => { e.preventDefault(); setDragging(true) }}
|
onDragOver={e => { e.preventDefault(); setDragging(true) }}
|
||||||
onDragLeave={() => setDragging(false)}
|
onDragLeave={() => setDragging(false)}
|
||||||
@@ -94,7 +94,7 @@ export function FileUpload({ onFilesChange, disabled = false }: Props) {
|
|||||||
{files.length > 0 && (
|
{files.length > 0 && (
|
||||||
<ul className="space-y-1">
|
<ul className="space-y-1">
|
||||||
{files.map((f, i) => (
|
{files.map((f, i) => (
|
||||||
<li key={i} className="flex items-center justify-between bg-gray-50 rounded px-3 py-2 text-sm">
|
<li key={i} className="flex items-center justify-between bg-gray-50 px-3 py-2 text-sm">
|
||||||
<span className="truncate max-w-xs">{f.name}</span>
|
<span className="truncate max-w-xs">{f.name}</span>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ export function IncidentDetail({ incident }: Props) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-6">
|
<div className="space-y-6">
|
||||||
<div className="bg-white rounded-xl shadow-sm p-5">
|
<div className="bg-surface shadow-sm p-5">
|
||||||
<div className="flex items-start justify-between mb-4">
|
<div className="flex items-start justify-between mb-4">
|
||||||
<div>
|
<div>
|
||||||
<h1 className="text-xl font-bold text-gray-900 font-mono">
|
<h1 className="text-xl font-bold text-gray-900 font-mono">
|
||||||
@@ -114,12 +114,12 @@ export function IncidentDetail({ incident }: Props) {
|
|||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="bg-white rounded-xl shadow-sm p-5">
|
<div className="bg-surface shadow-sm p-5">
|
||||||
<h2 className="text-sm font-semibold text-gray-900 mb-2">Description</h2>
|
<h2 className="text-sm font-semibold text-gray-900 mb-2">Description</h2>
|
||||||
<p className="text-sm text-gray-800 leading-relaxed whitespace-pre-wrap">{incident.description}</p>
|
<p className="text-sm text-gray-800 leading-relaxed whitespace-pre-wrap">{incident.description}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="bg-white rounded-xl shadow-sm p-5">
|
<div className="bg-surface shadow-sm p-5">
|
||||||
<h2 className="text-sm font-semibold text-gray-900 mb-3">
|
<h2 className="text-sm font-semibold text-gray-900 mb-3">
|
||||||
Evidence — Report Stage
|
Evidence — Report Stage
|
||||||
<span className="ml-2 text-gray-400 font-normal normal-case">
|
<span className="ml-2 text-gray-400 font-normal normal-case">
|
||||||
|
|||||||
@@ -77,20 +77,20 @@ function FiltersInner({ sites, trucks }: FiltersProps) {
|
|||||||
placeholder="Search reference or description..."
|
placeholder="Search reference or description..."
|
||||||
value={search}
|
value={search}
|
||||||
onChange={e => handleSearch(e.target.value)}
|
onChange={e => handleSearch(e.target.value)}
|
||||||
className="w-full pl-8 pr-3 py-1.5 text-sm border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"
|
className="w-full pl-8 pr-3 py-1.5 text-sm border border-divider focus:outline-none focus:ring-2 focus:ring-blue-500"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<select
|
<select
|
||||||
value={searchParams.get('status') ?? ''}
|
value={searchParams.get('status') ?? ''}
|
||||||
onChange={e => updateParam('status', e.target.value)}
|
onChange={e => updateParam('status', e.target.value)}
|
||||||
className="text-sm border border-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-blue-500 bg-surface"
|
||||||
>
|
>
|
||||||
{STATUS_OPTIONS.map(o => <option key={o.value} value={o.value}>{o.label}</option>)}
|
{STATUS_OPTIONS.map(o => <option key={o.value} value={o.value}>{o.label}</option>)}
|
||||||
</select>
|
</select>
|
||||||
<select
|
<select
|
||||||
value={searchParams.get('type') ?? ''}
|
value={searchParams.get('type') ?? ''}
|
||||||
onChange={e => updateParam('type', e.target.value)}
|
onChange={e => updateParam('type', e.target.value)}
|
||||||
className="text-sm border border-gray-300 rounded-lg px-2 py-1.5 focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white"
|
className="text-sm border border-divider px-2 py-1.5 focus:outline-none focus:ring-2 focus:ring-blue-500 bg-surface"
|
||||||
>
|
>
|
||||||
{TYPE_OPTIONS.map(o => <option key={o.value} value={o.value}>{o.label}</option>)}
|
{TYPE_OPTIONS.map(o => <option key={o.value} value={o.value}>{o.label}</option>)}
|
||||||
</select>
|
</select>
|
||||||
@@ -98,7 +98,7 @@ function FiltersInner({ sites, trucks }: FiltersProps) {
|
|||||||
<select
|
<select
|
||||||
value={searchParams.get('site_id') ?? ''}
|
value={searchParams.get('site_id') ?? ''}
|
||||||
onChange={e => updateParam('site_id', e.target.value)}
|
onChange={e => updateParam('site_id', e.target.value)}
|
||||||
className="text-sm border border-gray-300 rounded-lg px-2 py-1.5 focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white"
|
className="text-sm border border-divider px-2 py-1.5 focus:outline-none focus:ring-2 focus:ring-blue-500 bg-surface"
|
||||||
>
|
>
|
||||||
<option value="">All Sites</option>
|
<option value="">All Sites</option>
|
||||||
{sites.map(s => <option key={s.id} value={s.id}>{s.name}</option>)}
|
{sites.map(s => <option key={s.id} value={s.id}>{s.name}</option>)}
|
||||||
@@ -108,7 +108,7 @@ function FiltersInner({ sites, trucks }: FiltersProps) {
|
|||||||
<select
|
<select
|
||||||
value={searchParams.get('truck_id') ?? ''}
|
value={searchParams.get('truck_id') ?? ''}
|
||||||
onChange={e => updateParam('truck_id', e.target.value)}
|
onChange={e => updateParam('truck_id', e.target.value)}
|
||||||
className="text-sm border border-gray-300 rounded-lg px-2 py-1.5 focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white"
|
className="text-sm border border-divider px-2 py-1.5 focus:outline-none focus:ring-2 focus:ring-blue-500 bg-surface"
|
||||||
>
|
>
|
||||||
<option value="">All Trucks</option>
|
<option value="">All Trucks</option>
|
||||||
{trucks.map(tk => <option key={tk.id} value={tk.id}>{tk.truck_no}</option>)}
|
{trucks.map(tk => <option key={tk.id} value={tk.id}>{tk.truck_no}</option>)}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ export function IncidentHeader({
|
|||||||
canTriage, canInvestigate, canAddCapa,
|
canTriage, canInvestigate, canAddCapa,
|
||||||
}: Props) {
|
}: Props) {
|
||||||
return (
|
return (
|
||||||
<div className="sticky top-0 z-30 bg-white border-b border-gray-200 shadow-sm">
|
<div className="sticky top-0 z-30 bg-surface border-b border-divider shadow-sm">
|
||||||
<div className="max-w-3xl mx-auto px-4 py-3 flex items-center justify-between gap-4 flex-wrap">
|
<div className="max-w-3xl mx-auto px-4 py-3 flex items-center justify-between gap-4 flex-wrap">
|
||||||
<div className="flex items-center gap-3 min-w-0">
|
<div className="flex items-center gap-3 min-w-0">
|
||||||
<Link href={backHref} className="text-sm text-gray-500 hover:text-gray-700 shrink-0">
|
<Link href={backHref} className="text-sm text-gray-500 hover:text-gray-700 shrink-0">
|
||||||
@@ -53,7 +53,7 @@ export function IncidentHeader({
|
|||||||
{canTriage && (
|
{canTriage && (
|
||||||
<Link
|
<Link
|
||||||
href={`/hse/incidents/${incidentId}/triage`}
|
href={`/hse/incidents/${incidentId}/triage`}
|
||||||
className="text-xs px-3 py-1.5 bg-blue-600 text-white rounded-lg font-medium hover:bg-blue-700"
|
className="text-xs px-3 py-1.5 bg-blue-600 text-white font-medium hover:bg-blue-700"
|
||||||
>
|
>
|
||||||
Triage
|
Triage
|
||||||
</Link>
|
</Link>
|
||||||
@@ -61,7 +61,7 @@ export function IncidentHeader({
|
|||||||
{canInvestigate && (
|
{canInvestigate && (
|
||||||
<Link
|
<Link
|
||||||
href={`/hse/incidents/${incidentId}/investigation`}
|
href={`/hse/incidents/${incidentId}/investigation`}
|
||||||
className="text-xs px-3 py-1.5 bg-indigo-600 text-white rounded-lg font-medium hover:bg-indigo-700"
|
className="text-xs px-3 py-1.5 bg-indigo-600 text-white font-medium hover:bg-indigo-700"
|
||||||
>
|
>
|
||||||
Investigate
|
Investigate
|
||||||
</Link>
|
</Link>
|
||||||
@@ -69,7 +69,7 @@ export function IncidentHeader({
|
|||||||
{canAddCapa && (
|
{canAddCapa && (
|
||||||
<Link
|
<Link
|
||||||
href={`/hse/incidents/${incidentId}/capa/new`}
|
href={`/hse/incidents/${incidentId}/capa/new`}
|
||||||
className="text-xs px-3 py-1.5 bg-amber-600 text-white rounded-lg font-medium hover:bg-amber-700"
|
className="text-xs px-3 py-1.5 bg-amber-600 text-white font-medium hover:bg-amber-700"
|
||||||
>
|
>
|
||||||
Add CAPA
|
Add CAPA
|
||||||
</Link>
|
</Link>
|
||||||
|
|||||||
@@ -66,12 +66,12 @@ export function IncidentList({ incidents, basePath }: Props) {
|
|||||||
<input
|
<input
|
||||||
type="search"
|
type="search"
|
||||||
placeholder="Search ref, type, site…"
|
placeholder="Search ref, type, site…"
|
||||||
className="border border-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-blue-500"
|
||||||
value={search}
|
value={search}
|
||||||
onChange={e => setSearch(e.target.value)}
|
onChange={e => setSearch(e.target.value)}
|
||||||
/>
|
/>
|
||||||
<select
|
<select
|
||||||
className="border border-gray-300 rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"
|
className="border border-divider px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"
|
||||||
value={typeFilter}
|
value={typeFilter}
|
||||||
onChange={e => setTypeFilter(e.target.value)}
|
onChange={e => setTypeFilter(e.target.value)}
|
||||||
>
|
>
|
||||||
@@ -81,7 +81,7 @@ export function IncidentList({ incidents, basePath }: Props) {
|
|||||||
))}
|
))}
|
||||||
</select>
|
</select>
|
||||||
<select
|
<select
|
||||||
className="border border-gray-300 rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"
|
className="border border-divider px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"
|
||||||
value={statusFilter}
|
value={statusFilter}
|
||||||
onChange={e => setStatusFilter(e.target.value)}
|
onChange={e => setStatusFilter(e.target.value)}
|
||||||
>
|
>
|
||||||
@@ -95,7 +95,7 @@ export function IncidentList({ incidents, basePath }: Props) {
|
|||||||
{filtered.length === 0 ? (
|
{filtered.length === 0 ? (
|
||||||
<div className="text-center py-12 text-gray-500 text-sm">No incidents found</div>
|
<div className="text-center py-12 text-gray-500 text-sm">No incidents found</div>
|
||||||
) : (
|
) : (
|
||||||
<div className="divide-y divide-gray-100 bg-white rounded-xl shadow-sm overflow-hidden">
|
<div className="divide-y divide-divider bg-surface shadow-sm overflow-hidden">
|
||||||
{filtered.map(inc => (
|
{filtered.map(inc => (
|
||||||
<Link
|
<Link
|
||||||
key={inc.id}
|
key={inc.id}
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ export function InvestigationForm({ incidentId, existingInvestigationId }: Props
|
|||||||
type="button"
|
type="button"
|
||||||
onClick={getAiDraft}
|
onClick={getAiDraft}
|
||||||
disabled={aiDraftLoading}
|
disabled={aiDraftLoading}
|
||||||
className="bg-purple-50 text-purple-700 border border-purple-300 rounded-lg px-3 py-1.5 text-xs font-semibold disabled:opacity-50 hover:bg-purple-100"
|
className="bg-purple-50 text-purple-700 border border-purple-300 px-3 py-1.5 text-xs font-semibold disabled:opacity-50 hover:bg-purple-100"
|
||||||
>
|
>
|
||||||
{aiDraftLoading ? 'Drafting…' : 'Get AI Draft'}
|
{aiDraftLoading ? 'Drafting…' : 'Get AI Draft'}
|
||||||
</button>
|
</button>
|
||||||
@@ -148,11 +148,11 @@ export function InvestigationForm({ incidentId, existingInvestigationId }: Props
|
|||||||
<button
|
<button
|
||||||
key={m} type="button"
|
key={m} type="button"
|
||||||
onClick={() => setMethod(m)}
|
onClick={() => setMethod(m)}
|
||||||
className={`px-3 py-1.5 rounded-lg text-sm font-medium border ${
|
className={`px-3 py-1.5 text-sm font-medium border ${
|
||||||
method === m
|
method === m
|
||||||
? 'bg-blue-600 text-white border-blue-600'
|
? 'bg-blue-600 text-white border-blue-600'
|
||||||
: 'bg-white text-gray-700 border-gray-300 hover:border-blue-400'
|
: 'bg-surface text-gray-700 border-divider hover:border-blue-400'
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
{m === 'five_why' ? '5-Why' : m === 'fishbone' ? 'Fishbone' : 'Other'}
|
{m === 'five_why' ? '5-Why' : m === 'fishbone' ? 'Fishbone' : 'Other'}
|
||||||
</button>
|
</button>
|
||||||
@@ -164,19 +164,19 @@ export function InvestigationForm({ incidentId, existingInvestigationId }: Props
|
|||||||
<div className="space-y-3">
|
<div className="space-y-3">
|
||||||
<p className="text-sm font-medium text-gray-700">5-Why Analysis</p>
|
<p className="text-sm font-medium text-gray-700">5-Why Analysis</p>
|
||||||
{fiveWhy.map((step, i) => (
|
{fiveWhy.map((step, i) => (
|
||||||
<div key={i} className="border border-gray-200 rounded-lg p-3 space-y-2">
|
<div key={i} className="border border-divider p-3 space-y-2">
|
||||||
<label className="block text-xs text-gray-500">Why #{i + 1}</label>
|
<label className="block text-xs text-gray-500">Why #{i + 1}</label>
|
||||||
<input
|
<input
|
||||||
type="text" value={step.why}
|
type="text" value={step.why}
|
||||||
onChange={e => updateWhyStep(i, 'why', e.target.value)}
|
onChange={e => updateWhyStep(i, 'why', e.target.value)}
|
||||||
placeholder="Why did this happen?"
|
placeholder="Why did this happen?"
|
||||||
className="w-full rounded border border-gray-300 px-2 py-1.5 text-sm"
|
className="w-full border border-divider px-2 py-1.5 text-sm"
|
||||||
/>
|
/>
|
||||||
<textarea
|
<textarea
|
||||||
value={step.answer}
|
value={step.answer}
|
||||||
onChange={e => updateWhyStep(i, 'answer', e.target.value)}
|
onChange={e => updateWhyStep(i, 'answer', e.target.value)}
|
||||||
rows={2} placeholder="Answer / finding…"
|
rows={2} placeholder="Answer / finding…"
|
||||||
className="w-full rounded border border-gray-300 px-2 py-1.5 text-sm"
|
className="w-full border border-divider px-2 py-1.5 text-sm"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
@@ -193,7 +193,7 @@ export function InvestigationForm({ incidentId, existingInvestigationId }: Props
|
|||||||
<div className="space-y-3">
|
<div className="space-y-3">
|
||||||
<p className="text-sm font-medium text-gray-700">Fishbone (Ishikawa) Analysis</p>
|
<p className="text-sm font-medium text-gray-700">Fishbone (Ishikawa) Analysis</p>
|
||||||
{fishbone.map((cat, catIdx) => (
|
{fishbone.map((cat, catIdx) => (
|
||||||
<div key={cat.category} className="border border-gray-200 rounded-lg p-3">
|
<div key={cat.category} className="border border-divider p-3">
|
||||||
<p className="text-xs font-semibold text-gray-600 mb-2">{CATEGORY_LABELS[cat.category]}</p>
|
<p className="text-xs font-semibold text-gray-600 mb-2">{CATEGORY_LABELS[cat.category]}</p>
|
||||||
{cat.causes.map((cause, causeIdx) => (
|
{cat.causes.map((cause, causeIdx) => (
|
||||||
<input
|
<input
|
||||||
@@ -201,7 +201,7 @@ export function InvestigationForm({ incidentId, existingInvestigationId }: Props
|
|||||||
type="text" value={cause}
|
type="text" value={cause}
|
||||||
onChange={e => updateFishboneCause(catIdx, causeIdx, e.target.value)}
|
onChange={e => updateFishboneCause(catIdx, causeIdx, e.target.value)}
|
||||||
placeholder="Contributing cause…"
|
placeholder="Contributing cause…"
|
||||||
className="w-full rounded border border-gray-300 px-2 py-1.5 text-sm mb-1.5"
|
className="w-full border border-divider px-2 py-1.5 text-sm mb-1.5"
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
<button type="button" onClick={() => addFishboneCause(catIdx)}
|
<button type="button" onClick={() => addFishboneCause(catIdx)}
|
||||||
@@ -219,7 +219,7 @@ export function InvestigationForm({ incidentId, existingInvestigationId }: Props
|
|||||||
<select
|
<select
|
||||||
value={alcoholTest}
|
value={alcoholTest}
|
||||||
onChange={e => setAlcoholTest(e.target.value)}
|
onChange={e => setAlcoholTest(e.target.value)}
|
||||||
className="w-full rounded-lg border border-gray-300 px-3 py-2 text-sm"
|
className="w-full border border-divider px-3 py-2 text-sm"
|
||||||
>
|
>
|
||||||
<option value="">Not conducted</option>
|
<option value="">Not conducted</option>
|
||||||
<option value="negative">Negative</option>
|
<option value="negative">Negative</option>
|
||||||
@@ -233,7 +233,7 @@ export function InvestigationForm({ incidentId, existingInvestigationId }: Props
|
|||||||
<select
|
<select
|
||||||
value={urineTest}
|
value={urineTest}
|
||||||
onChange={e => setUrineTest(e.target.value)}
|
onChange={e => setUrineTest(e.target.value)}
|
||||||
className="w-full rounded-lg border border-gray-300 px-3 py-2 text-sm"
|
className="w-full border border-divider px-3 py-2 text-sm"
|
||||||
>
|
>
|
||||||
<option value="">Not conducted</option>
|
<option value="">Not conducted</option>
|
||||||
<option value="negative">Negative</option>
|
<option value="negative">Negative</option>
|
||||||
@@ -256,7 +256,7 @@ export function InvestigationForm({ incidentId, existingInvestigationId }: Props
|
|||||||
value={ref}
|
value={ref}
|
||||||
onChange={e => setWitnessRefs(witnessRefs.map((w, j) => (j === i ? e.target.value : w)))}
|
onChange={e => setWitnessRefs(witnessRefs.map((w, j) => (j === i ? e.target.value : w)))}
|
||||||
placeholder="e.g. Ali bin Ahmad — statement dated 12/07/2026"
|
placeholder="e.g. Ali bin Ahmad — statement dated 12/07/2026"
|
||||||
className="w-full rounded border border-gray-300 px-2 py-1.5 text-sm mb-1.5"
|
className="w-full border border-divider px-2 py-1.5 text-sm mb-1.5"
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
<button
|
<button
|
||||||
@@ -274,7 +274,7 @@ export function InvestigationForm({ incidentId, existingInvestigationId }: Props
|
|||||||
value={findingsText}
|
value={findingsText}
|
||||||
onChange={e => setFindingsText(e.target.value)}
|
onChange={e => setFindingsText(e.target.value)}
|
||||||
rows={3}
|
rows={3}
|
||||||
className="w-full rounded-lg border border-gray-300 px-3 py-2 text-sm"
|
className="w-full border border-divider px-3 py-2 text-sm"
|
||||||
placeholder="Describe the sequence of events and contributing factors…"
|
placeholder="Describe the sequence of events and contributing factors…"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -285,7 +285,7 @@ export function InvestigationForm({ incidentId, existingInvestigationId }: Props
|
|||||||
value={rootCause}
|
value={rootCause}
|
||||||
onChange={e => setRootCause(e.target.value)}
|
onChange={e => setRootCause(e.target.value)}
|
||||||
rows={2}
|
rows={2}
|
||||||
className="w-full rounded-lg border border-gray-300 px-3 py-2 text-sm"
|
className="w-full border border-divider px-3 py-2 text-sm"
|
||||||
placeholder="One-sentence root cause statement…"
|
placeholder="One-sentence root cause statement…"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -293,7 +293,7 @@ export function InvestigationForm({ incidentId, existingInvestigationId }: Props
|
|||||||
{!existingInvestigationId && (
|
{!existingInvestigationId && (
|
||||||
<label className="flex items-center gap-2 text-sm text-gray-700">
|
<label className="flex items-center gap-2 text-sm text-gray-700">
|
||||||
<input type="checkbox" checked={complete} onChange={e => setComplete(e.target.checked)}
|
<input type="checkbox" checked={complete} onChange={e => setComplete(e.target.checked)}
|
||||||
className="rounded border-gray-300 text-blue-600" />
|
className="border-divider text-blue-600" />
|
||||||
Mark investigation complete (transitions incident to CAPA Pending)
|
Mark investigation complete (transitions incident to CAPA Pending)
|
||||||
</label>
|
</label>
|
||||||
)}
|
)}
|
||||||
@@ -301,7 +301,7 @@ export function InvestigationForm({ incidentId, existingInvestigationId }: Props
|
|||||||
{error && <p className="text-sm text-red-600">{error}</p>}
|
{error && <p className="text-sm text-red-600">{error}</p>}
|
||||||
|
|
||||||
<button type="submit" disabled={saving}
|
<button type="submit" disabled={saving}
|
||||||
className="w-full bg-indigo-600 text-white rounded-lg py-2 text-sm font-semibold disabled:opacity-50">
|
className="w-full bg-indigo-600 text-white py-2 text-sm font-semibold disabled:opacity-50">
|
||||||
{saving ? 'Saving…' : existingInvestigationId ? 'Update Investigation' : 'Start Investigation'}
|
{saving ? 'Saving…' : existingInvestigationId ? 'Update Investigation' : 'Start Investigation'}
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@@ -35,16 +35,16 @@ export function InvestigationPanel({ investigation: inv }: Props) {
|
|||||||
const investigatorName = inv.investigator?.name ?? inv.investigator?.email ?? 'Unknown'
|
const investigatorName = inv.investigator?.name ?? inv.investigator?.email ?? 'Unknown'
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="mt-6 bg-white rounded-xl shadow-sm border border-gray-200 overflow-hidden">
|
<div className="mt-6 bg-surface shadow-sm border border-divider overflow-hidden">
|
||||||
<div className="flex items-center justify-between px-5 py-4 border-b border-gray-100">
|
<div className="flex items-center justify-between px-5 py-4 border-b border-divider">
|
||||||
<h2 className="text-sm font-semibold text-gray-900">Investigation</h2>
|
<h2 className="text-sm font-semibold text-gray-900">Investigation</h2>
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<span className="text-xs text-gray-500">{METHOD_LABELS[inv.method] ?? inv.method}</span>
|
<span className="text-xs text-gray-500">{METHOD_LABELS[inv.method] ?? inv.method}</span>
|
||||||
<span className={`text-xs font-medium px-2 py-0.5 rounded-full ${
|
<span className={`text-xs font-medium px-2 py-0.5 rounded-full ${
|
||||||
inv.completed_at
|
inv.completed_at
|
||||||
? 'bg-green-100 text-green-700'
|
? 'bg-green-100 text-green-700'
|
||||||
: 'bg-yellow-100 text-yellow-700'
|
: 'bg-yellow-100 text-yellow-700'
|
||||||
}`}>
|
}`}>
|
||||||
{inv.completed_at ? 'Completed' : 'In Progress'}
|
{inv.completed_at ? 'Completed' : 'In Progress'}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
@@ -107,7 +107,7 @@ export function InvestigationPanel({ investigation: inv }: Props) {
|
|||||||
|
|
||||||
{/* Root cause */}
|
{/* Root cause */}
|
||||||
{inv.root_cause_summary && (
|
{inv.root_cause_summary && (
|
||||||
<div className="bg-red-50 border border-red-100 rounded-lg px-4 py-3">
|
<div className="bg-red-50 border border-red-100 px-4 py-3">
|
||||||
<h3 className="text-xs font-semibold text-red-600 uppercase tracking-wide mb-1">Root Cause</h3>
|
<h3 className="text-xs font-semibold text-red-600 uppercase tracking-wide mb-1">Root Cause</h3>
|
||||||
<p className="text-sm text-gray-900 whitespace-pre-wrap">{inv.root_cause_summary}</p>
|
<p className="text-sm text-gray-900 whitespace-pre-wrap">{inv.root_cause_summary}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -56,15 +56,15 @@ export function OfflineSync() {
|
|||||||
if (pendingCount === 0) return null
|
if (pendingCount === 0) return null
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="fixed bottom-4 left-4 right-4 bg-yellow-50 border border-yellow-300 rounded-lg p-3 flex items-center justify-between shadow-md z-50">
|
<div className="fixed bottom-4 left-4 right-4 bg-yellow-50 border border-yellow-300 p-3 flex items-center justify-between shadow-md z-50">
|
||||||
<span className="text-sm text-yellow-800 font-medium">
|
<span className="text-sm text-yellow-800 font-medium">
|
||||||
{pendingCount} report{pendingCount > 1 ? 's' : ''} saved offline
|
{pendingCount} report{pendingCount > 1 ? 's' : ''} saved offline
|
||||||
</span>
|
</span>
|
||||||
<button
|
<button
|
||||||
onClick={syncNow}
|
onClick={syncNow}
|
||||||
disabled={syncing || !navigator.onLine}
|
disabled={syncing || !navigator.onLine}
|
||||||
className="text-xs bg-yellow-600 text-white px-3 py-1.5 rounded font-medium
|
className="text-xs bg-yellow-600 text-white px-3 py-1.5 font-medium
|
||||||
hover:bg-yellow-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors"
|
hover:bg-yellow-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors"
|
||||||
>
|
>
|
||||||
{syncing ? 'Syncing…' : 'Sync now'}
|
{syncing ? 'Syncing…' : 'Sync now'}
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ export function ReportForm({ zoneToken, trucks, initialTruckId }: Props) {
|
|||||||
value={(typeDetails[key] as string) ?? ''}
|
value={(typeDetails[key] as string) ?? ''}
|
||||||
onChange={e => setDetail(key, e.target.value)}
|
onChange={e => setDetail(key, e.target.value)}
|
||||||
placeholder={placeholder}
|
placeholder={placeholder}
|
||||||
className="w-full border border-gray-300 rounded-lg px-3 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"
|
className="w-full border border-divider px-3 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
@@ -205,22 +205,22 @@ export function ReportForm({ zoneToken, trucks, initialTruckId }: Props) {
|
|||||||
|
|
||||||
if (savedOffline) {
|
if (savedOffline) {
|
||||||
return (
|
return (
|
||||||
<div className="bg-green-50 border border-green-200 rounded-xl p-5 text-sm text-green-700">
|
<div className="bg-green-50 border border-green-200 p-5 text-sm text-green-700">
|
||||||
{t.savedOffline}
|
{t.savedOffline}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<form onSubmit={handleSubmit} className="space-y-5 bg-white rounded-xl shadow-sm p-5">
|
<form onSubmit={handleSubmit} className="space-y-5 bg-surface shadow-sm p-5">
|
||||||
{!isOnline && (
|
{!isOnline && (
|
||||||
<div className="bg-yellow-50 border border-yellow-200 rounded p-3 text-sm text-yellow-700">
|
<div className="bg-yellow-50 border border-yellow-200 p-3 text-sm text-yellow-700">
|
||||||
{t.offlineBanner}
|
{t.offlineBanner}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{error && (
|
{error && (
|
||||||
<div className="bg-red-50 border border-red-200 rounded p-3 text-sm text-red-700">
|
<div className="bg-red-50 border border-red-200 p-3 text-sm text-red-700">
|
||||||
{error}
|
{error}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
@@ -231,7 +231,7 @@ export function ReportForm({ zoneToken, trucks, initialTruckId }: Props) {
|
|||||||
</label>
|
</label>
|
||||||
<select
|
<select
|
||||||
required
|
required
|
||||||
className="w-full border border-gray-300 rounded-lg px-3 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"
|
className="w-full border border-divider px-3 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"
|
||||||
value={form.incident_type}
|
value={form.incident_type}
|
||||||
onChange={e => {
|
onChange={e => {
|
||||||
setForm(f => ({ ...f, incident_type: e.target.value as IncidentType, truck_id: '' }))
|
setForm(f => ({ ...f, incident_type: e.target.value as IncidentType, truck_id: '' }))
|
||||||
@@ -246,26 +246,26 @@ export function ReportForm({ zoneToken, trucks, initialTruckId }: Props) {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{form.incident_type === 'environmental' && (
|
{form.incident_type === 'environmental' && (
|
||||||
<div className="space-y-3 border border-gray-200 rounded-lg p-3">
|
<div className="space-y-3 border border-divider p-3">
|
||||||
{detailText('substance', tdLabels.substance, tdLabels.substancePlaceholder)}
|
{detailText('substance', tdLabels.substance, tdLabels.substancePlaceholder)}
|
||||||
{detailText('estimated_volume', tdLabels.estimatedVolume, tdLabels.estimatedVolumePlaceholder)}
|
{detailText('estimated_volume', tdLabels.estimatedVolume, tdLabels.estimatedVolumePlaceholder)}
|
||||||
{detailCheckbox('containment_deployed', tdLabels.containmentDeployed)}
|
{detailCheckbox('containment_deployed', tdLabels.containmentDeployed)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{form.incident_type === 'asset_damage' && (
|
{form.incident_type === 'asset_damage' && (
|
||||||
<div className="space-y-3 border border-gray-200 rounded-lg p-3">
|
<div className="space-y-3 border border-divider p-3">
|
||||||
{detailText('equipment_id', tdLabels.equipmentId, tdLabels.equipmentIdPlaceholder)}
|
{detailText('equipment_id', tdLabels.equipmentId, tdLabels.equipmentIdPlaceholder)}
|
||||||
{detailCheckbox('loto_applied', tdLabels.lotoApplied)}
|
{detailCheckbox('loto_applied', tdLabels.lotoApplied)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{form.incident_type === 'security' && (
|
{form.incident_type === 'security' && (
|
||||||
<div className="space-y-3 border border-gray-200 rounded-lg p-3">
|
<div className="space-y-3 border border-divider p-3">
|
||||||
{detailText('persons_involved', tdLabels.personsInvolved, tdLabels.personsInvolvedPlaceholder)}
|
{detailText('persons_involved', tdLabels.personsInvolved, tdLabels.personsInvolvedPlaceholder)}
|
||||||
{detailCheckbox('police_reported', tdLabels.policeReported)}
|
{detailCheckbox('police_reported', tdLabels.policeReported)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{form.incident_type === 'fire' && (
|
{form.incident_type === 'fire' && (
|
||||||
<div className="space-y-3 border border-gray-200 rounded-lg p-3">
|
<div className="space-y-3 border border-divider p-3">
|
||||||
{detailCheckbox('alarm_raised', tdLabels.alarmRaised)}
|
{detailCheckbox('alarm_raised', tdLabels.alarmRaised)}
|
||||||
{detailCheckbox('fire_brigade_called', tdLabels.fireBrigadeCalled)}
|
{detailCheckbox('fire_brigade_called', tdLabels.fireBrigadeCalled)}
|
||||||
</div>
|
</div>
|
||||||
@@ -278,7 +278,7 @@ export function ReportForm({ zoneToken, trucks, initialTruckId }: Props) {
|
|||||||
</label>
|
</label>
|
||||||
<select
|
<select
|
||||||
required
|
required
|
||||||
className="w-full border border-gray-300 rounded-lg px-3 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"
|
className="w-full border border-divider px-3 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"
|
||||||
value={form.truck_id}
|
value={form.truck_id}
|
||||||
onChange={e => setForm(f => ({ ...f, truck_id: e.target.value }))}
|
onChange={e => setForm(f => ({ ...f, truck_id: e.target.value }))}
|
||||||
>
|
>
|
||||||
@@ -301,14 +301,14 @@ export function ReportForm({ zoneToken, trucks, initialTruckId }: Props) {
|
|||||||
minLength={10}
|
minLength={10}
|
||||||
rows={4}
|
rows={4}
|
||||||
placeholder={t.descriptionPlaceholder}
|
placeholder={t.descriptionPlaceholder}
|
||||||
className="w-full border border-gray-300 rounded-lg px-3 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 resize-none"
|
className="w-full border border-divider px-3 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 resize-none"
|
||||||
value={form.description}
|
value={form.description}
|
||||||
onChange={e => setForm(f => ({ ...f, description: e.target.value }))}
|
onChange={e => setForm(f => ({ ...f, description: e.target.value }))}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{qualityCheck && !qualityCheck.passes && (
|
{qualityCheck && !qualityCheck.passes && (
|
||||||
<div className="rounded-lg bg-amber-50 border border-amber-200 p-3 space-y-2">
|
<div className="bg-amber-50 border border-amber-200 p-3 space-y-2">
|
||||||
<p className="text-xs font-semibold text-amber-700 uppercase tracking-wide">
|
<p className="text-xs font-semibold text-amber-700 uppercase tracking-wide">
|
||||||
{t.qualityScoreLabel.replace('{score}', String(qualityCheck.score))}
|
{t.qualityScoreLabel.replace('{score}', String(qualityCheck.score))}
|
||||||
</p>
|
</p>
|
||||||
@@ -325,7 +325,7 @@ export function ReportForm({ zoneToken, trucks, initialTruckId }: Props) {
|
|||||||
type="checkbox"
|
type="checkbox"
|
||||||
checked={overrideQuality}
|
checked={overrideQuality}
|
||||||
onChange={e => setOverrideQuality(e.target.checked)}
|
onChange={e => setOverrideQuality(e.target.checked)}
|
||||||
className="rounded border-amber-300 text-amber-600"
|
className="border-amber-300 text-amber-600"
|
||||||
/>
|
/>
|
||||||
{t.submitAnyway}
|
{t.submitAnyway}
|
||||||
</label>
|
</label>
|
||||||
@@ -350,7 +350,7 @@ export function ReportForm({ zoneToken, trucks, initialTruckId }: Props) {
|
|||||||
</label>
|
</label>
|
||||||
<select
|
<select
|
||||||
required={form.injury_involved}
|
required={form.injury_involved}
|
||||||
className="w-full border border-gray-300 rounded-lg px-3 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"
|
className="w-full border border-divider px-3 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"
|
||||||
value={form.medical_status}
|
value={form.medical_status}
|
||||||
onChange={e => setForm(f => ({ ...f, medical_status: e.target.value as MedicalStatus }))}
|
onChange={e => setForm(f => ({ ...f, medical_status: e.target.value as MedicalStatus }))}
|
||||||
>
|
>
|
||||||
@@ -383,8 +383,8 @@ export function ReportForm({ zoneToken, trucks, initialTruckId }: Props) {
|
|||||||
<button
|
<button
|
||||||
type="submit"
|
type="submit"
|
||||||
disabled={submitting || !form.incident_type || (form.incident_type === 'transport' && !form.truck_id)}
|
disabled={submitting || !form.incident_type || (form.incident_type === 'transport' && !form.truck_id)}
|
||||||
className="w-full bg-blue-600 text-white py-3 rounded-lg font-medium text-sm
|
className="w-full bg-blue-600 text-white py-3 font-medium text-sm
|
||||||
hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors"
|
hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors"
|
||||||
>
|
>
|
||||||
{submitting ? t.submitting : t.submitButton}
|
{submitting ? t.submitting : t.submitButton}
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ export function SimilarIncidentsPanel({ incidentId }: Props) {
|
|||||||
|
|
||||||
if (loading) {
|
if (loading) {
|
||||||
return (
|
return (
|
||||||
<div className="mt-6 bg-white rounded-xl shadow-sm p-5">
|
<div className="mt-6 bg-surface shadow-sm p-5">
|
||||||
<p className="text-sm text-gray-400">Loading similar incidents…</p>
|
<p className="text-sm text-gray-400">Loading similar incidents…</p>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
@@ -51,7 +51,7 @@ export function SimilarIncidentsPanel({ incidentId }: Props) {
|
|||||||
if (error || similar.length === 0) return null
|
if (error || similar.length === 0) return null
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="mt-6 bg-white rounded-xl shadow-sm p-5">
|
<div className="mt-6 bg-surface shadow-sm p-5">
|
||||||
<h2 className="text-sm font-semibold text-gray-700 uppercase tracking-wide mb-3">
|
<h2 className="text-sm font-semibold text-gray-700 uppercase tracking-wide mb-3">
|
||||||
Similar Past Incidents
|
Similar Past Incidents
|
||||||
</h2>
|
</h2>
|
||||||
@@ -60,7 +60,7 @@ export function SimilarIncidentsPanel({ incidentId }: Props) {
|
|||||||
<a
|
<a
|
||||||
key={inc.id}
|
key={inc.id}
|
||||||
href={`/hse/incidents/${inc.id}`}
|
href={`/hse/incidents/${inc.id}`}
|
||||||
className="block border border-gray-200 rounded-lg p-3 hover:border-blue-300 hover:bg-blue-50 transition-colors"
|
className="block border border-divider p-3 hover:border-blue-300 hover:bg-blue-50 transition-colors"
|
||||||
>
|
>
|
||||||
<div className="flex items-center justify-between mb-1">
|
<div className="flex items-center justify-between mb-1">
|
||||||
<span className="text-xs font-medium text-gray-500">
|
<span className="text-xs font-medium text-gray-500">
|
||||||
|
|||||||
@@ -95,17 +95,17 @@ export function TriageForm({ incidentId, currentSeverity }: Props) {
|
|||||||
<form onSubmit={handleSubmit} className="space-y-6">
|
<form onSubmit={handleSubmit} className="space-y-6">
|
||||||
<div>
|
<div>
|
||||||
<label className="block text-sm font-medium text-gray-700 mb-2">Severity</label>
|
<label className="block text-sm font-medium text-gray-700 mb-2">Severity</label>
|
||||||
<div className="flex rounded-lg border border-gray-300 overflow-hidden divide-x divide-gray-300">
|
<div className="flex border border-divider overflow-hidden divide-x divide-divider">
|
||||||
{([1, 2, 3, 4, 5] as const).map(v => (
|
{([1, 2, 3, 4, 5] as const).map(v => (
|
||||||
<button
|
<button
|
||||||
key={v}
|
key={v}
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() => setSeverity(v)}
|
onClick={() => setSeverity(v)}
|
||||||
className={`flex-1 py-2 text-xs font-medium transition-colors ${
|
className={`flex-1 py-2 text-xs font-medium transition-colors ${
|
||||||
severity === v
|
severity === v
|
||||||
? 'bg-blue-600 text-white border-blue-600'
|
? 'bg-blue-600 text-white border-blue-600'
|
||||||
: 'bg-white text-gray-700 hover:bg-gray-50'
|
: 'bg-surface text-gray-700 hover:bg-gray-50'
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
<span className="block font-bold">{v}</span>
|
<span className="block font-bold">{v}</span>
|
||||||
<span className="block">{SEVERITY_LABELS[v].split(' / ')[0]}</span>
|
<span className="block">{SEVERITY_LABELS[v].split(' / ')[0]}</span>
|
||||||
@@ -126,7 +126,7 @@ export function TriageForm({ incidentId, currentSeverity }: Props) {
|
|||||||
<input
|
<input
|
||||||
type="checkbox" checked={value}
|
type="checkbox" checked={value}
|
||||||
onChange={e => set(e.target.checked)}
|
onChange={e => set(e.target.checked)}
|
||||||
className="rounded border-gray-300 text-blue-600"
|
className="border-divider text-blue-600"
|
||||||
/>
|
/>
|
||||||
{label}
|
{label}
|
||||||
</label>
|
</label>
|
||||||
@@ -134,7 +134,7 @@ export function TriageForm({ incidentId, currentSeverity }: Props) {
|
|||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
{dosh.reasons.length > 0 && (
|
{dosh.reasons.length > 0 && (
|
||||||
<div className="rounded-lg bg-red-50 border border-red-200 p-3 space-y-1">
|
<div className="bg-red-50 border border-red-200 p-3 space-y-1">
|
||||||
<p className="text-xs font-semibold text-red-700 uppercase tracking-wide">DOSH Reporting Required</p>
|
<p className="text-xs font-semibold text-red-700 uppercase tracking-wide">DOSH Reporting Required</p>
|
||||||
{dosh.reasons.map(r => (
|
{dosh.reasons.map(r => (
|
||||||
<p key={r} className="text-xs text-red-600">{r}</p>
|
<p key={r} className="text-xs text-red-600">{r}</p>
|
||||||
@@ -151,13 +151,13 @@ export function TriageForm({ incidentId, currentSeverity }: Props) {
|
|||||||
value={triageNotes}
|
value={triageNotes}
|
||||||
onChange={e => setTriageNotes(e.target.value)}
|
onChange={e => setTriageNotes(e.target.value)}
|
||||||
rows={3}
|
rows={3}
|
||||||
className="w-full rounded-lg border border-gray-300 px-3 py-2 text-sm focus:ring-2 focus:ring-blue-500 focus:border-transparent"
|
className="w-full border border-divider px-3 py-2 text-sm focus:ring-2 focus:ring-blue-500 focus:border-transparent"
|
||||||
placeholder="Initial assessment, immediate actions taken..."
|
placeholder="Initial assessment, immediate actions taken..."
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{aiRationale && (
|
{aiRationale && (
|
||||||
<div className="rounded-lg bg-purple-50 border border-purple-200 p-3">
|
<div className="bg-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 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-600">{aiRationale}</p>
|
||||||
<p className="text-xs text-purple-400 mt-1">Fields pre-filled — review before submitting.</p>
|
<p className="text-xs text-purple-400 mt-1">Fields pre-filled — review before submitting.</p>
|
||||||
@@ -171,14 +171,14 @@ export function TriageForm({ incidentId, currentSeverity }: Props) {
|
|||||||
type="button"
|
type="button"
|
||||||
onClick={getAiSuggestion}
|
onClick={getAiSuggestion}
|
||||||
disabled={aiLoading || saving}
|
disabled={aiLoading || saving}
|
||||||
className="flex-1 bg-purple-50 text-purple-700 border border-purple-300 rounded-lg py-2 text-sm font-semibold disabled:opacity-50 hover:bg-purple-100"
|
className="flex-1 bg-purple-50 text-purple-700 border border-purple-300 py-2 text-sm font-semibold disabled:opacity-50 hover:bg-purple-100"
|
||||||
>
|
>
|
||||||
{aiLoading ? 'Getting suggestion…' : 'Get AI Suggestion'}
|
{aiLoading ? 'Getting suggestion…' : 'Get AI Suggestion'}
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
type="submit"
|
type="submit"
|
||||||
disabled={saving}
|
disabled={saving}
|
||||||
className="flex-1 bg-blue-600 text-white rounded-lg py-2 text-sm font-semibold disabled:opacity-50"
|
className="flex-1 bg-blue-600 text-white py-2 text-sm font-semibold disabled:opacity-50"
|
||||||
>
|
>
|
||||||
{saving ? 'Saving…' : 'Complete Triage'}
|
{saving ? 'Saving…' : 'Complete Triage'}
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ export function LanguageSwitcher() {
|
|||||||
value={current}
|
value={current}
|
||||||
onChange={e => handleChange(e.target.value)}
|
onChange={e => handleChange(e.target.value)}
|
||||||
aria-label="Select language"
|
aria-label="Select language"
|
||||||
className="text-xs border border-gray-300 rounded px-2 py-1 bg-white text-gray-700 focus:outline-none focus:ring-1 focus:ring-blue-500"
|
className="text-xs border border-divider px-2 py-1 bg-surface text-gray-700 focus:outline-none focus:ring-1 focus:ring-blue-500"
|
||||||
>
|
>
|
||||||
{Object.entries(LOCALES).map(([code, label]) => (
|
{Object.entries(LOCALES).map(([code, label]) => (
|
||||||
<option key={code} value={code}>{label}</option>
|
<option key={code} value={code}>{label}</option>
|
||||||
|
|||||||
@@ -117,11 +117,11 @@ function NavLink({ item, pathname }: { item: NavItem; pathname: string }) {
|
|||||||
return (
|
return (
|
||||||
<Link
|
<Link
|
||||||
href={item.href}
|
href={item.href}
|
||||||
className={`flex items-center gap-3 px-3 py-2 rounded-lg text-sm font-medium transition-colors ${
|
className={`flex items-center gap-3 px-3 py-2 text-sm font-medium transition-colors ${
|
||||||
isActive
|
isActive
|
||||||
? 'bg-blue-50 text-blue-700'
|
? 'bg-blue-50 text-blue-700'
|
||||||
: 'text-gray-600 hover:bg-gray-100 hover:text-gray-900'
|
: 'text-gray-600 hover:bg-gray-100 hover:text-gray-900'
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
<span className={isActive ? 'text-blue-600' : 'text-gray-400'}>{item.icon}</span>
|
<span className={isActive ? 'text-blue-600' : 'text-gray-400'}>{item.icon}</span>
|
||||||
{item.label}
|
{item.label}
|
||||||
@@ -147,9 +147,9 @@ export function Sidebar({ role, userName, userEmail }: SidebarProps) {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{/* Desktop sidebar */}
|
{/* Desktop sidebar */}
|
||||||
<aside className="hidden sm:flex fixed left-0 top-0 h-full w-60 bg-white border-r border-gray-200 flex-col z-40">
|
<aside className="hidden sm:flex fixed left-0 top-0 h-full w-60 bg-surface border-r border-divider flex-col z-40">
|
||||||
{/* Header */}
|
{/* Header */}
|
||||||
<div className="flex items-center justify-between px-4 py-4 border-b border-gray-100">
|
<div className="flex items-center justify-between px-4 py-4 border-b border-divider">
|
||||||
<span className="text-base font-bold text-gray-900 tracking-tight">IMS</span>
|
<span className="text-base font-bold text-gray-900 tracking-tight">IMS</span>
|
||||||
<NotificationBell />
|
<NotificationBell />
|
||||||
</div>
|
</div>
|
||||||
@@ -162,7 +162,7 @@ export function Sidebar({ role, userName, userEmail }: SidebarProps) {
|
|||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
{/* User + logout */}
|
{/* User + logout */}
|
||||||
<div className="border-t border-gray-100 px-3 py-3">
|
<div className="border-t border-divider px-3 py-3">
|
||||||
<div className="flex items-center gap-2 px-2 py-2 mb-1">
|
<div className="flex items-center gap-2 px-2 py-2 mb-1">
|
||||||
<div className="w-8 h-8 rounded-full bg-blue-600 flex items-center justify-center text-white text-xs font-bold flex-shrink-0">
|
<div className="w-8 h-8 rounded-full bg-blue-600 flex items-center justify-center text-white text-xs font-bold flex-shrink-0">
|
||||||
{initials(displayName)}
|
{initials(displayName)}
|
||||||
@@ -174,11 +174,11 @@ export function Sidebar({ role, userName, userEmail }: SidebarProps) {
|
|||||||
</div>
|
</div>
|
||||||
<Link
|
<Link
|
||||||
href="/account"
|
href="/account"
|
||||||
className={`flex items-center gap-2 w-full px-3 py-2 text-sm rounded-lg transition-colors ${
|
className={`flex items-center gap-2 w-full px-3 py-2 text-sm transition-colors ${
|
||||||
pathname === '/account'
|
pathname === '/account'
|
||||||
? 'bg-blue-50 text-blue-700'
|
? 'bg-blue-50 text-blue-700'
|
||||||
: 'text-gray-600 hover:bg-gray-100 hover:text-gray-900'
|
: 'text-gray-600 hover:bg-gray-100 hover:text-gray-900'
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
<span className={pathname === '/account' ? 'text-blue-600' : 'text-gray-400'}>
|
<span className={pathname === '/account' ? 'text-blue-600' : 'text-gray-400'}>
|
||||||
<IconUser />
|
<IconUser />
|
||||||
@@ -187,19 +187,19 @@ export function Sidebar({ role, userName, userEmail }: SidebarProps) {
|
|||||||
</Link>
|
</Link>
|
||||||
<button
|
<button
|
||||||
onClick={logout}
|
onClick={logout}
|
||||||
className="flex items-center gap-2 w-full px-3 py-2 text-sm text-gray-600 hover:bg-gray-100 hover:text-gray-900 rounded-lg transition-colors"
|
className="flex items-center gap-2 w-full px-3 py-2 text-sm text-gray-600 hover:bg-gray-100 hover:text-gray-900 transition-colors"
|
||||||
>
|
>
|
||||||
<IconLogout />
|
<IconLogout />
|
||||||
Logout
|
Logout
|
||||||
</button>
|
</button>
|
||||||
<div className="mt-3 pt-3 border-t border-gray-100 px-2 text-center">
|
<div className="mt-3 pt-3 border-t border-divider px-2 text-center">
|
||||||
<p className="text-xs text-gray-400">v1.2.2</p>
|
<p className="text-xs text-gray-400">v1.2.2</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</aside>
|
</aside>
|
||||||
|
|
||||||
{/* Mobile bottom tab bar */}
|
{/* Mobile bottom tab bar */}
|
||||||
<nav className="sm:hidden fixed bottom-0 left-0 right-0 bg-white border-t border-gray-200 flex z-40 safe-area-pb">
|
<nav className="sm:hidden fixed bottom-0 left-0 right-0 bg-surface border-t border-divider flex z-40 safe-area-pb">
|
||||||
{mobileItems.map(item => {
|
{mobileItems.map(item => {
|
||||||
const exactRoots = ['/reporter', '/supervisor', '/management', '/capa-owner', '/admin', '/report', '/account']
|
const exactRoots = ['/reporter', '/supervisor', '/management', '/capa-owner', '/admin', '/report', '/account']
|
||||||
const isActive = exactRoots.includes(item.href)
|
const isActive = exactRoots.includes(item.href)
|
||||||
@@ -210,8 +210,8 @@ export function Sidebar({ role, userName, userEmail }: SidebarProps) {
|
|||||||
key={item.href}
|
key={item.href}
|
||||||
href={item.href}
|
href={item.href}
|
||||||
className={`flex-1 flex flex-col items-center gap-1 py-2 text-[10px] font-medium transition-colors ${
|
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'
|
isActive ? 'text-blue-600' : 'text-gray-400'
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
{item.icon}
|
{item.icon}
|
||||||
<span className="leading-none">{item.label}</span>
|
<span className="leading-none">{item.label}</span>
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ export function NotificationBell() {
|
|||||||
<button
|
<button
|
||||||
onClick={() => setOpen(o => !o)}
|
onClick={() => setOpen(o => !o)}
|
||||||
aria-label={`Notifications${unread > 0 ? ` (${unread} unread)` : ''}`}
|
aria-label={`Notifications${unread > 0 ? ` (${unread} unread)` : ''}`}
|
||||||
className="relative bg-white rounded-full shadow-sm border border-gray-200 w-10 h-10 flex items-center justify-center hover:shadow-md transition-shadow"
|
className="relative bg-surface rounded-full shadow-sm border border-divider w-10 h-10 flex items-center justify-center hover:shadow-md transition-shadow"
|
||||||
>
|
>
|
||||||
<span className="text-lg" aria-hidden>🔔</span>
|
<span className="text-lg" aria-hidden>🔔</span>
|
||||||
{unread > 0 && (
|
{unread > 0 && (
|
||||||
@@ -73,8 +73,8 @@ export function NotificationBell() {
|
|||||||
</button>
|
</button>
|
||||||
|
|
||||||
{open && (
|
{open && (
|
||||||
<div className="absolute right-0 mt-2 w-80 max-h-96 overflow-y-auto bg-white rounded-xl shadow-lg border border-gray-200">
|
<div className="absolute right-0 mt-2 w-80 max-h-96 overflow-y-auto bg-surface shadow-lg border border-divider">
|
||||||
<div className="flex items-center justify-between px-4 py-2 border-b border-gray-100">
|
<div className="flex items-center justify-between px-4 py-2 border-b border-divider">
|
||||||
<span className="text-sm font-semibold text-gray-700">Notifications</span>
|
<span className="text-sm font-semibold text-gray-700">Notifications</span>
|
||||||
{unread > 0 && (
|
{unread > 0 && (
|
||||||
<button onClick={markAllRead} className="text-xs text-blue-600 hover:underline">
|
<button onClick={markAllRead} className="text-xs text-blue-600 hover:underline">
|
||||||
|
|||||||
@@ -44,14 +44,14 @@ export function ApiKeyForm({ settings }: Props) {
|
|||||||
{Object.keys(KEY_LABELS).map(key => {
|
{Object.keys(KEY_LABELS).map(key => {
|
||||||
const status = settings[key]
|
const status = settings[key]
|
||||||
return (
|
return (
|
||||||
<div key={key} className="bg-white rounded-xl shadow-sm p-5">
|
<div key={key} className="bg-surface shadow-sm p-5">
|
||||||
<div className="flex items-center justify-between mb-1">
|
<div className="flex items-center justify-between mb-1">
|
||||||
<label className="text-sm font-semibold text-gray-800">{KEY_LABELS[key]}</label>
|
<label className="text-sm font-semibold text-gray-800">{KEY_LABELS[key]}</label>
|
||||||
<span className={`text-xs font-medium px-2 py-0.5 rounded-full ${
|
<span className={`text-xs font-medium px-2 py-0.5 rounded-full ${
|
||||||
status?.set
|
status?.set
|
||||||
? 'bg-green-100 text-green-700'
|
? 'bg-green-100 text-green-700'
|
||||||
: 'bg-yellow-100 text-yellow-700'
|
: 'bg-yellow-100 text-yellow-700'
|
||||||
}`}>
|
}`}>
|
||||||
{status?.set ? 'Configured' : 'Not set'}
|
{status?.set ? 'Configured' : 'Not set'}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
@@ -66,12 +66,12 @@ export function ApiKeyForm({ settings }: Props) {
|
|||||||
value={values[key]}
|
value={values[key]}
|
||||||
onChange={e => setValues(v => ({ ...v, [key]: e.target.value }))}
|
onChange={e => setValues(v => ({ ...v, [key]: e.target.value }))}
|
||||||
placeholder={status?.set ? 'Enter new key to replace…' : 'Enter API key…'}
|
placeholder={status?.set ? 'Enter new key to replace…' : 'Enter API key…'}
|
||||||
className="flex-1 border border-gray-300 rounded-lg px-3 py-2 text-sm text-gray-900 placeholder-gray-500 focus:ring-2 focus:ring-blue-500 focus:border-transparent font-mono"
|
className="flex-1 border border-divider px-3 py-2 text-sm text-gray-900 placeholder-gray-500 focus:ring-2 focus:ring-blue-500 focus:border-transparent font-mono"
|
||||||
/>
|
/>
|
||||||
<button
|
<button
|
||||||
onClick={() => save(key)}
|
onClick={() => save(key)}
|
||||||
disabled={saving[key] || !values[key]}
|
disabled={saving[key] || !values[key]}
|
||||||
className="bg-blue-600 text-white rounded-lg px-4 py-2 text-sm font-semibold disabled:opacity-50 hover:bg-blue-700"
|
className="bg-blue-600 text-white px-4 py-2 text-sm font-semibold disabled:opacity-50 hover:bg-blue-700"
|
||||||
>
|
>
|
||||||
{saving[key] ? 'Saving…' : 'Save'}
|
{saving[key] ? 'Saving…' : 'Save'}
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -26,11 +26,11 @@ export function Modal({ open, onClose, title, children, footer, width = 'md' }:
|
|||||||
return (
|
return (
|
||||||
<div className="fixed inset-0 z-50 flex items-center justify-center p-4" role="dialog" aria-modal="true">
|
<div className="fixed inset-0 z-50 flex items-center justify-center p-4" role="dialog" aria-modal="true">
|
||||||
<div className="absolute inset-0 bg-gray-900/50" onClick={onClose} />
|
<div className="absolute inset-0 bg-gray-900/50" onClick={onClose} />
|
||||||
<div className={`relative w-full ${maxW} bg-white rounded-2xl shadow-2xl`}>
|
<div className={`relative w-full ${maxW} bg-surface shadow-lg`}>
|
||||||
<div className="flex items-center justify-between px-6 py-4 border-b border-gray-100">
|
<div className="flex items-center justify-between px-6 py-4 border-b border-divider">
|
||||||
<h2 className="text-sm font-semibold text-gray-900">{title}</h2>
|
<h2 className="text-sm font-semibold text-gray-900">{title}</h2>
|
||||||
<button onClick={onClose} aria-label="Close"
|
<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">
|
className="text-gray-400 hover:text-gray-600 p-1 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}>
|
<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" />
|
<path strokeLinecap="round" strokeLinejoin="round" d="M6 18 18 6M6 6l12 12" />
|
||||||
</svg>
|
</svg>
|
||||||
@@ -38,7 +38,7 @@ export function Modal({ open, onClose, title, children, footer, width = 'md' }:
|
|||||||
</div>
|
</div>
|
||||||
<div className="px-6 py-5">{children}</div>
|
<div className="px-6 py-5">{children}</div>
|
||||||
{footer && (
|
{footer && (
|
||||||
<div className="px-6 py-4 border-t border-gray-100 flex justify-end gap-2">
|
<div className="px-6 py-4 border-t border-divider flex justify-end gap-2">
|
||||||
{footer}
|
{footer}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -366,7 +366,6 @@ Create `tests/scripts/modernist-codemod.test.ts`:
|
|||||||
|
|
||||||
```ts
|
```ts
|
||||||
import { describe, it, expect } from 'vitest'
|
import { describe, it, expect } from 'vitest'
|
||||||
// @ts-expect-error plain .mjs script without types
|
|
||||||
import { transformSource } from '../../scripts/modernist-codemod.mjs'
|
import { transformSource } from '../../scripts/modernist-codemod.mjs'
|
||||||
|
|
||||||
const t = (s: string): string => transformSource(s)
|
const t = (s: string): string => transformSource(s)
|
||||||
@@ -450,8 +449,9 @@ function transformClassAttr(attr) {
|
|||||||
out = out.replace(/(?<![\w-])border-gray-(?:100|200|300)(?![\w-])/g, 'border-divider')
|
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-])divide-gray-(?:100|200|300)(?![\w-])/g, 'divide-divider')
|
||||||
out = out.replace(/(?<![\w-])shadow-(?:xl|2xl)(?![\w-])/g, 'shadow-lg')
|
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')
|
||||||
out = out.replace(/ {2,}/g, ' ')
|
out = out.replace(/ {2,}/g, ' ')
|
||||||
out = out.replace(/(["'`])\s+/g, '$1').replace(/\s+(["'`])/g, '$1')
|
|
||||||
return out
|
return out
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -489,7 +489,7 @@ function main() {
|
|||||||
if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) main()
|
if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) main()
|
||||||
```
|
```
|
||||||
|
|
||||||
Note on the whitespace cleanup: the `(["'`])\s+` replacement trims spaces just inside quotes of every class attribute, which is safe because class lists never need leading or trailing space.
|
Note on the whitespace cleanup: only string-literal bodies and the attribute's outer backtick delimiters are trimmed, so spaces around `?` and `:` inside `${...}` survive.
|
||||||
|
|
||||||
- [ ] **Step 4: Run the tests to verify they pass**
|
- [ ] **Step 4: Run the tests to verify they pass**
|
||||||
|
|
||||||
@@ -1592,7 +1592,6 @@ Create `tests/scripts/check-design-gates.test.ts`:
|
|||||||
|
|
||||||
```ts
|
```ts
|
||||||
import { describe, it, expect } from 'vitest'
|
import { describe, it, expect } from 'vitest'
|
||||||
// @ts-expect-error plain .mjs script without types
|
|
||||||
import { findViolations, ROUND_ALLOWED } from '../../scripts/check-design-gates.mjs'
|
import { findViolations, ROUND_ALLOWED } from '../../scripts/check-design-gates.mjs'
|
||||||
|
|
||||||
const rules = (src: string, file = 'components/x.tsx'): string[] =>
|
const rules = (src: string, file = 'components/x.tsx'): string[] =>
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
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')
|
||||||
|
out = out.replace(/ {2,}/g, ' ')
|
||||||
|
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()
|
||||||
@@ -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