From 3802549ed22d96f90c02fdf549ff1e237127aefa Mon Sep 17 00:00:00 2001 From: Radu Mojic Date: Tue, 20 Feb 2024 14:54:15 +0200 Subject: [PATCH] fix index issues --- src/helpers/getValue/getExpandRowDetails.ts | 23 +++++++++++---------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/helpers/getValue/getExpandRowDetails.ts b/src/helpers/getValue/getExpandRowDetails.ts index 382e02563..44faf1268 100644 --- a/src/helpers/getValue/getExpandRowDetails.ts +++ b/src/helpers/getValue/getExpandRowDetails.ts @@ -21,11 +21,12 @@ export const getExpandRowDetails = (nodes: NodeType[] = []) => { remainingDangerZoneValidators, remainingNotQualifiedValidators; - const qualifiedNotInDangerZoneValidators = nodes.filter( - (node) => node.auctionQualified && !node.isInDangerZone - ); - const dangerZoneValidators = nodes.filter((nodes) => nodes.isInDangerZone); - const notQualifiedValidators = nodes.filter((node) => !node.auctionQualified); + const qualifiedNotInDangerZoneValidators = + nodes.filter((node) => node.auctionQualified && !node.isInDangerZone) ?? []; + const dangerZoneValidators = + nodes.filter((nodes) => nodes.isInDangerZone) ?? []; + const notQualifiedValidators = + nodes.filter((node) => !node.auctionQualified) ?? []; if ( hasMinElements && @@ -36,10 +37,10 @@ export const getExpandRowDetails = (nodes: NodeType[] = []) => { qualifiedExpandPosition = qualifiedNotInDangerZoneValidators[AUCTION_LIST_EXPAND_ROW_POSITION] - .auctionPosition; + ?.auctionPosition; qualifiedExpandClosePosition = - qualifiedNotInDangerZoneValidators[closeIndex].auctionPosition; + qualifiedNotInDangerZoneValidators[closeIndex]?.auctionPosition; remainingQualifiedValidators = qualifiedNotInDangerZoneValidators.length - @@ -49,10 +50,10 @@ export const getExpandRowDetails = (nodes: NodeType[] = []) => { const closeIndex = dangerZoneValidators.length - 1 - closedRowPosition; dangerZoneExpandPosition = - dangerZoneValidators[AUCTION_LIST_EXPAND_ROW_POSITION].auctionPosition; + dangerZoneValidators[AUCTION_LIST_EXPAND_ROW_POSITION]?.auctionPosition; dangerZoneExpandClosePosition = - dangerZoneValidators[closeIndex].auctionPosition; + dangerZoneValidators[closeIndex]?.auctionPosition; remainingDangerZoneValidators = dangerZoneValidators.length - AUCTION_LIST_MIN_DISPLAY_ROW_COUNT; @@ -62,10 +63,10 @@ export const getExpandRowDetails = (nodes: NodeType[] = []) => { notQualifiedExpandPosition = qualifiedNotInDangerZoneValidators[AUCTION_LIST_EXPAND_ROW_POSITION] - .auctionPosition; + ?.auctionPosition; notQualifiedExpandClosePosition = - notQualifiedValidators[closeIndex].auctionPosition; + notQualifiedValidators[closeIndex]?.auctionPosition; remainingNotQualifiedValidators = notQualifiedValidators.length - AUCTION_LIST_MIN_DISPLAY_ROW_COUNT;