Skip to content

Commit

Permalink
fix(handler): add missing column "modifiedAt" for draft list (HL-914) (
Browse files Browse the repository at this point in the history
…#2928)

* fix(handler): add column 'modifiedAt' for drafts

* refactor(handler): use a var to pass complexity requirements
  • Loading branch information
sirtawast committed Apr 18, 2024
1 parent 155bca7 commit d7ac20a
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 5 deletions.
1 change: 1 addition & 0 deletions frontend/benefit/handler/public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@
"companyName": "Työnantaja",
"companyId": "Y-tunnus",
"submittedAt": "Saapunut",
"modifiedAt": "Muokattu",
"applicationNum": "Hakemusnumero",
"employeeName": "Työllistetty",
"employeeNameArchive": "Työllistetty",
Expand Down
1 change: 1 addition & 0 deletions frontend/benefit/handler/public/locales/fi/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@
"companyName": "Työnantaja",
"companyId": "Y-tunnus",
"submittedAt": "Saapunut",
"modifiedAt": "Muokattu",
"applicationNum": "Hakemusnumero",
"employeeName": "Työllistetty",
"employeeNameArchive": "Työllistetty",
Expand Down
1 change: 1 addition & 0 deletions frontend/benefit/handler/public/locales/sv/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@
"companyName": "Työnantaja",
"companyId": "Y-tunnus",
"submittedAt": "Saapunut",
"modifiedAt": "Muokattu",
"applicationNum": "Hakemusnumero",
"employeeName": "Työllistetty",
"employeeNameArchive": "Työllistetty",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,18 @@ const ApplicationList: React.FC<ApplicationListProps> = ({
const theme = useTheme();

const isAllStatuses: boolean = status === ALL_APPLICATION_STATUSES;
const isVisibleOnlyForStatus = React.useMemo(
() => ({
draft: status.includes(APPLICATION_STATUSES.DRAFT) && !isAllStatuses,
received:
status.includes(APPLICATION_STATUSES.RECEIVED) && !isAllStatuses,
handling:
status.includes(APPLICATION_STATUSES.HANDLING) && !isAllStatuses,
infoRequired:
status.includes(APPLICATION_STATUSES.INFO_REQUIRED) && !isAllStatuses,
}),
[isAllStatuses, status]
);

const columns = React.useMemo(() => {
const cols: ApplicationListTableColumns[] = [
Expand Down Expand Up @@ -95,7 +107,7 @@ const ApplicationList: React.FC<ApplicationListProps> = ({
},
];

if (status.includes(APPLICATION_STATUSES.HANDLING) && !isAllStatuses) {
if (isVisibleOnlyForStatus.handling) {
cols.push({
headerName: getHeader('handlerName'),
key: 'handlerName',
Expand All @@ -112,6 +124,15 @@ const ApplicationList: React.FC<ApplicationListProps> = ({
});
}

if (isVisibleOnlyForStatus.draft) {
cols.push({
headerName: getHeader('modifiedAt'),
key: 'modifiedAt',
isSortable: true,
customSortCompareFunction: sortFinnishDate,
});
}

if (isAllStatuses) {
cols.push({
transform: ({
Expand All @@ -133,7 +154,7 @@ const ApplicationList: React.FC<ApplicationListProps> = ({
});
}

if (status.includes(APPLICATION_STATUSES.RECEIVED) && !isAllStatuses) {
if (isVisibleOnlyForStatus.received) {
cols.push({
transform: ({ applicationOrigin }: ApplicationListTableTransforms) => (
<div>
Expand All @@ -152,7 +173,7 @@ const ApplicationList: React.FC<ApplicationListProps> = ({
});
}

if (status.includes(APPLICATION_STATUSES.INFO_REQUIRED) && !isAllStatuses) {
if (isVisibleOnlyForStatus.infoRequired) {
cols.push({
transform: ({
additionalInformationNeededBy,
Expand Down Expand Up @@ -197,7 +218,7 @@ const ApplicationList: React.FC<ApplicationListProps> = ({
});

return cols.filter(Boolean);
}, [t, getHeader, status, theme, isAllStatuses]);
}, [t, getHeader, status, theme, isAllStatuses, isVisibleOnlyForStatus]);

if (isLoading) {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ import {
ApplicationListItemData,
} from 'benefit-shared/types/application';
import { getFullName } from 'shared/utils/application.utils';
import { convertToUIDateFormat } from 'shared/utils/date.utils';
import {
convertToUIDateAndTimeFormat,
convertToUIDateFormat,
} from 'shared/utils/date.utils';

interface ApplicationListProps {
list: ApplicationListItemData[];
Expand All @@ -26,6 +29,7 @@ const useApplicationListData = (
employee,
company,
submitted_at,
modified_at,
application_number: applicationNum,
calculation,
additional_information_needed_by,
Expand All @@ -43,6 +47,7 @@ const useApplicationListData = (
employeeName:
getFullName(employee?.first_name, employee?.last_name) || '-',
submittedAt: convertToUIDateFormat(submitted_at) || '-',
modifiedAt: convertToUIDateAndTimeFormat(modified_at) || '-',
additionalInformationNeededBy:
convertToUIDateFormat(additional_information_needed_by) || '-',
applicationNum,
Expand Down

0 comments on commit d7ac20a

Please sign in to comment.