-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #386 from forbole/dev
Dev
- Loading branch information
Showing
28 changed files
with
481 additions
and
123 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
61 changes: 61 additions & 0 deletions
61
components/ConfirmTransactionDialog/ConfirmStageContent/MultiSendContent.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,61 @@ | ||
import React from 'react' | ||
import { Box, Divider, Typography, useTheme } from '@material-ui/core' | ||
import useTranslation from 'next-translate/useTranslation' | ||
import SendIcon from '../../../assets/images/icons/icon_send_tx.svg' | ||
import { formatTokenAmount, getTokenAmountFromDenoms } from '../../../misc/utils' | ||
|
||
interface MultiSendContentProps { | ||
totalAmount: TokenAmount | ||
msgs: TransactionMsgMultiSend[] | ||
denoms: TokenPrice[] | ||
account: Account | ||
} | ||
|
||
const MultiSendContent: React.FC<MultiSendContentProps> = ({ | ||
msgs, | ||
denoms, | ||
totalAmount, | ||
account, | ||
}) => { | ||
const { t, lang } = useTranslation('common') | ||
const theme = useTheme() | ||
return ( | ||
<> | ||
<Box display="flex" flexDirection="column" alignItems="center" mt={6}> | ||
<SendIcon width={theme.spacing(6)} height={theme.spacing(6)} /> | ||
<Box mt={2} mb={4}> | ||
<Typography variant="h4"> | ||
{t('send')} {formatTokenAmount(totalAmount, account.crypto, lang, ', ')} | ||
</Typography> | ||
</Box> | ||
</Box> | ||
<Divider /> | ||
<Box my={1}> | ||
<Typography>{t('from')}</Typography> | ||
<Typography color="textSecondary">{account.address}</Typography> | ||
</Box> | ||
<Divider /> | ||
{msgs[0].value.outputs.map((m, i) => ( | ||
<React.Fragment key={m.address}> | ||
<Box my={1}> | ||
<Typography>{t('send to', { number: `# ${i + 1}` })}</Typography> | ||
<Typography color="textSecondary" gutterBottom> | ||
{m.address} | ||
</Typography> | ||
<Typography>{t('amount')}</Typography> | ||
<Typography color="textSecondary"> | ||
{formatTokenAmount( | ||
getTokenAmountFromDenoms(m.coins, denoms || []), | ||
account.crypto, | ||
lang | ||
)} | ||
</Typography> | ||
</Box> | ||
<Divider /> | ||
</React.Fragment> | ||
))} | ||
</> | ||
) | ||
} | ||
|
||
export default MultiSendContent |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import React from 'react' | ||
import Link from 'next/link' | ||
import useTranslation from 'next-translate/useTranslation' | ||
import { gql, useSubscription } from '@apollo/client' | ||
import { | ||
Avatar, | ||
Box, | ||
ListItem, | ||
ListItemIcon, | ||
ListItemText, | ||
useTheme, | ||
CircularProgress, | ||
Typography, | ||
} from '@material-ui/core' | ||
import { useGeneralContext } from '../../contexts/GeneralContext' | ||
import { | ||
formatCurrency, | ||
formatTokenAmount, | ||
getTotalBalance, | ||
getTotalTokenAmount, | ||
transformGqlAcountBalance, | ||
} from '../../misc/utils' | ||
import { CustomTheme } from '../../misc/theme' | ||
import cryptocurrencies from '../../misc/cryptocurrencies' | ||
import useStyles from './styles' | ||
import { getLatestAccountBalance } from '../../graphql/queries/accountBalances' | ||
|
||
interface StarredAccountProps { | ||
account: Account | ||
} | ||
|
||
const StarredAccount: React.FC<StarredAccountProps> = ({ account }) => { | ||
const themeStyle: CustomTheme = useTheme() | ||
const { lang } = useTranslation('common') | ||
const { currency } = useGeneralContext() | ||
const classes = useStyles() | ||
const crypto = cryptocurrencies[account.crypto] | ||
// Latest data | ||
const { data: balanceData, loading } = useSubscription( | ||
gql` | ||
${getLatestAccountBalance(account.crypto)} | ||
`, | ||
{ variables: { address: account.address } } | ||
) | ||
const { tokenAmounts, usdBalance } = React.useMemo(() => { | ||
const accountBalance = transformGqlAcountBalance(balanceData, Date.now()) | ||
return { | ||
tokenAmounts: getTotalTokenAmount(accountBalance).amount, | ||
usdBalance: getTotalBalance(accountBalance).balance, | ||
} | ||
}, [balanceData]) | ||
return ( | ||
<Link key={account.address} href="/account/[address]" as={`/account/${account.address}`}> | ||
<ListItem className={classes.favMenuItem} button component="a"> | ||
<ListItemIcon> | ||
<Avatar | ||
alt={crypto.name} | ||
src={crypto.image} | ||
style={{ height: themeStyle.spacing(4), width: themeStyle.spacing(4) }} | ||
/> | ||
</ListItemIcon> | ||
<Box display="flex" flexDirection="column"> | ||
<ListItemText | ||
primary={account.name} | ||
primaryTypographyProps={{ | ||
variant: 'h6', | ||
}} | ||
/> | ||
{loading ? ( | ||
<Box> | ||
<CircularProgress size={20} /> | ||
</Box> | ||
) : ( | ||
<Box mt={-1}> | ||
<Typography variant="body2" color="textSecondary"> | ||
{formatTokenAmount(tokenAmounts, account.crypto, lang)} | ||
</Typography> | ||
{/* after USD balance is added */} | ||
{/* <Typography>{formatCurrency(usdBalance, currency, lang)}</Typography> */} | ||
</Box> | ||
)} | ||
</Box> | ||
</ListItem> | ||
</Link> | ||
) | ||
} | ||
|
||
export default StarredAccount |
Oops, something went wrong.