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

Update deceased age label & conditionals #792

Merged
merged 2 commits into from
Dec 12, 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
17 changes: 13 additions & 4 deletions src/form/birth/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ import {
fatherFirstNameConditionals,
fatherFamilyNameConditionals,
informantNotMotherOrFather,
detailsExistConditional
detailsExistConditional,
ageOfIndividualConditionals,
ageOfParentsConditionals
} from '../common/default-validation-conditionals'
import {
getNationalIDValidators,
Expand Down Expand Up @@ -248,7 +250,8 @@ export const birthForm: ISerializedForm = {
formMessageDescriptors.ageOfInformant,
exactDateOfBirthUnknownConditional.concat(
hideIfInformantMotherOrFather
)
),
ageOfIndividualConditionals
),
getNationality(
certificateHandlebars.informantNationality,
Expand Down Expand Up @@ -319,7 +322,10 @@ export const birthForm: ISerializedForm = {
exactDateOfBirthUnknown(detailsExistConditional),
getAgeOfIndividualInYears(
formMessageDescriptors.ageOfMother,
exactDateOfBirthUnknownConditional.concat(detailsExistConditional)
exactDateOfBirthUnknownConditional.concat(
detailsExistConditional
),
ageOfParentsConditionals
),
getNationality(
certificateHandlebars.motherNationality,
Expand Down Expand Up @@ -395,7 +401,10 @@ export const birthForm: ISerializedForm = {
exactDateOfBirthUnknown(detailsExistConditional),
getAgeOfIndividualInYears(
formMessageDescriptors.ageOfFather,
exactDateOfBirthUnknownConditional.concat(detailsExistConditional)
exactDateOfBirthUnknownConditional.concat(
detailsExistConditional
),
ageOfParentsConditionals
),
getNationality(
certificateHandlebars.fatherNationality,
Expand Down
19 changes: 4 additions & 15 deletions src/form/common/common-optional-fields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
} from './select-options'
import { certificateHandlebars } from '../birth/certificate-handlebars'
import { getFieldMapping } from '@countryconfig/utils/mapping/field-mapping-utils'
import { Validator } from '../types/validators'

const exactDobConditional: Conditional[] = [
{
Expand Down Expand Up @@ -53,27 +54,15 @@ export const exactDateOfBirthUnknown = (

export const getAgeOfIndividualInYears = (
label: MessageDescriptor,
conditionals: Conditional[]
conditionals: Conditional[],
validators: Validator[]
): SerializedFormField => ({
name: 'ageOfIndividualInYears',
type: 'NUMBER',
label,
required: true,
initialValue: '',
validator: [
{
operation: 'range',
parameters: [12, 120]
},
{
operation: 'maxLength',
parameters: [3]
},
{
operation: 'isValidParentsBirthDate',
parameters: [10, true]
}
],
validator: validators,
conditionals,
postfix: 'years',
inputFieldWidth: '78px'
Expand Down
41 changes: 41 additions & 0 deletions src/form/common/default-validation-conditionals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,47 @@ export const brideOrGroomBirthDateValidators = (spouseType: string) => [
}
]

export const brideOrGroomAgeValidators = [
{
operation: 'range',
parameters: [18, 120]
},
{
operation: 'maxLength',
parameters: [3]
}
] satisfies Validator[]

export const ageOfIndividualConditionals: Validator[] = [
{
operation: 'range',
parameters: [12, 120]
},
{
operation: 'maxLength',
parameters: [3]
}
]

export const ageOfParentsConditionals = [
...ageOfIndividualConditionals,
{
operation: 'isValidParentsBirthDate',
parameters: [10, true]
}
]

export const ageOfDeceasedConditionals = [
{
operation: 'range',
parameters: [0, 120]
},
{
operation: 'maxLength',
parameters: [3]
}
] satisfies Validator[]

export const exactDateOfBirthUnknownConditional = [
{
action: 'hide',
Expand Down
14 changes: 9 additions & 5 deletions src/form/death/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import {
getMaritalStatus,
registrationEmail,
registrationPhone,
divider,
getOccupation
divider
// getOccupation
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// getOccupation

Copy link
Collaborator Author

@Zangetsu101 Zangetsu101 Dec 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if it's there just as a guideline to the implementer perhaps?

} from '../common/common-optional-fields'
import {
getGender,
Expand Down Expand Up @@ -44,6 +44,8 @@ import {
hideIfNidIntegrationEnabled,
informantBirthDateConditionals,
informantFamilyNameConditionals,
ageOfIndividualConditionals,
ageOfDeceasedConditionals,
informantFirstNameConditionals,
exactDateOfBirthUnknownConditional,
isValidBirthDate /*,
Expand Down Expand Up @@ -192,8 +194,9 @@ export const deathForm = {
), // Required field.,
exactDateOfBirthUnknown([]),
getAgeOfIndividualInYears(
formMessageDescriptors.ageOfInformant,
exactDateOfBirthUnknownConditional
formMessageDescriptors.ageOfDeceased,
exactDateOfBirthUnknownConditional,
ageOfDeceasedConditionals
),
getNationality(certificateHandlebars.deceasedNationality, []),
getNationalID(
Expand Down Expand Up @@ -274,7 +277,8 @@ export const deathForm = {
exactDateOfBirthUnknown([]),
getAgeOfIndividualInYears(
formMessageDescriptors.ageOfInformant,
exactDateOfBirthUnknownConditional
exactDateOfBirthUnknownConditional,
ageOfIndividualConditionals
),
getNationality(certificateHandlebars.informantNationality, []),
getNationalID(
Expand Down
19 changes: 11 additions & 8 deletions src/form/marriage/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ import {
} from './required-fields'
import { Event, ISerializedForm } from '../types/types'
import {
ageOfIndividualConditionals,
brideOrGroomAgeValidators,
exactDateOfBirthUnknownConditional,
getNationalIDValidators
} from '../common/default-validation-conditionals'
Expand Down Expand Up @@ -128,7 +130,8 @@ export const marriageForm: ISerializedForm = {
formMessageDescriptors.ageOfInformant,
exactDateOfBirthUnknownConditional.concat(
hideIfInformantBrideOrGroom
)
),
ageOfIndividualConditionals
),
getNationality(
certificateHandlebars.informantNationality,
Expand Down Expand Up @@ -183,7 +186,8 @@ export const marriageForm: ISerializedForm = {
exactDateOfBirthUnknown([]),
getAgeOfIndividualInYears(
formMessageDescriptors.ageOfGroom,
exactDateOfBirthUnknownConditional
exactDateOfBirthUnknownConditional,
brideOrGroomAgeValidators
),
getNationality(certificateHandlebars.groomNationality, []), // Required field
getNationalID(
Expand Down Expand Up @@ -230,12 +234,11 @@ export const marriageForm: ISerializedForm = {
certificateHandlebars.brideBirthDate
), // Required field
exactDateOfBirthUnknown([]),
getAgeOfIndividualInYears(formMessageDescriptors.ageOfBride, [
{
action: 'hide',
expression: '!values.exactDateOfBirthUnknown'
}
]),
getAgeOfIndividualInYears(
formMessageDescriptors.ageOfBride,
exactDateOfBirthUnknownConditional,
brideOrGroomAgeValidators
),
getNationality(certificateHandlebars.brideNationality, []), // Required field
getNationalID(
'iD',
Expand Down
Loading