explorer: add load button for largest accounts card (#14437)
This commit is contained in:
parent
54a5876c48
commit
ecde98401b
|
@ -19,19 +19,15 @@ export function TopAccountsCard() {
|
||||||
const [showDropdown, setDropdown] = React.useState(false);
|
const [showDropdown, setDropdown] = React.useState(false);
|
||||||
const filter = useQueryFilter();
|
const filter = useQueryFilter();
|
||||||
|
|
||||||
// Fetch on load
|
|
||||||
React.useEffect(() => {
|
|
||||||
if (richList === Status.Idle && typeof supply === "object") fetchRichList();
|
|
||||||
}, [supply]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
||||||
|
|
||||||
if (typeof supply !== "object") return null;
|
if (typeof supply !== "object") return null;
|
||||||
|
|
||||||
if (richList === Status.Disconnected) {
|
if (richList === Status.Disconnected) {
|
||||||
return <ErrorCard text="Not connected to the cluster" />;
|
return <ErrorCard text="Not connected to the cluster" />;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (richList === Status.Idle || richList === Status.Connecting)
|
if (richList === Status.Connecting) {
|
||||||
return <LoadingCard />;
|
return <LoadingCard />;
|
||||||
|
}
|
||||||
|
|
||||||
if (typeof richList === "string") {
|
if (typeof richList === "string") {
|
||||||
return <ErrorCard text={richList} retry={fetchRichList} />;
|
return <ErrorCard text={richList} retry={fetchRichList} />;
|
||||||
|
@ -39,6 +35,8 @@ export function TopAccountsCard() {
|
||||||
|
|
||||||
let supplyCount: number;
|
let supplyCount: number;
|
||||||
let accounts, header;
|
let accounts, header;
|
||||||
|
|
||||||
|
if (richList !== Status.Idle) {
|
||||||
switch (filter) {
|
switch (filter) {
|
||||||
case "nonCirculating": {
|
case "nonCirculating": {
|
||||||
accounts = richList.nonCirculating;
|
accounts = richList.nonCirculating;
|
||||||
|
@ -60,6 +58,7 @@ export function TopAccountsCard() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
@ -84,6 +83,18 @@ export function TopAccountsCard() {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{richList === Status.Idle && (
|
||||||
|
<div className="card-body">
|
||||||
|
<span
|
||||||
|
className="btn btn-white ml-3 d-none d-md-inline"
|
||||||
|
onClick={fetchRichList}
|
||||||
|
>
|
||||||
|
Load Largest Accounts
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{accounts && (
|
||||||
<div className="table-responsive mb-0">
|
<div className="table-responsive mb-0">
|
||||||
<table className="table table-sm table-nowrap card-table">
|
<table className="table table-sm table-nowrap card-table">
|
||||||
<thead>
|
<thead>
|
||||||
|
@ -91,7 +102,9 @@ export function TopAccountsCard() {
|
||||||
<th className="text-muted">Rank</th>
|
<th className="text-muted">Rank</th>
|
||||||
<th className="text-muted">Address</th>
|
<th className="text-muted">Address</th>
|
||||||
<th className="text-muted text-right">Balance (SOL)</th>
|
<th className="text-muted text-right">Balance (SOL)</th>
|
||||||
<th className="text-muted text-right">% of {header} Supply</th>
|
<th className="text-muted text-right">
|
||||||
|
% of {header} Supply
|
||||||
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody className="list">
|
<tbody className="list">
|
||||||
|
@ -101,6 +114,7 @@ export function TopAccountsCard() {
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue