From 097fa340e9afb2709dcd5b44a49c610d69dd8938 Mon Sep 17 00:00:00 2001 From: Veronika Sif Date: Wed, 16 Oct 2024 17:24:34 +0000 Subject: [PATCH] [TS-926] Only display available months in TR applications --- .../AdditionalSupportForTheElderlyForm.ts | 66 +++++++++++------ .../additionalSupportForTheElderlyUtils.ts | 48 +++++++++--- .../src/forms/HouseholdSupplementForm.ts | 72 +++++++++++------- .../src/lib/householdSupplementUtils.ts | 36 +++++---- .../src/forms/OldAgePensionForm.ts | 68 ++++++++++------- .../src/lib/oldAgePensionUtils.ts | 50 +++++++------ .../src/forms/PensionSupplementForm.ts | 74 ++++++++++++------- .../src/lib/pensionSupplementUtils.ts | 30 +++++--- 8 files changed, 280 insertions(+), 164 deletions(-) diff --git a/libs/application/templates/social-insurance-administration/additional-support-for-the-elderly/src/forms/AdditionalSupportForTheElderlyForm.ts b/libs/application/templates/social-insurance-administration/additional-support-for-the-elderly/src/forms/AdditionalSupportForTheElderlyForm.ts index 447428a9d306..9772c3bdf933 100644 --- a/libs/application/templates/social-insurance-administration/additional-support-for-the-elderly/src/forms/AdditionalSupportForTheElderlyForm.ts +++ b/libs/application/templates/social-insurance-administration/additional-support-for-the-elderly/src/forms/AdditionalSupportForTheElderlyForm.ts @@ -3,50 +3,51 @@ import { buildCustomField, buildFileUploadField, buildForm, + buildHiddenInputWithWatchedValue, buildMultiField, buildRadioField, buildSection, buildSelectField, - buildSubSection, buildSubmitField, + buildSubSection, buildTextField, } from '@island.is/application/core' +import Logo from '@island.is/application/templates/social-insurance-administration-core/assets/Logo' import { - Application, - DefaultEvents, - Form, - FormModes, - FormValue, - YES, -} from '@island.is/application/types' + BankAccountType, + fileUploadSharedProps, + TaxLevelOptions, +} from '@island.is/application/templates/social-insurance-administration-core/lib/constants' +import { socialInsuranceAdministrationMessage } from '@island.is/application/templates/social-insurance-administration-core/lib/messages' import { friendlyFormatIBAN, friendlyFormatSWIFT, getBankIsk, - typeOfBankInfo, getCurrencies, - getYesNoOptions, getTaxOptions, + getYesNoOptions, + typeOfBankInfo, } from '@island.is/application/templates/social-insurance-administration-core/lib/socialInsuranceAdministrationUtils' -import Logo from '@island.is/application/templates/social-insurance-administration-core/assets/Logo' -import { additionalSupportForTheElderyFormMessage } from '../lib/messages' -import { socialInsuranceAdministrationMessage } from '@island.is/application/templates/social-insurance-administration-core/lib/messages' import { - BankAccountType, - fileUploadSharedProps, - MONTHS, - TaxLevelOptions, -} from '@island.is/application/templates/social-insurance-administration-core/lib/constants' -import { - getApplicationExternalData, - getAvailableYears, -} from '../lib/additionalSupportForTheElderlyUtils' + Application, + DefaultEvents, + Form, + FormModes, + FormValue, + YES, +} from '@island.is/application/types' import { applicantInformationMultiField, buildFormConclusionSection, } from '@island.is/application/ui-forms' -import { getApplicationAnswers } from '../lib/additionalSupportForTheElderlyUtils' import isEmpty from 'lodash/isEmpty' +import { + getApplicationAnswers, + getApplicationExternalData, + getAvailableMonths, + getAvailableYears, +} from '../lib/additionalSupportForTheElderlyUtils' +import { additionalSupportForTheElderyFormMessage } from '../lib/messages' export const AdditionalSupportForTheElderlyForm: Form = buildForm({ id: 'AdditionalSupportForTheElderlyDraft', @@ -352,7 +353,24 @@ export const AdditionalSupportForTheElderlyForm: Form = buildForm({ width: 'half', placeholder: socialInsuranceAdministrationMessage.period.monthDefaultText, - options: MONTHS, + options: (application: Application) => { + const { selectedYear } = getApplicationAnswers( + application.answers, + ) + + return getAvailableMonths(selectedYear) + }, + condition: (answers) => { + const { selectedYear, selectedYearHiddenInput } = + getApplicationAnswers(answers) + + return selectedYear === selectedYearHiddenInput + }, + }), + buildHiddenInputWithWatchedValue({ + // Needed to trigger an update on options in the select above + id: 'period.hiddenInput', + watchValue: 'period.year', }), ], }), diff --git a/libs/application/templates/social-insurance-administration/additional-support-for-the-elderly/src/lib/additionalSupportForTheElderlyUtils.ts b/libs/application/templates/social-insurance-administration/additional-support-for-the-elderly/src/lib/additionalSupportForTheElderlyUtils.ts index 52578d67db00..d1dd74e3811e 100644 --- a/libs/application/templates/social-insurance-administration/additional-support-for-the-elderly/src/lib/additionalSupportForTheElderlyUtils.ts +++ b/libs/application/templates/social-insurance-administration/additional-support-for-the-elderly/src/lib/additionalSupportForTheElderlyUtils.ts @@ -1,4 +1,16 @@ import { getValueViaPath } from '@island.is/application/core' +import { + BankAccountType, + MONTHS, + TaxLevelOptions, +} from '@island.is/application/templates/social-insurance-administration-core/lib/constants' +import { + AdditionalInformation, + Attachments, + BankInfo, + FileType, + PaymentInfo, +} from '@island.is/application/templates/social-insurance-administration-core/types' import { Application, ExternalData, @@ -7,22 +19,17 @@ import { import addMonths from 'date-fns/addMonths' import subMonths from 'date-fns/subMonths' import { AttachmentLabel, AttachmentTypes } from './constants' -import { - FileType, - Attachments, - AdditionalInformation, - BankInfo, - PaymentInfo, -} from '@island.is/application/templates/social-insurance-administration-core/types' -import { - BankAccountType, - TaxLevelOptions, -} from '@island.is/application/templates/social-insurance-administration-core/lib/constants' export const getApplicationAnswers = (answers: Application['answers']) => { const selectedYear = getValueViaPath(answers, 'period.year') as string const selectedMonth = getValueViaPath(answers, 'period.month') as string + + const selectedYearHiddenInput = getValueViaPath( + answers, + 'period.hiddenInput', + ) as string + const applicantPhonenumber = getValueViaPath( answers, 'applicant.phoneNumber', @@ -86,6 +93,7 @@ export const getApplicationAnswers = (answers: Application['answers']) => { applicantPhonenumber, selectedYear, selectedMonth, + selectedYearHiddenInput, comment, additionalAttachments, additionalAttachmentsRequired, @@ -230,6 +238,24 @@ export const getAvailableYears = () => { ) } +// returns available months for selected year, since available period is +// 3 months back in time and 6 months in the future. +export const getAvailableMonths = (selectedYear: string) => { + if (!selectedYear) return [] + + const threeMonthsBackInTime = subMonths(new Date(), 3) + const sixMonthsInTheFuture = addMonths(new Date(), 6) + + let months = MONTHS + if (threeMonthsBackInTime.getFullYear().toString() === selectedYear) { + months = months.slice(threeMonthsBackInTime.getMonth() + 1, months.length) + } else if (sixMonthsInTheFuture.getFullYear().toString() === selectedYear) { + months = months.slice(0, sixMonthsInTheFuture.getMonth() + 1) + } + + return months +} + export const isEligible = (externalData: ExternalData): boolean => { const { isEligible } = getApplicationExternalData(externalData) diff --git a/libs/application/templates/social-insurance-administration/household-supplement/src/forms/HouseholdSupplementForm.ts b/libs/application/templates/social-insurance-administration/household-supplement/src/forms/HouseholdSupplementForm.ts index 980124680daa..cbb1142f20ea 100644 --- a/libs/application/templates/social-insurance-administration/household-supplement/src/forms/HouseholdSupplementForm.ts +++ b/libs/application/templates/social-insurance-administration/household-supplement/src/forms/HouseholdSupplementForm.ts @@ -1,18 +1,33 @@ import { + buildAlertMessageField, + buildCustomField, + buildDescriptionField, + buildFileUploadField, buildForm, + buildHiddenInputWithWatchedValue, buildMultiField, buildPhoneField, + buildRadioField, buildSection, + buildSelectField, buildSubSection, buildSubmitField, buildTextField, - buildCustomField, - buildRadioField, - buildFileUploadField, - buildAlertMessageField, - buildSelectField, - buildDescriptionField, } from '@island.is/application/core' +import Logo from '@island.is/application/templates/social-insurance-administration-core/assets/Logo' +import { + BankAccountType, + fileUploadSharedProps, +} from '@island.is/application/templates/social-insurance-administration-core/lib/constants' +import { socialInsuranceAdministrationMessage } from '@island.is/application/templates/social-insurance-administration-core/lib/messages' +import { + friendlyFormatIBAN, + friendlyFormatSWIFT, + getBankIsk, + getCurrencies, + getYesNoOptions, + typeOfBankInfo, +} from '@island.is/application/templates/social-insurance-administration-core/lib/socialInsuranceAdministrationUtils' import { Application, DefaultEvents, @@ -22,32 +37,18 @@ import { NationalRegistrySpouse, YES, } from '@island.is/application/types' -import { householdSupplementFormMessage } from '../lib/messages' -import { socialInsuranceAdministrationMessage } from '@island.is/application/templates/social-insurance-administration-core/lib/messages' +import { buildFormConclusionSection } from '@island.is/application/ui-forms' +import * as kennitala from 'kennitala' +import isEmpty from 'lodash/isEmpty' import { HouseholdSupplementHousing, maritalStatuses } from '../lib/constants' import { - isExistsCohabitantOlderThan25, getApplicationAnswers, getApplicationExternalData, + getAvailableMonths, getAvailableYears, + isExistsCohabitantOlderThan25, } from '../lib/householdSupplementUtils' -import { - BankAccountType, - MONTHS, - fileUploadSharedProps, -} from '@island.is/application/templates/social-insurance-administration-core/lib/constants' -import { buildFormConclusionSection } from '@island.is/application/ui-forms' -import isEmpty from 'lodash/isEmpty' -import { - friendlyFormatIBAN, - friendlyFormatSWIFT, - getBankIsk, - typeOfBankInfo, - getCurrencies, - getYesNoOptions, -} from '@island.is/application/templates/social-insurance-administration-core/lib/socialInsuranceAdministrationUtils' -import Logo from '@island.is/application/templates/social-insurance-administration-core/assets/Logo' -import * as kennitala from 'kennitala' +import { householdSupplementFormMessage } from '../lib/messages' export const HouseholdSupplementForm: Form = buildForm({ id: 'HouseholdSupplementDraft', @@ -530,7 +531,24 @@ export const HouseholdSupplementForm: Form = buildForm({ width: 'half', placeholder: socialInsuranceAdministrationMessage.period.monthDefaultText, - options: MONTHS, + options: (application: Application) => { + const { selectedYear } = getApplicationAnswers( + application.answers, + ) + + return getAvailableMonths(selectedYear) + }, + condition: (answers) => { + const { selectedYear, selectedYearHiddenInput } = + getApplicationAnswers(answers) + + return selectedYear === selectedYearHiddenInput + }, + }), + buildHiddenInputWithWatchedValue({ + // Needed to trigger an update on options in the select above + id: 'period.hiddenInput', + watchValue: 'period.year', }), ], }), diff --git a/libs/application/templates/social-insurance-administration/household-supplement/src/lib/householdSupplementUtils.ts b/libs/application/templates/social-insurance-administration/household-supplement/src/lib/householdSupplementUtils.ts index 5fa576ae1a2c..5e21cf054916 100644 --- a/libs/application/templates/social-insurance-administration/household-supplement/src/lib/householdSupplementUtils.ts +++ b/libs/application/templates/social-insurance-administration/household-supplement/src/lib/householdSupplementUtils.ts @@ -1,29 +1,29 @@ import { getValueViaPath } from '@island.is/application/core' import { - HouseholdSupplementHousing, - AttachmentLabel, - AttachmentTypes, -} from './constants' + BankAccountType, + MONTHS, +} from '@island.is/application/templates/social-insurance-administration-core/lib/constants' +import { + Attachments, + BankInfo, + FileType, + PaymentInfo, +} from '@island.is/application/templates/social-insurance-administration-core/types' import { Application, - YesOrNo, - YES, ExternalData, + YES, + YesOrNo, } from '@island.is/application/types' import addMonths from 'date-fns/addMonths' import subYears from 'date-fns/subYears' import * as kennitala from 'kennitala' import { FileUpload } from '../types' import { - Attachments, - BankInfo, - FileType, - PaymentInfo, -} from '@island.is/application/templates/social-insurance-administration-core/types' -import { - BankAccountType, - MONTHS, -} from '@island.is/application/templates/social-insurance-administration-core/lib/constants' + AttachmentLabel, + AttachmentTypes, + HouseholdSupplementHousing, +} from './constants' export const getApplicationAnswers = (answers: Application['answers']) => { const applicantPhonenumber = getValueViaPath( @@ -55,6 +55,11 @@ export const getApplicationAnswers = (answers: Application['answers']) => { const selectedMonth = getValueViaPath(answers, 'period.month') as string + const selectedYearHiddenInput = getValueViaPath( + answers, + 'period.hiddenInput', + ) as string + const additionalAttachments = getValueViaPath( answers, 'fileUploadAdditionalFiles.additionalDocuments', @@ -102,6 +107,7 @@ export const getApplicationAnswers = (answers: Application['answers']) => { leaseAgreementAttachments, selectedYear, selectedMonth, + selectedYearHiddenInput, additionalAttachments, additionalAttachmentsRequired, comment, diff --git a/libs/application/templates/social-insurance-administration/old-age-pension/src/forms/OldAgePensionForm.ts b/libs/application/templates/social-insurance-administration/old-age-pension/src/forms/OldAgePensionForm.ts index e54267247f75..2d086a88fa4f 100644 --- a/libs/application/templates/social-insurance-administration/old-age-pension/src/forms/OldAgePensionForm.ts +++ b/libs/application/templates/social-insurance-administration/old-age-pension/src/forms/OldAgePensionForm.ts @@ -3,6 +3,7 @@ import { buildCustomField, buildFileUploadField, buildForm, + buildHiddenInputWithWatchedValue, buildMultiField, buildRadioField, buildRepeater, @@ -12,6 +13,23 @@ import { buildSubSection, buildTextField, } from '@island.is/application/core' +import Logo from '@island.is/application/templates/social-insurance-administration-core/assets/Logo' +import { + BankAccountType, + fileUploadSharedProps, + IS, + TaxLevelOptions, +} from '@island.is/application/templates/social-insurance-administration-core/lib/constants' +import { socialInsuranceAdministrationMessage } from '@island.is/application/templates/social-insurance-administration-core/lib/messages' +import { + friendlyFormatIBAN, + friendlyFormatSWIFT, + getBankIsk, + getCurrencies, + getTaxOptions, + getYesNoOptions, + typeOfBankInfo, +} from '@island.is/application/templates/social-insurance-administration-core/lib/socialInsuranceAdministrationUtils' import { Application, DefaultEvents, @@ -21,37 +39,20 @@ import { NO, YES, } from '@island.is/application/types' -import Logo from '@island.is/application/templates/social-insurance-administration-core/assets/Logo' -import { oldAgePensionFormMessage } from '../lib/messages' -import { socialInsuranceAdministrationMessage } from '@island.is/application/templates/social-insurance-administration-core/lib/messages' +import { + applicantInformationMultiField, + buildFormConclusionSection, +} from '@island.is/application/ui-forms' +import isEmpty from 'lodash/isEmpty' import { ApplicationType, Employment, RatioType } from '../lib/constants' +import { oldAgePensionFormMessage } from '../lib/messages' import { getApplicationAnswers, getApplicationExternalData, + getAvailableMonths, getAvailableYears, isEarlyRetirement, } from '../lib/oldAgePensionUtils' -import { - friendlyFormatIBAN, - friendlyFormatSWIFT, - getBankIsk, - getCurrencies, - typeOfBankInfo, - getYesNoOptions, - getTaxOptions, -} from '@island.is/application/templates/social-insurance-administration-core/lib/socialInsuranceAdministrationUtils' -import { - applicantInformationMultiField, - buildFormConclusionSection, -} from '@island.is/application/ui-forms' -import isEmpty from 'lodash/isEmpty' -import { - BankAccountType, - fileUploadSharedProps, - IS, - MONTHS, - TaxLevelOptions, -} from '@island.is/application/templates/social-insurance-administration-core/lib/constants' export const OldAgePensionForm: Form = buildForm({ id: 'OldAgePensionDraft', @@ -586,7 +587,24 @@ export const OldAgePensionForm: Form = buildForm({ width: 'half', placeholder: socialInsuranceAdministrationMessage.period.monthDefaultText, - options: MONTHS, + options: (application: Application) => { + const { selectedYear } = getApplicationAnswers( + application.answers, + ) + + return getAvailableMonths(application, selectedYear) + }, + condition: (answers) => { + const { selectedYear, selectedYearHiddenInput } = + getApplicationAnswers(answers) + + return selectedYear === selectedYearHiddenInput + }, + }), + buildHiddenInputWithWatchedValue({ + // Needed to trigger an update on options in the select above + id: 'period.hiddenInput', + watchValue: 'period.year', }), buildAlertMessageField({ id: 'period.alert', diff --git a/libs/application/templates/social-insurance-administration/old-age-pension/src/lib/oldAgePensionUtils.ts b/libs/application/templates/social-insurance-administration/old-age-pension/src/lib/oldAgePensionUtils.ts index 1834e636073e..7ddec140d8ad 100644 --- a/libs/application/templates/social-insurance-administration/old-age-pension/src/lib/oldAgePensionUtils.ts +++ b/libs/application/templates/social-insurance-administration/old-age-pension/src/lib/oldAgePensionUtils.ts @@ -1,40 +1,40 @@ import { getValueViaPath } from '@island.is/application/core' import { - oldAgePensionAge, - earlyRetirementMinAge, - earlyRetirementMaxAge, - ApplicationType, - Employment, - AttachmentLabel, - AttachmentTypes, -} from './constants' + BankAccountType, + MONTHS, + TaxLevelOptions, +} from '@island.is/application/templates/social-insurance-administration-core/lib/constants' +import { + Attachments, + BankInfo, + FileType, + PaymentInfo, +} from '@island.is/application/templates/social-insurance-administration-core/types' import { Application, NationalRegistryResidenceHistory, YesOrNo, } from '@island.is/application/types' -import { oldAgePensionFormMessage } from './messages' -import * as kennitala from 'kennitala' -import addYears from 'date-fns/addYears' import addMonths from 'date-fns/addMonths' +import addYears from 'date-fns/addYears' +import * as kennitala from 'kennitala' import { CombinedResidenceHistory, Employer, + FileUpload, IncompleteEmployer, SelfEmployed, - FileUpload, } from '../types' import { - BankAccountType, - MONTHS, - TaxLevelOptions, -} from '@island.is/application/templates/social-insurance-administration-core/lib/constants' -import { - Attachments, - BankInfo, - FileType, - PaymentInfo, -} from '@island.is/application/templates/social-insurance-administration-core/types' + ApplicationType, + AttachmentLabel, + AttachmentTypes, + earlyRetirementMaxAge, + earlyRetirementMinAge, + Employment, + oldAgePensionAge, +} from './constants' +import { oldAgePensionFormMessage } from './messages' export const getApplicationAnswers = (answers: Application['answers']) => { const pensionFundQuestion = getValueViaPath( @@ -51,6 +51,11 @@ export const getApplicationAnswers = (answers: Application['answers']) => { const selectedMonth = getValueViaPath(answers, 'period.month') as string + const selectedYearHiddenInput = getValueViaPath( + answers, + 'period.hiddenInput', + ) as string + const applicantPhonenumber = getValueViaPath( answers, 'applicant.phoneNumber', @@ -154,6 +159,7 @@ export const getApplicationAnswers = (answers: Application['answers']) => { applicationType, selectedYear, selectedMonth, + selectedYearHiddenInput, applicantPhonenumber, bank, residenceHistoryQuestion, diff --git a/libs/application/templates/social-insurance-administration/pension-supplement/src/forms/PensionSupplementForm.ts b/libs/application/templates/social-insurance-administration/pension-supplement/src/forms/PensionSupplementForm.ts index 6f81b31315d5..4e9a5fd7af24 100644 --- a/libs/application/templates/social-insurance-administration/pension-supplement/src/forms/PensionSupplementForm.ts +++ b/libs/application/templates/social-insurance-administration/pension-supplement/src/forms/PensionSupplementForm.ts @@ -1,21 +1,31 @@ import { + buildAlertMessageField, + buildCheckboxField, + buildCustomField, + buildFileUploadField, buildForm, + buildHiddenInputWithWatchedValue, buildMultiField, + buildRadioField, buildSection, + buildSelectField, + buildSubmitField, buildSubSection, buildTextField, - buildCustomField, - buildSubmitField, - buildCheckboxField, - buildFileUploadField, - buildAlertMessageField, - buildRadioField, - buildSelectField, } from '@island.is/application/core' +import Logo from '@island.is/application/templates/social-insurance-administration-core/assets/Logo' import { - applicantInformationMultiField, - buildFormConclusionSection, -} from '@island.is/application/ui-forms' + BankAccountType, + fileUploadSharedProps, +} from '@island.is/application/templates/social-insurance-administration-core/lib/constants' +import { socialInsuranceAdministrationMessage } from '@island.is/application/templates/social-insurance-administration-core/lib/messages' +import { + friendlyFormatIBAN, + friendlyFormatSWIFT, + getBankIsk, + getCurrencies, + typeOfBankInfo, +} from '@island.is/application/templates/social-insurance-administration-core/lib/socialInsuranceAdministrationUtils' import { Application, DefaultEvents, @@ -23,29 +33,20 @@ import { FormModes, FormValue, } from '@island.is/application/types' +import { + applicantInformationMultiField, + buildFormConclusionSection, +} from '@island.is/application/ui-forms' +import isEmpty from 'lodash/isEmpty' +import { ApplicationReason } from '../lib/constants' import { pensionSupplementFormMessage } from '../lib/messages' import { - getApplicationReasonOptions, getApplicationAnswers, getApplicationExternalData, + getApplicationReasonOptions, + getAvailableMonths, getAvailableYears, } from '../lib/pensionSupplementUtils' -import { ApplicationReason } from '../lib/constants' -import { - MONTHS, - fileUploadSharedProps, -} from '@island.is/application/templates/social-insurance-administration-core/lib/constants' -import isEmpty from 'lodash/isEmpty' -import { BankAccountType } from '@island.is/application/templates/social-insurance-administration-core/lib/constants' -import { - friendlyFormatIBAN, - friendlyFormatSWIFT, - getBankIsk, - getCurrencies, - typeOfBankInfo, -} from '@island.is/application/templates/social-insurance-administration-core/lib/socialInsuranceAdministrationUtils' -import Logo from '@island.is/application/templates/social-insurance-administration-core/assets/Logo' -import { socialInsuranceAdministrationMessage } from '@island.is/application/templates/social-insurance-administration-core/lib/messages' export const PensionSupplementForm: Form = buildForm({ id: 'PensionSupplementDraft', @@ -312,7 +313,24 @@ export const PensionSupplementForm: Form = buildForm({ width: 'half', placeholder: socialInsuranceAdministrationMessage.period.monthDefaultText, - options: MONTHS, + options: (application: Application) => { + const { selectedYear } = getApplicationAnswers( + application.answers, + ) + + return getAvailableMonths(selectedYear) + }, + condition: (answers) => { + const { selectedYear, selectedYearHiddenInput } = + getApplicationAnswers(answers) + + return selectedYear === selectedYearHiddenInput + }, + }), + buildHiddenInputWithWatchedValue({ + // Needed to trigger an update on options in the select above + id: 'period.hiddenInput', + watchValue: 'period.year', }), ], }), diff --git a/libs/application/templates/social-insurance-administration/pension-supplement/src/lib/pensionSupplementUtils.ts b/libs/application/templates/social-insurance-administration/pension-supplement/src/lib/pensionSupplementUtils.ts index 14615e6c3564..cdefa151c0ed 100644 --- a/libs/application/templates/social-insurance-administration/pension-supplement/src/lib/pensionSupplementUtils.ts +++ b/libs/application/templates/social-insurance-administration/pension-supplement/src/lib/pensionSupplementUtils.ts @@ -1,23 +1,23 @@ import { getValueViaPath } from '@island.is/application/core' -import { Application, ExternalData, Option } from '@island.is/application/types' import { - ApplicationReason, - AttachmentLabel, - AttachmentTypes, -} from './constants' -import { pensionSupplementFormMessage } from './messages' -import subYears from 'date-fns/subYears' -import addMonths from 'date-fns/addMonths' + BankAccountType, + MONTHS, +} from '@island.is/application/templates/social-insurance-administration-core/lib/constants' import { Attachments, BankInfo, FileType, } from '@island.is/application/templates/social-insurance-administration-core/types' -import { - BankAccountType, - MONTHS, -} from '@island.is/application/templates/social-insurance-administration-core/lib/constants' +import { Application, ExternalData, Option } from '@island.is/application/types' +import addMonths from 'date-fns/addMonths' +import subYears from 'date-fns/subYears' import { PensionSupplementAttachments } from '../types' +import { + ApplicationReason, + AttachmentLabel, + AttachmentTypes, +} from './constants' +import { pensionSupplementFormMessage } from './messages' export const getApplicationAnswers = (answers: Application['answers']) => { const applicantPhonenumber = getValueViaPath( @@ -34,6 +34,11 @@ export const getApplicationAnswers = (answers: Application['answers']) => { const selectedMonth = getValueViaPath(answers, 'period.month') as string + const selectedYearHiddenInput = getValueViaPath( + answers, + 'period.hiddenInput', + ) as string + const additionalAttachments = getValueViaPath( answers, 'fileUploadAdditionalFiles.additionalDocuments', @@ -106,6 +111,7 @@ export const getApplicationAnswers = (answers: Application['answers']) => { applicationReason, selectedYear, selectedMonth, + selectedYearHiddenInput, additionalAttachments, additionalAttachmentsRequired, comment,