mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
Refactor 'sendTransactionLinkRedeemedEmail' email to HTML and translatable
This commit is contained in:
parent
4b097f6f66
commit
224613f6d4
@ -7,7 +7,7 @@ html(lang=locale)
|
|||||||
#container.col
|
#container.col
|
||||||
p(style='margin-bottom: 24px;')= t('emails.general.helloName', { firstName, lastName })
|
p(style='margin-bottom: 24px;')= t('emails.general.helloName', { firstName, lastName })
|
||||||
p= t('emails.contributionConfirmed.commonGoodContributionConfirmed', { senderFirstName, senderLastName, contributionMemo })
|
p= t('emails.contributionConfirmed.commonGoodContributionConfirmed', { senderFirstName, senderLastName, contributionMemo })
|
||||||
p= t('emails.contributionConfirmed.contributionAmount', { contributionAmount })
|
p= t('emails.general.amountGDD', { amountGDD: contributionAmount })
|
||||||
p= t('emails.general.linkToYourAccount')
|
p= t('emails.general.linkToYourAccount')
|
||||||
span= " "
|
span= " "
|
||||||
a(href=overviewURL) #{overviewURL}
|
a(href=overviewURL) #{overviewURL}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import i18n from 'i18n'
|
|
||||||
import Decimal from 'decimal.js-light'
|
import Decimal from 'decimal.js-light'
|
||||||
import CONFIG from '@/config'
|
import CONFIG from '@/config'
|
||||||
|
import { decimalSeparatorByLanguage } from '@/util/utilities'
|
||||||
import { sendEmailTranslated } from './sendEmailTranslated'
|
import { sendEmailTranslated } from './sendEmailTranslated'
|
||||||
|
|
||||||
export const sendAddedContributionMessageEmail = (data: {
|
export const sendAddedContributionMessageEmail = (data: {
|
||||||
@ -79,12 +79,6 @@ export const sendContributionConfirmedEmail = (data: {
|
|||||||
contributionMemo: string
|
contributionMemo: string
|
||||||
contributionAmount: Decimal
|
contributionAmount: Decimal
|
||||||
}): Promise<Record<string, unknown> | null> => {
|
}): Promise<Record<string, unknown> | null> => {
|
||||||
const rememberLocaleToRestore = i18n.getLocale()
|
|
||||||
i18n.setLocale(data.language)
|
|
||||||
const contributionAmount = data.contributionAmount
|
|
||||||
.toFixed(2)
|
|
||||||
.replace('.', i18n.__('emails.general.decimalSeparator'))
|
|
||||||
i18n.setLocale(rememberLocaleToRestore)
|
|
||||||
return sendEmailTranslated({
|
return sendEmailTranslated({
|
||||||
receiver: { to: `${data.firstName} ${data.lastName} <${data.email}>` },
|
receiver: { to: `${data.firstName} ${data.lastName} <${data.email}>` },
|
||||||
template: 'contributionConfirmed',
|
template: 'contributionConfirmed',
|
||||||
@ -95,7 +89,7 @@ export const sendContributionConfirmedEmail = (data: {
|
|||||||
senderFirstName: data.senderFirstName,
|
senderFirstName: data.senderFirstName,
|
||||||
senderLastName: data.senderLastName,
|
senderLastName: data.senderLastName,
|
||||||
contributionMemo: data.contributionMemo,
|
contributionMemo: data.contributionMemo,
|
||||||
contributionAmount,
|
contributionAmount: decimalSeparatorByLanguage(data.contributionAmount, data.language),
|
||||||
overviewURL: CONFIG.EMAIL_LINK_OVERVIEW,
|
overviewURL: CONFIG.EMAIL_LINK_OVERVIEW,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@ -146,3 +140,31 @@ export const sendResetPasswordEmail = (data: {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const sendTransactionLinkRedeemedEmail = (data: {
|
||||||
|
firstName: string
|
||||||
|
lastName: string
|
||||||
|
email: string
|
||||||
|
language: string
|
||||||
|
senderFirstName: string
|
||||||
|
senderLastName: string
|
||||||
|
senderEmail: string
|
||||||
|
transactionMemo: string
|
||||||
|
transactionAmount: Decimal
|
||||||
|
}): Promise<Record<string, unknown> | null> => {
|
||||||
|
return sendEmailTranslated({
|
||||||
|
receiver: { to: `${data.firstName} ${data.lastName} <${data.email}>` },
|
||||||
|
template: 'transactionLinkRedeemed',
|
||||||
|
locals: {
|
||||||
|
firstName: data.firstName,
|
||||||
|
lastName: data.lastName,
|
||||||
|
locale: data.language,
|
||||||
|
senderFirstName: data.senderFirstName,
|
||||||
|
senderLastName: data.senderLastName,
|
||||||
|
senderEmail: data.senderEmail,
|
||||||
|
transactionMemo: data.transactionMemo,
|
||||||
|
transactionAmount: decimalSeparatorByLanguage(data.transactionAmount, data.language),
|
||||||
|
overviewURL: CONFIG.EMAIL_LINK_OVERVIEW,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
19
backend/src/emails/transactionLinkRedeemed/html.pug
Normal file
19
backend/src/emails/transactionLinkRedeemed/html.pug
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
doctype html
|
||||||
|
html(lang=locale)
|
||||||
|
head
|
||||||
|
title= t('emails.transactionLinkRedeemed.subject')
|
||||||
|
body
|
||||||
|
h1(style='margin-bottom: 24px;')= t('emails.transactionLinkRedeemed.subject')
|
||||||
|
#container.col
|
||||||
|
p(style='margin-bottom: 24px;')= t('emails.general.helloName', { firstName, lastName })
|
||||||
|
p= t('emails.transactionLinkRedeemed.hasRedeemedYourLink', { senderFirstName, senderLastName, senderEmail })
|
||||||
|
p= t('emails.general.amountGDD', { amountGDD: transactionAmount })
|
||||||
|
br
|
||||||
|
span= t('emails.transactionLinkRedeemed.memo', { transactionMemo })
|
||||||
|
p= t('emails.transactionLinkRedeemed.detailsYouFindOnLinkToYourAccount')
|
||||||
|
span= " "
|
||||||
|
a(href=overviewURL) #{overviewURL}
|
||||||
|
p= t('emails.general.pleaseDoNotReply')
|
||||||
|
p(style='margin-top: 24px;')= t('emails.general.sincerelyYours')
|
||||||
|
br
|
||||||
|
span= t('emails.general.yourGradidoTeam')
|
||||||
1
backend/src/emails/transactionLinkRedeemed/subject.pug
Normal file
1
backend/src/emails/transactionLinkRedeemed/subject.pug
Normal file
@ -0,0 +1 @@
|
|||||||
|
= t('emails.transactionLinkRedeemed.subject')
|
||||||
@ -36,7 +36,7 @@ import Decimal from 'decimal.js-light'
|
|||||||
import { BalanceResolver } from './BalanceResolver'
|
import { BalanceResolver } from './BalanceResolver'
|
||||||
import { MEMO_MAX_CHARS, MEMO_MIN_CHARS } from './const/const'
|
import { MEMO_MAX_CHARS, MEMO_MIN_CHARS } from './const/const'
|
||||||
import { findUserByEmail } from './UserResolver'
|
import { findUserByEmail } from './UserResolver'
|
||||||
import { sendTransactionLinkRedeemedEmail } from '@/mailer/sendTransactionLinkRedeemed'
|
import { sendTransactionLinkRedeemedEmail } from '@/emails/sendEmailVariants'
|
||||||
import { Event, EventTransactionReceive, EventTransactionSend } from '@/event/Event'
|
import { Event, EventTransactionReceive, EventTransactionSend } from '@/event/Event'
|
||||||
import { eventProtocol } from '@/event/EventProtocolEmitter'
|
import { eventProtocol } from '@/event/EventProtocolEmitter'
|
||||||
import { Decay } from '../model/Decay'
|
import { Decay } from '../model/Decay'
|
||||||
@ -182,15 +182,15 @@ export const executeTransaction = async (
|
|||||||
})
|
})
|
||||||
if (transactionLink) {
|
if (transactionLink) {
|
||||||
await sendTransactionLinkRedeemedEmail({
|
await sendTransactionLinkRedeemedEmail({
|
||||||
|
firstName: sender.firstName,
|
||||||
|
lastName: sender.lastName,
|
||||||
|
email: sender.emailContact.email,
|
||||||
|
language: sender.language,
|
||||||
senderFirstName: recipient.firstName,
|
senderFirstName: recipient.firstName,
|
||||||
senderLastName: recipient.lastName,
|
senderLastName: recipient.lastName,
|
||||||
recipientFirstName: sender.firstName,
|
|
||||||
recipientLastName: sender.lastName,
|
|
||||||
email: sender.emailContact.email,
|
|
||||||
senderEmail: recipient.emailContact.email,
|
senderEmail: recipient.emailContact.email,
|
||||||
amount,
|
transactionAmount: amount,
|
||||||
memo,
|
transactionMemo: memo,
|
||||||
overviewURL: CONFIG.EMAIL_LINK_OVERVIEW,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
logger.info(`finished executeTransaction successfully`)
|
logger.info(`finished executeTransaction successfully`)
|
||||||
|
|||||||
@ -21,7 +21,6 @@
|
|||||||
},
|
},
|
||||||
"contributionConfirmed": {
|
"contributionConfirmed": {
|
||||||
"commonGoodContributionConfirmed": "dein Gemeinwohl-Beitrag „{contributionMemo}“ wurde soeben von {senderFirstName} {senderLastName} bestätigt und in deinem Gradido-Konto gutgeschrieben.",
|
"commonGoodContributionConfirmed": "dein Gemeinwohl-Beitrag „{contributionMemo}“ wurde soeben von {senderFirstName} {senderLastName} bestätigt und in deinem Gradido-Konto gutgeschrieben.",
|
||||||
"contributionAmount": "Betrag: {contributionAmount} GDD",
|
|
||||||
"subject": "Gradido: Dein Gemeinwohl-Beitrag wurde bestätigt"
|
"subject": "Gradido: Dein Gemeinwohl-Beitrag wurde bestätigt"
|
||||||
},
|
},
|
||||||
"contributionRejected": {
|
"contributionRejected": {
|
||||||
@ -29,20 +28,29 @@
|
|||||||
"subject": "Gradido: Dein Gemeinwohl-Beitrag wurde abgelehnt",
|
"subject": "Gradido: Dein Gemeinwohl-Beitrag wurde abgelehnt",
|
||||||
"toSeeContributionsAndMessages": "Um deine Gemeinwohl-Beiträge und dazugehörige Nachrichten zu sehen, gehe in deinem Gradido-Konto ins Menü „Gemeinschaft“ auf den Tab „Meine Beiträge zum Gemeinwohl“!"
|
"toSeeContributionsAndMessages": "Um deine Gemeinwohl-Beiträge und dazugehörige Nachrichten zu sehen, gehe in deinem Gradido-Konto ins Menü „Gemeinschaft“ auf den Tab „Meine Beiträge zum Gemeinwohl“!"
|
||||||
},
|
},
|
||||||
"resetPassword": {
|
|
||||||
"duration": "Der Link hat eine Gültigkeit von {hours} Stunden und {minutes} Minuten. Sollte die Gültigkeit des Links bereits abgelaufen sein, kannst du dir hier einen neuen Link schicken lassen, in dem du deine E-Mail-Adresse eingibst:",
|
|
||||||
"pleaseClickLink": "Wenn du es warst, klicke bitte auf den Link:",
|
|
||||||
"subject": "Gradido: Passwort zurücksetzen",
|
|
||||||
"youOrSomeoneResetPassword": "du, oder jemand anderes, hast für dieses Konto ein Zurücksetzen des Passworts angefordert."
|
|
||||||
},
|
|
||||||
"general": {
|
"general": {
|
||||||
"decimalSeparator": ",",
|
"amountGDD": "Betrag: {amountGDD} GDD",
|
||||||
"helloName": "Hallo {firstName} {lastName},",
|
"helloName": "Hallo {firstName} {lastName},",
|
||||||
"linkToYourAccount": "Link zu deinem Konto:",
|
"linkToYourAccount": "Link zu deinem Konto:",
|
||||||
"orCopyLink": "oder kopiere den obigen Link in dein Browserfenster.",
|
"orCopyLink": "oder kopiere den obigen Link in dein Browserfenster.",
|
||||||
"pleaseDoNotReply": "Bitte antworte nicht auf diese E-Mail!",
|
"pleaseDoNotReply": "Bitte antworte nicht auf diese E-Mail!",
|
||||||
"sincerelyYours": "Liebe Grüße",
|
"sincerelyYours": "Liebe Grüße",
|
||||||
"yourGradidoTeam": "dein Gradido-Team"
|
"yourGradidoTeam": "dein Gradido-Team"
|
||||||
|
},
|
||||||
|
"resetPassword": {
|
||||||
|
"duration": "Der Link hat eine Gültigkeit von {hours} Stunden und {minutes} Minuten. Sollte die Gültigkeit des Links bereits abgelaufen sein, kannst du dir hier einen neuen Link schicken lassen, in dem du deine E-Mail-Adresse eingibst:",
|
||||||
|
"pleaseClickLink": "Wenn du es warst, klicke bitte auf den Link:",
|
||||||
|
"subject": "Gradido: Passwort zurücksetzen",
|
||||||
|
"youOrSomeoneResetPassword": "du, oder jemand anderes, hast für dieses Konto ein Zurücksetzen des Passworts angefordert."
|
||||||
|
},
|
||||||
|
"transactionLinkRedeemed": {
|
||||||
|
"detailsYouFindOnLinkToYourAccount": "Details zur Transaktion findest du in deinem Gradido-Konto:",
|
||||||
|
"hasRedeemedYourLink": "{senderFirstName} {senderLastName} ({senderEmail}) hat soeben deinen Link eingelöst.",
|
||||||
|
"memo": "Memo: {transactionMemo}",
|
||||||
|
"subject": "Gradido: Dein Gradido-Link wurde eingelöst"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"general": {
|
||||||
|
"decimalSeparator": ","
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -21,7 +21,6 @@
|
|||||||
},
|
},
|
||||||
"contributionConfirmed": {
|
"contributionConfirmed": {
|
||||||
"commonGoodContributionConfirmed": "Your public good contribution “{contributionMemo}” has just been confirmed by {senderFirstName} {senderLastName} and credited to your Gradido account.",
|
"commonGoodContributionConfirmed": "Your public good contribution “{contributionMemo}” has just been confirmed by {senderFirstName} {senderLastName} and credited to your Gradido account.",
|
||||||
"contributionAmount": "Amount: {contributionAmount} GDD",
|
|
||||||
"subject": "Gradido: Your common good contribution was confirmed"
|
"subject": "Gradido: Your common good contribution was confirmed"
|
||||||
},
|
},
|
||||||
"contributionRejected": {
|
"contributionRejected": {
|
||||||
@ -29,20 +28,29 @@
|
|||||||
"subject": "Gradido: Your common good contribution was rejected",
|
"subject": "Gradido: Your common good contribution was rejected",
|
||||||
"toSeeContributionsAndMessages": "To see your common good contributions and related messages, go to the “Community” menu in your Gradido account and click on the “My contributions to the common good” tab!"
|
"toSeeContributionsAndMessages": "To see your common good contributions and related messages, go to the “Community” menu in your Gradido account and click on the “My contributions to the common good” tab!"
|
||||||
},
|
},
|
||||||
"resetPassword": {
|
|
||||||
"duration": "The link has a validity of {hours} hours and {minutes} minutes. If the validity of the link has already expired, you can have a new link sent to you here by entering your email address:",
|
|
||||||
"pleaseClickLink": "If it was you, please click on the link:",
|
|
||||||
"subject": "Gradido: Reset password",
|
|
||||||
"youOrSomeoneResetPassword": "You, or someone else, requested a password reset for this account."
|
|
||||||
},
|
|
||||||
"general": {
|
"general": {
|
||||||
"decimalSeparator": ".",
|
"amountGDD": "Amount: {amountGDD} GDD",
|
||||||
"helloName": "Hello {firstName} {lastName}",
|
"helloName": "Hello {firstName} {lastName}",
|
||||||
"linkToYourAccount": "Link to your account:",
|
"linkToYourAccount": "Link to your account:",
|
||||||
"orCopyLink": "or copy the link above into your browser window.",
|
"orCopyLink": "or copy the link above into your browser window.",
|
||||||
"pleaseDoNotReply": "Please do not reply to this email!",
|
"pleaseDoNotReply": "Please do not reply to this email!",
|
||||||
"sincerelyYours": "Kind regards,",
|
"sincerelyYours": "Kind regards,",
|
||||||
"yourGradidoTeam": "your Gradido team"
|
"yourGradidoTeam": "your Gradido team"
|
||||||
|
},
|
||||||
|
"resetPassword": {
|
||||||
|
"duration": "The link has a validity of {hours} hours and {minutes} minutes. If the validity of the link has already expired, you can have a new link sent to you here by entering your email address:",
|
||||||
|
"pleaseClickLink": "If it was you, please click on the link:",
|
||||||
|
"subject": "Gradido: Reset password",
|
||||||
|
"youOrSomeoneResetPassword": "You, or someone else, requested a password reset for this account."
|
||||||
|
},
|
||||||
|
"transactionLinkRedeemed": {
|
||||||
|
"detailsYouFindOnLinkToYourAccount": "You can find transaction details in your Gradido account:",
|
||||||
|
"hasRedeemedYourLink": "{senderFirstName} {senderLastName} ({senderEmail}) has just redeemed your link.",
|
||||||
|
"memo": "Memo: {transactionMemo}",
|
||||||
|
"subject": "Gradido: Your Gradido link has been redeemed"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"general": {
|
||||||
|
"decimalSeparator": "."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,4 +1,5 @@
|
|||||||
import Decimal from 'decimal.js-light'
|
import Decimal from 'decimal.js-light'
|
||||||
|
import i18n from 'i18n'
|
||||||
|
|
||||||
export const objectValuesToArray = (obj: { [x: string]: string }): Array<string> => {
|
export const objectValuesToArray = (obj: { [x: string]: string }): Array<string> => {
|
||||||
return Object.keys(obj).map(function (key) {
|
return Object.keys(obj).map(function (key) {
|
||||||
@ -15,3 +16,11 @@ export const decimalAddition = (a: Decimal, b: Decimal): Decimal => {
|
|||||||
export const decimalSubtraction = (a: Decimal, b: Decimal): Decimal => {
|
export const decimalSubtraction = (a: Decimal, b: Decimal): Decimal => {
|
||||||
return a.minus(b.toString())
|
return a.minus(b.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const decimalSeparatorByLanguage = (a: Decimal, language: string): string => {
|
||||||
|
const rememberLocaleToRestore = i18n.getLocale()
|
||||||
|
i18n.setLocale(language)
|
||||||
|
const result = a.toFixed(2).replace('.', i18n.__('general.decimalSeparator'))
|
||||||
|
i18n.setLocale(rememberLocaleToRestore)
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user