2021-02-04 19:15:23 +01:00
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import React from 'react';
|
|
|
|
import { useSelector } from 'react-redux';
|
2023-06-01 23:14:38 +02:00
|
|
|
import { getTokenList } from '../../../selectors';
|
2021-02-04 19:15:23 +01:00
|
|
|
import { useTokenFiatAmount } from '../../../hooks/useTokenFiatAmount';
|
2023-06-14 17:51:19 +02:00
|
|
|
import { TokenListItem } from '../../multichain';
|
2020-06-10 20:04:56 +02:00
|
|
|
|
2023-06-01 23:14:38 +02:00
|
|
|
export default function TokenCell({ address, image, symbol, string, onClick }) {
|
2023-03-23 11:08:33 +01:00
|
|
|
const tokenList = useSelector(getTokenList);
|
|
|
|
const tokenData = Object.values(tokenList).find(
|
|
|
|
(token) => token.symbol === symbol,
|
|
|
|
);
|
|
|
|
const title = tokenData?.name || symbol;
|
|
|
|
const tokenImage = tokenData?.iconUrl || image;
|
2021-02-04 19:15:23 +01:00
|
|
|
const formattedFiat = useTokenFiatAmount(address, string, symbol);
|
2020-06-03 19:50:12 +02:00
|
|
|
|
|
|
|
return (
|
2023-06-14 17:51:19 +02:00
|
|
|
<TokenListItem
|
2023-06-01 23:14:38 +02:00
|
|
|
onClick={() => onClick(address)}
|
|
|
|
tokenSymbol={symbol}
|
|
|
|
tokenImage={tokenImage}
|
|
|
|
primary={`${string || 0}`}
|
|
|
|
secondary={formattedFiat}
|
|
|
|
title={title}
|
|
|
|
/>
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2020-06-03 19:50:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
TokenCell.propTypes = {
|
|
|
|
address: PropTypes.string,
|
|
|
|
symbol: PropTypes.string,
|
|
|
|
string: PropTypes.string,
|
|
|
|
onClick: PropTypes.func.isRequired,
|
2023-02-06 15:31:19 +01:00
|
|
|
image: PropTypes.string,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|