From eb0ac9b8a7e9faa8dace7fc3af433aa551dac7ea Mon Sep 17 00:00:00 2001 From: Sampo Tawast Date: Mon, 11 Nov 2024 09:52:11 +0200 Subject: [PATCH 1/2] fix: show applications with 2nd instalments only they are in payment --- .../applicationList/HandlerIndex.tsx | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/frontend/benefit/handler/src/components/applicationList/HandlerIndex.tsx b/frontend/benefit/handler/src/components/applicationList/HandlerIndex.tsx index 149688f059..ab9ea1a369 100644 --- a/frontend/benefit/handler/src/components/applicationList/HandlerIndex.tsx +++ b/frontend/benefit/handler/src/components/applicationList/HandlerIndex.tsx @@ -57,6 +57,14 @@ 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) => @@ -67,7 +75,10 @@ const HandlerIndex: React.FC = ({ ).length; const getTabCountInstalments = (): number => - list.filter((app: ApplicationListItemData) => app.pendingInstalment).length; + list.filter( + (app: ApplicationListItemData) => + app.pendingInstalment && isInPayment(app) + ).length; const getTabCountInPayment = (): number => list.filter( @@ -135,14 +146,6 @@ const HandlerIndex: React.FC = ({ const updateTabToUrl = (tabNumber: APPLICATION_LIST_TABS): void => window.history.pushState({ tab }, '', `/?tab=${tabNumber}`); - 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); - return ( <$BackgroundWrapper backgroundColor={layoutBackgroundColor}> @@ -287,7 +290,9 @@ const HandlerIndex: React.FC = ({ app.pendingInstalment)} + list={list.filter( + (app) => app.pendingInstalment && isInPayment(app) + )} heading={t(`${translationBase}.instalments`)} /> From a769c58b3f1fc205de64627ffcd42f3331b6757c Mon Sep 17 00:00:00 2001 From: Sampo Tawast Date: Tue, 12 Nov 2024 09:45:27 +0200 Subject: [PATCH 2/2] 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">