From 1ed681ae6ca93385321b7a993a902bfa616df5ae Mon Sep 17 00:00:00 2001 From: Sampo Tawast Date: Tue, 12 Nov 2024 09:45:27 +0200 Subject: [PATCH] fix: only show list of instalments if application is in payment --- .../applicationList/HandlerIndex.tsx | 20 ++++++++++--------- .../DecisionCalculationAccordion.tsx | 3 ++- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/frontend/benefit/handler/src/components/applicationList/HandlerIndex.tsx b/frontend/benefit/handler/src/components/applicationList/HandlerIndex.tsx index ab9ea1a369..971b7224a5 100644 --- a/frontend/benefit/handler/src/components/applicationList/HandlerIndex.tsx +++ b/frontend/benefit/handler/src/components/applicationList/HandlerIndex.tsx @@ -3,6 +3,7 @@ import { APPLICATION_LIST_TABS, } from 'benefit/handler/constants'; import FrontPageProvider from 'benefit/handler/context/FrontPageProvider'; +import { Application } from 'benefit/handler/types/application'; import { APPLICATION_STATUSES, BATCH_STATUSES } from 'benefit-shared/constants'; import { ApplicationListItemData } from 'benefit-shared/types/application'; import { LoadingSpinner, Tabs } from 'hds-react'; @@ -34,11 +35,20 @@ const isBatchStatusHandlingComplete = (batchStatus: BATCH_STATUSES): boolean => BATCH_STATUSES.REJECTED_BY_TALPA, ].includes(batchStatus); -const isAcceptedOrRejected = (status: APPLICATION_STATUSES): boolean => +export const isAcceptedOrRejected = (status: APPLICATION_STATUSES): boolean => [APPLICATION_STATUSES.ACCEPTED, APPLICATION_STATUSES.REJECTED].includes( status ); +export const isInPayment = ( + application: ApplicationListItemData | Application +): boolean => + [APPLICATION_STATUSES.ACCEPTED].includes(application.status) && + !isString(application.batch) && + [BATCH_STATUSES.DECIDED_ACCEPTED, BATCH_STATUSES.REJECTED_BY_TALPA].includes( + application?.batch?.status + ); + const HandlerIndex: React.FC = ({ layoutBackgroundColor, list = [], @@ -57,14 +67,6 @@ const HandlerIndex: React.FC = ({ | 'instalments' ): string => t(`${translationBase}.${headingStatus}`); - const isInPayment = (application: ApplicationListItemData): boolean => - [APPLICATION_STATUSES.ACCEPTED].includes(application.status) && - !isString(application.batch) && - [ - BATCH_STATUSES.DECIDED_ACCEPTED, - BATCH_STATUSES.REJECTED_BY_TALPA, - ].includes(application?.batch?.status); - const getTabCountPending = (): number => list.filter( (app: ApplicationListItemData) => diff --git a/frontend/benefit/handler/src/components/applicationReview/handlingView/DecisionCalculationAccordion.tsx b/frontend/benefit/handler/src/components/applicationReview/handlingView/DecisionCalculationAccordion.tsx index ab7aac6581..65f8f4b014 100644 --- a/frontend/benefit/handler/src/components/applicationReview/handlingView/DecisionCalculationAccordion.tsx +++ b/frontend/benefit/handler/src/components/applicationReview/handlingView/DecisionCalculationAccordion.tsx @@ -27,6 +27,7 @@ import { formatFloatToCurrency } from 'shared/utils/string.utils'; import { useTheme } from 'styled-components'; import { renderInstalmentTagPerStatus } from '../../applicationList/ApplicationListForInstalments'; +import { isInPayment } from '../../applicationList/HandlerIndex'; import { $CalculatorTableHeader, $CalculatorTableRow, @@ -158,7 +159,7 @@ const DecisionCalculationAccordion: React.FC = ({ data }) => { - {data.pendingInstalment && ( + {data.pendingInstalment && isInPayment(data) && ( <$DecisionCalculatorAccordion> <$DecisionCalculatorAccordionIconContainer aria-hidden="true">