-
Notifications
You must be signed in to change notification settings - Fork 504
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
plondon
committed
Dec 6, 2021
1 parent
78b3cff
commit f7834c2
Showing
12 changed files
with
304 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
packages/blockchain-wallet-v4-frontend/src/modals/Nfts/NftOrder/ShowAsset/Transfer/cta.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import React from 'react' | ||
import { FormattedMessage } from 'react-intl' | ||
|
||
import { Link, Text } from 'blockchain-info-components' | ||
import { NftOrderStepEnum } from 'data/components/nfts/types' | ||
|
||
import { Props as OwnProps } from '../..' | ||
|
||
const CTA: React.FC<Props> = (props) => { | ||
const { nftActions } = props | ||
|
||
return ( | ||
<> | ||
<Text size='12px' weight={500} style={{ margin: '8px 0', textAlign: 'center' }}> | ||
Or | ||
</Text> | ||
<Link | ||
weight={600} | ||
size='14px' | ||
onClick={() => nftActions.setOrderFlowStep({ step: NftOrderStepEnum.TRANSFER })} | ||
style={{ display: 'block', textAlign: 'center', width: '100%' }} | ||
> | ||
<FormattedMessage id='copy.transfer' defaultMessage='Transfer' /> | ||
</Link> | ||
</> | ||
) | ||
} | ||
|
||
type Props = OwnProps | ||
|
||
export default CTA |
69 changes: 69 additions & 0 deletions
69
packages/blockchain-wallet-v4-frontend/src/modals/Nfts/NftOrder/ShowAsset/Transfer/fees.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import React, { useEffect } from 'react' | ||
import { FormattedMessage } from 'react-intl' | ||
import BigNumber from 'bignumber.js' | ||
|
||
import { GasCalculationOperations, NftAsset } from '@core/network/api/nfts/types' | ||
import { NULL_ADDRESS } from '@core/redux/payment/nfts/utils' | ||
import { SpinningLoader } from 'blockchain-info-components' | ||
import CoinDisplay from 'components/Display/CoinDisplay' | ||
import FiatDisplay from 'components/Display/FiatDisplay' | ||
import { Title, Value } from 'components/Flyout/model' | ||
|
||
import { CTARow } from '../../../components' | ||
import { Props as OwnProps } from '../..' | ||
|
||
const Fees: React.FC<Props> = (props) => { | ||
const { nftActions, orderFlow } = props | ||
|
||
useEffect(() => { | ||
if (props.asset) { | ||
nftActions.fetchFees({ | ||
asset: props.asset, | ||
operation: GasCalculationOperations.Transfer, | ||
to: NULL_ADDRESS | ||
}) | ||
} | ||
}, []) | ||
|
||
return ( | ||
<> | ||
{orderFlow.fees.cata({ | ||
Failure: () => null, | ||
Loading: () => ( | ||
<CTARow> | ||
<div style={{ marginBottom: '22px' }}> | ||
<SpinningLoader width='14px' height='14px' borderWidth='3px' /> | ||
</div> | ||
</CTARow> | ||
), | ||
NotAsked: () => null, | ||
Success: (val) => { | ||
return ( | ||
<> | ||
<CTARow> | ||
<Title> | ||
<FormattedMessage id='copy.fees' defaultMessage='Fees' /> | ||
</Title> | ||
<Value> | ||
<div style={{ display: 'flex' }}> | ||
<CoinDisplay size='14px' color='black' weight={600} coin='ETH'> | ||
{new BigNumber(val.totalFees).multipliedBy(val.gasPrice).toString()} | ||
</CoinDisplay> | ||
- | ||
<FiatDisplay size='12px' color='grey600' weight={600} coin='ETH'> | ||
{new BigNumber(val.totalFees).multipliedBy(val.gasPrice).toString()} | ||
</FiatDisplay> | ||
</div> | ||
</Value> | ||
</CTARow> | ||
</> | ||
) | ||
} | ||
})} | ||
</> | ||
) | ||
} | ||
|
||
type Props = OwnProps & { asset: NftAsset } | ||
|
||
export default Fees |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
145 changes: 145 additions & 0 deletions
145
packages/blockchain-wallet-v4-frontend/src/modals/Nfts/NftOrder/Transfer/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
import React from 'react' | ||
import { FormattedMessage } from 'react-intl' | ||
import { connect, ConnectedProps } from 'react-redux' | ||
import { compose } from 'redux' | ||
import { Field, reduxForm } from 'redux-form' | ||
|
||
import { Remote } from '@core' | ||
import { convertCoinToCoin } from '@core/exchange' | ||
import { GasCalculationOperations } from '@core/network/api/nfts/types' | ||
import { Button, Icon, SpinningLoader, Text } from 'blockchain-info-components' | ||
import { ErrorCartridge } from 'components/Cartridge' | ||
import FiatDisplay from 'components/Display/FiatDisplay' | ||
import { Row, Title, Value } from 'components/Flyout/model' | ||
import { Form, NumberBox, TextBox } from 'components/Form' | ||
import TabMenuNftSaleType from 'components/Form/TabMenuNftSaleType' | ||
import { selectors } from 'data' | ||
import { NftOrderStepEnum } from 'data/components/nfts/types' | ||
import { required, validEthAddress } from 'services/forms' | ||
|
||
import { AssetDesc, FullAssetImage, StickyCTA } from '../../components' | ||
import { Props as OwnProps } from '..' | ||
import TransferFees from '../ShowAsset/Transfer/fees' | ||
|
||
const Transfer: React.FC<Props> = (props) => { | ||
const { close, formValues, nftActions, orderFlow } = props | ||
const coin = 'ETH' | ||
|
||
const disabled = formValues ? !formValues.to || Remote.Loading.is(props.sellOrder) : true | ||
|
||
return ( | ||
<> | ||
{orderFlow.asset.cata({ | ||
Failure: (e) => <Text>{e}</Text>, | ||
Loading: () => ( | ||
<AssetDesc> | ||
<SpinningLoader width='14px' height='14px' borderWidth='3px' /> | ||
</AssetDesc> | ||
), | ||
NotAsked: () => null, | ||
Success: (val) => ( | ||
<> | ||
<div style={{ position: 'relative' }}> | ||
<Icon | ||
onClick={() => nftActions.setOrderFlowStep({ step: NftOrderStepEnum.SHOW_ASSET })} | ||
name='arrow-left' | ||
cursor | ||
role='button' | ||
style={{ left: '40px', position: 'absolute', top: '40px' }} | ||
/> | ||
<Icon | ||
onClick={() => close()} | ||
name='close' | ||
cursor | ||
role='button' | ||
style={{ position: 'absolute', right: '40px', top: '40px' }} | ||
/> | ||
<FullAssetImage cropped backgroundImage={val?.image_url.replace(/=s\d*/, '')} /> | ||
</div> | ||
<AssetDesc> | ||
<Text size='16px' color='grey900' weight={600}> | ||
{val?.collection?.name} | ||
</Text> | ||
<Text style={{ marginTop: '4px' }} size='20px' color='grey900' weight={600}> | ||
{val?.name} | ||
</Text> | ||
</AssetDesc> | ||
<Row> | ||
<Title> | ||
<FormattedMessage id='copy.description' defaultMessage='Description' /> | ||
</Title> | ||
<Value> | ||
{val?.description || ( | ||
<FormattedMessage id='copy.none_found' defaultMessage='None found.' /> | ||
)} | ||
</Value> | ||
</Row> | ||
<Form> | ||
<Row> | ||
<Title> | ||
<b> | ||
<FormattedMessage id='copy.to' defaultMessage='To' /> | ||
</b> | ||
</Title> | ||
<Value> | ||
<Field name='to' component={TextBox} validate={[required, validEthAddress]} /> | ||
</Value> | ||
</Row> | ||
</Form> | ||
<StickyCTA> | ||
<TransferFees {...props} asset={val} /> | ||
{props.orderFlow.fees.cata({ | ||
Failure: () => ( | ||
<Button jumbo nature='sent' fullwidth data-e2e='sellNft' disabled> | ||
<FormattedMessage id='copy.transfer' defaultMessage='Transfer' /> | ||
</Button> | ||
), | ||
Loading: () => ( | ||
<Button jumbo nature='primary' fullwidth data-e2e='sellNft' disabled> | ||
<FormattedMessage id='copy.transfer' defaultMessage='Transfer' /> | ||
</Button> | ||
), | ||
NotAsked: () => null, | ||
Success: (fees) => ( | ||
<Button | ||
jumbo | ||
nature='primary' | ||
fullwidth | ||
data-e2e='transferNft' | ||
disabled={disabled} | ||
onClick={() => | ||
nftActions.createTransfer({ | ||
asset: val, | ||
gasData: fees, | ||
to: formValues.to | ||
}) | ||
} | ||
> | ||
<FormattedMessage id='copy.transfer' defaultMessage='Transfer' /> | ||
</Button> | ||
) | ||
})} | ||
</StickyCTA> | ||
</> | ||
) | ||
})} | ||
</> | ||
) | ||
} | ||
|
||
const mapStateToProps = (state) => ({ | ||
formValues: selectors.form.getFormValues('nftTransfer')(state) as { to: string } | ||
}) | ||
|
||
const connector = connect(mapStateToProps) | ||
|
||
const enhance = compose( | ||
reduxForm<{}, OwnProps>({ | ||
form: 'nftTransfer' | ||
}), | ||
connector | ||
) | ||
|
||
type Props = OwnProps & ConnectedProps<typeof connector> | ||
|
||
export default enhance(Transfer) as React.FC<OwnProps> |
Oops, something went wrong.