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
  • Loading branch information
sirtawast committed Nov 12, 2024
1 parent 1c2d9e4 commit eb0ac9b
Showing 1 changed file with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ 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 All @@ -67,7 +75,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 +146,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 +290,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

0 comments on commit eb0ac9b

Please sign in to comment.