Skip to content

Commit 5a2d40c

Browse files
committed
formatDate helper
1 parent 628fcde commit 5a2d40c

File tree

5 files changed

+13
-4
lines changed

5 files changed

+13
-4
lines changed

functions/src/email/handlebarsHelpers.ts

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export const registerHelpers = () => {
1010
handlebars.registerHelper("addCounts", helpers.addCounts)
1111
handlebars.registerHelper("ifGreaterThan", helpers.ifGreaterThan)
1212
handlebars.registerHelper("isDefined", helpers.isDefined)
13+
handlebars.registerHelper("formatDate", helpers.formatDate)
1314
handlebars.registerHelper("minusFour", helpers.minusFour)
1415
handlebars.registerHelper("noUpdatesFormat", helpers.noUpdatesFormat)
1516
handlebars.registerHelper("toLowerCase", helpers.toLowerCase)

functions/src/email/helpers.ts

+9
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,15 @@ export function isDefined(v: unknown) {
2222
return v !== undefined
2323
}
2424

25+
export function formatDate(timestamp: Date) {
26+
const date = new Date(timestamp)
27+
const month = String(date.getMonth() + 1).padStart(2, "0")
28+
const day = String(date.getDate()).padStart(2, "0")
29+
const year = date.getFullYear()
30+
31+
return `${month}/${day}/${year}`
32+
}
33+
2534
export function minusFour(value: number) {
2635
const result = value - 4
2736
return result

functions/src/email/partials/header.handlebars

+1-3
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,8 @@
1515
</h2>
1616
<p class="subheadline blue center" style="font-weight: 600; font-size: 12px; line-height: 125%;
1717
color: #1a3185; display: block; margin: auto; width: 30%">
18-
{{startDate}} - {{endDate}}
18+
{{formatDate startDate}} - {{formatDate endDate}}
1919
</p>
2020
</div>
2121
<img src="https://mapletestimony.org/email/images_no-svgs/Mail Report.png" alt="Report" style="display: block; margin: auto; width: 32%" />
22-
{{!-- On prod, replace with: --}}
23-
{{!-- <img src="https://mapletestimony.org/email/images_no-svgs/Mail Report.png" alt="Report" style="display: block; margin: auto; width: 32%;" /> --}}
2422
</header>

functions/src/email/partials/noUpdates.handlebars

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div class="noUpdatesIcon">
1+
<div style="padding-top: 12px; padding-bottom: 20px; display: block; margin: auto; width: 65%">
22
<img src="https://mapletestimony.org/email/images_no-svgs/empty-mail.png" alt="Empty Mail" />
33
</div>
44
<h5 style="font-weight: 600; font-size: 25px; line-height: 125%; margin-bottom: 0px;

scripts/firebase-admin/sendTestEmail.ts

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const EMAIL_TEMPLATE_PATH = "./functions/src/email/digestEmail.handlebars"
2222
handlebars.registerHelper("addCounts", helpers.addCounts)
2323
handlebars.registerHelper("ifGreaterThan", helpers.ifGreaterThan)
2424
handlebars.registerHelper("isDefined", helpers.isDefined)
25+
handlebars.registerHelper("formatDate", helpers.formatDate)
2526
handlebars.registerHelper("minusFour", helpers.minusFour)
2627
handlebars.registerHelper("noUpdatesFormat", helpers.noUpdatesFormat)
2728
handlebars.registerHelper("toLowerCase", helpers.toLowerCase)

0 commit comments

Comments
 (0)