-
Notifications
You must be signed in to change notification settings - Fork 487
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
Changed to current date time instead of date time at which app was loaded. #6791
Changed to current date time instead of date time at which app was loaded. #6791
Conversation
✅ Deploy Preview for care-egov-staging ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
LGTM |
useEffect(() => { | ||
dispatch({ | ||
type: "set_form", | ||
form: { ...state.form, admission_date: new Date() }, | ||
}); | ||
}, []); | ||
|
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 would be quite similar, this date would be generated when the component is initialized, i.e., if a user opens the form and moves away for some reason, this wouldn't be accurate if time is tracked.
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.
You could do this while submitting, something like
onSubmit(() => {
apiCall({...state, admission_date: (() => new Date())()})
})
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.
@khavinshankar but the user should be able to see the current date and time in the field of date of admission rather than the date at which the app was loaded. The user can also edit the date so if we take the new Date()
when onSubmit then there will be no use of the custom date field which is displayed to the user.
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.
He meant more like:
admission_date: state.form.admission_date ?? new Date() // API call
And in the date time input field, you can have something like this to always show current time while the form state's admission_date being null. It would be non-null only when onChange
is triggered.
value={state.form.admission_date ?? new Date()}
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.
@khavinshankar but I don't think that's a good way. It could mess up with the draft forms right?
Say the user wanted to create an admission consultation at 11 AM. But had to put the app in background for some reason, bought the app back, form drafts restored the form, but the form drafts would have saved admission_date
as null. This would cause the admission date to be time at which the submit button was clicked although user may not have intended that.
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.
@rithviknishad @khavinshankar can you suggest me the final changes?
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.
@khavinshankar @Ashesh3 final changes ?
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 think it should be left to be done on component mount, so that drafts play nice with it. In any case, the user should correctly set and verify the admission date before submission. I do see the issue of the "time" part not being pin point accurate in this solution, but it's manually configurable and they do see it while filling out the form. (correct me here if admission_date is a hidden field)
LGTM |
@shyamprakash123 We truly appreciate your efforts. Thank you for taking the time to contribute; this is a very valuable contribution to us 🥇. We always welcome your contribution 🙂, so feel free to contribute to anything anytime, and never lose that spirit of innovation 🙌. |
…aded
WHAT
🤖[deprecated] Generated by Copilot at 2d24c63
Pre-fill admission date in
ConsultationForm
component. This change sets theadmission_date
field to the current date when the component mounts, using auseEffect
hook insrc/Components/Facility/ConsultationForm.tsx
.Proposed Changes
@coronasafe/care-fe-code-reviewers @coronasafe/code-reviewers
Merge Checklist
HOW
🤖[deprecated] Generated by Copilot at 2d24c63
ConsultationForm
component mounts (link)