-
Notifications
You must be signed in to change notification settings - Fork 9
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
VATEAM-90733: Normalize OMB info fields #2252
VATEAM-90733: Normalize OMB info fields #2252
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no problem with any of this provided the various GraphQL tests pass, but will hold approval until reviewed by someone on the form builder team.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work. One requested change that we discussed around date conversion.
const formatDate = dateString => | ||
// Depending on what time zone our servers operate on, we may need to adjust | ||
// this offset. | ||
new Date(Date.parse(`${dateString}T04:00-05:00`)).toLocaleDateString(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Slack conversation about this: https://agilesix.slack.com/archives/D076J681TB5/p1725460391490419?thread_ts=1725460364.715049&cid=D076J681TB5
Takeaway: it might be better to not convert to a Date
object (and thus introduce a time component) and instead just parse the input string to create the output string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A possible starting point:
const removeLeadingZero = s => s.substr(0, 1) === '0' ? s.substr(1) : s;
const convertDate = dateInput => {
const [year, month, day] = dateInput.split('-');
return `${removeLeadingZero(month)}/${removeLeadingZero(day)}/${year}`;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated. I found a regex expression that reduced the amount of code needed for removeLeadingZero
, but other than that, it's mostly your starting point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work!
@@ -11,6 +11,12 @@ const extractAdditionalFields = entity => { | |||
}; | |||
const extractForms = resultObject => resultObject?.data?.nodeQuery?.entities; | |||
|
|||
const formatDate = dateString => { | |||
const removeLeadingZero = s => s.replace(/^0+/, ''); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will remove multiple leading zeroes, should they be present, which I think is noteworthy but also should be N/A. In fact, if it somehow were the case that a string came over with multiple leading zeroes, I think we would want them all removed, so this is great. Makes me wonder if removeLeadingZeroes
is a better name, but that feels pedantic and possibly confusing given the context.
Nicely done!
aeb51af
to
fe17a57
Compare
f4446a6
to
680b6b5
Compare
680b6b5
to
4d7dc20
Compare
fe17a57
to
fd22547
Compare
Summary
Example output
Related issue(s)
Testing done
content-build
What areas of the site does it impact?
Only affects the output of digital-forms.json, which is not currently generated in production.
Acceptance criteria
Quality Assurance & Testing
Error Handling
Authentication
Requested Feedback
I made the decision to format the Expiration Date at this stage. As far as I can tell, we won't need it as anything other than a formatted string in the Form Renderer app, and this seems like the least expensive place to do that formatting. I am open to other suggestions.