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

Changed to current date time instead of date time at which app was loaded. #6791

Merged

Conversation

shyamprakash123
Copy link
Contributor

@shyamprakash123 shyamprakash123 commented Dec 4, 2023

…aded

WHAT

🤖[deprecated] Generated by Copilot at 2d24c63

Pre-fill admission date in ConsultationForm component. This change sets the admission_date field to the current date when the component mounts, using a useEffect hook in src/Components/Facility/ConsultationForm.tsx.

Proposed Changes

Merge Checklist

  • Add specs that demonstrate bug / test a new feature.
  • Update product documentation.
  • Ensure that UI text is kept in I18n files.
  • Prep screenshot or demo video for changelog entry, and attach it to issue.
  • Request for Peer Reviews
  • Completion of QA

HOW

🤖[deprecated] Generated by Copilot at 2d24c63

  • Pre-fill the admission date field with the current date when the ConsultationForm component mounts (link)

@shyamprakash123 shyamprakash123 requested a review from a team as a code owner December 4, 2023 14:30
Copy link

netlify bot commented Dec 4, 2023

Deploy Preview for care-egov-staging ready!

Name Link
🔨 Latest commit 0c5a72b
🔍 Latest deploy log https://app.netlify.com/sites/care-egov-staging/deploys/65af50d8f2d6d20008693e35
😎 Deploy Preview https://deploy-preview-6791--care-egov-staging.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

vercel bot commented Dec 4, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
care-storybook ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 23, 2024 5:39am

@nihal467
Copy link
Member

nihal467 commented Dec 6, 2023

LGTM

Comment on lines 321 to 327
useEffect(() => {
dispatch({
type: "set_form",
form: { ...state.form, admission_date: new Date() },
});
}, []);

Copy link
Member

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.

Copy link
Member

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())()})
})

Copy link
Contributor Author

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.

Copy link
Member

@rithviknishad rithviknishad Dec 9, 2023

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()}

Copy link
Member

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.

Copy link
Contributor Author

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@khavinshankar @Ashesh3 final changes ?

Copy link
Member

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)

cc: @rithviknishad @khavinshankar

@rithviknishad rithviknishad added question Further information is requested and removed changes required labels Dec 14, 2023
@rithviknishad rithviknishad added needs testing and removed question Further information is requested tested labels Jan 19, 2024
@nihal467
Copy link
Member

LGTM

@khavinshankar khavinshankar merged commit 01bb090 into ohcnetwork:develop Jan 23, 2024
36 checks passed
Copy link

@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 🙌.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Form default date time values: To be current date time instead of date time at which app was loaded
5 participants