Skip to content

Commit

Permalink
✨ Add resend props for transaction template
Browse files Browse the repository at this point in the history
  • Loading branch information
shellyYG committed Mar 22, 2021
1 parent ce24e78 commit 312f210
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 15 deletions.
3 changes: 2 additions & 1 deletion src/i18n/translations/cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,6 @@

"transaction.subject": "你已收到 {amount} LikeCoin",
"transaction.subtitle": "你已收到 {amount} LikeCoin",
"transaction.content": "{name} 你好, <br></br><br></br> 你已收到 {fromUser} 發送的 {amount} LikeCoin。 <br></br> 查阅交易详情:"
"transaction.content": "{name} 你好, <br></br><br></br> 你已收到 {fromUser} 發送的 {amount} LikeCoin。 <br></br> 查阅交易详情:",
"resend": "重发"
}
3 changes: 2 additions & 1 deletion src/i18n/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,6 @@

"transaction.subject": "You have received {amount} LikeCoin",
"transaction.subtitle": "You have received {amount} LikeCoin",
"transaction.content": "Hi {name}, <br></br><br></br> You have received {amount} LikeCoin from {fromUser}. <br></br> Check the transaction details: "
"transaction.content": "Hi {name}, <br></br><br></br> You have received {amount} LikeCoin from {fromUser}. <br></br> Check the transaction details: ",
"resend": "Resend"
}
3 changes: 2 additions & 1 deletion src/i18n/translations/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,6 @@

"transaction.subject": "您已收到 {amount} LikeCoin",
"transaction.subtitle": "您已收到 {amount} LikeCoin",
"transaction.content": "{name} 您好, <br></br><br></br> 您已收到 {fromUser} 發送的 {amount} LikeCoin。 <br></br> 查閱交易詳情: "
"transaction.content": "{name} 您好, <br></br><br></br> 您已收到 {fromUser} 發送的 {amount} LikeCoin。 <br></br> 查閱交易詳情: ",
"resend": "重發"
}
12 changes: 7 additions & 5 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ import { Mjml2HtmlOptions, render } from 'mjml-react';

import { initIntl } from './i18n';

import {
getLocalizedMonthlyReportSubject,
getLocalizedTransactionSubject,
} from './utils/localization';
import { getLocalizedMonthlyReportSubject } from './utils/localization';

import { BasicTemplate, BasicTemplateProps } from './templates/basic';
import {
Expand Down Expand Up @@ -80,7 +77,12 @@ export const getTransactionTemplate = (
options?: Mjml2HtmlOptions
) => {
const intl = initIntl();
const subject = getLocalizedTransactionSubject(intl, props.amount);
let subject = intl.formatMessage(
{ id: 'transaction.subject' },
{ amount: props.amount }
);
const { isResend } = props;
if (isResend) subject = intl.formatMessage({ id: 'resend' }).concat(subject);
const { html: body } = render(
<TransactionTemplate {...{ ...props, subject }} />,
options
Expand Down
1 change: 1 addition & 0 deletions src/templates/transaction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export interface TransactionTemplateProps {
fromDisplayName?: string;
viewTxURL?: string;
amount: string;
isResend?: boolean;
}

export const TransactionTemplate = ({
Expand Down
7 changes: 0 additions & 7 deletions src/utils/localization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,3 @@ export function getLocalizedMonthlyReportSubject(
}
);
}

export function getLocalizedTransactionSubject(
intl: IntlShape,
amount: string
) {
return intl.formatMessage({ id: 'transaction.subject' }, { amount: amount });
}

0 comments on commit 312f210

Please sign in to comment.