This repository has been archived by the owner on Oct 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Deposit] Update UI to show pending assets (#1505)
- [x] Show alert box in case of pending assets - [x] Disable deposit form in case of pending assets - [x] Reload data of pending assets by clicking "reload" button - [x] Link to asgard.exchange to recover pending asset - [x] Update i18n
- Loading branch information
Showing
20 changed files
with
449 additions
and
127 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
97 changes: 97 additions & 0 deletions
97
src/renderer/components/deposit/add/Deposit.subcomponents.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,97 @@ | ||
import React, { useState } from 'react' | ||
|
||
import { assetToString, baseToAsset, formatAssetAmount } from '@xchainjs/xchain-util' | ||
import * as FP from 'fp-ts/lib/function' | ||
import { useIntl } from 'react-intl' | ||
|
||
import { Network } from '../../../../shared/api/types' | ||
import { AssetWithAmount } from '../../../types/asgardex' | ||
import { Button } from '../../uielements/button' | ||
import * as Styled from './Deposit.style' | ||
|
||
type AssetIconAmountProps = { | ||
assetWB: AssetWithAmount | ||
network: Network | ||
loading: boolean | ||
} | ||
|
||
const AssetIconAmount: React.FC<AssetIconAmountProps> = (props): JSX.Element => { | ||
const { | ||
assetWB: { asset, amount }, | ||
network, | ||
loading | ||
} = props | ||
return ( | ||
<Styled.PendingAssetContainer> | ||
<Styled.PendingAssetIcon asset={asset} network={network} /> | ||
<Styled.PendingAssetLabel asset={asset} /> | ||
<Styled.PendingAssetAmountLabel loading={loading}> | ||
{formatAssetAmount({ | ||
amount: baseToAsset(amount), | ||
decimal: amount.decimal, | ||
trimZeros: true | ||
})} | ||
</Styled.PendingAssetAmountLabel> | ||
</Styled.PendingAssetContainer> | ||
) | ||
} | ||
|
||
type PendingAssetsProps = { | ||
network: Network | ||
assets: AssetWithAmount[] | ||
loading: boolean | ||
onClickRecovery: FP.Lazy<void> | ||
} | ||
|
||
export const PendingAssets: React.FC<PendingAssetsProps> = (props): JSX.Element => { | ||
const { assets, network, loading, onClickRecovery } = props | ||
|
||
const intl = useIntl() | ||
|
||
const [collapsed, setCollapsed] = useState(false) | ||
|
||
const subContent = ( | ||
<> | ||
<Styled.RecoveryInfoButton selected={collapsed} onClick={() => setCollapsed((v) => !v)}> | ||
<Styled.RecoveryInfoButtonLabel> | ||
{intl.formatMessage({ id: 'common.informationMore' })} | ||
</Styled.RecoveryInfoButtonLabel> | ||
<Styled.RecoveryInfoButtonIcon selected={collapsed} /> | ||
</Styled.RecoveryInfoButton> | ||
<> | ||
{collapsed ? ( | ||
<> | ||
<Styled.RecoveryDescription> | ||
{intl.formatMessage({ id: 'deposit.add.pendingAssets.description' })} | ||
</Styled.RecoveryDescription> | ||
{assets.map((assetWB, index) => ( | ||
<AssetIconAmount | ||
network={network} | ||
assetWB={assetWB} | ||
loading={loading} | ||
key={`${assetToString(assetWB.asset)}-${index}`} | ||
/> | ||
))} | ||
<Styled.RecoveryDescription> | ||
{intl.formatMessage({ id: 'deposit.add.pendingAssets.recoveryDescription' })} | ||
</Styled.RecoveryDescription> | ||
<Button onClick={onClickRecovery} typevalue="outline" color="warning"> | ||
{intl.formatMessage({ id: 'deposit.add.pendingAssets.recoveryTitle' })} | ||
<Styled.OpenRecoveryToolIcon /> | ||
</Button> | ||
</> | ||
) : ( | ||
<></> | ||
)} | ||
</> | ||
</> | ||
) | ||
|
||
return ( | ||
<Styled.Alert | ||
type="warning" | ||
message={intl.formatMessage({ id: 'deposit.add.pendingAssets.title' })} | ||
description={subContent} | ||
/> | ||
) | ||
} |
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
Oops, something went wrong.