Changeset View
Changeset View
Standalone View
Standalone View
web/cashtab/src/components/Send/Send.js
import React, { useState, useEffect } from 'react'; | import React, { useState, useEffect } from 'react'; | ||||
import styled from 'styled-components'; | import styled from 'styled-components'; | ||||
import { WalletContext } from '@utils/context'; | import { WalletContext } from '@utils/context'; | ||||
import { Form, notification, message, Spin, Modal, Alert } from 'antd'; | import { Form, notification, message, Spin, Modal, Alert } from 'antd'; | ||||
import { CashLoader, CashLoadingIcon } from '@components/Common/CustomIcons'; | import { CashLoader, CashLoadingIcon } from '@components/Common/CustomIcons'; | ||||
import { Row, Col } from 'antd'; | import { Row, Col } from 'antd'; | ||||
import BigNumber from 'bignumber.js'; | |||||
import Paragraph from 'antd/lib/typography/Paragraph'; | import Paragraph from 'antd/lib/typography/Paragraph'; | ||||
import PrimaryButton, { | import PrimaryButton, { | ||||
SecondaryButton, | SecondaryButton, | ||||
} from '@components/Common/PrimaryButton'; | } from '@components/Common/PrimaryButton'; | ||||
import { | import { | ||||
SendBchInput, | SendBchInput, | ||||
FormItemWithQRCodeAddon, | FormItemWithQRCodeAddon, | ||||
} from '@components/Common/EnhancedInputs'; | } from '@components/Common/EnhancedInputs'; | ||||
▲ Show 20 Lines • Show All 324 Lines • ▼ Show 20 Lines | const handleBchAmountChange = e => { | ||||
bchValue = (value / fiatPrice).toFixed(8); | bchValue = (value / fiatPrice).toFixed(8); | ||||
} | } | ||||
// Validate value for > 0 | // Validate value for > 0 | ||||
if (isNaN(bchValue)) { | if (isNaN(bchValue)) { | ||||
error = 'Amount must be a number'; | error = 'Amount must be a number'; | ||||
} else if (bchValue <= 0) { | } else if (bchValue <= 0) { | ||||
error = 'Amount must be greater than 0'; | error = 'Amount must be greater than 0'; | ||||
} else if (bchValue < currency.dust) { | } else if (new BigNumber(bchValue).lt(new BigNumber(currency.dust))) { | ||||
error = `Send amount must be at least ${currency.dust} ${currency.ticker}`; | error = `Send amount must be at least ${currency.dust} ${currency.ticker}`; | ||||
} else if (bchValue > balances.totalBalance) { | } else if (bchValue > balances.totalBalance) { | ||||
error = `Amount cannot exceed your ${currency.ticker} balance`; | error = `Amount cannot exceed your ${currency.ticker} balance`; | ||||
} else if (!isNaN(bchValue) && bchValue.toString().includes('.')) { | } else if (!isNaN(bchValue) && bchValue.toString().includes('.')) { | ||||
if (bchValue.toString().split('.')[1].length > 8) { | if (bchValue.toString().split('.')[1].length > 8) { | ||||
error = `${currency.ticker} transactions do not support more than 8 decimal places`; | error = `${currency.ticker} transactions do not support more than 8 decimal places`; | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 187 Lines • Show Last 20 Lines |