Feature/holders tab (#47)

* fix: finished Holders tab on address page

* fix: add format for balance
pull/48/head
vpcodebase 3 years ago committed by GitHub
parent 5b8e30def4
commit a8bccf7b52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      src/components/tables/TransactionsTable.tsx
  2. 4
      src/pages/AddressPage/AddressDetails.tsx
  3. 41
      src/pages/AddressPage/tabs/holders/HoldersTab.tsx

@ -162,6 +162,8 @@ interface TransactionTableProps {
noScrollTop?: boolean; noScrollTop?: boolean;
step?: number; step?: number;
primaryKey?: string; primaryKey?: string;
showPages?: boolean
textType?: string
} }
export function TransactionsTable(props: TransactionTableProps) { export function TransactionsTable(props: TransactionTableProps) {
@ -181,6 +183,8 @@ export function TransactionsTable(props: TransactionTableProps) {
hideCounter, hideCounter,
noScrollTop, noScrollTop,
minWidth = "1310px", minWidth = "1310px",
showPages = false,
textType = 'transcation'
} = props; } = props;
const _IsLoading = isLoading; const _IsLoading = isLoading;
@ -201,7 +205,7 @@ export function TransactionsTable(props: TransactionTableProps) {
> >
{!hideCounter ? ( {!hideCounter ? (
<Text style={{ flex: "1 1 100%" }}> <Text style={{ flex: "1 1 100%" }}>
<b>{Math.min(limit, data.length)}</b> transaction <b>{Math.min(limit, data.length)}</b> {textType}
{data.length !== 1 ? "s" : ""} shown {data.length !== 1 ? "s" : ""} shown
</Text> </Text>
) : ( ) : (
@ -216,6 +220,7 @@ export function TransactionsTable(props: TransactionTableProps) {
elements={data} elements={data}
noScrollTop={noScrollTop} noScrollTop={noScrollTop}
property="block_number" property="block_number"
showPages={showPages}
/> />
)} )}
</Box> </Box>

@ -18,10 +18,10 @@ import { CircleQuestion } from "grommet-icons";
import styled from "styled-components"; import styled from "styled-components";
export const StyledBox = styled(Box)` export const StyledBox = styled(Box)`
transition: all .2s linear; transition: all 0.2s linear;
border-radius: 2px; border-radius: 2px;
padding-left: 5px; padding-left: 5px;
` `;
interface AddressDetailsProps { interface AddressDetailsProps {
address: string; address: string;
contracts: AddressDetails | null; contracts: AddressDetails | null;

@ -3,10 +3,13 @@ import React, { useEffect, useState } from "react";
import { getERC20TokenHolders } from "src/api/client"; import { getERC20TokenHolders } from "src/api/client";
import { IHoldersInfo, IUserERC721Assets } from "src/api/client.interface"; import { IHoldersInfo, IUserERC721Assets } from "src/api/client.interface";
import { TransactionsTable } from "src/components/tables/TransactionsTable"; import { TransactionsTable } from "src/components/tables/TransactionsTable";
import { Address } from "src/components/ui"; import { Address, TokenValue } from "src/components/ui";
import { useERC1155Pool } from "src/hooks/ERC1155_Pool";
import { useERC20Pool } from "src/hooks/ERC20_Pool";
import { useERC721Pool } from "src/hooks/ERC721_Pool";
import { Filter } from "src/types"; import { Filter } from "src/types";
const getColumns = (): ColumnConfig<IHoldersInfo>[] => { const getColumns = (id: string): ColumnConfig<IHoldersInfo>[] => {
return [ return [
{ {
property: "ownerAddres", property: "ownerAddres",
@ -33,21 +36,8 @@ const getColumns = (): ColumnConfig<IHoldersInfo>[] => {
</Text> </Text>
), ),
render: (data) => ( render: (data) => (
<Text size="small" style={{ width: "140px" }}> <Text size="small" style={{ width: "140px" }}>
{data.balance} <TokenValue value={data.balance} tokenAddress={id} />
</Text>
),
},
{
property: "Updated",
header: (
<Text color="minorText" size="small" style={{ fontWeight: 300 }}>
Updated
</Text>
),
render: (data) => (
<Text size="12px">
{data.lastUpdateBlockNumber ? data.lastUpdateBlockNumber : "—"}
</Text> </Text>
), ),
}, },
@ -59,6 +49,16 @@ export function HoldersTab(props: {
type: "erc20" | "erc721" | "erc1155"; type: "erc20" | "erc721" | "erc1155";
inventory?: IUserERC721Assets[]; inventory?: IUserERC721Assets[];
}) { }) {
const erc20Map = useERC20Pool();
const erc721Map = useERC721Pool();
const erc1155Map = useERC1155Pool();
const holdersTotal =
erc20Map[props.id]?.holders ||
erc721Map[props.id]?.holders ||
erc1155Map[props.id]?.holders;
const limitValue = localStorage.getItem("tableLimitValue"); const limitValue = localStorage.getItem("tableLimitValue");
const initFilter: Partial<Filter> = { const initFilter: Partial<Filter> = {
@ -128,14 +128,17 @@ export function HoldersTab(props: {
return ( return (
<Box style={{ padding: "10px" }}> <Box style={{ padding: "10px" }}>
<TransactionsTable <TransactionsTable
columns={getColumns()} columns={getColumns(props.id)}
filter={filter} filter={filter}
hideCounter={false}
setFilter={setFilter} setFilter={setFilter}
limit={filter.limit || 10} limit={filter.limit || 10}
data={holders} data={holders}
totalElements={filter.limit || 10} totalElements={+holdersTotal}
noScrollTop noScrollTop
minWidth="1266px" minWidth="1266px"
showPages={true}
textType={'holder'}
/> />
</Box> </Box>
); );

Loading…
Cancel
Save