Skip to content

Commit

Permalink
X2-10712 fix negative sign order for currency component (#350)
Browse files Browse the repository at this point in the history
fix negative sign order for currency component
  • Loading branch information
SemenStruchev authored Oct 23, 2024
1 parent 4573905 commit cbecb12
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/components/Utilities/Currency.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,29 @@ export const Currency = ({

const maxDigits = isZeroDecimal(currency) ? 0 : maximumFractionDigits;
let formattedAmount = numberFormat(amount, currency, locale, maxDigits, compact);

const isNegative = amount < 0;
if (isNegative) {
formattedAmount = formattedAmount.replace("-", "");
}

if (compact) {
return (
<span className="ui-currency">
{isNegative && "-"}
{getSymbol(currency, locale, isNarrowSymbolForm)}
{formattedAmount}
</span>
);
}

formattedAmount = shouldRemoveTrailingZeroes ? formattedAmount.replace(".00", "") : formattedAmount;
return <span className="ui-currency">{formattedAmount}</span>;
return (
<span className="ui-currency">
{isNegative && "-"}
{formattedAmount}
</span>
);
};

Currency.propTypes = {
Expand Down

0 comments on commit cbecb12

Please sign in to comment.