Skip to content

Commit

Permalink
DIG-27962 viser korrekt valuta for kontoer med andre valutaer enn NOK
Browse files Browse the repository at this point in the history
  • Loading branch information
Eivind Wikheim committed Oct 25, 2017
1 parent 99a6471 commit ed7f411
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 8 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Changelog
# v.7.10.0
* Show correct currency for accounts with currencyCodes other than NOK.

# v7.9.2
* Fixed issue where iOS9 units may not receive click event
Expand Down
1 change: 1 addition & 0 deletions examples/account-selector.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class AccountSelectorExample extends Component {
locale='nb'
id='account-selector'
suggestionsHeightMax={500}
showBalance={true}
/>
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ffe-account-selector-react",
"version": "7.9.2",
"version": "7.10.0",
"main": "lib/index.js",
"scripts": {
"build": "babel -d lib/. --ignore=*.test.js src/.",
Expand Down
4 changes: 2 additions & 2 deletions src/account/account-details.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {accountFormatter, balanceWithCurrency} from '../util/format';
import {Account, Locale} from '../util/types';

function AccountDetails({account, locale, showBalance = true}) {
const {balance, accountNumber} = account;
const {balance, accountNumber, currencyCode} = account;
const hasBalance = balance != null;
return (
<div className='ffe-account-selector__details'>
Expand All @@ -13,7 +13,7 @@ function AccountDetails({account, locale, showBalance = true}) {
</div>
{showBalance && hasBalance &&
<div className='ffe-account-selector__details--right'>
{ balanceWithCurrency(balance, locale) }
{ balanceWithCurrency(balance, locale, currencyCode) }
</div>
}
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/account/account-suggestion-multi.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {accountFormatter, balanceWithCurrency} from '../util/format';
import {Account, Locale} from '../util/types';

function AccountSuggestionMulti({account, locale, selected}) {
const {accountNumber, balance, name}= account;
const {accountNumber, balance, name, currencyCode} = account;
const hasBalance = balance !== null;
return (
<div className='ffe-account-suggestion__account--multi'>
Expand All @@ -24,7 +24,7 @@ function AccountSuggestionMulti({account, locale, selected}) {
</span>
{hasBalance &&
<span className='ffe-account-suggestion__balance'>
{balanceWithCurrency(balance, locale)}
{balanceWithCurrency(balance, locale, currencyCode)}
</span>
}
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/account/account-suggestion.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {accountFormatter, balanceWithCurrency} from '../util/format';
import {Account, Locale} from '../util/types';

const AccountSuggestionItem = ({account, locale, showBalance = true}) => {
const {accountNumber, balance, name}= account;
const {accountNumber, balance, name, currencyCode }= account;
const hasBalance = balance !== null;
return (
<div className='ffe-account-suggestion__account'>
Expand All @@ -15,7 +15,7 @@ const AccountSuggestionItem = ({account, locale, showBalance = true}) => {
</span>
{showBalance && hasBalance &&
<span className='ffe-account-suggestion__balance'>
{ balanceWithCurrency(balance, locale)}
{ balanceWithCurrency(balance, locale, currencyCode)}
</span>
}
</div>
Expand Down
6 changes: 5 additions & 1 deletion src/util/format.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ export function accountFormatter(accountNumber) {
return accountNumber;
}

export function balanceWithCurrency(balance = '', locale) {
export function balanceWithCurrency(balance = '', locale, currencyCode) {
if (currencyCode && currencyCode !== "NOK") {
return `${amountFormatter(balance, locale)} ${currencyCode}`;
}

return `${amountFormatter(balance, locale)} ${currencyPostfix[locale]}`;
}

0 comments on commit ed7f411

Please sign in to comment.