import React, {useMemo } from 'react'; import { useTable, useSortBy } from 'react-table'; import ReactTooltip from 'react-tooltip'; import IconQuestionCircle from './icons/question-circle'; import Spinner from './spinner'; import { PromiseArea, ButtonText, ContractState } from '../util/enum'; import { convertQaToCommaStr } from '../util/utils'; import { PendingWithdrawStats } from '../util/interface'; import { useAppSelector } from '../store/hooks'; function Table({ columns, data, tableId }: any) { const { getTableProps, getTableBodyProps, headerGroups, rows, prepareRow, } = useTable( { columns, data, initialState : { sortBy: [ { id: "blkNumCountdown", desc: false } ] } }, 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 CompleteWithdrawalTable(props: any) { const data: PendingWithdrawStats[] = useAppSelector(state => state.user.pending_withdraw_list); const completeWithdrawAmt = useAppSelector(state => state.user.complete_withdrawal_amt); const columns = useMemo( () => [ { Header: 'pending blocks till claim', accessor: 'blkNumCountdown' }, { Header: 'progress', accessor: 'progress', Cell: ({ row }: any) => {row.original.progress}% }, { Header: 'amount (ZIL)', accessor: 'amount', Cell: ({ row }: any) => {convertQaToCommaStr(row.original.amount)} } ], [] ); return ( <> { data.length !== 0 &&
Pending Stake Withdrawals 
You can now withdraw {convertQaToCommaStr(completeWithdrawAmt)} ZIL
{ data.length !== 0 && } { data.length !== 0 && }
{ data.length === 0 && You have no ZILs ready for withdrawal yet. } When you initiate a stake withdrawal, the amount is not withdrawn immediately.
The amount is processed at a certain block number and only available to withdraw
once the required block number is reached.
} ) } export default CompleteWithdrawalTable;