Custom auth stack: bcryptjs password hashing (cost 10, GoTrue-compatible), jose JWT session cookies (edge-safe, 8hr TTL), new API routes for login/logout/reset/change-password, middleware rewritten to JWT-only verification with no DB access. All 38 protected pages and API routes migrated from supabase.auth.getUser() to getSession(). Supabase .from() queries retained for Phase 4. lib/db/index.ts refactored to lazy Proxy singleton to avoid module-level throw during Next.js build. tsc: clean, build: clean, tests: 4/4 passed Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
36 lines
1.2 KiB
TypeScript
36 lines
1.2 KiB
TypeScript
export const dynamic = 'force-dynamic'
|
|
|
|
import { redirect } from 'next/navigation'
|
|
import Link from 'next/link'
|
|
import { createClient } from '@/lib/supabase/server'
|
|
import { getSession } from '@/lib/auth/get-session'
|
|
import { CapaBoard } from '@/components/capa/capa-board'
|
|
|
|
export default async function CapaListPage() {
|
|
const session = await getSession()
|
|
if (!session) redirect('/login?redirect=/hse/capa')
|
|
|
|
const supabase = await createClient()
|
|
|
|
const { data: capas } = await supabase
|
|
.from('capa_actions')
|
|
.select(`
|
|
id, incident_id, description, department, due_date, priority, status,
|
|
incidents (reference_no, incident_type),
|
|
owner:users!owner_user_id (name, email)
|
|
`)
|
|
.order('due_date', { ascending: true })
|
|
|
|
return (
|
|
<main className="max-w-6xl mx-auto px-4 py-6">
|
|
<div className="flex items-center justify-between mb-6">
|
|
<h1 className="text-2xl font-bold text-gray-900">CAPA Board</h1>
|
|
<Link href="/hse/incidents" className="text-sm text-blue-600 hover:underline">
|
|
← Incidents
|
|
</Link>
|
|
</div>
|
|
<CapaBoard capas={(capas ?? []) as unknown as Parameters<typeof CapaBoard>[0]['capas']} />
|
|
</main>
|
|
)
|
|
}
|