Skip to content

Commit

Permalink
New PlaceHolder in common/placeholders freeCodeCamp#1
Browse files Browse the repository at this point in the history
  • Loading branch information
ronaldblanco committed Sep 21, 2017
1 parent 5d28ad7 commit 0cdbb07
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
19 changes: 17 additions & 2 deletions common/placeholders.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
const placeholderTypes = {
PAGE: 'page',
EMAIL: 'email',
ATTACHMENT: 'attachment'
ATTACHMENT: 'attachment',
TABLE: 'table'
}

const placeholders = [
Expand Down Expand Up @@ -32,7 +33,14 @@ const placeholders = [
label: 'Signature',
type: placeholderTypes.ATTACHMENT,
format: () => '<img src="cid:signature" alt="Signature" />'
}
},
{
id: 'donationReceipt',
label: 'Donation Receipt Information',
type: placeholderTypes.TABLE,
required: true,
format: value => `<table><tr><td><a href="${value}">Reset Password</a></td></tr></table>`
},
]

function getPagePlaceholders() {
Expand All @@ -47,6 +55,10 @@ function getAttachmentPlaceholders() {
return placeholders.filter(pl => pl.type === placeholderTypes.ATTACHMENT)
}

function getTablePlaceholders() {
return placeholders.filter(pl => pl.type === placeholderTypes.TABLE)
}

function getPlaceholders(types) {
let placeholders = getPagePlaceholders()

Expand All @@ -56,6 +68,9 @@ function getPlaceholders(types) {
if (types.find(type => type === placeholderTypes.ATTACHMENT))
placeholders = placeholders.concat(getAttachmentPlaceholders())

if (types.find(type => type === placeholderTypes.TABLE))
placeholders = placeholders.concat(getTablePlaceholders())

return placeholders
}

Expand Down
2 changes: 2 additions & 0 deletions server/lib/mail/donation-receipt.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import Donation from '../../models/donation'
import Donor from '../../models/donor'
6 changes: 4 additions & 2 deletions server/lib/seed/seed-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,16 @@ export const pages = [{
<p>
<span class="ql-placeholder-content" data-id="organization" data-label="Foodbank Name"></span> is committed to protecting your personal information by following responsible information handling practices and in keeping with privacy laws. All information remains strictly confidential as outlined by <span class="ql-placeholder-content" data-id="organization" data-label="Foodbank Name"></span>'s Privacy Policy that can be accessed at <span class="ql-placeholder-content" data-id="url" data-label="Foodbank Website"></span>.
</p>
<p>If you have any questions or concerns, feel free to contact us.</p>`
<p>If you have any questions or concerns, feel free to contact us.</p>
`
}, {
identifier: pageIdentifiers.DONATION_RECEIPT,
title: 'Donation Receipt',
type: pageTypes.EMAIL,
subject: '<p>Receipt for Your Donation to <span class="ql-placeholder-content" data-id="organization" data-label="Foodbank Name"></span></p>',
body: `<p>Dear <span class="ql-placeholder-content" data-id="fullName" data-label="User Full Name"></span>,</p>
`
<p>Here you have a list of the donations our organization recibed from you:</p>
<p><span class="ql-placeholder-content" data-id="donationReceipt" data-label="Donation Receipt information" data-required="true"></span></p>`
}]

const commonFields = [
Expand Down

0 comments on commit 0cdbb07

Please sign in to comment.