Fix mint holders page when supply is zero (#11586)

This commit is contained in:
Justin Starry 2020-08-13 01:56:17 +08:00 committed by GitHub
parent 55b5957d49
commit 5715f0b81a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 7 deletions

View File

@ -22,7 +22,7 @@ export function TokenLargestAccountsCard({ pubkey }: { pubkey: PublicKey }) {
}, [mintAddress]); // eslint-disable-line react-hooks/exhaustive-deps
const supplyTotal = supply?.data?.uiAmount;
if (!supplyTotal || !largestAccounts) {
if (supplyTotal === undefined || !largestAccounts) {
return null;
}
@ -78,6 +78,10 @@ const renderAccountRow = (
index: number,
supply: number
) => {
let percent = "-";
if (supply > 0) {
percent = `${((100 * account.uiAmount) / supply).toFixed(3)}%`;
}
return (
<tr key={index}>
<td>
@ -87,10 +91,7 @@ const renderAccountRow = (
<Address pubkey={account.address} link />
</td>
<td className="text-right">{account.uiAmount}</td>
<td className="text-right">{`${(
(100 * account.uiAmount) /
supply
).toFixed(3)}%`}</td>
<td className="text-right">{percent}</td>
</tr>
);
};

View File

@ -158,8 +158,8 @@ function MoreSection({
<div className="header">
<div className="header-body pt-0">
<ul className="nav nav-tabs nav-overflow header-tabs">
{tabs.map(({ title, path }) => (
<li className="nav-item">
{tabs.map(({ title, slug, path }) => (
<li key={slug} className="nav-item">
<NavLink
className="nav-link"
to={clusterPath(`/address/${address}${path}`)}