Skip to content

Commit

Permalink
fix: only show list of instalments if application is in payment
Browse files Browse the repository at this point in the history
  • Loading branch information
sirtawast committed Nov 12, 2024
1 parent eb0ac9b commit 1ed681a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 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 All @@ -57,14 +67,6 @@ const HandlerIndex: React.FC<ApplicationListProps> = ({
| '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) =>
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 1ed681a

Please sign in to comment.