46 lines
1.7 KiB
TypeScript
46 lines
1.7 KiB
TypeScript
export function newIncidentTemplate(params: {
|
|
reference_no: string
|
|
incident_type: string
|
|
site_name: string
|
|
reporter_name: string
|
|
reported_at: string
|
|
site_url: string
|
|
incident_id: string
|
|
}): { subject: string; html: string; text: string } {
|
|
const typeLabel = params.incident_type.replace(/_/g, ' ')
|
|
const subject = `[IMS] New incident ${params.reference_no} — ${typeLabel} at ${params.site_name}`
|
|
const link = `${params.site_url}/hse/incidents/${params.incident_id}`
|
|
|
|
const text = `
|
|
New incident report received.
|
|
|
|
Reference: ${params.reference_no}
|
|
Type: ${typeLabel}
|
|
Site: ${params.site_name}
|
|
Reported by: ${params.reporter_name}
|
|
Time: ${params.reported_at}
|
|
|
|
View incident: ${link}
|
|
`.trim()
|
|
|
|
const html = `
|
|
<div style="font-family:sans-serif;max-width:600px;margin:0 auto">
|
|
<h2 style="color:#1e293b">New Incident Report</h2>
|
|
<table style="border-collapse:collapse;width:100%">
|
|
<tr><td style="padding:6px 0;color:#64748b">Reference</td><td style="padding:6px 0;font-weight:600">${params.reference_no}</td></tr>
|
|
<tr><td style="padding:6px 0;color:#64748b">Type</td><td style="padding:6px 0">${typeLabel}</td></tr>
|
|
<tr><td style="padding:6px 0;color:#64748b">Site</td><td style="padding:6px 0">${params.site_name}</td></tr>
|
|
<tr><td style="padding:6px 0;color:#64748b">Reported by</td><td style="padding:6px 0">${params.reporter_name}</td></tr>
|
|
<tr><td style="padding:6px 0;color:#64748b">Time</td><td style="padding:6px 0">${params.reported_at}</td></tr>
|
|
</table>
|
|
<p style="margin-top:20px">
|
|
<a href="${link}" style="background:#2563eb;color:#fff;padding:10px 18px;text-decoration:none;border-radius:6px;display:inline-block">
|
|
View Incident
|
|
</a>
|
|
</p>
|
|
</div>
|
|
`.trim()
|
|
|
|
return { subject, html, text }
|
|
}
|