Changeset View
Changeset View
Standalone View
Standalone View
web/cashtab/src/components/Send/SendToken.js
import React, { useState, useEffect } from 'react'; | import React, { useState, useEffect } from 'react'; | ||||
import { WalletContext } from '../../utils/context'; | import { WalletContext } from '../../utils/context'; | ||||
import { Alert, Form, notification, message } from 'antd'; | import { Alert, Form, notification, message } from 'antd'; | ||||
import { CashSpin, CashSpinIcon } from '../Common/CustomSpinner'; | import { CashSpin, CashSpinIcon } from '../Common/CustomSpinner'; | ||||
import { Row, Col } from 'antd'; | import { Row, Col } from 'antd'; | ||||
import Paragraph from 'antd/lib/typography/Paragraph'; | import Paragraph from 'antd/lib/typography/Paragraph'; | ||||
import PrimaryButton, { SecondaryButton } from '../Common/PrimaryButton'; | import { SecondaryButton } from '../Common/PrimaryButton'; | ||||
import { CashLoader } from '../Common/CustomIcons'; | import { CashLoader } from '../Common/CustomIcons'; | ||||
import { | import { | ||||
FormItemWithMaxAddon, | FormItemWithMaxAddon, | ||||
FormItemWithQRCodeAddon, | FormItemWithQRCodeAddon, | ||||
} from '../Common/EnhancedInputs'; | } from '../Common/EnhancedInputs'; | ||||
import useBCH from '../../hooks/useBCH'; | import useBCH from '../../hooks/useBCH'; | ||||
import { BalanceHeader } from './Send'; | import { BalanceHeader } from './Send'; | ||||
import { Redirect } from 'react-router-dom'; | import { Redirect } from 'react-router-dom'; | ||||
Show All 23 Lines | const [formData, setFormData] = useState({ | ||||
value: '', | value: '', | ||||
address: '', | address: '', | ||||
}); | }); | ||||
const [loading, setLoading] = useState(false); | const [loading, setLoading] = useState(false); | ||||
const { getBCH, getRestUrl, sendToken } = useBCH(); | const { getBCH, getRestUrl, sendToken } = useBCH(); | ||||
const BCH = getBCH(); | const BCH = getBCH(); | ||||
// Keep this function around for re-enabling later | |||||
// eslint-disable-next-line no-unused-vars | |||||
async function submit() { | async function submit() { | ||||
setFormData({ | setFormData({ | ||||
...formData, | ...formData, | ||||
dirty: false, | dirty: false, | ||||
}); | }); | ||||
if ( | if ( | ||||
!formData.address || | !formData.address || | ||||
▲ Show 20 Lines • Show All 223 Lines • ▼ Show 20 Lines | return ( | ||||
{apiError || sendTokenAmountError ? ( | {apiError || sendTokenAmountError ? ( | ||||
<> | <> | ||||
<SecondaryButton> | <SecondaryButton> | ||||
Send {token.info.tokenName} | Send {token.info.tokenName} | ||||
</SecondaryButton> | </SecondaryButton> | ||||
{apiError && <CashLoader />} | {apiError && <CashLoader />} | ||||
</> | </> | ||||
) : ( | ) : ( | ||||
<PrimaryButton | <SecondaryButton> | ||||
onClick={() => submit()} | |||||
> | |||||
Send {token.info.tokenName} | Send {token.info.tokenName} | ||||
</PrimaryButton> | </SecondaryButton> | ||||
)} | )} | ||||
</div> | </div> | ||||
{apiError && ( | {apiError && ( | ||||
<p style={{ color: 'red' }}> | <p style={{ color: 'red' }}> | ||||
<b> | <b> | ||||
An error occured on our end. | An error occured on our end. | ||||
Reconnecting... | Reconnecting... | ||||
</b> | </b> | ||||
</p> | </p> | ||||
)} | )} | ||||
</Form> | </Form> | ||||
<Alert | <Alert | ||||
message="Warning" | message="Warning" | ||||
description="This wallet sends transactions with a Bitcoin ABC node. SLP tokens existing before the Nov 15, 2020 fork may not be supported on both chains." | description="Sending SLPA tokens is currently disabled." | ||||
type="warning" | type="warning" | ||||
showIcon | showIcon | ||||
closable | closable | ||||
style={{ textAlign: 'left' }} | style={{ textAlign: 'left' }} | ||||
/> | /> | ||||
</CashSpin> | </CashSpin> | ||||
</Col> | </Col> | ||||
</Row> | </Row> | ||||
</> | </> | ||||
)} | )} | ||||
</> | </> | ||||
); | ); | ||||
}; | }; | ||||
export default SendToken; | export default SendToken; |