Skip to content

Commit

Permalink
chore: final v1.3.2 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
tahmidrahman-dsi committed Jul 10, 2024
1 parent be98775 commit f248d94
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 66 deletions.
64 changes: 35 additions & 29 deletions src/form/birth/custom-fields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export function getLegacyBirthRegistrationNumber(
name: fieldName,
customQuestionMappingId: fieldId,
custom: true,
required: false,
required: true,
type: 'TEXT', // ANY FORM FIELD TYPE IS POSSIBLE. ADD ADDITIONAL PROPS AS REQUIRED. REFER TO THE form/README.md FILE
label: {
id: 'form.field.label.legacyBirthRegistrationNumber',
Expand Down Expand Up @@ -135,6 +135,37 @@ export function getLegacyBirthRegistrationTime(): SerializedFormField {
}
}

/**
* Handlebar fields:
* birthMotherCustomizedExactDateOfBirthUnknown / birthFatherCustomizedExactDateOfBirthUnknown / birthInformantCustomizedExactDateOfBirthUnknown
*/
export function getCustomizedExactDateOfBirthUnknown(
subject: 'mother' | 'father' | 'informant',
conditionals: Conditional[] = []
): SerializedFormField {
const fieldName: string = 'customizedExactDateOfBirthUnknown'
const fieldId: string = `birth.${subject}.${subject}-view-group.${fieldName}`

return {
name: fieldName,
customQuestionMappingId: fieldId,
custom: true,
required: false,
hideHeader: true,
hideInPreview: true,
type: 'CHECKBOX', // ANY FORM FIELD TYPE IS POSSIBLE. ADD ADDITIONAL PROPS AS REQUIRED. REFER TO THE form/README.md FILE
label: {
defaultMessage: 'Exact date of birth unknown',
description: 'Checkbox for exact date of birth unknown',
id: 'form.field.label.exactDateOfBirthUnknown'
},
initialValue: false,
validator: [], // EDIT VALIDATORS AS YOU SEE FIT
mapping: getCustomFieldMapping(fieldId), // ALL CUSTOM FIELDS MUST USE THIS MAPPING FUNCTION
conditionals // EDIT VALIDATORS AS YOU SEE FIT
}
}

/**
* Handlebar fields:
* birthMotherYearOfBirth / birthFatherYearOfBirth / birthInformantYearOfBirth
Expand All @@ -157,7 +188,7 @@ export function getYearOfBirth(
validator: [
{
operation: 'range',
parameters: [1883, 2060]
parameters: [1883, Number.parseInt(new Date().getFullYear().toString())]
},
{
operation: 'maxLength',
Expand All @@ -183,6 +214,7 @@ export function getYearOfBirth(
export function getFokontanyCustomAdress(
subject: 'child' | 'mother' | 'father' | 'informant',
conditionals: Conditional[] = [],
required: boolean,
labelOfFokontanyCustomAddress: MessageDescriptor
): SerializedFormField {
const fieldName: string = 'fokontanyCustomAddress'
Expand All @@ -192,7 +224,7 @@ export function getFokontanyCustomAdress(
name: fieldName,
customQuestionMappingId: fieldId,
custom: true,
required: true,
required: required,
type: 'TEXT', // ANY FORM FIELD TYPE IS POSSIBLE. ADD ADDITIONAL PROPS AS REQUIRED. REFER TO THE form/README.md FILE
label: labelOfFokontanyCustomAddress,
initialValue: '',
Expand All @@ -202,29 +234,3 @@ export function getFokontanyCustomAdress(
maxLength: 255
}
}

export const exactDateOfBirthUnknown = (
section: 'mother' | 'father' | 'informant',
conditionalCase: Conditional[]
): SerializedFormField => {
const fieldName = 'exactDateOfBirthUnknown'
const fieldId: string = `birth.${section}.${section}-view-group.${fieldName}`
return {
name: fieldName,
type: 'CHECKBOX',
label: {
defaultMessage: 'Exact date of birth unknown',
description: 'Checkbox for exact date of birth unknown',
id: 'form.field.label.exactDateOfBirthUnknown'
},
hideInPreview: true,
required: false,
custom: true,
customQuestionMappingId: fieldId,
hideHeader: true,
initialValue: false,
validator: [],
conditionals: conditionalCase,
mapping: getCustomFieldMapping(fieldId)
}
}
84 changes: 52 additions & 32 deletions src/form/birth/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import {
import {
// getAgeOfIndividualInYears,
getMaritalStatus,
registrationEmail,
registrationPhone,
getOccupation,
divider
Expand All @@ -53,8 +52,7 @@ import {
fatherFamilyNameConditionals,
informantNotMotherOrFather,
detailsExistConditional,
primaryAddressSameAsOtherPrimary,
locationOfBirthIsNotHealthFacility
primaryAddressSameAsOtherPrimary
} from '../common/default-validation-conditionals'
import {
getNationalIDValidators,
Expand All @@ -69,14 +67,14 @@ import { certificateHandlebars } from './certificate-handlebars'
import { getSectionMapping } from '@countryconfig/utils/mapping/section/birth/mapping-utils'
import { getCommonSectionMapping } from '@countryconfig/utils/mapping/field-mapping-utils'
import {
getCustomizedExactDateOfBirthUnknown,
getFokontanyCustomAdress,
getLegacyBirthRegistrationDate,
getLegacyBirthRegistrationNumber,
getLegacyBirthRegistrationTime,
getPlaceOfBirth,
getTimeOfBirth,
getYearOfBirth,
exactDateOfBirthUnknown
getYearOfBirth
} from './custom-fields'
// import { createCustomFieldExample } from '../custom-fields'

Expand Down Expand Up @@ -141,7 +139,7 @@ export const birthForm: ISerializedForm = {
},
{
defaultMessage:
'Once the declaration is processed you will receive an SMS to tell you when to visit the office to collect the certificate - Take your ID with you.',
'Once the declaration is processed you will receive you will receive an SMS to tell you when to visit the office to collect the certificate - Take your ID with you.',
description: 'Form information for birth',
id: 'form.section.information.birth.bullet3'
},
Expand Down Expand Up @@ -196,7 +194,15 @@ export const birthForm: ISerializedForm = {
weightAtBirth,
getFokontanyCustomAdress(
'child',
locationOfBirthIsNotHealthFacility,
[
{
action: 'hide',
expression:
'values.placeOfBirth!="PRIVATE_HOME" && values.placeOfBirth!="OTHER"'
}
],
true,
// locationOfBirthIsNotHealthFacility, // this display the field fktCustomAddress at the first opening of child section
{
id: 'form.field.label.fokontanyCustomAddress',
description: 'A form field that asks for name of fokontany',
Expand Down Expand Up @@ -240,7 +246,11 @@ export const birthForm: ISerializedForm = {
getNationalIDValidators('informant'),
certificateHandlebars.informantNID
),
exactDateOfBirthUnknown('informant', hideIfInformantMotherOrFather),
getCustomizedExactDateOfBirthUnknown(
'informant',
hideIfInformantMotherOrFather
),
// exactDateOfBirthUnknown(hideIfInformantMotherOrFather),
getBirthDate(
'informantBirthDate',
informantBirthDateConditionals.concat(
Expand Down Expand Up @@ -286,31 +296,32 @@ export const birthForm: ISerializedForm = {
), // Required field. In Farajaland, we have built the option to integrate with MOSIP. So we have different conditionals for each name to check MOSIP responses. You could always refactor firstNamesEng for a basic setup
// getCustomAddress('informant', hideIfInformantMotherOrFather),
registrationPhone, // If you wish to enable automated SMS notifications to informants, include this
registrationEmail, // If you wish to enable automated Email notifications to informants, include this
getFokontanyCustomAdress(
'informant',
hideIfInformantMotherOrFather,
{
id: 'form.field.label.customAddress',
description:
'A form field that asks for informent current address',
defaultMessage: 'Address'
}
),
// registrationEmail, // If you wish to enable automated Email notifications to informants, include this
// preceding field of address fields
divider('informant-nid-seperator', [
{
action: 'hide',
expression: informantNotMotherOrFather
}
])
]),
// ADDRESS FIELDS WILL RENDER HERE
/* divider('informant-address-seperator', [
{
action: 'hide',
expression: informantNotMotherOrFather
}
]), */
getFokontanyCustomAdress(
'informant',
hideIfInformantMotherOrFather,
true,
{
id: 'form.field.label.customAddress',
description:
'A form field that asks for informent current address',
defaultMessage: 'Address'
}
)
],
previewGroups: [informantNameInEnglish]
}
Expand Down Expand Up @@ -345,7 +356,10 @@ export const birthForm: ISerializedForm = {
getNationalIDValidators('mother'),
certificateHandlebars.motherNID
),
exactDateOfBirthUnknown('mother', detailsExistConditional),
getCustomizedExactDateOfBirthUnknown(
'mother',
detailsExistConditional
),
getBirthDate(
'motherBirthDate',
mothersBirthDateConditionals,
Expand All @@ -356,6 +370,7 @@ export const birthForm: ISerializedForm = {
'mother',
exactDateOfBirthUnknownConditional.concat(detailsExistConditional)
),
// exactDateOfBirthUnknown(detailsExistConditional),
// getAgeOfIndividualInYears(
// formMessageDescriptors.ageOfMother,
// exactDateOfBirthUnknownConditional.concat(detailsExistConditional)
Expand All @@ -378,16 +393,16 @@ export const birthForm: ISerializedForm = {
}
]),
getOccupation(certificateHandlebars.motherOccupation),
getFokontanyCustomAdress('mother', detailsExistConditional, {
id: 'form.field.label.customAddress',
description: 'A form field that asks for mother current address',
defaultMessage: 'Address'
}),
// getCustomAddress('mother', detailsExist),
// preceding field of address fields
divider('mother-nid-seperator', detailsExist),
// ADDRESS FIELDS WILL RENDER HERE
divider('mother-address-seperator', detailsExist)
getFokontanyCustomAdress('mother', detailsExistConditional, true, {
id: 'form.field.label.customAddress',
description: 'A form field that asks for mother current address',
defaultMessage: 'Address'
})
// divider('mother-address-seperator', detailsExist)
// getEducation(certificateHandlebars.motherEducationalAttainment),
// multipleBirth
],
Expand Down Expand Up @@ -432,7 +447,10 @@ export const birthForm: ISerializedForm = {
getNationalIDValidators('father'),
certificateHandlebars.fatherNID
),
exactDateOfBirthUnknown('father', detailsExistConditional),
getCustomizedExactDateOfBirthUnknown(
'father',
detailsExistConditional
),
getBirthDate(
'fatherBirthDate',
fathersBirthDateConditionals,
Expand All @@ -443,6 +461,7 @@ export const birthForm: ISerializedForm = {
'father',
exactDateOfBirthUnknownConditional.concat(detailsExistConditional)
),
// exactDateOfBirthUnknown(detailsExistConditional),
// getAgeOfIndividualInYears(
// formMessageDescriptors.ageOfFather,
// exactDateOfBirthUnknownConditional.concat(detailsExistConditional)
Expand All @@ -465,20 +484,21 @@ export const birthForm: ISerializedForm = {
}
]),
getOccupation(certificateHandlebars.fatherOccupation),
// getCustomAddress('father', detailsExist),
// preceding field of address fields
divider('father-nid-seperator', detailsExist),
// ADDRESS FIELDS WILL RENDER HERE
getFokontanyCustomAdress(
'father',
primaryAddressSameAsOtherPrimary.concat(detailsExistConditional),
true,
{
id: 'form.field.label.customAddress',
description:
'A form field that asks for father current address',
defaultMessage: 'Address'
}
),
// getCustomAddress('father', detailsExist),
// preceding field of address fields
divider('father-nid-seperator', detailsExist),
// ADDRESS FIELDS WILL RENDER HERE
divider('father-address-seperator', detailsExist)
// getEducation(certificateHandlebars.fatherEducationalAttainment),
],
Expand Down
17 changes: 16 additions & 1 deletion src/form/birth/required-sections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,11 @@ export const birthDocumentType = {
PASSPORT: 'PASSPORT',
OTHER: 'OTHER',
NOTIFICATION_OF_BIRTH: 'NOTIFICATION_OF_BIRTH',
NOTIFICATION_OF_BIRTH_VERSO: 'NOTIFICATION_OF_BIRTH_VERSO',
PROOF_OF_LEGAL_GUARDIANSHIP: 'PROOF_OF_LEGAL_GUARDIANSHIP',
PROOF_OF_ASSIGNED_RESPONSIBILITY: 'PROOF_OF_ASSIGNED_RESPONSIBILITY'
PROOF_OF_ASSIGNED_RESPONSIBILITY: 'PROOF_OF_ASSIGNED_RESPONSIBILITY',
ADOPTION_LETTER: 'ADOPTION_LETTER',
LIVRET_DE_FAMILLE: 'LIVRET_DE_FAMILLE'
}

export const documentsSection = {
Expand Down Expand Up @@ -67,6 +70,10 @@ export const documentsSection = {
{
value: birthDocumentType.NOTIFICATION_OF_BIRTH,
label: formMessageDescriptors.docTypeChildBirthProof
},
{
value: birthDocumentType.NOTIFICATION_OF_BIRTH_VERSO,
label: formMessageDescriptors.docTypeChildBirthProofVerso
}
],
mapping: getFieldMapping('documents')
Expand Down Expand Up @@ -131,6 +138,14 @@ export const documentsSection = {
{
value: birthDocumentType.OTHER,
label: formMessageDescriptors.docTypeOther
},
{
value: birthDocumentType.ADOPTION_LETTER,
label: formMessageDescriptors.docTypeAdoption
},
{
value: birthDocumentType.LIVRET_DE_FAMILLE,
label: formMessageDescriptors.docTypeLivretDeFamille
}
],
conditionals: [
Expand Down
6 changes: 3 additions & 3 deletions src/form/common/common-optional-fields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { Validator } from '../types/validators'
const exactDobConditional: Conditional[] = [
{
action: 'hide',
expression: '!window.config.FEATURES.DATE_OF_BIRTH_UNKNOWN'
expression: '!window.config.DATE_OF_BIRTH_UNKNOWN'
}
]

Expand All @@ -36,7 +36,7 @@ export const exactDateOfBirthUnknown = (
description: 'Checkbox for exact date of birth unknown',
id: 'form.field.label.exactDateOfBirthUnknown'
},
hideInPreview: true,
hideInPreview: false, // true
required: false,
hideHeader: true,
initialValue: false,
Expand Down Expand Up @@ -174,7 +174,7 @@ export const getOccupation = (
description: 'text for occupation form field',
id: 'form.field.label.occupation'
},
required: false,
required: true,
initialValue: '',
validator: [],
conditionals: [
Expand Down
2 changes: 1 addition & 1 deletion src/form/common/default-validation-conditionals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ export const brideOrGroomBirthDateValidators = (spouseType: string) => [
export const exactDateOfBirthUnknownConditional = [
{
action: 'hide',
expression: '!values.exactDateOfBirthUnknown'
expression: '!values.customizedExactDateOfBirthUnknown'
// '!values.exactDateOfBirthUnknown || !values.customizedExactDateOfBirthUnknown || !values.birthInformantCustomizedExactDateOfBirthUnknown'
}
]
Expand Down

0 comments on commit f248d94

Please sign in to comment.