import React, { useMemo } from 'react'; import { useTable, useSortBy } from 'react-table'; import ReactTooltip from 'react-tooltip'; import { OperationStatus } from '../util/enum'; import { convertQaToCommaStr, convertQaToZilFull } from '../util/utils'; import { DelegStakingPortfolioStats } from '../util/interface'; import DelegatorDropdown from './delegator-dropdown'; import { useAppSelector } from '../store/hooks'; import SpinnerNormal from './spinner-normal'; function Table({ columns, data }: any) { const { getTableProps, getTableBodyProps, headerGroups, rows, prepareRow, } = useTable( { columns, data, initialState : { pageIndex: 0, sortBy: [ { id: 'delegAmt', desc: true } ] } }, useSortBy); return ( {headerGroups.map(headerGroup => ( {headerGroup.headers.map(column => ( ))} ))} {rows.map((row, i) => { prepareRow(row) return ( {row.cells.map(cell => { return })} ) })}
{column.render('Header')}
{cell.render('Cell')}
); } function StakingPortfolio(props: any) { // const networkURL = props.network; // const data: DelegStakingPortfolioStats[] = props.data; const data: DelegStakingPortfolioStats[] = useAppSelector(state => state.user.deleg_staking_portfolio_list); const loading: OperationStatus = useAppSelector(state => state.user.is_deleg_stats_loading); const columns = useMemo( () => [ { Header: 'name', accessor: 'ssnName', }, { Header: 'deposit (ZIL)', accessor: 'delegAmt', Cell: ({ row }: any) => {convertQaToCommaStr(row.original.delegAmt)} }, { Header: 'rewards (ZIL)', accessor: 'rewards', Cell: ({ row }: any) => <> {convertQaToCommaStr(row.original.rewards)} }, { Header: 'actions', accessor: 'actions', Cell: ({ row }: any) => <> } ], [] ); return ( <> { loading === OperationStatus.PENDING && } { loading === OperationStatus.COMPLETE && <> { (data.length === 0) &&
You have not deposited in any nodes yet.
} { (data.length > 0) && } } ); } export default StakingPortfolio;