From e66bcce85467c522422bf5ed43f694dbdb697ebd Mon Sep 17 00:00:00 2001 From: Sampo Tawast <5328394+sirtawast@users.noreply.github.com> Date: Mon, 4 Mar 2024 13:41:39 +0200 Subject: [PATCH] refactor: move applicant consent to edit view (hl-1171) (#2867) * 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 --- .../handler/public/locales/en/common.json | 2 +- .../handler/public/locales/fi/common.json | 2 +- .../handler/public/locales/sv/common.json | 2 +- .../formContent/FormContent.tsx | 10 ++++++++++ .../reviewChanges/ReviewEditChanges.tsx | 8 +++++++- .../applicationForm/reviewChanges/utils.ts | 11 ++++++++++- .../applicationForm/utils/applicationForm.ts | 18 ++++++++++++++++-- .../consentView/ConsentView.tsx | 18 +++--------------- .../employeeView/EmployeeView.tsx | 16 ++-------------- .../employmentView/EmpoymentView.tsx | 16 ++-------------- .../reviewSection/ReviewSection.sc.ts | 4 ++-- 11 files changed, 55 insertions(+), 52 deletions(-) diff --git a/frontend/benefit/handler/public/locales/en/common.json b/frontend/benefit/handler/public/locales/en/common.json index 251faf3513..cbabf87258 100644 --- a/frontend/benefit/handler/public/locales/en/common.json +++ b/frontend/benefit/handler/public/locales/en/common.json @@ -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", diff --git a/frontend/benefit/handler/public/locales/fi/common.json b/frontend/benefit/handler/public/locales/fi/common.json index ee8a62e0d7..a81a91f7ae 100644 --- a/frontend/benefit/handler/public/locales/fi/common.json +++ b/frontend/benefit/handler/public/locales/fi/common.json @@ -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", diff --git a/frontend/benefit/handler/public/locales/sv/common.json b/frontend/benefit/handler/public/locales/sv/common.json index 251faf3513..cbabf87258 100644 --- a/frontend/benefit/handler/public/locales/sv/common.json +++ b/frontend/benefit/handler/public/locales/sv/common.json @@ -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", diff --git a/frontend/benefit/handler/src/components/applicationForm/formContent/FormContent.tsx b/frontend/benefit/handler/src/components/applicationForm/formContent/FormContent.tsx index ad8ed2708d..f41d1fe636 100644 --- a/frontend/benefit/handler/src/components/applicationForm/formContent/FormContent.tsx +++ b/frontend/benefit/handler/src/components/applicationForm/formContent/FormContent.tsx @@ -692,6 +692,16 @@ const FormContent: React.FC = ({ /> )} + {application.applicationOrigin === APPLICATION_ORIGINS.APPLICANT && ( + <$GridCell $colSpan={12}> + + + )} = ({ 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 diff --git a/frontend/benefit/handler/src/components/applicationForm/reviewChanges/utils.ts b/frontend/benefit/handler/src/components/applicationForm/reviewChanges/utils.ts index c3440e0444..d813988ddc 100644 --- a/frontend/benefit/handler/src/components/applicationForm/reviewChanges/utils.ts +++ b/frontend/benefit/handler/src/components/applicationForm/reviewChanges/utils.ts @@ -92,7 +92,8 @@ export const getDeMinimisChanged = ( export const getDiffPrefilter = ( path: string[], key: string, - requiredKeys: Set + requiredKeys: Set, + isOfHandlerOrigin: boolean ): boolean => { if (path.length > 0 && path.includes('employee')) return false; if ( @@ -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; }; diff --git a/frontend/benefit/handler/src/components/applicationForm/utils/applicationForm.ts b/frontend/benefit/handler/src/components/applicationForm/utils/applicationForm.ts index 5c4ca0daa8..5af6943302 100644 --- a/frontend/benefit/handler/src/components/applicationForm/utils/applicationForm.ts +++ b/frontend/benefit/handler/src/components/applicationForm/utils/applicationForm.ts @@ -12,6 +12,7 @@ import { ApplicationFields, } from 'benefit/handler/types/application'; import { + APPLICATION_ORIGINS, APPLICATION_STATUSES, ATTACHMENT_TYPES, EMPLOYEE_KEYS, @@ -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, @@ -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 ); }; diff --git a/frontend/benefit/handler/src/components/applicationReview/consentView/ConsentView.tsx b/frontend/benefit/handler/src/components/applicationReview/consentView/ConsentView.tsx index 885a85476e..57acd2a34a 100644 --- a/frontend/benefit/handler/src/components/applicationReview/consentView/ConsentView.tsx +++ b/frontend/benefit/handler/src/components/applicationReview/consentView/ConsentView.tsx @@ -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 = ({ - data, - isUploading, - handleUpload, -}) => { +const ConsentView: React.FC = ({ data }) => { const translationsBase = 'common:review'; const { t } = useTranslation(); const cbPrefix = 'application_consent'; @@ -30,16 +24,10 @@ const ConsentView: React.FC = ({ const theme = useTheme(); return ( - ) : null - } + action={!ACTIONLESS_STATUSES.includes(data.status) ? true : null} > {data.applicationOrigin === APPLICATION_ORIGINS.APPLICANT ? ( <$GridCell $colSpan={12}> diff --git a/frontend/benefit/handler/src/components/applicationReview/employeeView/EmployeeView.tsx b/frontend/benefit/handler/src/components/applicationReview/employeeView/EmployeeView.tsx index cc4c5e9ab5..27537dd4d2 100644 --- a/frontend/benefit/handler/src/components/applicationReview/employeeView/EmployeeView.tsx +++ b/frontend/benefit/handler/src/components/applicationReview/employeeView/EmployeeView.tsx @@ -12,13 +12,8 @@ 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 = ({ - data, - handleUpload, - isUploading, -}) => { +const EmployeeView: React.FC = ({ data }) => { const translationsBase = 'common:review'; const { t } = useTranslation(); return ( @@ -26,14 +21,7 @@ const EmployeeView: React.FC = ({ id={data.id} header={t(`${translationsBase}.headings.heading5`)} section="employee" - action={ - !ACTIONLESS_STATUSES.includes(data.status) ? ( - - ) : null - } + action={!ACTIONLESS_STATUSES.includes(data.status) ? true : null} > <$GridCell $colSpan={6}> <$ViewFieldBold large> diff --git a/frontend/benefit/handler/src/components/applicationReview/employmentView/EmpoymentView.tsx b/frontend/benefit/handler/src/components/applicationReview/employmentView/EmpoymentView.tsx index a2b05c58a3..1411d11ba8 100644 --- a/frontend/benefit/handler/src/components/applicationReview/employmentView/EmpoymentView.tsx +++ b/frontend/benefit/handler/src/components/applicationReview/employmentView/EmpoymentView.tsx @@ -14,13 +14,8 @@ 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 = ({ - data, - isUploading, - handleUpload, -}) => { +const EmploymentView: React.FC = ({ data }) => { const translationsBase = 'common:review'; const { t } = useTranslation(); return ( @@ -28,14 +23,7 @@ const EmploymentView: React.FC = ({ id={data.id} header={t(`${translationsBase}.headings.heading8`)} section="employment" - action={ - !ACTIONLESS_STATUSES.includes(data.status) ? ( - - ) : null - } + action={!ACTIONLESS_STATUSES.includes(data.status) ? true : null} > <$GridCell $colSpan={6} $colStart={1}> <$ViewFieldBold> diff --git a/frontend/benefit/handler/src/components/reviewSection/ReviewSection.sc.ts b/frontend/benefit/handler/src/components/reviewSection/ReviewSection.sc.ts index 23c3408165..e4d02efced 100644 --- a/frontend/benefit/handler/src/components/reviewSection/ReviewSection.sc.ts +++ b/frontend/benefit/handler/src/components/reviewSection/ReviewSection.sc.ts @@ -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; `;