feat(auth): merge reporter, supervisor, capa_owner into ssa role
Add Site Safety Assistant (ssa) role replacing reporter, supervisor and capa_owner. Portals move under /ssa (overview, my-reports, incidents, capas). Update RLS, schema, API role checks, notification recipients, nav and tests. Add db/ops/2026-11-06-merge-roles-into-ssa.sql (not yet applied; needs owner go-ahead and a pg_dump first). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
701fefd286
commit
813395700f
@@ -21,10 +21,10 @@ const STATUS_LABELS: Record<string, string> = {
|
||||
closed: 'Closed',
|
||||
}
|
||||
|
||||
export default async function CapaOwnerPage() {
|
||||
export default async function MyCapasPage() {
|
||||
const session = await getSession()
|
||||
if (!session) redirect('/login')
|
||||
if (!['capa_owner', 'admin', 'hse', 'supervisor'].includes(session.role)) redirect('/')
|
||||
if (!['ssa', 'admin', 'hse'].includes(session.role)) redirect('/')
|
||||
|
||||
const rows = await asAdmin(db =>
|
||||
db.select({
|
||||
+2
-2
@@ -14,7 +14,7 @@ interface Props {
|
||||
params: Promise<{ id: string }>
|
||||
}
|
||||
|
||||
export default async function SupervisorIncidentDetailPage({ params }: Props) {
|
||||
export default async function SsaIncidentDetailPage({ params }: Props) {
|
||||
const { id } = await params
|
||||
|
||||
const session = await getSession()
|
||||
@@ -136,7 +136,7 @@ export default async function SupervisorIncidentDetailPage({ params }: Props) {
|
||||
|
||||
return (
|
||||
<main className="max-w-3xl mx-auto px-4 py-6">
|
||||
<Link href="/supervisor/incidents" className="text-sm text-accent-700 hover:underline mb-4 inline-block">
|
||||
<Link href="/ssa/incidents" className="text-sm text-accent-700 hover:underline mb-4 inline-block">
|
||||
← Back to inbox
|
||||
</Link>
|
||||
<IncidentDetail incident={incidentProp} />
|
||||
+2
-2
@@ -8,7 +8,7 @@ import { IncidentTable } from '@/components/incidents/incident-table'
|
||||
import { loadIncidentList } from '@/lib/incidents/list-query'
|
||||
import { parseListParams } from '@/lib/incidents/list-params'
|
||||
|
||||
export default async function SupervisorInboxPage({
|
||||
export default async function SsaInboxPage({
|
||||
searchParams,
|
||||
}: {
|
||||
searchParams: Promise<Record<string, string | undefined>>
|
||||
@@ -27,7 +27,7 @@ export default async function SupervisorInboxPage({
|
||||
</div>
|
||||
<IncidentTable
|
||||
incidents={data.incidents}
|
||||
basePath="/supervisor"
|
||||
basePath="/ssa"
|
||||
total={data.total}
|
||||
counts={data.counts}
|
||||
params={params}
|
||||
+2
-2
@@ -12,7 +12,7 @@ const STATUS_LABELS: Record<string, string> = {
|
||||
reported: 'Reported', triaged: 'Triaged', investigating: 'Investigating',
|
||||
capa_pending: 'CAPA Pending', verification: 'Verification', closed: 'Closed',
|
||||
}
|
||||
export default async function ReporterIncidentDetail({
|
||||
export default async function MyReportDetail({
|
||||
params,
|
||||
}: {
|
||||
params: Promise<{ id: string }>
|
||||
@@ -60,7 +60,7 @@ export default async function ReporterIncidentDetail({
|
||||
return (
|
||||
<main className="max-w-2xl mx-auto px-4 py-6 space-y-4">
|
||||
<div className="flex items-center gap-2 mb-2">
|
||||
<Link href="/reporter" className="text-sm text-accent-700 hover:underline">← My Reports</Link>
|
||||
<Link href="/ssa/my-reports" className="text-sm text-accent-700 hover:underline">← My Reports</Link>
|
||||
</div>
|
||||
|
||||
<div className="bg-surface shadow-sm p-5">
|
||||
@@ -22,7 +22,7 @@ const TYPE_LABELS: Record<string, string> = {
|
||||
asset_damage: 'Asset Damage', environmental: 'Environmental', security: 'Security', fire: 'Fire',
|
||||
}
|
||||
|
||||
export default async function ReporterPage() {
|
||||
export default async function MyReportsPage() {
|
||||
const session = await getSession()
|
||||
if (!session) redirect('/login')
|
||||
|
||||
@@ -83,7 +83,7 @@ export default async function ReporterPage() {
|
||||
) : (
|
||||
<div className="bg-surface shadow-sm divide-y divide-gray-50">
|
||||
{rows.map(inc => (
|
||||
<Link key={inc.id} href={`/reporter/incidents/${inc.id}`} className="block p-4 cursor-pointer hover:bg-gray-50 transition-colors">
|
||||
<Link key={inc.id} href={`/ssa/my-reports/${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-1 min-w-0">
|
||||
<p className="text-sm font-semibold text-gray-900">
|
||||
@@ -19,15 +19,15 @@ const STATUS_LABELS: Record<string, string> = {
|
||||
closed: 'Closed',
|
||||
}
|
||||
|
||||
export default async function SupervisorPage() {
|
||||
export default async function SsaPage() {
|
||||
const session = await getSession()
|
||||
if (!session) redirect('/login')
|
||||
if (!['supervisor', 'admin'].includes(session.role)) redirect('/')
|
||||
if (!['ssa', 'admin'].includes(session.role)) redirect('/')
|
||||
|
||||
if (!session.siteId) {
|
||||
return (
|
||||
<main className="max-w-4xl mx-auto px-4 py-6">
|
||||
<h1 className="text-2xl font-bold text-gray-900 mb-4">Supervisor Portal</h1>
|
||||
<h1 className="text-2xl font-bold text-gray-900 mb-4">Site Safety Assistant Portal</h1>
|
||||
<p className="text-sm text-gray-500">No site assigned — contact your administrator.</p>
|
||||
</main>
|
||||
)
|
||||
@@ -108,10 +108,10 @@ export default async function SupervisorPage() {
|
||||
<main className="max-w-4xl mx-auto px-4 py-6">
|
||||
<div className="flex items-center justify-between mb-6">
|
||||
<div>
|
||||
<h1 className="text-2xl font-bold text-gray-900">Supervisor Portal</h1>
|
||||
<h1 className="text-2xl font-bold text-gray-900">Site Safety Assistant Portal</h1>
|
||||
<p className="text-sm text-gray-500 mt-1">{siteName}</p>
|
||||
</div>
|
||||
<Link href="/supervisor/incidents" className="text-sm text-accent-700 hover:underline">
|
||||
<Link href="/ssa/incidents" className="text-sm text-accent-700 hover:underline">
|
||||
All incidents →
|
||||
</Link>
|
||||
</div>
|
||||
@@ -134,7 +134,7 @@ export default async function SupervisorPage() {
|
||||
{openIncidents.map(inc => (
|
||||
<Link
|
||||
key={inc.id}
|
||||
href={`/supervisor/incidents/${inc.id}`}
|
||||
href={`/ssa/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"
|
||||
>
|
||||
<div>
|
||||
Reference in New Issue
Block a user