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 #8533

Merged
merged 14 commits into from
Feb 7, 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?".

if (typeof value === 'string') {
const formattedDate = value
.split('-')
.map((d: string) => d.padStart(2, '0'))
Copy link
Collaborator

Choose a reason for hiding this comment

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

What happens to years here? Could you move this under utils.ts next to FormFieldGenerator? We could write test cases under utils.test.ts and run this function with different values.

I think with -- this returns 00-00-00

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Valid years are always of four digits. So, if there is a year which is of less than two digits, it should be considered invalid. In that sense, we don't need to make it four digits. What do you think?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sorry, let me rephrase.

Could we write few test cases for this function. If I understand correctly, it receives values from formik. Formik DateField returns a string. When DATE input is empty, '--' is returned.

When we are building on top of that, I'm more worried that the functionality goes undocumented. Tests could help us there if we are not changing DateField behavior.

Pseudocode:

const cases = [
{
   expected: '--',
   actual: // whatever you expect
},
{
   expected: '01-02-',
   actual: // whatever you expect
},
{
   expected: '1-2-3',
   actual: // whatever you expect
},
{
   expected: '01-2-32',
   actual: // whatever you expect
},
...,
];


cases.forEach((case) => {
 // or snapshot if you prefer
  expect(case.input).toBe(case.output)
})

}
return acc
},
{ ...values }
Copy link
Collaborator

Choose a reason for hiding this comment

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

I suppose this does not need to be destructured. Let's aim that we don't mutate as a principle

/**
* Checks if the date is within `days` days in the past from now.
*/
isAfter: (days: number) => FieldAPI
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could inPast work? Then possible inFuture would work. (or
Would it make isBeforeNow -> isPast?
Something that would work both ways and we could unify the terms under.

daysInPast daysAgo daysAfter daysSince daysPassedSince

* @returns adds 0 before single digit days and months to make them 2 digit
* @because ajv's `formatMaximum` and `formatMinimum` does not allow single digit day or months
*/
function getValuesWithFormattedDate(
Copy link
Collaborator

@makelicious makelicious Jan 31, 2025

Choose a reason for hiding this comment

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

Appreciate the comment 🙏 @ because might not be supported. It seems that we are going through all the values but only touching one. Would there be more specific names to functions, or could the implementation be more generic?

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.

Good job! Comment on the nested structure

@@ -95,17 +95,30 @@ export function eventHasAction(type: ActionDocument['type']) {
}
}

type dateBoundary = {
Copy link
Collaborator

Choose a reason for hiding this comment

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

DateBoundary

Comment on lines 206 to 212
isAfter: () => ({
days: (days: number) => ({
inPast: () =>
addCondition(getDateRange(getDateFromNow(days), 'formatMinimum')),
inFuture: () =>
addCondition(getDateRange(getDateFromNow(-days), 'formatMinimum'))
}),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Really like the abstraction effort! Is the isAfter nested with inPast and inFuture bit odd? could they be flattened or what do yout hink?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

isAfter and isBefore are the boundaries, whereas inPast and inFuture indicates if some boundary is n days in the past (n days before now) or n days in the future (n days after now).
We could ditch inPast and inFuture to make it refer to the past date by default, and future when days is -n .

@jamil314 jamil314 enabled auto-merge (squash) February 7, 2025 08:06
@jamil314 jamil314 merged commit 0c73bae into develop Feb 7, 2025
40 of 41 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.

None yet

2 participants