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: Myinfo Child DOB #6648

Merged
merged 13 commits into from
Aug 29, 2023
Merged

fix: Myinfo Child DOB #6648

merged 13 commits into from
Aug 29, 2023

Conversation

wanlingt
Copy link
Contributor

@wanlingt wanlingt commented Aug 23, 2023

Problem

Myinfo Child DOB is not showing up in the correct format in the frontend.

Solution

When the Myinfo Child DOB value is set, convert the date from the formats 'yyyy-MM-dd' to 'dd/MM/yyyy'.

The way the Myinfo Child values are processed is different from normal Myinfo fields. For example, for normal Myinfo fields, the preview of the field is distinct from the value of the field that's submitted. However, for Myinfo child fields, the value shown in the field is what's submitted. Hence, in this case, the formatting takes place in 2 areas:

  1. In the frontend (ChildrenCompoundField) before the field value is set
  2. In the backend, before the value gets hashed (myinfo.util.ts)

(TODO for the future - Ideally, the Myinfo child values will be processed in the same way as the normal Myinfo fields)

Details

  • Created a shared function to format Myinfo dates (formatMyinfoDate)

Breaking Changes

  • No - this PR is backwards compatible

Before & After Screenshots

(Look at the Child DOB field)

BEFORE:
image

AFTER:
image

Tests

  1. Happy path test
  • On a Myinfo form, create a child field with the DOB.
  • Fill in the form (Staging Myinfo accounts here)
  • The DOB should be in the format 'dd/MM/yyyy' on the form UI.
  • Submit the form
  • Check the email submission - the DOB for the child's field should also be in the same format.
  1. Regression test
  • On a Myinfo form, add the (non-child) Myinfo fields DOB (already has existing Myinfo data) and Marriage Date (has no existing Myinfo data)
  • The dates should be in the format 'dd/MM/yyyy' on the form UI.
  • Submit the form
  • Check the email submission - the dates should show up correctly

@wanlingt wanlingt temporarily deployed to staging August 23, 2023 09:46 — with GitHub Actions Inactive
@wanlingt wanlingt requested a review from foochifa August 23, 2023 10:40
@wanlingt wanlingt marked this pull request as ready for review August 23, 2023 10:40
Copy link
Contributor

@foochifa foochifa left a comment

Choose a reason for hiding this comment

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

Generally LGTM! Thanks for locating the problem @wanlingt

Copy link
Contributor

@foochifa foochifa left a comment

Choose a reason for hiding this comment

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

Approving again haha LGTM Thanks @wanlingt

@wanlingt wanlingt merged commit e34c951 into develop Aug 29, 2023
23 checks passed
@wanlingt wanlingt deleted the fix/myinfo-child-dob branch August 29, 2023 01:13
wanlingt added a commit that referenced this pull request Aug 29, 2023
* ref: shift MYINFO_DATE_FORMAT const to DateField

* feat: parse and format myinfo DOB

* fix: change dateFormat of ChildDateOfBirth

* fix: add space to CHILD_PREFIX

* fix: undo date formatting

* fix: change date format

* fix: add validation to backend

* fix: move date constants to shared

* ref: use shared formatMyinfoDate function

* test: use correct import

* fix: remove unused imports

* docs: add explanation

* ref: use const for myInfoFormattedValue
@KenLSM KenLSM mentioned this pull request Aug 31, 2023
92 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants