Skip to content

Commit

Permalink
review fix
Browse files Browse the repository at this point in the history
  • Loading branch information
vctt94 committed May 22, 2019
1 parent f849e1f commit aa77d42
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 16 deletions.
2 changes: 1 addition & 1 deletion app/components/TxHistory/TxHistoryRow/RegularTxRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const RegularTxRow = ({ txAmount, txDescription, txDirection, overview, txAccoun
</div>}
{!pending &&
<div className="transaction-time-date-spacer">
{timeMessage(txTs)}
{timeMessage(txTs, props.intl)}
</div>}
</div>
<div className="transaction-amount-hash">{(txDescription.addressStr || []).join(", ")}</div>
Expand Down
2 changes: 1 addition & 1 deletion app/components/TxHistory/TxHistoryRow/StakeTxRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const StakeTxRow = ({ status, ...props }) => {
<span className="transaction-stake-type-overview">{typeMsg}</span>
{!pending &&
<div className="transaction-time-date-spacer">
{timeMessage(txTs)}
{timeMessage(txTs, props.intl)}
</div>}
</div>
<div className="transaction-info-price-reward">
Expand Down
25 changes: 12 additions & 13 deletions app/components/TxHistory/TxHistoryRow/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { RegularTxRowOfClass as regular } from "./RegularTxRow";
import { StakeTxRowOfType as stake } from "./StakeTxRow";
import { FormattedDate, FormattedTime, FormattedMessage as T } from "react-intl";
import { defineMessages, injectIntl } from "react-intl";
import "style/TxHistory.less";

const TxRowByType = { // TODO: use constants instead of string
Expand All @@ -21,18 +21,16 @@ const TxRowByType = { // TODO: use constants instead of string
"Coinbase": regular("Receive", true),
};

export const timeMessage = (txTimestamp) => <T
id="txHistory.statusSmall.date"
defaultMessage="{day} {month} {year} {time}"
values={{
day: <FormattedDate value={txTimestamp} day="2-digit" />,
month: <FormattedDate value={txTimestamp} month="short" />,
year: <FormattedDate value={txTimestamp} year="numeric" />,
time: <FormattedTime value={txTimestamp} hour12={false} />,
}}
/>;
export const timeMessageDefine = defineMessages({
dayMonthHourDisplay: {
id: "txHistory.dayMonthHourDisplay",
defaultMessage: "{value, date, short-month-24hour}"
},
});

const TxRow = ({ tx, overview, tsDate }, { router }) => {
export const timeMessage = (txTimestamp, intl) => intl.formatMessage(timeMessageDefine.dayMonthHourDisplay, { value: txTimestamp });

const TxRow = ({ tx, overview, tsDate, intl }, { router }) => {
const rowType = tx.status ? tx.status :
tx.txType ? tx.txType : tx.txDirection;
const Component = TxRowByType[rowType];
Expand All @@ -41,6 +39,7 @@ const TxRow = ({ tx, overview, tsDate }, { router }) => {
<Component
{...{
...tx,
intl,
txTs: tsDate(tx.txTimestamp),
overview,
pending: !tx.txTimestamp,
Expand All @@ -54,4 +53,4 @@ TxRow.contextTypes = {
router: PropTypes.object.isRequired,
};

export default TxRow;
export default injectIntl(TxRow);
11 changes: 10 additions & 1 deletion app/i18n/locales/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,17 @@ export const defaultFormats = {
},
"short-month": {
month: "short"
},
"short-month-24hour": {
day: "2-digit",
month: "short",
year: "numeric",
hour: "numeric",
minute: "numeric",
hour12: false,
formatMatcher: "best fit"
}
}
},
};

const de = {
Expand Down

0 comments on commit aa77d42

Please sign in to comment.