feat: email notifications via Resend on new incident

This commit is contained in:
2026-07-10 13:24:44 +08:00
parent 3f8da5bd91
commit 2239b6e2df
6 changed files with 254 additions and 38 deletions
+4
View File
@@ -2,6 +2,7 @@ import { NextResponse } from 'next/server'
import { createClient } from '@/lib/supabase/server'
import { validateIncidentInput } from '@/lib/incidents/validate'
import { uploadEvidenceFile, type EvidenceStage } from '@/lib/supabase/storage'
import { sendNewIncidentEmail } from '@/lib/notifications/email'
export const dynamic = 'force-dynamic'
@@ -105,5 +106,8 @@ export async function POST(request: Request) {
p_new_value: { incident_type: input.incident_type, reported_by: user.id },
})
sendNewIncidentEmail(incident.id, zone.site_id, incident.reference_no ?? '', input.incident_type)
.catch(err => console.error('email notification failed:', err))
return NextResponse.json({ id: incident.id, reference_no: incident.reference_no }, { status: 201 })
}