feat: incident inbox pages with filter/search for HSE and supervisor roles

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AWxyMibCuGGtSQSqfajDQ7
This commit is contained in:
2026-07-11 07:39:43 +08:00
co-authored by Claude Sonnet 4.6
parent 2239b6e2df
commit 2f2018f27a
6 changed files with 294 additions and 10 deletions
+29
View File
@@ -0,0 +1,29 @@
export const dynamic = 'force-dynamic'
import { createClient } from '@/lib/supabase/server'
import { IncidentList } from '@/components/incidents/incident-list'
export default async function HseInboxPage() {
const supabase = await createClient()
const { data: incidents } = await supabase
.from('incidents')
.select(`
id, reference_no, incident_type, status, severity, reported_at,
sites (name),
zones (name),
reporter:users!reported_by (name)
`)
.order('reported_at', { ascending: false })
.limit(100)
return (
<main className="max-w-4xl mx-auto px-4 py-6">
<div className="flex items-center justify-between mb-6">
<h1 className="text-2xl font-bold text-gray-900">Incident Inbox</h1>
<span className="text-sm text-gray-500">{incidents?.length ?? 0} incidents</span>
</div>
<IncidentList incidents={(incidents ?? []) as any} basePath="/hse" />
</main>
)
}
+28 -5
View File
@@ -1,9 +1,32 @@
// app/(protected)/hse/page.tsx
export default function HSEHome() {
export const dynamic = 'force-dynamic'
import Link from 'next/link'
import { createClient } from '@/lib/supabase/server'
import { redirect } from 'next/navigation'
export default async function HsePage() {
const supabase = await createClient()
const { data: { user } } = await supabase.auth.getUser()
if (!user) redirect('/login')
const { data: profile } = await supabase.from('users').select('name').eq('id', user.id).single()
return (
<main className="p-8 max-w-4xl mx-auto">
<h1 className="text-2xl font-bold">HSE Officer Dashboard</h1>
<p className="mt-2 text-gray-500">Phase 1: Incident inbox + triage coming here.</p>
<main className="max-w-4xl mx-auto px-4 py-6">
<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, {profile?.name ?? user.email}</p>
<div className="grid grid-cols-2 gap-4 sm:grid-cols-3">
<Link href="/hse/incidents" className="bg-white rounded-xl shadow-sm p-5 hover:shadow-md transition-shadow border border-gray-100">
<div className="text-2xl mb-2">📋</div>
<div className="font-semibold text-gray-900">Incident Inbox</div>
<div className="text-xs text-gray-500 mt-1">View all incidents</div>
</Link>
<Link href="/hse/dashboard" className="bg-white rounded-xl shadow-sm p-5 hover:shadow-md transition-shadow border border-gray-100">
<div className="text-2xl mb-2">📊</div>
<div className="font-semibold text-gray-900">Dashboard</div>
<div className="text-xs text-gray-500 mt-1">Stats & overview</div>
</Link>
</div>
</main>
)
}