Skip to content

Commit 04b19b2

Browse files
committed
refactor(tangle-dapp): Cleanup unstake & withdraw restake tables
1 parent e66a476 commit 04b19b2

File tree

16 files changed

+153
-175
lines changed

16 files changed

+153
-175
lines changed

apps/tangle-dapp/src/components/LiquidStaking/LsUnbondingTable.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import {
1313
TANGLE_DOCS_LIQUID_STAKING_URL,
1414
Typography,
1515
} from '@webb-tools/webb-ui-components';
16-
import { TableVariant } from '@webb-tools/webb-ui-components/components/Table/types';
1716
import addCommasToNumber from '@webb-tools/webb-ui-components/utils/addCommasToNumber';
1817
import pluralize from '@webb-tools/webb-ui-components/utils/pluralize';
1918
import { FC, useMemo, useState } from 'react';
@@ -177,7 +176,6 @@ const LsUnbondingTable: FC = () => {
177176

178177
return (
179178
<Table
180-
variant={TableVariant.DEFAULT}
181179
tableProps={table}
182180
title={pluralize('unstake request', rows.length !== 1)}
183181
isPaginated

apps/tangle-dapp/src/components/LiquidStaking/LsValidatorTable.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import {
2121
Table,
2222
Typography,
2323
} from '@webb-tools/webb-ui-components';
24-
import { TableVariant } from '@webb-tools/webb-ui-components/components/Table/types';
2524
import pluralize from '@webb-tools/webb-ui-components/utils/pluralize';
2625
import { useEffect, useMemo, useRef, useState } from 'react';
2726

@@ -192,11 +191,7 @@ export const LsValidatorTable = () => {
192191
debounceTime={300}
193192
/>
194193

195-
<Table
196-
variant={TableVariant.DEFAULT}
197-
tableProps={table}
198-
totalRecords={tableData.length}
199-
/>
194+
<Table tableProps={table} totalRecords={tableData.length} />
200195
</div>
201196

202197
{data.length > DEFAULT_PAGINATION.pageSize && (

apps/tangle-dapp/src/components/NominationsTable/NominationsTable.tsx

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import {
2222
Table,
2323
Typography,
2424
} from '@webb-tools/webb-ui-components';
25-
import { TableVariant } from '@webb-tools/webb-ui-components/components/Table/types';
2625
import { FC, useState } from 'react';
2726

2827
import calculateCommission from '../../utils/calculateCommission';
@@ -31,10 +30,10 @@ import PercentageCell from '../tableCells/PercentageCell';
3130
import TokenAmountCell from '../tableCells/TokenAmountCell';
3231
import pluralize from '@webb-tools/webb-ui-components/utils/pluralize';
3332

34-
const columnHelper = createColumnHelper<Nominee>();
33+
const COLUMN_HELPER = createColumnHelper<Nominee>();
3534

36-
const columns = [
37-
columnHelper.accessor('address', {
35+
const COLUMNS = [
36+
COLUMN_HELPER.accessor('address', {
3837
header: () => <HeaderCell title="Validator" className="justify-start" />,
3938
cell: (props) => {
4039
const address = props.getValue();
@@ -62,7 +61,7 @@ const columns = [
6261
},
6362
sortingFn: getSortAddressOrIdentityFnc<Nominee>(),
6463
}),
65-
columnHelper.accessor('isActive', {
64+
COLUMN_HELPER.accessor('isActive', {
6665
header: () => <HeaderCell title="Status" className="justify-start" />,
6766
cell: (props) => {
6867
const isActive = props.getValue();
@@ -77,12 +76,12 @@ const columns = [
7776
return isActiveA ? 1 : -1;
7877
},
7978
}),
80-
columnHelper.accessor('selfStakeAmount', {
79+
COLUMN_HELPER.accessor('selfStakeAmount', {
8180
header: () => <HeaderCell title="Self-staked" className="justify-center" />,
8281
cell: (props) => <TokenAmountCell amount={props.getValue()} />,
8382
sortingFn: sortBnValueForNomineeOrValidator,
8483
}),
85-
columnHelper.accessor('totalStakeAmount', {
84+
COLUMN_HELPER.accessor('totalStakeAmount', {
8685
header: () => (
8786
<HeaderCell title="Effective amount staked" className="justify-center" />
8887
),
@@ -94,13 +93,13 @@ const columns = [
9493
),
9594
sortingFn: sortBnValueForNomineeOrValidator,
9695
}),
97-
columnHelper.accessor('nominatorCount', {
96+
COLUMN_HELPER.accessor('nominatorCount', {
9897
header: () => <HeaderCell title="Nominations" className="justify-center" />,
9998
cell: (props) => (
10099
<StringCell value={props.getValue().toString()} className="text-start" />
101100
),
102101
}),
103-
columnHelper.accessor('commission', {
102+
COLUMN_HELPER.accessor('commission', {
104103
header: () => <HeaderCell title="Commission" className="justify-center" />,
105104
cell: (props) => (
106105
<PercentageCell percentage={calculateCommission(props.getValue())} />
@@ -125,7 +124,7 @@ const NominationsTable: FC<NominationsTableProps> = ({
125124

126125
const table = useReactTable({
127126
data: nominees,
128-
columns,
127+
columns: COLUMNS,
129128
initialState: {
130129
pagination: {
131130
pageSize,
@@ -149,7 +148,6 @@ const NominationsTable: FC<NominationsTableProps> = ({
149148
return (
150149
<div className="overflow-hidden border rounded-lg bg-mono-0 dark:bg-mono-180 border-mono-40 dark:border-mono-160">
151150
<Table
152-
variant={TableVariant.DEFAULT}
153151
thClassName="border-t-0 bg-mono-0"
154152
paginationClassName="bg-mono-0 dark:bg-mono-180 pl-6"
155153
tableProps={table}

apps/tangle-dapp/src/components/PayoutTable/PayoutTable.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import {
2525
Table,
2626
Typography,
2727
} from '@webb-tools/webb-ui-components';
28-
import { TableVariant } from '@webb-tools/webb-ui-components/components/Table/types';
2928
import pluralize from '@webb-tools/webb-ui-components/utils/pluralize';
3029
import { type FC, useState } from 'react';
3130

@@ -243,7 +242,6 @@ const PayoutTable: FC<PayoutTableProps> = ({
243242
<>
244243
<div className="overflow-hidden border rounded-lg bg-mono-0 dark:bg-mono-180 border-mono-40 dark:border-mono-160">
245244
<Table
246-
variant={TableVariant.DEFAULT}
247245
tableProps={table}
248246
isPaginated
249247
totalRecords={data.length}

apps/tangle-dapp/src/components/ValidatorTable/ValidatorTable.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import {
2525
Table,
2626
Typography,
2727
} from '@webb-tools/webb-ui-components';
28-
import { TableVariant } from '@webb-tools/webb-ui-components/components/Table/types';
2928
import pluralize from '@webb-tools/webb-ui-components/utils/pluralize';
3029
import { Link } from 'react-router';
3130
import { FC, useMemo, useState } from 'react';
@@ -203,7 +202,6 @@ const ValidatorTable: FC<ValidatorTableProps> = ({
203202

204203
return (
205204
<Table
206-
variant={TableVariant.DEFAULT}
207205
trClassName={IS_PRODUCTION_ENV ? '' : 'cursor-pointer'}
208206
tableProps={table}
209207
isPaginated

apps/tangle-dapp/src/data/useIdentities.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,18 @@ const useIdentities = (
2121
);
2222

2323
const identityNames = useMemo(() => {
24-
if (result === null) return [];
24+
if (result === null) {
25+
return [];
26+
}
2527

26-
return result.map((identityResult, idx) => {
28+
return result.map((identityResult, index) => {
2729
if (identityResult.isNone) {
28-
return [addresses[idx], null] as const;
30+
return [addresses[index], null] as const;
2931
}
3032

3133
const info = extractIdentityInfo(identityResult.unwrap()[0]);
3234

33-
return [addresses[idx], info] as const;
35+
return [addresses[index], info] as const;
3436
});
3537
}, [addresses, result]);
3638

apps/tangle-dapp/src/pages/nomination/[validatorAddress]/NodeSpecificationsTable.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
} from '@tanstack/react-table';
99
import TableStatus from '@webb-tools/tangle-shared-ui/components/tables/TableStatus';
1010
import { fuzzyFilter, Table, Typography } from '@webb-tools/webb-ui-components';
11-
import { TableVariant } from '@webb-tools/webb-ui-components/components/Table/types';
1211
import cx from 'classnames';
1312
import { FC } from 'react';
1413

@@ -113,11 +112,7 @@ const NodeSpecificationsTable: FC<NodeSpecificationsTableProps> = ({
113112

114113
{/* Success; show the table */}
115114
{!isLoading && error === null && nodeSpecifications.length > 0 && (
116-
<Table
117-
variant={TableVariant.DEFAULT}
118-
tableProps={table}
119-
totalRecords={nodeSpecifications.length}
120-
/>
115+
<Table tableProps={table} totalRecords={nodeSpecifications.length} />
121116
)}
122117
</div>
123118
</div>

apps/tangle-dapp/src/pages/restake/overview/OperatorsTable.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ const OperatorsTable: FC<Props> = ({
4141
([addressString, { delegations, restakersCount }]) => {
4242
const address = assertSubstrateAddress(addressString);
4343
const tvlInUsd = operatorTVL?.[address] ?? null;
44+
4445
const concentrationPercentage =
4546
operatorConcentration?.[address] ?? null;
4647

0 commit comments

Comments
 (0)