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: create address input #362

Merged
merged 48 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
52fce1c
chore: update yarn.lock
jamil314 Jan 1, 2025
5d4ca76
feat: wip: birth event v2
jamil314 Jan 1, 2025
6654398
feat: use select option in gender, attendantAtBirth and birthType
jamil314 Jan 1, 2025
d11abb6
fix: use number for weight at birth
jamil314 Jan 2, 2025
fc6587d
feat: person input wip
jamil314 Jan 3, 2025
78ba94b
Merge branch 'develop' into feat-birth-v2
jamil314 Jan 6, 2025
6015741
feat: show dob or age based on dobUnknown checkbox
jamil314 Jan 6, 2025
505a08e
chore: rename directory
jamil314 Jan 6, 2025
373323b
amend: import from renamed directory
jamil314 Jan 6, 2025
07be5e2
feat: add informant relation to birth form
jamil314 Jan 6, 2025
4acd8f7
Merge branch 'develop' into feat-birth-v2
jamil314 Jan 7, 2025
c05f0d9
feat: render informant fields based on relation to child
jamil314 Jan 7, 2025
15fe150
feat: separate the logic for concatenating field id
jamil314 Jan 7, 2025
2a3758a
feat: complete informant details apart form person inputs
jamil314 Jan 7, 2025
29b280a
feat: implement id and address
jamil314 Jan 8, 2025
ed40dd7
refactor: create utils
jamil314 Jan 8, 2025
2b184f9
fix: handle undefined values in conditionals
jamil314 Jan 9, 2025
64a65aa
chore: Merge branch "develop" into feat-birth-v2
jamil314 Jan 9, 2025
cd43a65
feat: implement father and mother details
jamil314 Jan 9, 2025
a177f5e
feat: implement upload supporting document
jamil314 Jan 9, 2025
9e8e724
fix: use simpler concat
jamil314 Jan 9, 2025
e360b7b
feat: use country field
jamil314 Jan 9, 2025
d9fbb68
feat: add place of birth
jamil314 Jan 9, 2025
fd1019a
fix: typo
jamil314 Jan 9, 2025
a0a48ba
fix: align label and required properties with legecy birth
jamil314 Jan 9, 2025
18b98a2
fix: font of bulletList
jamil314 Jan 10, 2025
540454a
feat: add helper texts
jamil314 Jan 10, 2025
b7852bc
chore: bump up @opencrvs/toolkit
jamil314 Jan 10, 2025
d5a20de
chore: update yarn.lock
jamil314 Jan 13, 2025
468dea3
feat: use Location type in address
jamil314 Jan 13, 2025
d643fe5
feat: implement urbanOrRural
jamil314 Jan 13, 2025
94820da
feat: implement health_failities
jamil314 Jan 13, 2025
cca21ab
feat: add addressInput in tennis-club-membership
jamil314 Jan 14, 2025
100370a
Merge branch develop into feat-birth-v2
jamil314 Jan 15, 2025
545bd24
Merge branch "feat-birth-v2" into address-input-v2
jamil314 Jan 15, 2025
b154e6d
fix: update ids of other country input fields
jamil314 Jan 15, 2025
a215493
rename: BirthEvent to birthEvent
jamil314 Jan 15, 2025
ebbf8f1
chore: remove the messages that are not in use
jamil314 Jan 15, 2025
75278c5
chore: remove unused
jamil314 Jan 15, 2025
cbae59e
refactor: use informantType instead of hardcoding
jamil314 Jan 15, 2025
9511916
refactor: birth event
jamil314 Jan 16, 2025
fc1e9fe
chore: bump up toolkit
jamil314 Jan 16, 2025
b5ab7da
Merge branch `feat-birth-v2` into address-input-v2
jamil314 Jan 16, 2025
6878756
Merge branch `address-input-v2` of github.com:opencrvs/opencrvs-count…
jamil314 Jan 16, 2025
a86f06f
feat: add relation to child for someone else
jamil314 Jan 16, 2025
cd96a60
feat: usual place of residence same as mother
jamil314 Jan 16, 2025
e6e005c
refactor: make suggested changes
jamil314 Jan 17, 2025
0c7f19f
fix: update types
jamil314 Jan 17, 2025
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 src/form/v2/birth/forms/child.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@
},
{
id: 'child.birthLocation',
type: 'LOCATION',

Check failure on line 238 in src/form/v2/birth/forms/child.ts

View workflow job for this annotation

GitHub Actions / test

Type '"LOCATION"' is not assignable to type '"TEXT" | "DATE" | "PARAGRAPH" | "RADIO_GROUP" | "BULLET_LIST" | "SELECT" | "CHECKBOX" | "FILE" | "COUNTRY"'.
required: true,
label: {
defaultMessage: 'Health Institution',
Expand All @@ -243,7 +243,7 @@
id: 'event.birth.action.declare.form.section.child.field.birthLocation.label'
},
options: {
type: 'HEALTH_FACILITY'

Check failure on line 246 in src/form/v2/birth/forms/child.ts

View workflow job for this annotation

GitHub Actions / test

Type '{ type: "HEALTH_FACILITY"; }' is not assignable to type '{ value: string; label: { id: string; description: string; defaultMessage: string; }; }[]'.
},
conditionals: [
{
Expand All @@ -255,7 +255,7 @@
]
},
...appendConditionalsToFields({
inputFields: getAddressFields('child.privateHome'),
inputFields: getAddressFields('child.residentialAddress'),
newConditionals: [
{
type: 'HIDE',
Expand Down
8 changes: 6 additions & 2 deletions src/form/v2/birth/forms/informant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
import { defineFormPage, TranslationConfig } from '@opencrvs/toolkit/events'
import { field } from '@opencrvs/toolkit/conditionals'
import { appendConditionalsToFields, createSelectOptions } from '../../utils'
import { getInformantFields } from '../../person'
import { getPersonInputCommonFields } from '../../person'
import { getAddressFields } from '../../person/address'

export const InformantTypes = {
MOTHER: 'MOTHER',
Expand Down Expand Up @@ -111,7 +112,10 @@ export const informantPage = defineFormPage({
]
},
...appendConditionalsToFields({
inputFields: getInformantFields('informant'),
inputFields: [
...getPersonInputCommonFields('informant'),
...getAddressFields('informant')
],
newConditionals: [
{
type: 'HIDE',
Expand Down
8 changes: 7 additions & 1 deletion src/form/v2/person/address.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
import { FieldConfig, TranslationConfig } from '@opencrvs/toolkit/events'
import { field } from '@opencrvs/toolkit/conditionals'
import { appendConditionalsToFields, createSelectOptions } from '../utils'
import { PersonTypes } from '.'
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should not matter most of the time if build works, but filename could be added


export type AddressTypes =
| 'child.residentialAddress'
| 'child.other'
| PersonTypes

const UrbanRuralTypes = {
URBAN: 'URBAN',
Expand All @@ -36,7 +42,7 @@
urbanRuralMessageDescriptors
)

export const getAddressFields = (person: string): FieldConfig[] => {
export const getAddressFields = (person: AddressTypes): FieldConfig[] => {
const prefix = `${person}.address`

const genericAddressFields: FieldConfig[] = [
Expand Down Expand Up @@ -167,7 +173,7 @@
const farajalandAddressFields: FieldConfig[] = [
{
id: `${prefix}.province`,
type: 'LOCATION',

Check failure on line 176 in src/form/v2/person/address.ts

View workflow job for this annotation

GitHub Actions / test

Type '"LOCATION"' is not assignable to type '"TEXT" | "DATE" | "PARAGRAPH" | "RADIO_GROUP" | "BULLET_LIST" | "SELECT" | "CHECKBOX" | "FILE" | "COUNTRY"'.
required: true,
label: {
defaultMessage: 'Province',
Expand All @@ -175,12 +181,12 @@
id: `event.birth.action.declare.form.section.${person}.field.address.province.label`
},
options: {
type: 'ADMIN_STRUCTURE'

Check failure on line 184 in src/form/v2/person/address.ts

View workflow job for this annotation

GitHub Actions / test

Type '{ type: "ADMIN_STRUCTURE"; }' is not assignable to type '{ value: string; label: { id: string; description: string; defaultMessage: string; }; }[]'.
}
},
{
id: `${prefix}.district`,
type: 'LOCATION',

Check failure on line 189 in src/form/v2/person/address.ts

View workflow job for this annotation

GitHub Actions / test

Type '"LOCATION"' is not assignable to type '"TEXT" | "DATE" | "PARAGRAPH" | "RADIO_GROUP" | "BULLET_LIST" | "SELECT" | "CHECKBOX" | "FILE" | "COUNTRY"'.
required: true,
label: {
defaultMessage: 'District',
Expand All @@ -188,7 +194,7 @@
id: `event.birth.action.declare.form.section.${person}.field.address.district.label`
},
options: {
partOf: {

Check failure on line 197 in src/form/v2/person/address.ts

View workflow job for this annotation

GitHub Actions / test

Type '{ partOf: { $data: string; }; type: "ADMIN_STRUCTURE"; }' is not assignable to type '{ value: string; label: { id: string; description: string; defaultMessage: string; }; }[]'.
$data: `${prefix}.province`
},
type: 'ADMIN_STRUCTURE'
Expand All @@ -197,7 +203,7 @@
{
id: `${prefix}.urbanOrRural`,
type: 'RADIO_GROUP',
options: urbanRuralRadioOptions,

Check failure on line 206 in src/form/v2/person/address.ts

View workflow job for this annotation

GitHub Actions / test

Type '{ value: string; label: { id: string; description: string; defaultMessage: string; }; }[]' is not assignable to type '{ value: string; label: string; }[]'.
flexDirection: 'row',
required: false,
label: {
Expand Down
178 changes: 93 additions & 85 deletions src/form/v2/person/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import { getAddressFields } from './address'
import { appendConditionalsToFields, createSelectOptions } from '../utils'

export type PersonTypes = 'father' | 'mother' | 'informant' | 'applicant'
Copy link
Collaborator

Choose a reason for hiding this comment

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

We could use same pattern like this:

export const PersonType = {
  father: 'father',
  mother: 'mother'
} as const

export type PersonType = keyof typeof PersonType

and use the PersonType.father later in the file, so satisfy wouldn't be needed because they derive from the same source


const IDTypes = {
NATIONAL_ID: 'NATIONAL_ID',
PASSPORT: 'PASSPORT',
Expand Down Expand Up @@ -150,7 +152,7 @@
yesNoMessageDescriptors
)

const getIdFields = (person: string): FieldConfig[] => [
const getIdFields = (person: PersonTypes): FieldConfig[] => [
{
id: `${person}.idType`,
type: 'SELECT',
Expand Down Expand Up @@ -218,56 +220,9 @@
}
]

const getAddressOrSameAsMotherFields = (person: string): FieldConfig[] => {
if (person === 'father')
return [
...appendConditionalsToFields({
inputFields: [
{
id: `${person}.addressSameAsHelper`,
type: 'PARAGRAPH',
label: {
defaultMessage: "Same as mother's usual place of residence?",
description: 'This is the label for the field',
id: `event.birth.action.declare.form.section.${person}.field.addressSameAsHelper.label`
},
options: { fontVariant: 'reg16' }
},
{
id: `${person}.addressSameAs`,
type: 'RADIO_GROUP',
options: yesNoRadioOptions,
required: true,
label: {
defaultMessage: "Same as mother's usual place of residence?",
description: 'This is the label for the field',
id: `event.birth.action.declare.form.section.${person}.field.address.addressSameAs.label`
}
}
],
newConditionals: [
{
type: 'HIDE',
conditional: field('mother.detailsNotAvailable').isInArray(['true'])
}
]
}),
...appendConditionalsToFields({
inputFields: getAddressFields(person),
newConditionals: [
{
type: 'HIDE',
conditional: field(`${person}.addressSameAs`).isInArray([
YesNoTypes.YES
])
}
]
})
]
return getAddressFields(person)
}

export const getInformantFields = (person: string): FieldConfig[] => [
export const getPersonInputCommonFields = (
person: PersonTypes
): FieldConfig[] => [
{
id: `${person}.firstname`,
type: 'TEXT',
Expand Down Expand Up @@ -362,42 +317,95 @@
id: `event.birth.action.declare.form.section.${person}.field.addressHelper.label`
},
options: { fontVariant: 'h2' }
},
...getAddressOrSameAsMotherFields(person)
}
]

export const getPersonInputFields = (person: string): FieldConfig[] => [
...getInformantFields(person),
{
id: `${person}.maritalStatus`,
type: 'SELECT',
required: false,
label: {
defaultMessage: 'Marital Status',
description: 'This is the label for the field',
id: `event.birth.action.declare.form.section.${person}.field.maritalStatus.label`
const fatherAddressFields = [
...appendConditionalsToFields({
inputFields: [
{
id: `${'father' satisfies PersonTypes}.addressSameAsHelper`,
type: 'PARAGRAPH',
label: {
defaultMessage: "Same as mother's usual place of residence?",
description: 'This is the label for the field',
id: `event.birth.action.declare.form.section.${
'father' satisfies PersonTypes
}.field.addressSameAsHelper.label`
},
options: { fontVariant: 'reg16' }
},
{
id: `${'father' satisfies PersonTypes}.addressSameAs`,
type: 'RADIO_GROUP',
options: yesNoRadioOptions,

Check failure on line 341 in src/form/v2/person/index.ts

View workflow job for this annotation

GitHub Actions / test

Type '{ value: string; label: { id: string; description: string; defaultMessage: string; }; }[]' is not assignable to type '{ value: string; label: string; }[]'.
required: true,
label: {
defaultMessage: "Same as mother's usual place of residence?",
description: 'This is the label for the field',
id: `event.birth.action.declare.form.section.${
'father' satisfies PersonTypes
}.field.address.addressSameAs.label`
}
}
],
newConditionals: [
{
type: 'HIDE',
conditional: field(
`${'mother' satisfies PersonTypes}.detailsNotAvailable`
).isInArray(['true'])
}
]
}),
...appendConditionalsToFields({
inputFields: getAddressFields('father' satisfies PersonTypes),
newConditionals: [
{
type: 'HIDE',
conditional: field(
`${'father' satisfies PersonTypes}.addressSameAs`
).isInArray([YesNoTypes.YES])
}
]
})
]
export const getPersonInputFields = (person: PersonTypes): FieldConfig[] => {
const isFather = person === 'father'
return [
...getPersonInputCommonFields(person),
...(isFather ? fatherAddressFields : getAddressFields(person)),
{
id: `${person}.maritalStatus`,
type: 'SELECT',
required: false,
label: {
defaultMessage: 'Marital Status',
description: 'This is the label for the field',
id: `event.birth.action.declare.form.section.${person}.field.maritalStatus.label`
},
options: maritalStatusOptions
},
options: maritalStatusOptions
},
{
id: `${person}.educationalAttainment`,
type: 'SELECT',
required: false,
label: {
defaultMessage: 'Level of education',
description: 'This is the label for the field',
id: `event.birth.action.declare.form.section.${person}.field.educationalAttainment.label`
{
id: `${person}.educationalAttainment`,
type: 'SELECT',
required: false,
label: {
defaultMessage: 'Level of education',
description: 'This is the label for the field',
id: `event.birth.action.declare.form.section.${person}.field.educationalAttainment.label`
},
options: educationalAttainmentOptions
},
options: educationalAttainmentOptions
},
{
id: `${person}.occupation`,
type: 'TEXT',
required: false,
label: {
defaultMessage: 'Occupation',
description: 'This is the label for the field',
id: `event.birth.action.declare.form.section.${person}.field.occupation.label`
{
id: `${person}.occupation`,
type: 'TEXT',
required: false,
label: {
defaultMessage: 'Occupation',
description: 'This is the label for the field',
id: `event.birth.action.declare.form.section.${person}.field.occupation.label`
}
}
}
]
]
}
Loading