feat(capa): wire owner notes form into capa-owner page and HSE detail view

This commit is contained in:
2026-07-23 12:00:43 +08:00
parent 5f34dbb644
commit 938eb7e08d
2 changed files with 12 additions and 1 deletions
+3 -1
View File
@@ -5,6 +5,7 @@ import { createClient } from '@/lib/supabase/server'
import { redirect } from 'next/navigation' import { redirect } from 'next/navigation'
import { StatCard } from '@/components/dashboard/stat-card' import { StatCard } from '@/components/dashboard/stat-card'
import { CapaOwnerActions } from '@/components/capa/capa-owner-actions' import { CapaOwnerActions } from '@/components/capa/capa-owner-actions'
import { CapaOwnerNotesForm } from '@/components/capa/capa-owner-notes-form'
const STATUS_LABELS: Record<string, string> = { const STATUS_LABELS: Record<string, string> = {
open: 'Open', open: 'Open',
@@ -36,7 +37,7 @@ export default async function CapaOwnerPage() {
const { data: capas } = await supabase const { data: capas } = await supabase
.from('capa_actions') .from('capa_actions')
.select('id, description, due_date, priority, status, incident_id, incidents (reference_no)') .select('id, description, due_date, priority, status, incident_id, owner_notes, incidents (reference_no)')
.eq('owner_user_id', user.id) .eq('owner_user_id', user.id)
.order('due_date', { ascending: true, nullsFirst: false }) .order('due_date', { ascending: true, nullsFirst: false })
@@ -99,6 +100,7 @@ export default async function CapaOwnerPage() {
<CapaOwnerActions capaId={capa.id} currentStatus={capa.status} /> <CapaOwnerActions capaId={capa.id} currentStatus={capa.status} />
</div> </div>
</div> </div>
<CapaOwnerNotesForm capaId={capa.id} initialNotes={(capa as { owner_notes: string | null }).owner_notes} />
</div> </div>
) )
})} })}
+9
View File
@@ -30,6 +30,7 @@ export default async function CapaDetailPage({ params }: Props) {
.select(` .select(`
id, incident_id, root_cause_ref, description, department, id, incident_id, root_cause_ref, description, department,
due_date, priority, status, completed_at, verified_by, verified_at, created_at, due_date, priority, status, completed_at, verified_by, verified_at, created_at,
owner_notes,
incidents (reference_no, incident_type), incidents (reference_no, incident_type),
owner:users!owner_user_id (name, email) owner:users!owner_user_id (name, email)
`) `)
@@ -77,6 +78,14 @@ export default async function CapaDetailPage({ params }: Props) {
<p className="text-xs text-gray-500">Status</p> <p className="text-xs text-gray-500">Status</p>
<p className="text-gray-800 capitalize">{status.replace(/_/g, ' ')}</p> <p className="text-gray-800 capitalize">{status.replace(/_/g, ' ')}</p>
</div> </div>
{(capa as { owner_notes: string | null }).owner_notes && (
<div className="col-span-2">
<p className="text-xs text-gray-500">Owner Notes</p>
<p className="text-sm text-gray-800 whitespace-pre-wrap">
{(capa as { owner_notes: string }).owner_notes}
</p>
</div>
)}
</div> </div>
{(capa as { root_cause_ref: string | null }).root_cause_ref && ( {(capa as { root_cause_ref: string | null }).root_cause_ref && (