-
Notifications
You must be signed in to change notification settings - Fork 1
/
email_content.js
108 lines (106 loc) · 4.34 KB
/
email_content.js
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
let emailContentFormatter = async(centerFilteredData) => {
await console.log(centerFilteredData.length);
await console.log(centerFilteredData[0].sessions.length);
let rows = ``;
for (i = 0; i < centerFilteredData.length; i++) {
let subrows = ``;
for (j = 0; j < centerFilteredData[i].sessions.length; j++) {
let textColor = "green";
if (centerFilteredData[i].sessions[j].available_capacity <= 10)
textColor = "#afa31a";
let subrow = `
<tr>
<td>` + (j+1) + `</td>
<td>` + centerFilteredData[i].sessions[j].date + `</td>
<td>` + centerFilteredData[i].sessions[j].min_age_limit + `</td>
<td style="color:` + textColor +`">` + centerFilteredData[i].sessions[j].available_capacity + `</td>
<td>` + centerFilteredData[i].sessions[j].vaccine + `</td>
</tr>
`;
subrows = subrows + subrow;
}
let row = `
<tr>
<td>` + (i + 1) + `</td>
<td>` + centerFilteredData[i].name + `</td>
<td>` + centerFilteredData[i].address + `</td>
<td>` + centerFilteredData[i].district_name + `</td>
<td>` + centerFilteredData[i].pincode + `</td>
<td>
<table style="width:100%">
<thead>
<tr>
<th>#</th>
<th>Date</th>
<th>Min Age</th>
<th>Available</th>
<th>Vaccine</th>
</tr>
</thead>
<tbody>` + subrows + `</tbody>
</table>
</td>
</tr>
`;
rows = rows + row;
};
let html = `
<!DOCTYPE HTML>
<html>
<head xmlns="http://www.w3.org/1999/xhtml" lang="en-GB">
<title>Vaccination Notifier</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<style>
#records {
font-family: Verdana, Helvetica, sans-serif;
border-collapse: collapse;
width: 100%;
}
#records td, #records th {
border: 1px solid #ddd;
padding: 1px;
}
#records tr:nth-child(even){
background-color: #f2f2f2;
}
#records tr:hover {background-color: #ddd;}
#records th {
padding-top: 5px;
padding-bottom: 5px;
text-align: center;
background-color: #343a40;
color: white;
}
.additionalStyles{
font-family: Verdana, Helvetica, sans-serif;
}
</style>
</head>
<body class="text-center" data-new-gr-c-s-check-loaded="14.1008.0" data-gr-ext-installed="">
<h2>Vaccine availability details for your preferred location:</h2>
Get vaccinated today!
<p></p>
<i><sub>Not you? Update preferences? Visit http://findvacc.in to update/unsubscribe.</sub></i>
<p></p>
<div class="table-responsive-lg">
<table id="records" align="center">
<thead class="thead-dark">
<tr>
<th style="width:3%">#</th>
<th style="width:14%">Center Name</th>
<th style="width:18%">Address</th>
<th style="width:8%">District</th>
<th style="width:10%">Pincode</th>
<th style="width:67%">Sessions</th>
</tr>
</thead>
<tbody>` + rows + `</tbody>
</table>
</div>
</body>
</html>
`;
return {html: html, numRecords: centerFilteredData.length};
};
module.exports = { emailContentFormatter };