105 lines
5.8 KiB
TypeScript
105 lines
5.8 KiB
TypeScript
/**
|
|
* Approval Request Email Template (Single Approver)
|
|
*/
|
|
|
|
import { ApprovalRequestData } from './types';
|
|
import { getEmailFooter, getPrioritySection, getRequestSummaryTable, getEmailActionButtons, getEmailHeader, HeaderStyles, getResponsiveStyles, wrapRichText, getEmailContainerStyles, getCustomMessageSection } from './helpers';
|
|
import { getBrandedHeader } from './branding.config';
|
|
|
|
export function getApprovalRequestEmail(data: ApprovalRequestData): string {
|
|
return `
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
<meta name="format-detection" content="telephone=no">
|
|
<title>Approval Request</title>
|
|
${getResponsiveStyles()}
|
|
</head>
|
|
<body style="margin: 0; padding: 0; font-family: Arial, Helvetica, sans-serif; background-color: #f4f4f4;">
|
|
<table role="presentation" style="width: 100%; border-collapse: collapse; background-color: #f4f4f4;" cellpadding="0" cellspacing="0">
|
|
<tr>
|
|
<td style="padding: 40px 0;">
|
|
<table role="presentation" class="email-container" style="${getEmailContainerStyles()}" cellpadding="0" cellspacing="0">
|
|
<!-- Header -->
|
|
${getEmailHeader(getBrandedHeader({
|
|
title: 'Approval Request',
|
|
...HeaderStyles.info
|
|
}))}
|
|
|
|
<!-- Content -->
|
|
<tr>
|
|
<td class="email-content" style="padding: 40px 30px;">
|
|
<p style="margin: 0 0 20px; color: #333333; font-size: 16px; line-height: 1.6;">
|
|
Dear <strong style="color: #667eea;">${data.approverName}</strong>,
|
|
</p>
|
|
|
|
<p style="margin: 0 0 30px; color: #666666; font-size: 16px; line-height: 1.6;">
|
|
<strong style="color: #333333;">${data.initiatorName}</strong> has submitted a request that requires your approval.
|
|
</p>
|
|
|
|
<!-- Request Summary (FR-2.2.3) -->
|
|
<div style="margin-bottom: 30px;">
|
|
<h3 style="margin: 0 0 15px; color: #333333; font-size: 16px; font-weight: 600;">Request Summary:</h3>
|
|
${getRequestSummaryTable({
|
|
priority: data.priority,
|
|
requestType: data.requestType,
|
|
purpose: data.requestDescription
|
|
})}
|
|
</div>
|
|
|
|
<!-- Custom Message Section -->
|
|
${getCustomMessageSection(data.customMessage)}
|
|
|
|
<!-- Description (supports rich text HTML including tables) -->
|
|
<div style="margin-bottom: 30px;">
|
|
<h3 style="margin: 0 0 15px; color: #333333; font-size: 16px; font-weight: 600;">Description:</h3>
|
|
<div style="padding: 15px; background-color: #f8f9fa; border-left: 4px solid #667eea; border-radius: 4px; overflow-x: auto;">
|
|
${wrapRichText(data.requestDescription)}
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Priority Section (dynamic) -->
|
|
${getPrioritySection(data.priority)}
|
|
|
|
${data.showActionButtons ? `
|
|
<!-- QUICK ACTIONS -->
|
|
<div style="margin-bottom: 40px; padding: 25px; border: 2px dashed #dee2e6; border-radius: 8px; background-color: #ffffff;">
|
|
<h3 style="margin: 0 0 15px; color: #333333; font-size: 18px; font-weight: 700; text-align: center; text-transform: uppercase; letter-spacing: 1px;">Quick Actions</h3>
|
|
<p style="margin: 0 0 20px; color: #666666; font-size: 14px; text-align: center;">
|
|
You can approve or reject this request directly from your email by clicking one of the buttons below.
|
|
</p>
|
|
${getEmailActionButtons(data.requestId, data.requestId)}
|
|
</div>
|
|
` : ''}
|
|
|
|
<!-- View Details Button -->
|
|
<table role="presentation" style="width: 100%; border-collapse: collapse; margin-bottom: 20px;" cellpadding="0" cellspacing="0">
|
|
<tr>
|
|
<td style="text-align: center;">
|
|
<a href="${data.viewDetailsLink}" class="cta-button" style="display: inline-block; padding: 15px 40px; background-color: #1a1a1a; color: #ffffff; text-decoration: none; text-align: center; border-radius: 6px; font-size: 16px; font-weight: 600; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); min-width: 200px;">
|
|
View Request Details
|
|
</a>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
|
|
<p style="margin: 0; color: #666666; font-size: 14px; line-height: 1.6; text-align: center;">
|
|
Click the button above to review and take action on this request.
|
|
</p>
|
|
</td>
|
|
</tr>
|
|
|
|
${getEmailFooter(data.companyName)}
|
|
</table>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</body>
|
|
</html>
|
|
`;
|
|
}
|
|
|