Skip to content

Conversation

@JuhQ
Copy link
Contributor

@JuhQ JuhQ commented Apr 20, 2021

This pull request shifts the scheduled end date according to the date difference to the start date, when scheduled start date is changed

const initialStartDate = (scheduledStartDate || value).replace('00:00', '').trim();
const initialEndDate = scheduledEndDate.replace('00:00', '').trim();

const dateFormat = 'dd-MMM-yyyy';
Copy link
Member

Choose a reason for hiding this comment

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

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

};
}

const initialStartDate = (scheduledStartDate || value).replace('00:00', '').trim();
Copy link
Member

Choose a reason for hiding this comment

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

Why removing time part instead of processing the date with a datetime format?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Add Activity dialog seems to be giving current time in the value, will change the hardcoded 00:00 to a regex.

}
}

updateScheduleProperty = (key, value) => {
Copy link
Member

Choose a reason for hiding this comment

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

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Separated the logic to a utils file, it's now used in both places

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants