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

feat: Reason for delayed registration in v2 birth #390

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"@hapi/boom": "^9.1.1",
"@hapi/hapi": "^20.0.1",
"@hapi/inert": "^6.0.3",
"@opencrvs/toolkit": "0.0.32-jr",
"@opencrvs/toolkit": "0.0.33-jr",
"@types/chalk": "^2.2.0",
"@types/csv2json": "^1.4.0",
"@types/fhir": "^0.0.30",
Expand Down
4 changes: 4 additions & 0 deletions src/form/tennis-club-membership.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ const TENNIS_CLUB_FORM = defineForm({
{
id: 'applicant.firstname',
type: 'TEXT',
options: { maxLength: 32 },
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could this be added as constant to ease up the development and possible refactoring

required: true,
label: {
defaultMessage: "Applicant's first name",
Expand All @@ -67,6 +68,7 @@ const TENNIS_CLUB_FORM = defineForm({
{
id: 'applicant.surname',
type: 'TEXT',
options: { maxLength: 32 },
required: true,
label: {
defaultMessage: "Applicant's surname",
Expand Down Expand Up @@ -151,6 +153,7 @@ const TENNIS_CLUB_FORM = defineForm({
},
{
id: 'recommender.firstname',
options: { maxLength: 32 },
type: 'TEXT',
required: true,
conditionals: [
Expand All @@ -167,6 +170,7 @@ const TENNIS_CLUB_FORM = defineForm({
},
{
id: 'recommender.surname',
options: { maxLength: 32 },
type: 'TEXT',
required: true,
conditionals: [
Expand Down
33 changes: 30 additions & 3 deletions src/form/v2/birth/forms/child.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@
*/

import { defineFormPage, TranslationConfig } from '@opencrvs/toolkit/events'
import { field } from '@opencrvs/toolkit/conditionals'
import { field, or } from '@opencrvs/toolkit/conditionals'
import {
appendConditionalsToFields,
createSelectOptions,
emptyMessage
} from '../../utils'
import { AddressType, getAddressFields } from '../../person/address'
import { applicationConfig } from '@countryconfig/api/application/application-config'

const GenderTypes = {
MALE: 'male',
Expand Down Expand Up @@ -178,6 +179,7 @@ export const childPage = defineFormPage({
{
id: 'child.firstname',
type: 'TEXT',
options: { maxLength: 32 },
required: true,
label: {
defaultMessage: 'First name(s)',
Expand All @@ -188,6 +190,7 @@ export const childPage = defineFormPage({
{
id: 'child.surname',
type: 'TEXT',
options: { maxLength: 32 },
required: true,
label: {
defaultMessage: 'Last name',
Expand Down Expand Up @@ -227,7 +230,31 @@ export const childPage = defineFormPage({
}
},
{
id: 'child.placeOfBirth.divider.start',
id: 'child.reason',
type: 'TEXT',
required: true,
label: {
defaultMessage: 'Reason for delayed registration',
description: 'This is the label for the field',
id: 'event.birth.action.declare.form.section.child.field.reason.label'
},
conditionals: [
{
type: 'HIDE',
conditional: field('child.dob')
.isAfter(applicationConfig.BIRTH.LATE_REGISTRATION_TARGET)
.apply()
},
{
type: 'HIDE',
conditional: field('child.dob')
.or((field) => field.isUndefined().not.isBeforeNow())
.apply()
}
]
},
{
id: 'child.divider_1',
type: 'DIVIDER',
label: emptyMessage
},
Expand Down Expand Up @@ -287,7 +314,7 @@ export const childPage = defineFormPage({
]
}),
{
id: 'child.placeOfBirth.divider.end',
id: 'child.divider_2',
type: 'DIVIDER',
label: emptyMessage
},
Expand Down
2 changes: 1 addition & 1 deletion src/form/v2/birth/forms/informant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export const informantPage = defineFormPage({
...getAddressFields(PersonType.informant),

{
id: 'informant.address.divider.end',
id: 'informant.divider',
type: 'DIVIDER',
label: emptyMessage
}
Expand Down
6 changes: 4 additions & 2 deletions src/form/v2/person/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ export const getPersonInputCommonFields = (
): FieldConfig[] => [
{
id: `${person}.firstname`,
options: { maxLength: 32 },
type: 'TEXT',
required: true,
label: {
Expand All @@ -248,6 +249,7 @@ export const getPersonInputCommonFields = (
},
{
id: `${person}.surname`,
options: { maxLength: 32 },
type: 'TEXT',
required: true,
label: {
Expand Down Expand Up @@ -329,7 +331,7 @@ export const getPersonInputCommonFields = (
},
...getIdFields(person),
{
id: `${person}.address.divider.start`,
id: `${person}.addressDivider_1`,
Copy link
Collaborator

Choose a reason for hiding this comment

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

any reason for changing casing here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This was done so that ES would not nest the dot separated fields

type: 'DIVIDER',
label: emptyMessage
},
Expand Down Expand Up @@ -388,7 +390,7 @@ export const getPersonInputFields = (person: PersonType): FieldConfig[] => {
...getPersonInputCommonFields(person),
...(isFather ? fatherAddressFields : getAddressFields(person)),
{
id: `${person}.address.divider.end`,
id: `${person}.addressDivider_2`,
type: 'DIVIDER',
label: emptyMessage
},
Expand Down
Loading