Changeset View
Changeset View
Standalone View
Standalone View
cashtab/src/components/Send/SendXec.js
// Copyright (c) 2024 The Bitcoin developers | // Copyright (c) 2024 The Bitcoin developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
import React, { useState, useEffect } from 'react'; | import React, { useState, useEffect } from 'react'; | ||||
import { useLocation } from 'react-router-dom'; | import { useLocation } from 'react-router-dom'; | ||||
import { WalletContext } from 'wallet/context'; | import { WalletContext } from 'wallet/context'; | ||||
import { | import { | ||||
ThemedMailOutlined, | ThemedMailOutlined, | ||||
CashReceivedNotificationIcon, | CashReceivedNotificationIcon, | ||||
} from 'components/Common/CustomIcons'; | } from 'components/Common/CustomIcons'; | ||||
import { CustomCollapseCtn } from 'components/Common/StyledCollapse'; | import { CustomCollapseCtn } from 'components/Common/StyledCollapse'; | ||||
import { Alert, Switch } from 'antd'; | import { Alert } from 'antd'; | ||||
import Modal from 'components/Common/Modal'; | import Modal from 'components/Common/Modal'; | ||||
import PrimaryButton from 'components/Common/PrimaryButton'; | import PrimaryButton from 'components/Common/PrimaryButton'; | ||||
import { toSatoshis, toXec } from 'wallet'; | import { toSatoshis, toXec } from 'wallet'; | ||||
import { getMaxSendAmountSatoshis } from 'ecash-coinselect'; | import { getMaxSendAmountSatoshis } from 'ecash-coinselect'; | ||||
import { sumOneToManyXec } from 'utils/cashMethods'; | import { sumOneToManyXec } from 'utils/cashMethods'; | ||||
import { Event } from 'components/Common/GoogleAnalytics'; | import { Event } from 'components/Common/GoogleAnalytics'; | ||||
import { | import { | ||||
isValidMultiSendUserInput, | isValidMultiSendUserInput, | ||||
Show All 33 Lines | |||||
import { isMobile, getUserLocale } from 'helpers'; | import { isMobile, getUserLocale } from 'helpers'; | ||||
import { hasEnoughToken, fiatToSatoshis } from 'wallet'; | import { hasEnoughToken, fiatToSatoshis } from 'wallet'; | ||||
import { toast } from 'react-toastify'; | import { toast } from 'react-toastify'; | ||||
import { | import { | ||||
InputWithScanner, | InputWithScanner, | ||||
SendXecInput, | SendXecInput, | ||||
TextArea, | TextArea, | ||||
} from 'components/Common/Inputs'; | } from 'components/Common/Inputs'; | ||||
import CashtabSwitch from 'components/Common/Switch'; | |||||
const SwitchContainer = styled.div` | const SwitchContainer = styled.div` | ||||
display: flex; | display: flex; | ||||
align-items: center; | align-items: center; | ||||
justify-content: flex-end; | justify-content: flex-end; | ||||
color: ${props => props.theme.forms.text}; | color: ${props => props.theme.forms.text}; | ||||
white-space: nowrap; | white-space: nowrap; | ||||
margin: 12px; | margin: 12px 0; | ||||
`; | `; | ||||
const SentLink = styled.a` | const SentLink = styled.a` | ||||
color: ${props => props.theme.walletBackground}; | color: ${props => props.theme.walletBackground}; | ||||
text-decoration: none; | text-decoration: none; | ||||
`; | `; | ||||
const AppCreatedTxSummary = styled.div` | const AppCreatedTxSummary = styled.div` | ||||
▲ Show 20 Lines • Show All 723 Lines • ▼ Show 20 Lines | return ( | ||||
)} | )} | ||||
<SidePaddingCtn data-testid="send-xec-ctn"> | <SidePaddingCtn data-testid="send-xec-ctn"> | ||||
{txInfoFromUrl && ( | {txInfoFromUrl && ( | ||||
<AppCreatedTxSummary data-testid="app-created-tx"> | <AppCreatedTxSummary data-testid="app-created-tx"> | ||||
Webapp Tx Request | Webapp Tx Request | ||||
</AppCreatedTxSummary> | </AppCreatedTxSummary> | ||||
)} | )} | ||||
{!txInfoFromUrl && !('queryString' in parsedAddressInput) && ( | |||||
<SwitchContainer> | <SwitchContainer> | ||||
Multiple Recipients: | <CashtabSwitch | ||||
<Switch | name="Send to many" | ||||
data-testid="multiple-recipients-switch" | on="Send to many" | ||||
defaultunchecked="true" | off="Send to one" | ||||
width={150} | |||||
right={115} | |||||
checked={isOneToManyXECSend} | checked={isOneToManyXECSend} | ||||
onChange={() => { | disabled={ | ||||
setIsOneToManyXECSend(!isOneToManyXECSend); | txInfoFromUrl || 'queryString' in parsedAddressInput | ||||
// Do not persist multisend input to single send and vice versa | } | ||||
clearInputForms(); | handleToggle={() => | ||||
}} | setIsOneToManyXECSend(!isOneToManyXECSend) | ||||
} | |||||
/> | /> | ||||
</SwitchContainer> | </SwitchContainer> | ||||
)} | |||||
<ExpandingAddressInputCtn open={isOneToManyXECSend}> | <ExpandingAddressInputCtn open={isOneToManyXECSend}> | ||||
<SendInputCtn> | <SendInputCtn> | ||||
<DestinationAddressSingleCtn> | <DestinationAddressSingleCtn> | ||||
<InputWithScanner | <InputWithScanner | ||||
placeholder={ | placeholder={ | ||||
aliasSettings.aliasEnabled | aliasSettings.aliasEnabled | ||||
? `Address or Alias` | ? `Address or Alias` | ||||
: `Address` | : `Address` | ||||
▲ Show 20 Lines • Show All 182 Lines • Show Last 20 Lines |