Skip to content

Commit

Permalink
fix: filter batches using auto_generated_by_ahjo value (hl-1304) (#2979)
Browse files Browse the repository at this point in the history
* fix: filter batches using auto_generated_by_ahjo value

* fix: new ahjo ui filters out batched applications differently

* test(applicant): last day would not sometimes be applied using subMonths
  • Loading branch information
sirtawast committed May 10, 2024
1 parent e7240ff commit f6a8c64
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { HttpRequestHook } from '@frontend/shared/browser-tests/http-utils/http-
import requestLogger from '@frontend/shared/browser-tests/utils/request-logger';
import { clearDataToPrintOnFailure } from '@frontend/shared/browser-tests/utils/testcafe.utils';
import { convertToUIDateFormat } from '@frontend/shared/src/utils/date.utils';
import { addMonths, subMonths } from 'date-fns';
import addDays from 'date-fns/addDays';
import subMonths from 'date-fns/subMonths';
import { t } from 'testcafe';

import DeMinimisAid from '../page-model/deminimis';
Expand All @@ -28,7 +29,7 @@ fixture('Company')
});

const startDate = subMonths(new Date(), 4);
const endDate = addMonths(new Date(), 3);
const endDate = addDays(startDate, 30);
const form: ApplicationFormData = {
organization: {
iban: '6051437344779954',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,16 @@ const HandlerIndex: React.FC<ApplicationListProps> = ({
[APPLICATION_STATUSES.ACCEPTED].includes(app.status)
).length;

const getTabCountAll = (): number =>
list.filter((app: ApplicationListItemData) => !app.batch).length;

const getTabCount = (
statuses: APPLICATION_STATUSES[],
handled?: 'inPayment' | 'pending'
): number => {
if (handled === 'pending') return getTabCountPending();
if (handled === 'inPayment') return getTabCountInPayment();
if (handled === 'all') return getTabCountAll();
return list.filter((app: ApplicationListItemData) =>
statuses.includes(app.status)
).length;
Expand Down Expand Up @@ -133,7 +137,7 @@ const HandlerIndex: React.FC<ApplicationListProps> = ({
<Tabs.TabPanel>
<ApplicationList
isLoading={isLoading}
list={list}
list={list.filter((app) => !app.batch)}
heading={t(`${translationBase}.all`)}
status={ALL_APPLICATION_STATUSES}
/>
Expand Down
5 changes: 3 additions & 2 deletions frontend/benefit/handler/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,13 @@ const ApplicantIndex: NextPage = () => {

const translationBase = 'common:applications.list.headings';

const isNewAhjoMode = useDetermineAhjoMode();

const { list, shouldShowSkeleton } = useApplicationListData(
ALL_APPLICATION_STATUSES,
true
!isNewAhjoMode
);
const { t } = useApplicationList();
const isNewAhjoMode = useDetermineAhjoMode();

const getHeadingTranslation = (
headingStatus: APPLICATION_STATUSES | 'all'
Expand Down

0 comments on commit f6a8c64

Please sign in to comment.