Skip to content

Commit

Permalink
fix: remove list items that are handled with new ahjo mode (#3113)
Browse files Browse the repository at this point in the history
  • Loading branch information
sirtawast authored Jun 25, 2024
1 parent aff14ec commit 5ea5967
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ const ApplicationList: React.FC<ApplicationListProps> = ({
isLoading = true,
}) => {
const { t, translationsBase, getHeader } = useApplicationList();

const theme = useTheme();

const isAllStatuses: boolean = status === ALL_APPLICATION_STATUSES;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import useApplicationsQuery from 'benefit/handler/hooks/useApplicationsQuery';
import { useDetermineAhjoMode } from 'benefit/handler/hooks/useDetermineAhjoMode';
import { APPLICATION_STATUSES } from 'benefit-shared/constants';
import {
ApplicationData,
Expand All @@ -20,10 +21,11 @@ const useApplicationListData = (
status: APPLICATION_STATUSES[],
excludeBatched?: boolean
): ApplicationListProps => {
const isNewAhjoMode = useDetermineAhjoMode();
const query = useApplicationsQuery(status, '-submitted_at', excludeBatched);

const list = query.data?.map(
(application: ApplicationData): ApplicationListItemData => {
const list = query.data
?.map((application: ApplicationData): ApplicationListItemData => {
const {
id = '',
employee,
Expand All @@ -39,6 +41,7 @@ const useApplicationListData = (
talpa_status,
ahjo_case_id,
application_origin: applicationOrigin,
handled_by_ahjo_automation,
} = application;

return {
Expand All @@ -64,9 +67,18 @@ const useApplicationListData = (
applicationOrigin,
talpaStatus: talpa_status,
ahjoCaseId: ahjo_case_id,
handledByAhjoAutomation: handled_by_ahjo_automation,
};
}
);
})
.filter(
(application) =>
isNewAhjoMode ||
(![
APPLICATION_STATUSES.ACCEPTED,
APPLICATION_STATUSES.REJECTED,
].includes(application.status) &&
!application.handledByAhjoAutomation)
);

const shouldShowSkeleton = query.isLoading;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const useApplicationsHandled = (
(a: ApplicationData, b: ApplicationData): number =>
Date.parse(b.handled_at ?? '') - Date.parse(a.handled_at ?? '')
)
.filter((app: ApplicationData) => !app.handled_by_ahjo_automation)
.map((application: ApplicationData): ApplicationListItemData => {
const {
id = '',
Expand Down
1 change: 1 addition & 0 deletions frontend/benefit/shared/src/types/application.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,7 @@ export type ApplicationListItemData = {
talpaStatus?: string;
ahjoCaseId?: string;
calculationEndDate?: string;
handledByAhjoAutomation?: boolean;
};

export type TextProp = 'textFi' | 'textEn' | 'textSv';
Expand Down

0 comments on commit 5ea5967

Please sign in to comment.