|
@@ -1,16 +1,25 @@
|
|
|
function _getIndefiniteArticle(providerName) {
|
|
function _getIndefiniteArticle(providerName) {
|
|
|
const vowels = ['a', 'e', 'i', 'o', 'u']
|
|
const vowels = ['a', 'e', 'i', 'o', 'u']
|
|
|
- if (vowels.includes(providerName.charAt(0).toLowerCase())) return 'an'
|
|
|
|
|
- return 'a'
|
|
|
|
|
|
|
+
|
|
|
|
|
+ return vowels.includes(providerName.charAt(0).toLowerCase()) ? 'an' : 'a'
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+function _actionBuilder(providerName, action, accountLinked) {
|
|
|
|
|
+ if (providerName.toLowerCase() !== 'google') {
|
|
|
|
|
+ return `${providerName} account ${action}`
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return accountLinked ? `New account ${action}` : `Account ${action}`
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function linkOrUnlink(accountLinked, providerName, email) {
|
|
function linkOrUnlink(accountLinked, providerName, email) {
|
|
|
const action = accountLinked ? 'linked' : 'no longer linked'
|
|
const action = accountLinked ? 'linked' : 'no longer linked'
|
|
|
const actionDescribed = accountLinked ? 'was linked to' : 'was unlinked from'
|
|
const actionDescribed = accountLinked ? 'was linked to' : 'was unlinked from'
|
|
|
const indefiniteArticle = _getIndefiniteArticle(providerName)
|
|
const indefiniteArticle = _getIndefiniteArticle(providerName)
|
|
|
|
|
+
|
|
|
return {
|
|
return {
|
|
|
to: email,
|
|
to: email,
|
|
|
- action: `${providerName} account ${action}`,
|
|
|
|
|
|
|
+ action: _actionBuilder(providerName, action, accountLinked),
|
|
|
actionDescribed: `${indefiniteArticle} ${providerName} account ${actionDescribed} your account ${email}`,
|
|
actionDescribed: `${indefiniteArticle} ${providerName} account ${actionDescribed} your account ${email}`,
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|