Skip to content

Commit

Permalink
fix: show applications with 2nd instalments only they are in payment (#…
Browse files Browse the repository at this point in the history
…3528)

* fix: show applications with 2nd instalments only they are in payment

* fix: only show list of instalments if application is in payment
  • Loading branch information
sirtawast authored Nov 12, 2024
1 parent 1c2d9e4 commit db2f099
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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<ApplicationListProps> = ({
layoutBackgroundColor,
list = [],
Expand Down Expand Up @@ -67,7 +77,10 @@ const HandlerIndex: React.FC<ApplicationListProps> = ({
).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(
Expand Down Expand Up @@ -135,14 +148,6 @@ const HandlerIndex: React.FC<ApplicationListProps> = ({
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 (
<FrontPageProvider>
<$BackgroundWrapper backgroundColor={layoutBackgroundColor}>
Expand Down Expand Up @@ -287,7 +292,9 @@ const HandlerIndex: React.FC<ApplicationListProps> = ({
<Tabs.TabPanel>
<ApplicationListForInstalments
isLoading={isLoading}
list={list.filter((app) => app.pendingInstalment)}
list={list.filter(
(app) => app.pendingInstalment && isInPayment(app)
)}
heading={t(`${translationBase}.instalments`)}
/>
</Tabs.TabPanel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -158,7 +159,7 @@ const DecisionCalculationAccordion: React.FC<Props> = ({ data }) => {
</$GridCell>
</Accordion>
</$DecisionCalculatorAccordion>
{data.pendingInstalment && (
{data.pendingInstalment && isInPayment(data) && (
<$DecisionCalculatorAccordion>
<$DecisionCalculatorAccordionIconContainer aria-hidden="true">
<IconBagCogwheel />
Expand Down

0 comments on commit db2f099

Please sign in to comment.