Skip to content

Commit

Permalink
refactor: move applicant consent to edit view (hl-1171) (#2867)
Browse files Browse the repository at this point in the history
* fix: small tweaks to application review

* refactor: move applicant consent to edit view

* fix: do not diff for paper application when origin is applicant

* fix: do not diff for paper application when origin is applicant
  • Loading branch information
sirtawast authored Mar 4, 2024
1 parent ba5e2db commit e66bcce
Show file tree
Hide file tree
Showing 11 changed files with 55 additions and 52 deletions.
2 changes: 1 addition & 1 deletion frontend/benefit/handler/public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@
"review": {
"actions": {
"handle": "Ota käsittelyyn",
"edit": "Muokkaa hakemusta",
"edit": "Muokkaa",
"close": "Sulje",
"done": "Tee päätösehdotus",
"saveAndContinue": "Tallenna ja sulje",
Expand Down
2 changes: 1 addition & 1 deletion frontend/benefit/handler/public/locales/fi/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@
"review": {
"actions": {
"handle": "Ota käsittelyyn",
"edit": "Muokkaa hakemusta",
"edit": "Muokkaa",
"close": "Sulje",
"done": "Tee päätösehdotus",
"saveAndContinue": "Tallenna ja sulje",
Expand Down
2 changes: 1 addition & 1 deletion frontend/benefit/handler/public/locales/sv/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@
"review": {
"actions": {
"handle": "Ota käsittelyyn",
"edit": "Muokkaa hakemusta",
"edit": "Muokkaa",
"close": "Sulje",
"done": "Tee päätösehdotus",
"saveAndContinue": "Tallenna ja sulje",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,16 @@ const FormContent: React.FC<Props> = ({
/>
</$GridCell>
)}
{application.applicationOrigin === APPLICATION_ORIGINS.APPLICANT && (
<$GridCell $colSpan={12}>
<AttachmentsList
attachments={attachments}
attachmentType={ATTACHMENT_TYPES.EMPLOYEE_CONSENT}
handleQuietSave={handleQuietSave}
required
/>
</$GridCell>
)}
</FormSection>
<FormSection
paddingBottom
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { APPLICATION_FIELD_KEYS } from 'benefit/handler/constants';
import DeMinimisContext from 'benefit/handler/context/DeMinimisContext';
import { Application } from 'benefit/handler/types/application';
import { APPLICATION_ORIGINS } from 'benefit-shared/constants';
import deepDiff from 'deep-diff';
import { IconArrowRight } from 'hds-react';
import { useTranslation } from 'next-i18next';
Expand Down Expand Up @@ -63,7 +64,12 @@ const ReviewEditChanges: React.FC<ReviewEditChangesProps> = ({
const diff: Difference[] =
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
deepDiff(initialValues, currentValues, (path: string[], key: string) =>
getDiffPrefilter(path, key, requiredKeys)
getDiffPrefilter(
path,
key,
requiredKeys,
currentValues.applicationOrigin === APPLICATION_ORIGINS.HANDLER
)
) || [];
setChanges(diff);
// eslint-disable-next-line react-hooks/exhaustive-deps
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ export const getDeMinimisChanged = (
export const getDiffPrefilter = (
path: string[],
key: string,
requiredKeys: Set<APPLICATION_FIELD_KEYS>
requiredKeys: Set<APPLICATION_FIELD_KEYS>,
isOfHandlerOrigin: boolean
): boolean => {
if (path.length > 0 && path.includes('employee')) return false;
if (
Expand All @@ -102,6 +103,14 @@ export const getDiffPrefilter = (
].includes(key as APPLICATION_FIELD_KEYS)
)
return true;

if (
key === APPLICATION_FIELD_KEYS.PAPER_APPLICATION_DATE &&
!isOfHandlerOrigin
) {
return true;
}

const isRequiredKey = requiredKeys.has(key as APPLICATION_FIELD_KEYS);
return !isRequiredKey;
};
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
ApplicationFields,
} from 'benefit/handler/types/application';
import {
APPLICATION_ORIGINS,
APPLICATION_STATUSES,
ATTACHMENT_TYPES,
EMPLOYEE_KEYS,
Expand Down Expand Up @@ -52,7 +53,9 @@ const getApplication = (
...applicationData,
start_date: convertToUIDateFormat(applicationData.start_date),
end_date: convertToUIDateFormat(applicationData.end_date),
paper_application_date: convertToUIDateFormat(applicationData.paper_application_date),
paper_application_date: convertToUIDateFormat(
applicationData.paper_application_date
),
calculation: applicationData.calculation
? {
...applicationData.calculation,
Expand Down Expand Up @@ -222,11 +225,22 @@ const requiredAttachments = (
)
);
}

let hasApplicantConsent = true;
if (values.applicationOrigin === APPLICATION_ORIGINS.APPLICANT) {
hasApplicantConsent = !isEmpty(
values?.attachments?.find(
(att: BenefitAttachment) =>
att.attachmentType === ATTACHMENT_TYPES.EMPLOYEE_CONSENT
)
);
}
return (
hasWorkContract &&
hasFullApplication &&
hasPaySubsidyDecision &&
hasApprenticeshipProgram
hasApprenticeshipProgram &&
hasApplicantConsent
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,7 @@ import useLocale from 'shared/hooks/useLocale';
import { capitalize } from 'shared/utils/string.utils';
import { useTheme } from 'styled-components';

import ConsentActions from './consentActions/ConsentActions';

const ConsentView: React.FC<ApplicationReviewViewProps> = ({
data,
isUploading,
handleUpload,
}) => {
const ConsentView: React.FC<ApplicationReviewViewProps> = ({ data }) => {
const translationsBase = 'common:review';
const { t } = useTranslation();
const cbPrefix = 'application_consent';
Expand All @@ -30,16 +24,10 @@ const ConsentView: React.FC<ApplicationReviewViewProps> = ({
const theme = useTheme();
return (
<ReviewSection
id={data.id}
header={t(`${translationsBase}.headings.heading9`)}
section="approval"
action={
!ACTIONLESS_STATUSES.includes(data.status) ? (
<ConsentActions
isUploading={isUploading}
handleUpload={handleUpload}
/>
) : null
}
action={!ACTIONLESS_STATUSES.includes(data.status) ? true : null}
>
{data.applicationOrigin === APPLICATION_ORIGINS.APPLICANT ? (
<$GridCell $colSpan={12}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,16 @@ import { $GridCell } from 'shared/components/forms/section/FormSection.sc';
import { getFullName } from 'shared/utils/application.utils';

import AttachmentsListView from '../../attachmentsListView/AttachmentsListView';
import EmployeeActions from './EmployeeActions/EmployeeActions';

const EmployeeView: React.FC<ApplicationReviewViewProps> = ({
data,
handleUpload,
isUploading,
}) => {
const EmployeeView: React.FC<ApplicationReviewViewProps> = ({ data }) => {
const translationsBase = 'common:review';
const { t } = useTranslation();
return (
<ReviewSection
id={data.id}
header={t(`${translationsBase}.headings.heading5`)}
section="employee"
action={
!ACTIONLESS_STATUSES.includes(data.status) ? (
<EmployeeActions
handleUpload={handleUpload}
isUploading={isUploading}
/>
) : null
}
action={!ACTIONLESS_STATUSES.includes(data.status) ? true : null}
>
<$GridCell $colSpan={6}>
<$ViewFieldBold large>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,16 @@ import { $GridCell } from 'shared/components/forms/section/FormSection.sc';
import { formatFloatToCurrency } from 'shared/utils/string.utils';

import AttachmentsListView from '../../attachmentsListView/AttachmentsListView';
import EmploymentActions from './employmentActions/EmploymentActions';

const EmploymentView: React.FC<ApplicationReviewViewProps> = ({
data,
isUploading,
handleUpload,
}) => {
const EmploymentView: React.FC<ApplicationReviewViewProps> = ({ data }) => {
const translationsBase = 'common:review';
const { t } = useTranslation();
return (
<ReviewSection
id={data.id}
header={t(`${translationsBase}.headings.heading8`)}
section="employment"
action={
!ACTIONLESS_STATUSES.includes(data.status) ? (
<EmploymentActions
handleUpload={handleUpload}
isUploading={isUploading}
/>
) : null
}
action={!ACTIONLESS_STATUSES.includes(data.status) ? true : null}
>
<$GridCell $colSpan={6} $colStart={1}>
<$ViewFieldBold>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const $CheckIconFill = styled(IconCheckCircleFill)`

export const $EditButtonContainer = styled.div`
position: absolute;
top: 0;
right: 0;
top: 18px;
right: 18px;
z-index: 99;
`;

0 comments on commit e66bcce

Please sign in to comment.