diff --git a/libs/accounts/src/lib/accounts-table.spec.tsx b/libs/accounts/src/lib/accounts-table.spec.tsx index d30981836..c0ebe4168 100644 --- a/libs/accounts/src/lib/accounts-table.spec.tsx +++ b/libs/accounts/src/lib/accounts-table.spec.tsx @@ -38,7 +38,7 @@ describe('AccountsTable', () => { null} /> ); }); - const expectedHeaders = ['Asset', 'Total', 'Used', '', '']; + const expectedHeaders = ['Asset', 'Total', 'Used', 'Available', '', '']; const headers = await screen.findAllByRole('columnheader'); expect(headers).toHaveLength(expectedHeaders.length); expect( @@ -56,7 +56,8 @@ describe('AccountsTable', () => { const expectedValues = [ 'tBTC', '1,256.00', - '1,256.001,256.00', + '1,256.00', + '1,256.00', 'Breakdown', 'Deposit', ]; diff --git a/libs/accounts/src/lib/accounts-table.tsx b/libs/accounts/src/lib/accounts-table.tsx index 1a3d34f35..96126354c 100644 --- a/libs/accounts/src/lib/accounts-table.tsx +++ b/libs/accounts/src/lib/accounts-table.tsx @@ -1,21 +1,11 @@ import { forwardRef, useState } from 'react'; -import type { ValueFormatterParams } from 'ag-grid-community'; import { addDecimalsFormatNumber, isNumeric, t, } from '@vegaprotocol/react-helpers'; -import type { - ValueProps, - VegaICellRendererParams, -} from '@vegaprotocol/ui-toolkit'; -import { - Button, - ButtonLink, - Dialog, - Intent, - progressBarCellRendererSelector, -} from '@vegaprotocol/ui-toolkit'; +import type { VegaICellRendererParams } from '@vegaprotocol/ui-toolkit'; +import { Button, ButtonLink, Dialog } from '@vegaprotocol/ui-toolkit'; import { TooltipCellComponent } from '@vegaprotocol/ui-toolkit'; import { AgGridDynamic as AgGrid } from '@vegaprotocol/ui-toolkit'; import { AgGridColumn } from 'ag-grid-react'; @@ -25,33 +15,6 @@ import type { VegaValueFormatterParams } from '@vegaprotocol/ui-toolkit'; import BreakdownTable from './breakdown-table'; import type { AccountFields } from './accounts-data-provider'; -export const progressBarValueFormatter = ({ - data, - node, -}: ValueFormatterParams): ValueProps['valueFormatted'] | undefined => { - if (!data || node?.rowPinned) { - return undefined; - } - const min = BigInt(data.used); - const mid = BigInt(data.available); - const max = BigInt(data.deposited); - const range = max > min ? max : min; - return { - low: addDecimalsFormatNumber(min.toString(), data.asset.decimals, 4), - high: addDecimalsFormatNumber(mid.toString(), data.asset.decimals, 4), - value: range ? Number((min * BigInt(100)) / range) : 0, - intent: Intent.Warning, - }; -}; - -export const progressBarHeaderComponentParams = { - template: - '', -}; - export interface GetRowsParams extends Omit { successCallback(rowsThisBlock: AccountFields[], lastRow?: number): void; } @@ -134,12 +97,36 @@ export const AccountTable = forwardRef( ) => + data && + data.asset && + isNumeric(value) && + addDecimalsFormatNumber(value, data.asset.decimals) + } + maxWidth={300} + /> + ) => + data && + data.asset && + isNumeric(value) && + addDecimalsFormatNumber(value, data.asset.decimals) + } + maxWidth={300} /> { + if (!data || node?.rowPinned) { + return undefined; + } + const min = BigInt(data.used); + const mid = BigInt(data.available); + const max = BigInt(data.deposited); + const range = max > min ? max : min; + return { + low: addDecimalsFormatNumber(min.toString(), data.asset.decimals, 4), + high: addDecimalsFormatNumber(mid.toString(), data.asset.decimals, 4), + value: range ? Number((min * BigInt(100)) / range) : 0, + intent: Intent.Warning, + }; +}; + +export const progressBarHeaderComponentParams = { + template: + '', +}; interface BreakdownTableProps extends AgGridReactProps { data: AccountFields[] | null;