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

fix(ocrvs-5086): show different label when father address matches #183

Merged

Conversation

makelicious
Copy link
Collaborator

@makelicious makelicious commented Jul 2, 2024

Show matching label depending on father's primary address selection.

  • Extend conditionalCase type, allow passing Conditional[]

preview-father-details

I could not get to a nicely working solution without utilising the Conditional type. I opted for not trying to modify the primaryAddress previewGroup since it was much more involved.

Let me know what you think. I left a todo comment which I intend to fix if you find the approach ok.

Allow passing array of conditionals, create helper
@makelicious
Copy link
Collaborator Author

@Zangetsu101 @rikukissa Just to clarify the discussion we had earlier:

  1. Initial specification was to change the question labels
    Yes -> Same as mother's usual place of residence
    No -> Different from mother’s usual place of residence
  2. Tameem pointed out that we would need to create an exception for that
  3. Another way would be to just use the "actual" label Same as mother's usual place of residence? instead of Usual place of residence

I could not find a simple way to change the label as suggested. Let me know if I missed something.

@makelicious makelicious marked this pull request as draft July 2, 2024 14:14
@makelicious makelicious marked this pull request as ready for review July 3, 2024 06:47
@makelicious makelicious added this to the v1.5.0 milestone Jul 3, 2024
Copy link
Collaborator

@Zangetsu101 Zangetsu101 left a comment

Choose a reason for hiding this comment

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

The changes look good! It's better this way than to handling the form label & review label separately. One other thing, although it's not mentioned in the ticket, in death form we also have a similar case for informant & spouse if I'm not wrong. They should have a field like "place of residence same as deceased". Let's add the conditionals for them as well please!

fields: SerializedFormField[],
conditionalCase: string | Conditional[]
) {
fields.forEach((field) => {
Copy link
Member

Choose a reason for hiding this comment

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

Was there some other mutation happening on a higher level that forced this function also to mutate the inner array values?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I will check! I opted for caution if there was some performance reason for mutating.

Copy link
Member

Choose a reason for hiding this comment

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

If you see code with side effects in our codebase you can safely assume it's either:

  1. Something higher in the call stack is built using mutation and the author didn't have time to fix the root issue
  2. Side-effectful code got past code review unnoticed

We advocate for immutable values and anything else should be a rare exception

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Clear! On this particular case, We are mutating on higher levels. Taking into account the 1.5. delivery, I suggest I'll merge this one after the new changes have been reviewed and check whether I could get rid of the mutations.

@makelicious
Copy link
Collaborator Author

Added same conditionals for informant and spouse fields on 'Death' event
preview-father-dead

Copy link
Collaborator

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

@makelicious makelicious merged commit 025b2a0 into develop Jul 3, 2024
1 check passed
github-actions bot pushed a commit that referenced this pull request Jul 3, 2024
github-actions bot pushed a commit that referenced this pull request Jul 3, 2024
makelicious added a commit that referenced this pull request Jul 3, 2024
🍒 Merge changes from PR #183 to release-v1.5.0
@Zangetsu101 Zangetsu101 deleted the fix/ocrvs-5086-update-father-primary-address-review-copy branch July 3, 2024 14:11
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.

Father usual place of residence same as mother. Review just says Yes.
3 participants