Repository navigation
Expand file tree
/
Copy pathcreateVolunteerApplicationEmailTemplate.ts
More file actions
111 lines (100 loc) · 4.85 KB
/
Copy pathcreateVolunteerApplicationEmailTemplate.ts
File metadata and controls
111 lines (100 loc) · 4.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
import { escapeHtml, sanitizeHref } from "./escapeHtml";
type VolunteerApplicationDetails = {
name: string;
email: string;
link?: string;
location: string;
areaLabel: string;
workOn: string;
experience?: string;
whyCodu: string;
commitmentLabel: string;
other?: string;
submittedAt: string;
};
const section = (title: string, body: string) => `
<h2 style="color: #171717; font-size: 16px; margin: 24px 0 12px 0; padding-bottom: 8px; border-bottom: 2px solid #e5e5e5;">${escapeHtml(title)}</h2>
<div style="margin-bottom: 16px; padding: 16px; background: #fafafa; border-radius: 8px; border-left: 4px solid #db2777;">
<p style="margin: 0; color: #404040; white-space: pre-wrap; line-height: 1.6;">${escapeHtml(body)}</p>
</div>
`;
export const createVolunteerApplicationEmailTemplate = (
details: VolunteerApplicationDetails,
) => {
const name = escapeHtml(details.name);
const email = escapeHtml(details.email);
const emailHref = sanitizeHref(`mailto:${details.email}`);
const location = escapeHtml(details.location);
const areaLabel = escapeHtml(details.areaLabel);
const commitmentLabel = escapeHtml(details.commitmentLabel);
const submittedAt = escapeHtml(details.submittedAt);
const linkHref = sanitizeHref(details.link);
const linkText = escapeHtml(details.link);
const replyHref = sanitizeHref(
`mailto:${details.email}?subject=Re: Codú Volunteer Application`,
);
return `
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body style="margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; background-color: #f5f5f5;">
<div style="max-width: 600px; margin: 0 auto; padding: 20px;">
<div style="background: linear-gradient(to right, #fb923c, #db2777); padding: 30px; border-radius: 12px 12px 0 0;">
<h1 style="color: white; margin: 0; font-size: 24px;">New Volunteer Application</h1>
<p style="color: rgba(255,255,255,0.9); margin: 10px 0 0 0;">Someone wants to help run Codú!</p>
</div>
<div style="background: white; padding: 30px; border-radius: 0 0 12px 12px; box-shadow: 0 4px 6px rgba(0,0,0,0.1);">
<h2 style="color: #171717; font-size: 16px; margin: 0 0 16px 0; padding-bottom: 8px; border-bottom: 2px solid #e5e5e5;">Contact</h2>
<table style="width: 100%; border-collapse: collapse; margin-bottom: 16px;">
<tr>
<td style="padding: 8px 0; color: #525252; width: 120px;">Name</td>
<td style="padding: 8px 0; font-weight: 600;">${name}</td>
</tr>
<tr>
<td style="padding: 8px 0; color: #525252;">Email</td>
<td style="padding: 8px 0;"><a href="${emailHref}" style="color: #db2777; text-decoration: none; font-weight: 600;">${email}</a></td>
</tr>
<tr>
<td style="padding: 8px 0; color: #525252;">Location</td>
<td style="padding: 8px 0;">${location}</td>
</tr>
${
linkHref
? `
<tr>
<td style="padding: 8px 0; color: #525252;">Link</td>
<td style="padding: 8px 0;"><a href="${linkHref}" style="color: #db2777; text-decoration: none;">${linkText}</a></td>
</tr>
`
: ""
}
</table>
<h2 style="color: #171717; font-size: 16px; margin: 24px 0 12px 0; padding-bottom: 8px; border-bottom: 2px solid #e5e5e5;">Area of interest</h2>
<p style="margin: 0 0 8px 0;">
<span style="display: inline-block; background: linear-gradient(to right, #fb923c, #db2777); color: white; padding: 6px 14px; border-radius: 9999px; font-size: 13px;">${areaLabel}</span>
</p>
<h2 style="color: #171717; font-size: 16px; margin: 24px 0 12px 0; padding-bottom: 8px; border-bottom: 2px solid #e5e5e5;">Time commitment</h2>
<p style="margin: 0 0 8px 0; font-size: 18px; font-weight: 600; color: #171717;">${commitmentLabel}</p>
${section("What they want to work on", details.workOn)}
${details.experience ? section("Relevant experience", details.experience) : ""}
${section("Why Codú", details.whyCodu)}
${details.other ? section("Anything else", details.other) : ""}
<p style="color: #a3a3a3; font-size: 12px; margin: 24px 0 0 0;">Submitted: ${submittedAt}</p>
<div style="margin-top: 24px; padding-top: 20px; border-top: 1px solid #e5e5e5; text-align: center;">
<a href="${replyHref}"
style="display: inline-block; background: linear-gradient(to right, #fb923c, #db2777); color: white; padding: 14px 28px; border-radius: 8px; text-decoration: none; font-weight: 600;">
Reply to ${name}
</a>
</div>
</div>
<p style="text-align: center; color: #a3a3a3; font-size: 12px; margin-top: 20px;">
Submitted via codu.co/volunteer
</p>
</div>
</body>
</html>
`;
};