Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const BigAmount = ({ type, showPlusMinusSymbol, value, currency }) => {
switch (type) {
case "currency": {
const { decimalSeparator, spaceBetweenAmountAndSymbol, symbol, symbolOnLeft } = currencyFormatter.findCurrency(
currency,
);
const formattedValue = currencyFormatter.format(Math.abs(value), {
code: currency,
symbol: "",
});
const [integerValue, decimalValue] = formattedValue.split(decimalSeparator);
const optionalSpacing = spaceBetweenAmountAndSymbol ? " " : "";
return (
{showPlusMinusSymbol && value > 0 && {PLUS_SYMBOL}}
{showPlusMinusSymbol && value < 0 && {MINUS_SYMBOL}}
{symbolOnLeft && {`${symbol}${optionalSpacing}`}}
{integerValue && <span>{integerValue}</span>}
{decimalValue && {`${decimalSeparator}${decimalValue}`}}
symbolFor: c => {
if (!currency.isKnown(c)) {
throw new Error(`Unknown currency: ${c}`);
}
return findCurrency(c).symbol;
},
makeFormat: c => {
isKnown: c => typeof findCurrency(c) !== 'undefined',
symbolFor: c => {
makeFormat: c => {
if (!currency.isKnown(c)) {
throw new Error(`Unknown currency: ${c}`);
}
let { decimalDigits } = findCurrency(c);
return amount => {
let am = Math.abs(amount) < Math.pow(10, -decimalDigits - 2) ? 0 : amount;
return currencyFormatter(am, { code: c });
};
}
};