diff --git a/backend/benefit/applications/api/v1/serializers/application.py b/backend/benefit/applications/api/v1/serializers/application.py index cf4c54b559..e73aee4bb4 100755 --- a/backend/benefit/applications/api/v1/serializers/application.py +++ b/backend/benefit/applications/api/v1/serializers/application.py @@ -205,6 +205,7 @@ class Meta: "ahjo_case_id", "changes", "archived_for_applicant", + "is_granted_as_de_minimis_aid", "alterations", "calculated_benefit_amount", "ahjo_decision_date", @@ -233,6 +234,7 @@ class Meta: "total_deminimis_amount", "changes", "archived_for_applicant", + "is_granted_as_de_minimis_aid", "alterations", "calculated_benefit_amount", "ahjo_decision_date", @@ -465,7 +467,12 @@ class Meta: archived_for_applicant = serializers.SerializerMethodField( method_name="get_archived_for_applicant", - help_text=("Should be shown in the archive view for an applicant"), + help_text="Should be shown in the archive view for an applicant", + ) + + is_granted_as_de_minimis_aid = serializers.SerializerMethodField( + method_name="get_is_granted_as_de_minimis_aid", + help_text="Granted as de minimis aid", ) def get_applicant_terms_approval_needed(self, obj): @@ -1424,6 +1431,12 @@ def get_archived_for_applicant(self, application): ApplicationBatchStatus.COMPLETED, ] and application.batch.decision_date < date.today() + relativedelta(days=-14) + def get_is_granted_as_de_minimis_aid(self, application): + if not hasattr(application, "calculation"): + return None + + return application.calculation.granted_as_de_minimis_aid + class ApplicantApplicationStatusChoiceField(serializers.ChoiceField): """ diff --git a/frontend/benefit/applicant/public/locales/en/common.json b/frontend/benefit/applicant/public/locales/en/common.json index cf62f83b02..5aceb29975 100644 --- a/frontend/benefit/applicant/public/locales/en/common.json +++ b/frontend/benefit/applicant/public/locales/en/common.json @@ -434,7 +434,8 @@ "decisionDate": "Decision made on", "benefitPeriod": "Benefit period", "benefitAmount": "Total benefit granted", - "existingAlterations": "Change to employment" + "existingAlterations": "Change to employment", + "extraDetails": "Additional details" }, "alterationList": { "count_one": "{{count}} change in employment reported", @@ -471,6 +472,7 @@ "cancel": "Cancel" } }, + "grantedAsDeMinimisAid": "Benefit was granted as de minimis aid", "actions": { "showDecision": "View decision", "reportAlteration": "Report changes to employment" diff --git a/frontend/benefit/applicant/public/locales/fi/common.json b/frontend/benefit/applicant/public/locales/fi/common.json index 3f381a22d2..8896d4ea4d 100644 --- a/frontend/benefit/applicant/public/locales/fi/common.json +++ b/frontend/benefit/applicant/public/locales/fi/common.json @@ -434,7 +434,8 @@ "decisionDate": "Päätös tehty", "benefitPeriod": "Tukiaika", "benefitAmount": "Myönnetty tuki yhteensä", - "existingAlterations": "Muutokset työsuhteessa" + "existingAlterations": "Muutokset työsuhteessa", + "extraDetails": "Lisätiedot" }, "alterationList": { "count_one": "{{count}} ilmoitettu muutos työsuhteessa", @@ -471,6 +472,7 @@ "cancel": "Peruuta" } }, + "grantedAsDeMinimisAid": "Tuki on myönnetty de minimis -tukena", "actions": { "showDecision": "Tarkastele päätöstä", "reportAlteration": "Ilmoita työsuhteen muutoksesta" diff --git a/frontend/benefit/applicant/public/locales/sv/common.json b/frontend/benefit/applicant/public/locales/sv/common.json index c608c345c8..4be5ff9aa7 100644 --- a/frontend/benefit/applicant/public/locales/sv/common.json +++ b/frontend/benefit/applicant/public/locales/sv/common.json @@ -434,7 +434,8 @@ "decisionDate": "Beslutet fattades", "benefitPeriod": "Stödtid", "benefitAmount": "Beviljat stöd sammanlagt", - "existingAlterations": "Ändring i anställningen" + "existingAlterations": "Ändring i anställningen", + "extraDetails": "Ytterligare information" }, "alterationList": { "count_one": "{{count}} ändring i anställningen anmälde", @@ -471,6 +472,7 @@ "cancel": "Ångra" } }, + "grantedAsDeMinimisAid": "Stödet har beviljats som de minimis-stöd", "actions": { "showDecision": "Kontrollera beslutet", "reportAlteration": "Anmäl ändring i anställningen" diff --git a/frontend/benefit/applicant/src/components/applications/pageContent/PageContent.tsx b/frontend/benefit/applicant/src/components/applications/pageContent/PageContent.tsx index 3188cd093c..184415ac19 100644 --- a/frontend/benefit/applicant/src/components/applications/pageContent/PageContent.tsx +++ b/frontend/benefit/applicant/src/components/applications/pageContent/PageContent.tsx @@ -21,14 +21,21 @@ import { ROUTES, SUBMITTED_STATUSES } from 'benefit/applicant/constants'; import { useAskem } from 'benefit/applicant/hooks/useAnalytics'; import DecisionSummary from 'benefit-shared/components/decisionSummary/DecisionSummary'; import StatusIcon from 'benefit-shared/components/statusIcon/StatusIcon'; -import { ALTERATION_STATE, ALTERATION_TYPE, APPLICATION_STATUSES } from 'benefit-shared/constants'; +import { + ALTERATION_STATE, + ALTERATION_TYPE, + APPLICATION_STATUSES, +} from 'benefit-shared/constants'; import { DecisionDetailList } from 'benefit-shared/types/application'; import { Button, IconInfoCircleFill, LoadingSpinner, Stepper } from 'hds-react'; import { useRouter } from 'next/router'; import React, { useEffect, useMemo } from 'react'; import Container from 'shared/components/container/Container'; import { getFullName } from 'shared/utils/application.utils'; -import { convertToUIDateAndTimeFormat, convertToUIDateFormat } from 'shared/utils/date.utils'; +import { + convertToUIDateAndTimeFormat, + convertToUIDateFormat, +} from 'shared/utils/date.utils'; import { formatFloatToCurrency } from 'shared/utils/string.utils'; import { useTheme } from 'styled-components'; @@ -75,27 +82,41 @@ const PageContent: React.FC = () => { window.scrollTo(0, 0); }, [currentStep]); - const decisionDetailList = useMemo(() => [ - { - accessor: (app) => <> - - {t(`common:applications.statuses.${app.status}`)} - , - key: 'status', - }, - { - accessor: (app) => formatFloatToCurrency(app.calculatedBenefitAmount), - key: 'benefitAmount', - }, - { - accessor: (app) => `${convertToUIDateFormat(app.startDate)} – ${convertToUIDateFormat(app.endDate)}`, - key: 'benefitPeriod', - }, - { - accessor: (app) => convertToUIDateFormat(app.ahjoDecisionDate), - key: 'decisionDate', - } - ], [t]); + const decisionDetailList = useMemo( + () => [ + { + accessor: (app) => ( + <> + + {t(`common:applications.statuses.${app.status}`)} + + ), + key: 'status', + }, + { + accessor: (app) => formatFloatToCurrency(app.calculatedBenefitAmount), + key: 'benefitAmount', + }, + { + accessor: (app) => + `${convertToUIDateFormat(app.startDate)} – ${convertToUIDateFormat( + app.endDate + )}`, + key: 'benefitPeriod', + }, + { + accessor: (app) => convertToUIDateFormat(app.ahjoDecisionDate), + key: 'decisionDate', + }, + { + accessor: () => t('common:applications.decision.grantedAsDeMinimisAid'), + key: 'extraDetails', + width: 6, + showIf: (app) => app.isGrantedAsDeMinimisAid === true, + }, + ], + [t] + ); if (isLoading) { return ( @@ -198,7 +219,8 @@ const PageContent: React.FC = () => { @@ -210,7 +232,8 @@ const PageContent: React.FC = () => { > {t('common:applications.decision.actions.reportAlteration')} - ) : null} + ) : null + } itemComponent={AlterationAccordionItem} detailList={decisionDetailList} /> diff --git a/frontend/benefit/shared/src/components/decisionSummary/DecisionSummary.sc.ts b/frontend/benefit/shared/src/components/decisionSummary/DecisionSummary.sc.ts index 60900702bc..60f2435957 100644 --- a/frontend/benefit/shared/src/components/decisionSummary/DecisionSummary.sc.ts +++ b/frontend/benefit/shared/src/components/decisionSummary/DecisionSummary.sc.ts @@ -1,4 +1,4 @@ -import { respondAbove } from 'shared/styles/mediaQueries'; +import { $Grid } from 'shared/components/forms/section/FormSection.sc'; import styled from 'styled-components'; export const $DecisionBox = styled.section` @@ -28,26 +28,10 @@ export const $Subheading = styled.h2` font-size: ${(props) => props.theme.fontSize.heading.s}; `; -export const $DecisionDetails = styled.dl` - display: flex; - flex-direction: column; - flex-wrap: wrap; - box-sizing: border-box; - margin: 0 calc(${(props) => props.theme.spacing.s} * -1); - - ${respondAbove('md')` - flex-direction: row; - justify-content: stretch; - - div { - width: 25%; - } - `}; - - div { - box-sizing: border-box; - padding: ${(props) => props.theme.spacing.s}; - } +export const $DecisionDetails = styled($Grid)` + margin: ${(props) => props.theme.spacing.l} 0 + ${(props) => props.theme.spacing.s}; + row-gap: ${(props) => props.theme.spacing.l}; dt { font-weight: 500; diff --git a/frontend/benefit/shared/src/components/decisionSummary/DecisionSummary.tsx b/frontend/benefit/shared/src/components/decisionSummary/DecisionSummary.tsx index 89fbf41394..6f9d46c02b 100644 --- a/frontend/benefit/shared/src/components/decisionSummary/DecisionSummary.tsx +++ b/frontend/benefit/shared/src/components/decisionSummary/DecisionSummary.tsx @@ -8,11 +8,16 @@ import { $DecisionNumber, $Subheading, } from 'benefit-shared/components/decisionSummary/DecisionSummary.sc'; -import { AlterationAccordionItemProps, Application, DecisionDetailList } from 'benefit-shared/types/application'; +import { + AlterationAccordionItemProps, + Application, + DecisionDetailList, +} from 'benefit-shared/types/application'; import { isTruthy } from 'benefit-shared/utils/common'; import { Button, IconLinkExternal } from 'hds-react'; import { useTranslation } from 'next-i18next'; import React, { ReactNode } from 'react'; +import { $GridCell } from 'shared/components/forms/section/FormSection.sc'; import { convertToUIDateFormat } from 'shared/utils/date.utils'; type Props = { @@ -23,7 +28,13 @@ type Props = { extraInformation?: ReactNode; }; -const DecisionSummary = ({ application, actions, itemComponent: ItemComponent, detailList, extraInformation }: Props): JSX.Element => { +const DecisionSummary = ({ + application, + actions, + itemComponent: ItemComponent, + detailList, + extraInformation, +}: Props): JSX.Element => { const { t } = useTranslation(); if (!application.ahjoCaseId) { @@ -57,13 +68,21 @@ const DecisionSummary = ({ application, actions, itemComponent: ItemComponent, d dateRangeEnd: convertToUIDateFormat(application.endDate), })} - <$DecisionDetails> - {detailList.map((detail) =>
-
{t(`common:applications.decision.headings.${detail.key}`)}
-
- {detail.accessor(application) || '-'} -
-
)} + <$DecisionDetails as="dl"> + {detailList.map((detail) => { + if (detail.showIf && !detail.showIf(application)) { + return null; + } + + return ( + <$GridCell $colSpan={detail.width || 3} key={detail.key}> +
+ {t(`common:applications.decision.headings.${detail.key}`)} +
+
{detail.accessor(application) || '-'}
+ + ); + })} {extraInformation} <$DecisionActionContainer> @@ -96,9 +115,7 @@ const DecisionSummary = ({ application, actions, itemComponent: ItemComponent, d application={application} /> ))} - <$AlterationActionContainer> - {actions} - + <$AlterationActionContainer>{actions} )} diff --git a/frontend/benefit/shared/src/types/application.d.ts b/frontend/benefit/shared/src/types/application.d.ts index 9d937f3bbd..ecce08e534 100644 --- a/frontend/benefit/shared/src/types/application.d.ts +++ b/frontend/benefit/shared/src/types/application.d.ts @@ -292,6 +292,7 @@ export type Application = { organizationType?: ORGANIZATION_TYPES; associationImmediateManagerCheck?: boolean; archivedForApplicant?: boolean; + isGrantedAsDeMinimisAid?: boolean | null; ahjoCaseId?: string; ahjoDecisionDate?: string; calculatedBenefitAmount?: number; @@ -451,6 +452,8 @@ export type ApplicationData = { company_contact_person_last_name: string; talpa_status: TALPA_STATUSES; ahjo_case_id: string; + archived_for_applicant?: boolean; + is_granted_as_de_minimis_aid?: boolean | null; }; export type EmployeeData = { @@ -676,6 +679,8 @@ export type AlterationAccordionItemProps = { export type DecisionDetailAccessorFunction = (app: Application) => ReactNode; export type DecisionDetailList = Array<{ - accessor: DecisionDetailAccessorFunction; key: string; + accessor: DecisionDetailAccessorFunction; + width?: number; + showIf?: (app: Application) => boolean; }>; diff --git a/frontend/yarn.lock b/frontend/yarn.lock index 812220a6b1..334ee2e67a 100644 --- a/frontend/yarn.lock +++ b/frontend/yarn.lock @@ -4886,11 +4886,11 @@ brace-expansion@^2.0.1: balanced-match "^1.0.0" braces@^3.0.2, braces@~3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107" - integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A== + version "3.0.3" + resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.3.tgz#490332f40919452272d55a8480adc0c441358789" + integrity sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA== dependencies: - fill-range "^7.0.1" + fill-range "^7.1.1" broadcast-channel@^3.4.1: version "3.7.0" @@ -7665,10 +7665,10 @@ filelist@^1.0.4: dependencies: minimatch "^5.0.1" -fill-range@^7.0.1: - version "7.0.1" - resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.0.1.tgz#1919a6a7c75fe38b2c7c77e5198535da9acdda40" - integrity sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ== +fill-range@^7.1.1: + version "7.1.1" + resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.1.1.tgz#44265d3cac07e3ea7dc247516380643754a05292" + integrity sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg== dependencies: to-regex-range "^5.0.1"