diff --git a/web/cashtab/src/components/Send/Send.js b/web/cashtab/src/components/Send/Send.js --- a/web/cashtab/src/components/Send/Send.js +++ b/web/cashtab/src/components/Send/Send.js @@ -32,6 +32,7 @@ import { getWalletState } from '@utils/cashMethods'; import { CashReceivedNotificationIcon } from '@components/Common/CustomIcons'; import ApiError from '@components/Common/ApiError'; +import { formatFiatBalance } from '@utils/validation'; // Note jestBCH is only used for unit tests; BCHJS must be mocked for jest const SendBCH = ({ jestBCH, passLoadingStatus }) => { @@ -359,21 +360,28 @@ let fiatPriceString = ''; if (fiatPrice !== null && !isNaN(formData.value)) { if (selectedCurrency === currency.ticker) { - fiatPriceString = `${ - cashtabSettings - ? `${ - currency.fiatCurrencies[cashtabSettings.fiatCurrency] - .symbol - } ` - : '$ ' - } ${(fiatPrice * Number(formData.value)).toFixed(2)} ${ - cashtabSettings && cashtabSettings.fiatCurrency - ? cashtabSettings.fiatCurrency.toUpperCase() - : 'USD' - }`; + // calculate conversion to fiatPrice + fiatPriceString = `${(fiatPrice * Number(formData.value)).toFixed( + 2, + )}`; + + // formats to fiat locale style + fiatPriceString = formatFiatBalance(Number(fiatPriceString)); + + // insert symbol and currency before/after the locale formatted fiat balance + fiatPriceString = + currency.fiatCurrencies[cashtabSettings?.fiatCurrency]?.symbol + + ' ' + + fiatPriceString + + ' ' + + cashtabSettings?.fiatCurrency.toUpperCase(); } else { fiatPriceString = `${ - formData.value ? fiatToCrypto(formData.value, fiatPrice) : '0' + formData.value + ? formatFiatBalance( + Number(fiatToCrypto(formData.value, fiatPrice)), + ) + : formatFiatBalance(0) } ${currency.ticker}`; } } diff --git a/web/cashtab/src/components/Send/__tests__/__snapshots__/Send.test.js.snap b/web/cashtab/src/components/Send/__tests__/__snapshots__/Send.test.js.snap --- a/web/cashtab/src/components/Send/__tests__/__snapshots__/Send.test.js.snap +++ b/web/cashtab/src/components/Send/__tests__/__snapshots__/Send.test.js.snap @@ -318,7 +318,7 @@ > = - $ NaN USD + undefined NaN undefined