Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use custom translation for attachement of pay subsidy for people 55+ (HL-944) #2349

Merged
merged 8 commits into from
Oct 16, 2023
3 changes: 3 additions & 0 deletions frontend/benefit/applicant/public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,9 @@
"title": "Pay subsidy decision",
"message": "Attach both issued pay subsidy decisions"
},
"paySubsidyDecisionAged": {
"title": "Decision for employment aid for people aged 55 and above"
},
"commissionContract": {
"title": "Toimeksiantosopimus",
"message": ""
Expand Down
3 changes: 3 additions & 0 deletions frontend/benefit/applicant/public/locales/fi/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,9 @@
"title": "Palkkatukipäätös",
"message": "Liitä molemmat myönnetyt palkkatukipäätökset"
},
"paySubsidyDecisionAged": {
"title": "55 vuotta täyttäneiden työllistämistukipäätös"
},
"commissionContract": {
"title": "Toimeksiantosopimus",
"message": ""
Expand Down
3 changes: 3 additions & 0 deletions frontend/benefit/applicant/public/locales/sv/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,9 @@
"title": "Beslut om lönesubvention",
"message": "Bifoga båda besluten om beviljad lönesubvention"
},
"paySubsidyDecisionAged": {
"title": "Beslut om finansiella stöd för personer som är 55 år och äldre"
},
"commissionContract": {
"title": "Toimeksiantosopimus",
"message": ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,18 @@ import StepperActions from '../stepperActions/StepperActions';
import AttachmentsList from './attachmentsList/AttachmentsList';
import { useApplicationFormStep3 } from './useApplicationFormStep3';

const translationKeyForPaySubsidyAttachement = (
paySubsidyGranted: PAY_SUBSIDY_GRANTED
): 'paySubsidyDecision' | 'paySubsidyDecisionAged' => {
if (paySubsidyGranted === PAY_SUBSIDY_GRANTED.GRANTED) {
return 'paySubsidyDecision';
}
if (paySubsidyGranted === PAY_SUBSIDY_GRANTED.GRANTED_AGED) {
return 'paySubsidyDecisionAged';
}
return 'paySubsidyDecision';
};

const ApplicationFormStep3: React.FC<DynamicFormStepComponentProps> = ({
data,
}) => {
Expand Down Expand Up @@ -60,6 +72,9 @@ const ApplicationFormStep3: React.FC<DynamicFormStepComponentProps> = ({
as="li"
attachments={attachments}
attachmentType={ATTACHMENT_TYPES.PAY_SUBSIDY_CONTRACT}
attachmentTypeTranslationKey={translationKeyForPaySubsidyAttachement(
paySubsidyGranted
)}
showMessage={showSubsidyMessage}
required
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ATTACHMENT_TYPES } from 'benefit-shared/constants';
import camelCase from 'lodash/camelCase';
import { TFunction } from 'next-i18next';
import * as React from 'react';
import AttachmentsListBase from 'shared/components/attachments/AttachmentsList';
import { BenefitAttachment } from 'shared/types/attachment';
Expand All @@ -8,14 +9,28 @@ import { useAttachmentsList } from './useAttachmentsList';

export type AttachmentsListProps = {
attachmentType: ATTACHMENT_TYPES;
attachmentTypeTranslationKey?: string;
showMessage?: boolean;
attachments?: BenefitAttachment[];
required?: boolean;
as?: 'div' | 'li';
};

const getTitleTranslation = (
t: TFunction,
translationsBase: string,
attachmentType: ATTACHMENT_TYPES,
attachmentTypeTranslationKey: string
): string => {
const key = attachmentTypeTranslationKey
? String(attachmentTypeTranslationKey)
: attachmentType;
return t(`${translationsBase}.types.${camelCase(key)}.title`);
};

const AttachmentsList: React.FC<AttachmentsListProps> = ({
attachmentType,
attachmentTypeTranslationKey,
showMessage = true,
attachments,
required,
Expand All @@ -38,7 +53,12 @@ const AttachmentsList: React.FC<AttachmentsListProps> = ({
return (
<AttachmentsListBase
as={as}
title={t(`${translationsBase}.types.${camelCase(attachmentType)}.title`)}
title={getTitleTranslation(
t,
translationsBase,
attachmentType,
attachmentTypeTranslationKey
)}
attachmentType={attachmentType}
name={attachmentType}
message={showMessage && message}
Expand Down
Loading