Conversation
src/ui/pages/work/Workorder.js
Outdated
| const initialStartDate = (scheduledStartDate || value).replace('00:00', '').trim(); | ||
| const initialEndDate = scheduledEndDate.replace('00:00', '').trim(); | ||
|
|
||
| const dateFormat = 'dd-MMM-yyyy'; |
There was a problem hiding this comment.
We have constants for date formats and datetime formats in eam-components, that can be reused for this.
https://github.com/cern-eam/eam-components/blob/master/src/enums/Constants.js
src/ui/pages/work/Workorder.js
Outdated
| }; | ||
| } | ||
|
|
||
| const initialStartDate = (scheduledStartDate || value).replace('00:00', '').trim(); |
There was a problem hiding this comment.
Why removing time part instead of processing the date with a datetime format?
There was a problem hiding this comment.
The datepicker gives date format, having time in the format will cause an error. Not sure if the error comes from date-fns format/parse or the datepicker. The datepicker handles dates, not datetimes, the time itself is then not needed. I guess the time values come from the backend?
There was a problem hiding this comment.
Add Activity dialog seems to be giving current time in the value, will change the hardcoded 00:00 to a regex.
| } | ||
| } | ||
|
|
||
| updateScheduleProperty = (key, value) => { |
There was a problem hiding this comment.
Although this implementation can be used for the scheduled start/end dates of a Work Order, we still need the same behavior for the 'Add Activity' dialog start/end dates.
I believe the logic to add the days difference could be extracted in order to be reused.
There was a problem hiding this comment.
Separated the logic to a utils file, it's now used in both places
8e32eed to
2d80128
Compare
This pull request shifts the scheduled end date according to the date difference to the start date, when scheduled start date is changed