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

feat: create address input #362

merged 48 commits into from
Jan 17, 2025

Conversation

jamil314
Copy link
Collaborator

No description provided.

Copy link

Oops! Looks like you forgot to update the changelog. When updating CHANGELOG.md, please consider the following:

  • Changelog is read by country implementors who might not always be familiar with all technical details of OpenCRVS. Keep language high-level, user friendly and avoid technical references to internals.
  • Answer "What's new?", "Why was the change made?" and "Why should I care?" for each change.
  • If it's a breaking change, include a migration guide answering "What do I need to do to upgrade?".

@jamil314 jamil314 changed the base branch from feat-birth-v2 to develop January 16, 2025 13:29
@@ -195,6 +218,55 @@ const getIdFields = (person: string): FieldConfig[] => [
}
]

const getAddressOrSameAsMotherFields = (person: string): FieldConfig[] => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

could we have a tighter type for person?

Copy link
Collaborator

@makelicious makelicious left a comment

Choose a reason for hiding this comment

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

Looks good! Some suggestions

@@ -291,7 +363,7 @@ export const getInformantFields = (person: string): FieldConfig[] => [
},
options: { fontVariant: 'h2' }
},
...getAddressFields(person)
...getAddressOrSameAsMotherFields(person)
Copy link
Collaborator

Choose a reason for hiding this comment

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

We might want to separate this function to two different ones. Often it is perfectly fine to have condition nested inside a function.

When we need to name the function with "or" it might sometimes be better to bring that condition up a level, especially if the condition is "rare".

On high-level, it might be something like this:

const isFather = person === 'father';

// You know better how to name the function and the domain rules.
// Is father only one using the function? Is it always mother? Or can they be other way around? Would be cool if that is either reflected on function name or parameters.
const addressFields =  isFather ? getAddressWithSharedResidenceFields(father)  : getAddressFields(person)


@@ -14,6 +14,8 @@ import { field } from '@opencrvs/toolkit/conditionals'
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

@@ -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

@jamil314 jamil314 merged commit 3a608c7 into develop Jan 17, 2025
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants