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(driving-license): 65 renewal updates #15946

Merged
merged 7 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -3,43 +3,30 @@ import {
buildCustomField,
buildSubSection,
buildAlertMessageField,
hasYes,
buildDescriptionField,
YES,
} from '@island.is/application/core'
import { NationalRegistryUser } from '@island.is/api/schema'
import { info } from 'kennitala'
import { m } from '../../lib/messages'
import { hasNoDrivingLicenseInOtherCountry } from '../../lib/utils'
import {
hasHealthRemarks,
isYoungerThan65,
needsHealthCertificateCondition,
} from '../../lib/utils/formUtils'
import { BE } from '../../lib/constants'

export const subSectionHealthDeclaration = buildSubSection({
id: 'healthDeclaration',
title: m.healthDeclarationSectionTitle,
condition: hasNoDrivingLicenseInOtherCountry,
condition: (answers, externalData) =>
hasNoDrivingLicenseInOtherCountry(answers) &&
isYoungerThan65(answers, externalData),
children: [
buildMultiField({
id: 'overview',
title: m.healthDeclarationMultiFieldTitle,
description: m.healthDeclarationSubTitle,
space: 2,
condition: (answers, externalData) => {
if ((answers.fakeData as any).age) {
return (answers.fakeData as any).age < 65
}

return (
!hasYes(answers?.drivingLicenseInOtherCountry) &&
info(
(externalData.nationalRegistry.data as NationalRegistryUser)
.nationalId,
).age < 65
)
},
children: [
buildCustomField({
id: 'remarks',
Expand Down Expand Up @@ -173,32 +160,5 @@ export const subSectionHealthDeclaration = buildSubSection({
}),
],
}),
/* Different set of the Health Declaration screen for people over the age of 65 */
buildMultiField({
id: 'healthDeclarationAge65',
title: m.healthDeclarationMultiFieldTitle,
description: m.healthDeclarationAge65MultiFieldSubTitle,
space: 1,
condition: (answers, externalData) => {
if ((answers.fakeData as any).age) {
return (answers.fakeData as any).age >= 65
}

return (
!hasYes(answers?.drivingLicenseInOtherCountry) &&
info(
(externalData.nationalRegistry.data as NationalRegistryUser)
.nationalId,
).age >= 65
)
},
children: [
buildDescriptionField({
id: 'healthDeclarationAge65Description',
title: '',
description: 'Þetta view er í vinnslu',
}),
],
}),
],
})
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
buildRadioField,
buildSubSection,
getValueViaPath,
hasYes,
buildDescriptionField,
} from '@island.is/application/core'
import { m } from '../../lib/messages'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
BE,
B_TEMP,
B_FULL,
B_FULL_RENEWAL_65,
ApiActions,
} from './constants'
import { dataSchema } from './dataSchema'
Expand Down Expand Up @@ -83,6 +84,10 @@ const template: ApplicationTemplate<
? m.applicationForDrivingLicense.defaultMessage +
' - ' +
m.applicationForFullLicenseTitle.defaultMessage
: application.answers.applicationFor === B_FULL_RENEWAL_65
? m.applicationForDrivingLicense.defaultMessage +
' - ' +
m.applicationForRenewalLicenseTitle.defaultMessage
: m.applicationForDrivingLicense.defaultMessage,
institution: m.nationalCommissionerOfPolice,
dataSchema,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@ import {
B_FULL,
B_TEMP,
DrivingLicenseApplicationFor,
DrivingLicenseFakeData,
NO,
YES,
} from '../constants'
import { NationalRegistryUser } from '@island.is/api/schema'
import { info } from 'kennitala'

export const allowFakeCondition =
(result = YES) =>
Expand Down Expand Up @@ -50,6 +53,18 @@ export const hasNoDrivingLicenseInOtherCountry = (answers: FormValue) =>
getValueViaPath(answers, 'otherCountry.drivingLicenseInOtherCountry') ===
NO || true

export const isYoungerThan65 = (
answers: FormValue,
externalData: ExternalData,
) => {
const fakeData = getValueViaPath<DrivingLicenseFakeData>(answers, 'fakeData')
const age = info(
(externalData.nationalRegistry.data as NationalRegistryUser).nationalId,
)?.age

return fakeData && fakeData.age ? fakeData.age < 65 : age < 65
}

export const chooseDistrictCommissionerDescription = ({
answers,
}: {
Expand Down