-
Notifications
You must be signed in to change notification settings - Fork 248
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
O3-2720: Visit stop time input not working in edit mode #1621
Conversation
I don't think this fixes the underlying problem. This change seems to change the default start and end time in the form to current date / time. We still want to keep it defaulted to the original start / end time of the visit. The problem is with the |
Hello @chibongho , i updated the code accordingly . |
Hi @denniskigen .Looking forward to hear from you. |
Hey, @sherrif10, thanks for working on this. Is the first video you linked to in the PR description meant to replicate the problem? I'm not sure that it does. |
Some additional context on the minDate and maxDate props for Carbon datepickers:
|
Hello @denniskigen , Yes the first vedio is meant to replicate this issue.Are you suggesting i replace VisitDateTimeField with DatePicker for visit stop date while leveraging use of datePicker from carbon. |
@@ -497,8 +497,9 @@ const StartVisitForm: React.FC<StartVisitFormProps> = ({ | |||
return [maxVisitStartDatetime, minVisitStopDatetime]; | |||
}, [visitToEdit]); | |||
|
|||
const visitStartDate = getValues('visitStartDate'); | |||
minVisitStopDatetime = minVisitStopDatetime ?? Date.parse(visitStartDate.toLocaleString()); | |||
const visitStartDate = getValues('visitStartDate') || 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.
Why are we optionally calling new Date()
here? It looks like its already getting called conditionally higher up when initializing defaultValues
.
You are right , this pattern ensures that if visitToEdit doesn't have a start or stop datetime, the default value is set to the current date. The shared screen shot is the same. |
const visitStartDateValue = getValues('visitStartDate'); | ||
const visitStartDate = visitStartDateValue !== undefined ? visitStartDateValue : new Date(); | ||
const minVisitStopDatetimeFallback = Date.parse(visitStartDate.toLocaleString()); | ||
minVisitStopDatetime = minVisitStopDatetime || minVisitStopDatetimeFallback; |
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.
const visitStartDateValue = getValues('visitStartDate'); | |
const visitStartDate = visitStartDateValue !== undefined ? visitStartDateValue : new Date(); | |
const minVisitStopDatetimeFallback = Date.parse(visitStartDate.toLocaleString()); | |
minVisitStopDatetime = minVisitStopDatetime || minVisitStopDatetimeFallback; | |
const visitStartDate = getValues('visitStartDate') ?? new Date(); | |
minVisitStopDatetime = minVisitStopDatetime ?? Date.parse(visitStartDate.toLocaleString()); |
Isn't this the whole change you did?
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.
hI @vasharma05 ,Here is an updated screen shot
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.
Hi @denniskigen @vasharma05 . i addressed your comments. let me know your suggestions.
Requirements
Summary
Screenshots
Related Issue
Other
Ticket : https://openmrs.atlassian.net/browse/O3-2720
In the original code
visitStartDate
andvisitStopDate
are used to initialize the start and stop dates, respectively. If visitStartDate or visitStopDate is provided, they are used; otherwise, the current date is used. however the time-related fields visitStartTime, visitStartTimeFormat, visitStopTime, visitStopTimeFormat) are always initialized based on the provided or current date. in the fix i ensured consistency for both start and stop date. the code uses newDate() to get current date and time. Let me know your suggestions. cc @chibongho @rbuisson @vasharma05www_screencapture_com_2024-1-26_01_01.mp4
After