fix(liquidity): use LP order ID as ag-grid row ID (#3615)
This commit is contained in:
parent
7b15d2db10
commit
85e293f3ec
@ -22,7 +22,6 @@ import type {
|
||||
LiquidityProvisionsQueryVariables,
|
||||
LiquidityProvisionsUpdateSubscription,
|
||||
} from './__generated__/MarketLiquidity';
|
||||
import type { IterableElement } from 'type-fest';
|
||||
|
||||
export const liquidityProvisionsDataProvider = makeDataProvider<
|
||||
LiquidityProvisionsQuery,
|
||||
@ -39,8 +38,8 @@ export const liquidityProvisionsDataProvider = makeDataProvider<
|
||||
) => {
|
||||
return produce(data || [], (draft) => {
|
||||
deltas?.forEach((delta) => {
|
||||
const id = getId(delta);
|
||||
const index = draft.findIndex((a) => getId(a) === id);
|
||||
const id = delta.id;
|
||||
const index = draft.findIndex((a) => delta.id === id);
|
||||
if (index !== -1) {
|
||||
draft[index].commitmentAmount = delta.commitmentAmount;
|
||||
draft[index].fee = delta.fee;
|
||||
@ -76,27 +75,6 @@ export const liquidityProvisionsDataProvider = makeDataProvider<
|
||||
},
|
||||
});
|
||||
|
||||
function isLpFragment(
|
||||
entry:
|
||||
| LiquidityProvisionFieldsFragment
|
||||
| IterableElement<
|
||||
LiquidityProvisionsUpdateSubscription['liquidityProvisions']
|
||||
>
|
||||
): entry is LiquidityProvisionFieldsFragment {
|
||||
return entry.__typename === 'LiquidityProvision';
|
||||
}
|
||||
|
||||
export const getId = (
|
||||
entry:
|
||||
| LiquidityProvisionFieldsFragment
|
||||
| IterableElement<
|
||||
LiquidityProvisionsUpdateSubscription['liquidityProvisions']
|
||||
>
|
||||
) =>
|
||||
isLpFragment(entry)
|
||||
? `${entry.party.id}${entry.status}${entry.createdAt}`
|
||||
: `${entry.partyID}${entry.status}${entry.createdAt}`;
|
||||
|
||||
export const marketLiquidityDataProvider = makeDataProvider<
|
||||
MarketLpQuery,
|
||||
MarketLpQuery,
|
||||
|
@ -17,7 +17,6 @@ import type { ValueFormatterParams } from 'ag-grid-community';
|
||||
import BigNumber from 'bignumber.js';
|
||||
import { LiquidityProvisionStatusMapping } from '@vegaprotocol/types';
|
||||
import type { LiquidityProvisionData } from './liquidity-data-provider';
|
||||
import { getId } from './liquidity-data-provider';
|
||||
|
||||
const percentageFormatter = ({ value }: ValueFormatterParams) => {
|
||||
if (!value) return '-';
|
||||
@ -56,7 +55,7 @@ export const LiquidityTable = forwardRef<AgGridReact, LiquidityTableProps>(
|
||||
<AgGrid
|
||||
style={{ width: '100%', height: '100%' }}
|
||||
overlayNoRowsTemplate={t('No liquidity provisions')}
|
||||
getRowId={({ data }) => getId(data)}
|
||||
getRowId={({ data }) => data.id}
|
||||
ref={ref}
|
||||
tooltipShowDelay={500}
|
||||
defaultColDef={{
|
||||
|
Loading…
Reference in New Issue
Block a user