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

fix(old-age-pension): add applicationType and move fishermen option t… #11574

Merged
merged 1 commit into from
Jun 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import { useLocale } from '@island.is/localization'
import { oldAgePensionFormMessage } from '../../../lib/messages'
import { ReviewGroupProps } from './props'
import { useStatefulAnswers } from '../../../hooks/useStatefulAnswers'
import { ApplicationType, NO, YES } from '../../../lib/constants'

export const Fishermen = ({ application }: ReviewGroupProps) => {
const [{ isFishermen }] = useStatefulAnswers(application)
const [{ applicationType }] = useStatefulAnswers(application)

const { formatMessage } = useLocale()

Expand All @@ -16,7 +17,7 @@ export const Fishermen = ({ application }: ReviewGroupProps) => {
<GridColumn span={['12/12', '12/12', '12/12', '5/12']}>
<RadioValue
label={formatMessage(oldAgePensionFormMessage.review.fishermen)}
value={isFishermen}
value={applicationType === ApplicationType.FISHERMEN ? YES : NO}
/>
</GridColumn>
</GridRow>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import * as kennitala from 'kennitala'
import Logo from '../assets/Logo'
import { oldAgePensionFormMessage } from '../lib/messages'
import {
ApplicationType,
ConnectedApplications,
FILE_SIZE_LIMIT,
HomeAllowanceHousing,
Expand All @@ -36,6 +37,7 @@ import {
import {
getApplicationAnswers,
getApplicationExternalData,
getYesNOOptions,
isEarlyRetirement,
isExistsCohabitantOlderThan25,
} from '../lib/oldAgePensionUtils'
Expand Down Expand Up @@ -284,10 +286,7 @@ export const OldAgePensionForm: Form = buildForm({
id: 'residenceHistory.question',
title:
oldAgePensionFormMessage.residence.residenceHistoryQuestion,
options: [
{ value: YES, label: oldAgePensionFormMessage.shared.yes },
{ value: NO, label: oldAgePensionFormMessage.shared.no },
],
options: getYesNOOptions(),
width: 'half',
largeButtons: true,
// condition: (answers, externalData) => {
Expand Down Expand Up @@ -384,9 +383,9 @@ export const OldAgePensionForm: Form = buildForm({
uploadButtonLabel:
oldAgePensionFormMessage.fileUpload.attachmentButton,
condition: (answers) => {
const { isFishermen } = getApplicationAnswers(answers)
const { applicationType } = getApplicationAnswers(answers)

return isFishermen === YES
return applicationType === ApplicationType.FISHERMEN
},
}),
],
Expand All @@ -408,16 +407,7 @@ export const OldAgePensionForm: Form = buildForm({
description:
oldAgePensionFormMessage.onePaymentPerYear
.onePaymentPerYearDescription,
options: [
{
value: YES,
label: oldAgePensionFormMessage.shared.yes,
},
{
value: NO,
label: oldAgePensionFormMessage.shared.no,
},
],
options: getYesNOOptions(),
defaultValue: NO,
width: 'half',
}),
Expand Down Expand Up @@ -534,16 +524,7 @@ export const OldAgePensionForm: Form = buildForm({
title:
oldAgePensionFormMessage.homeAllowance
.childrenBetween18And25,
options: [
{
value: YES,
label: oldAgePensionFormMessage.shared.yes,
},
{
value: NO,
label: oldAgePensionFormMessage.shared.no,
},
],
options: getYesNOOptions(),
width: 'half',
required: true,
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@ import {
UserProfileApi,
} from '@island.is/application/types'
import Logo from '../assets/Logo'
import { NO, YES } from '../lib/constants'
import { ApplicationType, NO, YES } from '../lib/constants'
import { oldAgePensionFormMessage } from '../lib/messages'
import { getApplicationAnswers } from '../lib/oldAgePensionUtils'
import {
getApplicationAnswers,
getYesNOOptions,
} from '../lib/oldAgePensionUtils'
import {
NationalRegistryResidenceHistoryApi,
NationalRegistryCohabitantsApi,
Expand Down Expand Up @@ -80,6 +83,46 @@ export const PrerequisitesForm: Form = buildForm({
}),
],
}),
buildSubSection({
id: 'applicationType',
title: oldAgePensionFormMessage.pre.applicationTypeTitle,
children: [
buildRadioField({
id: 'applicationType.option',
title: oldAgePensionFormMessage.pre.applicationTypeTitle,
description:
oldAgePensionFormMessage.pre.applicationTypeDescription,
options: [
{
value: ApplicationType.RETIREMENTPENSION,
label:
oldAgePensionFormMessage.pre
.retirementPensionApplicationTitle,
subLabel:
oldAgePensionFormMessage.pre
.retirementPensionApplicationDescription,
},
{
value: ApplicationType.HALFRETIREMENTPENSION,
label:
oldAgePensionFormMessage.pre
.halfRetirementPensionApplicationTitle,
subLabel:
oldAgePensionFormMessage.pre
.halfRetirementPensionApplicationDescription,
},
{
value: ApplicationType.FISHERMEN,
label: oldAgePensionFormMessage.pre.fishermenApplicationTitle,
subLabel:
oldAgePensionFormMessage.pre
.fishermenApplicationDescription,
},
],
required: true,
}),
],
}),
buildSubSection({
id: 'questions',
title: oldAgePensionFormMessage.pre.questionTitle,
Expand All @@ -92,10 +135,7 @@ export const PrerequisitesForm: Form = buildForm({
id: 'questions.pensionFund',
title: oldAgePensionFormMessage.pre.pensionFundQuestionTitle,
description: '',
options: [
{ value: YES, label: oldAgePensionFormMessage.shared.yes },
{ value: NO, label: oldAgePensionFormMessage.shared.no },
],
options: getYesNOOptions(),
width: 'half',
}),
buildCustomField(
Expand All @@ -116,16 +156,6 @@ export const PrerequisitesForm: Form = buildForm({
},
{ type: 'warning' },
),
buildRadioField({
id: 'questions.fishermen',
title: oldAgePensionFormMessage.pre.fishermenQuestionTitle,
description: '',
options: [
{ value: YES, label: oldAgePensionFormMessage.shared.yes },
{ value: NO, label: oldAgePensionFormMessage.shared.no },
],
width: 'half',
}),
buildSubmitField({
id: 'toDraft',
title: oldAgePensionFormMessage.pre.confirmationTitle,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
} from '../oldAgePensionUtils'
import {
AnswerValidationConstants,
ApplicationType,
earlyRetirementMaxAge,
earlyRetirementMinAge,
YES,
Expand All @@ -23,9 +24,11 @@ export const fileUpploadPenEarlyFisher = (
const obj = newAnswer as Record<string, Answer>
const { FILEUPLOADPENEARLYFISHER } = AnswerValidationConstants

const { selectedMonth, selectedYear, isFishermen } = getApplicationAnswers(
application.answers,
)
const {
selectedMonth,
selectedYear,
applicationType,
} = getApplicationAnswers(application.answers)
const dateOfBirth = kennitala.info(application.applicant).birthday

const dateOfBirth00 = new Date(
Expand Down Expand Up @@ -57,7 +60,7 @@ export const fileUpploadPenEarlyFisher = (
}
}

if (isFishermen === YES && obj.fishermen) {
if (applicationType === ApplicationType.FISHERMEN && obj.fishermen) {
if (isEmpty((obj as { fishermen: unknown[] }).fishermen)) {
return buildError(
validatorErrorMessages.requireAttachment,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import { buildError } from './utils'
export const period = (newAnswer: unknown, application: Application) => {
const obj = newAnswer as Record<string, Answer>
const { PERIOD } = AnswerValidationConstants
const { isFishermen } = getApplicationAnswers(application.answers)
const { applicationType } = getApplicationAnswers(application.answers)

const { startDate, endDate } = getStartDateAndEndDate(
application.applicant,
isFishermen,
applicationType,
)
const { year, month } = obj

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,9 @@ export enum AnswerValidationConstants {
FILEUPLOADPENEARLYFISHER = 'fileUploadEarlyPenFisher',
FILEUPLOADHOMEALLOWANCE = 'fileUploadHomeAllowance',
}

export enum ApplicationType {
RETIREMENTPENSION = 'retirementPension',
HALFRETIREMENTPENSION = 'halfRetirementPension',
FISHERMEN = 'fishermen',
}
10 changes: 8 additions & 2 deletions libs/application/templates/old-age-pension/src/lib/dataSchema.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
import { parsePhoneNumberFromString } from 'libphonenumber-js'
import { z } from 'zod'
import { HomeAllowanceHousing, NO, YES } from './constants'
import { ApplicationType, HomeAllowanceHousing, NO, YES } from './constants'
import { oldAgePensionFormMessage } from './messages'

export const dataSchema = z.object({
approveExternalData: z.boolean().refine((v) => v),
applicationType: z.object({
option: z.enum([
ApplicationType.RETIREMENTPENSION,
ApplicationType.HALFRETIREMENTPENSION,
ApplicationType.FISHERMEN,
]),
}),
questions: z.object({
pensionFund: z.enum([YES, NO]),
fishermen: z.enum([YES, NO]),
}),
applicantInfo: z.object({
email: z.string().email(),
Expand Down
46 changes: 46 additions & 0 deletions libs/application/templates/old-age-pension/src/lib/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,52 @@ export const oldAgePensionFormMessage: MessageDir = {
defaultMessage: 'Sækirðu um ellilífeyri sjómanna?',
description: 'Are you applying for fishermen old-age pension?',
},
applicationTypeTitle: {
id: 'pl.application:applicationType.title',
defaultMessage: 'Tegund umsóknar',
description: 'Type of application',
},
applicationTypeDescription: {
id: 'pl.application:applicationType.description',
defaultMessage: 'Vinsamlegast veldu tegund umsóknar',
description: 'Vinsamlegast veldu tegund umsóknar',
},
retirementPensionApplicationTitle: {
id: 'pl.application:retirementPension.application.title',
defaultMessage: 'Umsókn um ellilífeyri',
description: 'retirement pension application',
},
retirementPensionApplicationDescription: {
id: 'pl.application:retirementPension.application.description',
defaultMessage:
'Þeir sem eru 65 ára og eldri og hafa átt lögheimili á Íslandi í minnst þrjú ár gætu átt einhvern rétt á ellilífeyri. Sækja þarf um ellilífeyri en almennt myndast réttur við 67 ára aldur.',
description:
'Those who are 65 years of age or older and have had legal residence in Iceland for at least three years may have some right to a retirement pension. You have to apply for retirement pension, but in general you are entitled to it at the age of 67.',
},
halfRetirementPensionApplicationTitle: {
id: 'pl.application:halfRetirementPension.application.title',
defaultMessage: 'Umsókn um hálfan ellilífeyri',
description: 'Application for half retirement pension',
},
halfRetirementPensionApplicationDescription: {
id: 'pl.application:halfRetirementPension.application.description',
defaultMessage:
'Hægt er að sækja um hálfan ellilífeyri hjá TR samhliða greiðslu hálfs lífeyris frá skyldubundnum atvinnutengdum lífeyrissjóðum.',
description:
'You can apply for a half retirement pension from TR together with the payment of half a pension from compulsory employment-related pension funds.',
},
fishermenApplicationTitle: {
id: 'pl.application:fishermen.application.title',
defaultMessage: 'Umsókn um ellilífeyri sjómanna',
description: "Fishermen's retirement pension",
},
fishermenApplicationDescription: {
id: 'pl.application:fishermen.application.description',
defaultMessage:
'Sá sem hefur stundað sjómennsku á lögskráðu íslensku skipi eða skipi gert út af íslenskum aðilum í 25 ár eða lengur getur átt rétt á ellilífeyri frá 60 ára aldri. Fjöldi lögskráðra daga á sjó þarf að vera að lágmarki 180 dagar að meðaltali á ári á 25 árum.',
description:
'Anyone who has practiced seamanship on a registered Icelandic ship or a ship built by Icelandic entities for 25 years or more can be entitled to a retirement pension from the age of 60. The number of legally registered days at sea must be a minimum of 180 days on average per year over 25 years.',
},
}),

applicant: defineMessages({
Expand Down
Loading