Skip to content

Commit

Permalink
Merge pull request #1066 from multiversx/mm-fix-data-testids
Browse files Browse the repository at this point in the history
Fixed code.
  • Loading branch information
Miro authored Mar 8, 2024
2 parents b6a6b76 + 3be40be commit 351e5eb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@multiversx/sdk-dapp",
"version": "2.28.8-alpha.3",
"version": "2.28.8-alpha.4",
"description": "A library to hold the main logic for a dapp on the MultiversX blockchain",
"author": "MultiversX",
"license": "GPL-3.0-or-later",
Expand Down
25 changes: 14 additions & 11 deletions src/UI/Balance/Balance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,31 +36,34 @@ export const BalanceComponent = ({
: mainBalance;

const getBalancePayload = () => {
const balancePayload: Record<string, string> = {};
const balancePayload: Record<string, string> = { processedMainBalance };

if (addEqualSign && displayAsUsd) {
Object.assign(balancePayload, { approximation: '≈' });
}

if (processedMainBalance) {
Object.assign(balancePayload, { processedMainBalance });
balancePayload.approximation = '≈';
}

if (decimalBalance) {
Object.assign(balancePayload, { decimalBalance: `.${decimalBalance}` });
balancePayload.decimalBalance = `.${decimalBalance}`;
}

if (!displayAsUsd && showTokenLabel) {
Object.assign(balancePayload, { tokenLabel: ` ${tokenLabel}` });
balancePayload.tokenLabel = ` ${tokenLabel}`;
}

return balancePayload;
};

const balancePayload = getBalancePayload();
const dataBalanceValue = Object.values(balancePayload).reduce(
(totalBalanceValue, currentBalanceValue) =>
totalBalanceValue.concat(currentBalanceValue),
const dataValues = [
balancePayload.approximation,
balancePayload.processedMainBalance,
balancePayload.decimalBalance,
balancePayload.tokenLabel
];

const dataBalanceValue = dataValues.reduce(
(totalDataValue, dataValueItem) =>
dataValueItem ? totalDataValue.concat(dataValueItem) : totalDataValue,
''
);

Expand Down

0 comments on commit 351e5eb

Please sign in to comment.