Changeset View
Changeset View
Standalone View
Standalone View
web/cashtab/src/components/Send/Send.js
Show All 16 Lines | |||||
import { isMobile, isIOS, isSafari } from 'react-device-detect'; | import { isMobile, isIOS, isSafari } from 'react-device-detect'; | ||||
import { | import { | ||||
currency, | currency, | ||||
isValidTokenPrefix, | isValidTokenPrefix, | ||||
parseAddress, | parseAddress, | ||||
toLegacy, | toLegacy, | ||||
} from '@components/Common/Ticker.js'; | } from '@components/Common/Ticker.js'; | ||||
import { Event } from '@utils/GoogleAnalytics'; | import { Event } from '@utils/GoogleAnalytics'; | ||||
import { shouldRejectAmountInput } from '@utils/validation'; | import { fiatToCrypto, shouldRejectAmountInput } from '@utils/validation'; | ||||
export const BalanceHeader = styled.div` | export const BalanceHeader = styled.div` | ||||
p { | p { | ||||
color: #777; | color: #777; | ||||
width: 100%; | width: 100%; | ||||
font-size: 14px; | font-size: 14px; | ||||
margin-bottom: 0px; | margin-bottom: 0px; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 170 Lines • ▼ Show 20 Lines | async function submit() { | ||||
); | ); | ||||
return; | return; | ||||
} | } | ||||
// Calculate the amount in BCH | // Calculate the amount in BCH | ||||
let bchValue = value; | let bchValue = value; | ||||
if (selectedCurrency === 'USD') { | if (selectedCurrency === 'USD') { | ||||
bchValue = (value / fiatPrice).toFixed(8); | bchValue = fiatToCrypto(value, fiatPrice); | ||||
} | } | ||||
try { | try { | ||||
const link = await sendBch( | const link = await sendBch( | ||||
BCH, | BCH, | ||||
wallet, | wallet, | ||||
slpBalancesAndUtxos.nonSlpUtxos, | slpBalancesAndUtxos.nonSlpUtxos, | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 153 Lines • ▼ Show 20 Lines | const SendBCH = ({ filledAddress, callbackTxId }) => { | ||||
// Display price in USD below input field for send amount, if it can be calculated | // Display price in USD below input field for send amount, if it can be calculated | ||||
let fiatPriceString = ''; | let fiatPriceString = ''; | ||||
if (fiatPrice !== null && !isNaN(formData.value)) { | if (fiatPrice !== null && !isNaN(formData.value)) { | ||||
if (selectedCurrency === currency.ticker) { | if (selectedCurrency === currency.ticker) { | ||||
fiatPriceString = `$ ${(fiatPrice * Number(formData.value)).toFixed( | fiatPriceString = `$ ${(fiatPrice * Number(formData.value)).toFixed( | ||||
2, | 2, | ||||
)} USD`; | )} USD`; | ||||
} else { | } else { | ||||
fiatPriceString = `${(Number(formData.value) / fiatPrice).toFixed( | fiatPriceString = `${ | ||||
8, | formData.value ? fiatToCrypto(formData.value, fiatPrice) : '0' | ||||
)} ${currency.ticker}`; | } ${currency.ticker}`; | ||||
} | } | ||||
} | } | ||||
return ( | return ( | ||||
<> | <> | ||||
<Modal | <Modal | ||||
title="Confirm Send" | title="Confirm Send" | ||||
visible={isModalVisible} | visible={isModalVisible} | ||||
▲ Show 20 Lines • Show All 137 Lines • Show Last 20 Lines |