Skip to content

Commit

Permalink
fix: remove irrelevant fields from decision box et cetera (#3123)
Browse files Browse the repository at this point in the history
Also changes the default visibility of the decision box to be shown for
cancelled and rejected applications (first of which should rarely if ever
have an ahjo case ID in a real world scenario), and adds translation
strings for an application with additional information needed requested
(in this case the ahjo case ID should be present for the box to be shown).
  • Loading branch information
EmiliaMakelaVincit authored Aug 9, 2024
1 parent faf3c75 commit 46dfc21
Show file tree
Hide file tree
Showing 11 changed files with 119 additions and 58 deletions.
8 changes: 5 additions & 3 deletions frontend/benefit/applicant/public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"common": {
"created": "Created",
"employee": "Employee",
"saved": "Tallennettu",
"saved": "Saved",
"edit": "Edit",
"sent": "Submitted",
"applicationNumber": "Application number",
Expand Down Expand Up @@ -425,7 +425,8 @@
"accepted": "The application has been approved and the Helsinki benefit has been granted for the period of {{dateRangeStart}} - {{dateRangeEnd}}",
"rejected": "The application was rejected. No Helsinki benefit is granted.",
"handling": "The application is being processed.",
"cancelled": "The application has been cancelled."
"cancelled": "The application has been cancelled.",
"additional_information_needed": "The application is being processed."
},
"headings": {
"mainHeading": "Decision details",
Expand Down Expand Up @@ -453,7 +454,8 @@
"label": "Status",
"received": "Received",
"opened": "Handling",
"handled": "Processed"
"handled": "Processed",
"additional_information_needed": "Additional information is needed"
},
"recoveryAmount": "Recovered benefit",
"recoveryPeriod": "Time period for which the benefit was recovered",
Expand Down
6 changes: 4 additions & 2 deletions frontend/benefit/applicant/public/locales/fi/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,8 @@
"accepted": "Hakemus on hyväksytty ja Helsinki-lisää on myönnetty aikavälille {{dateRangeStart}} – {{dateRangeEnd}}",
"rejected": "Hakemus on hylätty. Helsinki-lisää ei myönnetä.",
"handling": "Hakemus on käsittelyssä.",
"cancelled": "Hakemus on peruttu."
"cancelled": "Hakemus on peruttu.",
"additional_information_needed": "Hakemus on käsittelyssä."
},
"headings": {
"mainHeading": "Päätöksen tiedot",
Expand Down Expand Up @@ -453,7 +454,8 @@
"label": "Tila",
"received": "Lähetetty",
"opened": "Vastaanotettu",
"handled": "Käsitelty"
"handled": "Käsitelty",
"additional_information_needed": "Lisätietoa tarvitaan"
},
"recoveryAmount": "Takaisinlaskutettu tuki",
"recoveryPeriod": "Aika, jolta tukea laskutettiin takaisin",
Expand Down
6 changes: 4 additions & 2 deletions frontend/benefit/applicant/public/locales/sv/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,8 @@
"accepted": "Ansökan har godkänts och Helsingforstillägg har beviljats för tiden {{dateRangeStart}} - {{dateRangeEnd}}",
"rejected": "Ansökan har avslagits. Helsingforstillägg beviljas inte.",
"handling": "Ansökan behandlas.",
"cancelled": "Ansökan har avbrutits."
"cancelled": "Ansökan har avbrutits.",
"additional_information_needed": "Ansökan behandlas."
},
"headings": {
"mainHeading": "Uppgifter om beslutet",
Expand Down Expand Up @@ -453,7 +454,8 @@
"label": "Status",
"received": "Mottagen",
"opened": "Behandling",
"handled": "Behandlad"
"handled": "Behandlad",
"additional_information_needed": "Ytterligare uppgifter behövs"
},
"recoveryAmount": "Stöd som återkrävts",
"recoveryPeriod": "Tid för vilken stödet återkrävs",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ const PageContent: React.FC = () => {
const router = useRouter();
const canShowAskem = useAskem(router.locale, isSubmittedApplication);

const showMonetaryFields = ![
APPLICATION_STATUSES.CANCELLED,
APPLICATION_STATUSES.REJECTED,
].includes(application.status);

useEffect(() => {
if (isReadOnly) document.title = t('common:pageTitles.viewApplication');
else if (router.query.id)
Expand All @@ -96,13 +101,15 @@ const PageContent: React.FC = () => {
{
accessor: (app) => formatFloatToCurrency(app.calculatedBenefitAmount),
key: 'benefitAmount',
showIf: () => showMonetaryFields,
},
{
accessor: (app) =>
`${convertToUIDateFormat(app.startDate)}${convertToUIDateFormat(
app.endDate
)}`,
key: 'benefitPeriod',
showIf: () => showMonetaryFields,
},
{
accessor: (app) => convertToUIDateFormat(app.ahjoDecisionDate),
Expand All @@ -112,10 +119,11 @@ const PageContent: React.FC = () => {
accessor: () => t('common:applications.decision.grantedAsDeMinimisAid'),
key: 'extraDetails',
width: 6,
showIf: (app) => app.isGrantedAsDeMinimisAid === true,
showIf: (app) =>
app.isGrantedAsDeMinimisAid === true && showMonetaryFields,
},
],
[t]
[t, showMonetaryFields]
);

if (isLoading) {
Expand Down
6 changes: 4 additions & 2 deletions frontend/benefit/handler/public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,8 @@
"accepted": "Hakemus on hyväksytty ja Helsinki-lisää on myönnetty aikavälille {{dateRangeStart}} – {{dateRangeEnd}}",
"rejected": "Hakemus on hylätty. Helsinki-lisää ei myönnetä.",
"handling": "Hakemus on käsittelyssä.",
"cancelled": "Hakemus on peruttu."
"cancelled": "Hakemus on peruttu.",
"additional_information_needed": "Hakemus on käsittelyssä."
},
"headings": {
"mainHeading": "Päätöksen tiedot",
Expand Down Expand Up @@ -762,7 +763,8 @@
"received": "Odottaa käsittelyä",
"opened": "Käsittelyssä",
"handled": "Käsitelty",
"cancelled": "Peruutettu"
"cancelled": "Peruutettu",
"additional_information_needed": "Odottaa lisätietoja"
},
"recoveryAmount": "Takaisinlaskutettu tuki",
"recoveryPeriod": "Aika, jolta tukea laskutettiin takaisin",
Expand Down
6 changes: 4 additions & 2 deletions frontend/benefit/handler/public/locales/fi/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,8 @@
"accepted": "Hakemus on hyväksytty ja Helsinki-lisää on myönnetty aikavälille {{dateRangeStart}} – {{dateRangeEnd}}",
"rejected": "Hakemus on hylätty. Helsinki-lisää ei myönnetä.",
"handling": "Hakemus on käsittelyssä.",
"cancelled": "Hakemus on peruttu."
"cancelled": "Hakemus on peruttu.",
"additional_information_needed": "Hakemus on käsittelyssä."
},
"headings": {
"mainHeading": "Päätöksen tiedot",
Expand Down Expand Up @@ -762,7 +763,8 @@
"received": "Odottaa käsittelyä",
"opened": "Käsittelyssä",
"handled": "Käsitelty",
"cancelled": "Peruutettu"
"cancelled": "Peruutettu",
"additional_information_needed": "Odottaa lisätietoja"
},
"recoveryAmount": "Takaisinlaskutettu tuki",
"recoveryPeriod": "Aika, jolta tukea laskutettiin takaisin",
Expand Down
6 changes: 4 additions & 2 deletions frontend/benefit/handler/public/locales/sv/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,8 @@
"accepted": "Hakemus on hyväksytty ja Helsinki-lisää on myönnetty aikavälille {{dateRangeStart}} – {{dateRangeEnd}}",
"rejected": "Hakemus on hylätty. Helsinki-lisää ei myönnetä.",
"handling": "Hakemus on käsittelyssä.",
"cancelled": "Hakemus on peruttu."
"cancelled": "Hakemus on peruttu.",
"additional_information_needed": "Hakemus on käsittelyssä."
},
"headings": {
"mainHeading": "Päätöksen tiedot",
Expand Down Expand Up @@ -762,7 +763,8 @@
"received": "Odottaa käsittelyä",
"opened": "Käsittelyssä",
"handled": "Käsitelty",
"cancelled": "Peruutettu"
"cancelled": "Peruutettu",
"additional_information_needed": "Odottaa lisätietoja"
},
"recoveryAmount": "Takaisinlaskutettu tuki",
"recoveryPeriod": "Aika, jolta tukea laskutettiin takaisin",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ const HandlingStep1: React.FC<HandlingStepProps> = ({
useApplicationReview();
const router = useRouter();

const showMonetaryFields = ![
APPLICATION_STATUSES.CANCELLED,
APPLICATION_STATUSES.REJECTED,
APPLICATION_STATUSES.INFO_REQUIRED,
].includes(application.status);
const showBasicDecisionFields =
application.status !== APPLICATION_STATUSES.CANCELLED;

const decisionDetailList = useMemo<DecisionDetailList>(
() => [
{
Expand All @@ -71,28 +79,33 @@ const HandlingStep1: React.FC<HandlingStepProps> = ({
{
accessor: (app) => formatFloatToCurrency(app.calculatedBenefitAmount),
key: 'benefitAmount',
showIf: () => showMonetaryFields,
},
{
accessor: (app) =>
`${convertToUIDateFormat(app.startDate)}${convertToUIDateFormat(
app.endDate
)}`,
key: 'benefitPeriod',
showIf: () => showMonetaryFields,
},
{
accessor: (app) => app.batch?.sectionOfTheLaw,
key: 'sectionOfLaw',
showIf: () => showBasicDecisionFields,
},
{
accessor: (app) =>
app.calculation.grantedAsDeMinimisAid
? t('utility.yes')
: t('utility.no'),
key: 'grantedAsDeMinimis',
showIf: () => showMonetaryFields,
},
{
accessor: (app) => convertToUIDateFormat(app.ahjoDecisionDate),
key: 'decisionDate',
showIf: () => showBasicDecisionFields,
},
{
accessor: (app) =>
Expand All @@ -103,9 +116,10 @@ const HandlingStep1: React.FC<HandlingStepProps> = ({
{
accessor: (app) => app.batch?.decisionMakerName,
key: 'decisionMaker',
showIf: () => showBasicDecisionFields,
},
],
[t]
[t, showMonetaryFields, showBasicDecisionFields]
);

const hasPendingAlteration = application.alterations.some(
Expand Down Expand Up @@ -144,7 +158,11 @@ const HandlingStep1: React.FC<HandlingStepProps> = ({
]}
itemComponent={AlterationAccordionItem}
detailList={decisionDetailList}
extraInformation={<DecisionCalculationAccordion data={application} />}
extraInformation={
showMonetaryFields ? (
<DecisionCalculationAccordion data={application} />
) : null
}
/>
{application.applicationOrigin === APPLICATION_ORIGINS.HANDLER && (
<PaperView data={application} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
$DecisionNumber,
$Subheading,
} from 'benefit-shared/components/decisionSummary/DecisionSummary.sc';
import { APPLICATION_STATUSES } from 'benefit-shared/constants';
import {
AlterationAccordionItemProps,
Application,
Expand All @@ -23,7 +24,7 @@ import { convertToUIDateFormat } from 'shared/utils/date.utils';
type Props = {
application: Application;
actions: ReactNode;
itemComponent: React.ComponentType<AlterationAccordionItemProps>;
itemComponent?: React.ComponentType<AlterationAccordionItemProps>;
detailList: DecisionDetailList;
extraInformation?: ReactNode;
};
Expand All @@ -37,7 +38,12 @@ const DecisionSummary = ({
}: Props): JSX.Element => {
const { t } = useTranslation();

if (!application.ahjoCaseId) {
const isAccepted = ![
APPLICATION_STATUSES.REJECTED,
APPLICATION_STATUSES.CANCELLED,
].includes(application.status);

if (!application.ahjoCaseId && isAccepted) {
return null;
}

Expand All @@ -57,11 +63,13 @@ const DecisionSummary = ({
<$DecisionBoxTitle>
{t('common:applications.decision.headings.mainHeading')}
</$DecisionBoxTitle>
<$DecisionNumber>
{t('common:applications.decision.headings.caseId')}
{': '}
{application.ahjoCaseId}
</$DecisionNumber>
{isAccepted && (
<$DecisionNumber>
{t('common:applications.decision.headings.caseId')}
{': '}
{application.ahjoCaseId}
</$DecisionNumber>
)}
<$Subheading>
{t(`common:applications.decision.description.${application.status}`, {
dateRangeStart: convertToUIDateFormat(application.startDate),
Expand All @@ -74,6 +82,10 @@ const DecisionSummary = ({
return null;
}

if (detail.invisible) {
return <$GridCell $colSpan={detail.width || 3} key={detail.key} />;
}

return (
<$GridCell $colSpan={detail.width || 3} key={detail.key}>
<dt>
Expand All @@ -85,41 +97,44 @@ const DecisionSummary = ({
})}
</$DecisionDetails>
{extraInformation}
<$DecisionActionContainer>
<Button
iconRight={<IconLinkExternal />}
onClick={displayDecision}
theme="black"
variant="secondary"
role="link"
>
{t('common:applications.decision.actions.showDecision')}
</Button>
</$DecisionActionContainer>
{isTruthy(process.env.NEXT_PUBLIC_ENABLE_ALTERATION_FEATURES) && (
<>
<$Subheading>
{t('common:applications.decision.headings.existingAlterations')}
</$Subheading>
<$AlterationListCount>
{application.alterations?.length > 0
? t('common:applications.decision.alterationList.count', {
count: application.alterations.length,
})
: t('common:applications.decision.alterationList.empty')}
</$AlterationListCount>
<div data-testid="alteration-list">
{sortedAlterations.map((alteration) => (
<ItemComponent
key={alteration.id}
alteration={alteration}
application={application}
/>
))}
</div>
<$AlterationActionContainer>{actions}</$AlterationActionContainer>
</>
{isAccepted && (
<$DecisionActionContainer>
<Button
iconRight={<IconLinkExternal />}
onClick={displayDecision}
theme="black"
variant="secondary"
role="link"
>
{t('common:applications.decision.actions.showDecision')}
</Button>
</$DecisionActionContainer>
)}
{isTruthy(process.env.NEXT_PUBLIC_ENABLE_ALTERATION_FEATURES) &&
isAccepted && (
<>
<$Subheading>
{t('common:applications.decision.headings.existingAlterations')}
</$Subheading>
<$AlterationListCount>
{application.alterations?.length > 0
? t('common:applications.decision.alterationList.count', {
count: application.alterations.length,
})
: t('common:applications.decision.alterationList.empty')}
</$AlterationListCount>
<div data-testid="alteration-list">
{sortedAlterations.map((alteration) => (
<ItemComponent
key={alteration.id}
alteration={alteration}
application={application}
/>
))}
</div>
<$AlterationActionContainer>{actions}</$AlterationActionContainer>
</>
)}
</$DecisionBox>
);
};
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 @@ -685,4 +685,5 @@ export type DecisionDetailList = Array<{
accessor: DecisionDetailAccessorFunction;
width?: number;
showIf?: (app: Application) => boolean;
invisible?: boolean;
}>;
Loading

0 comments on commit 46dfc21

Please sign in to comment.