Skip to content

Commit

Permalink
Merge pull request #740 from opencollective/fix1232
Browse files Browse the repository at this point in the history
Keep previous endsAt date when using a template
  • Loading branch information
xdamman committed Sep 4, 2018
2 parents 0fc25b6 + 6db4b34 commit 9d7e271
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/components/EditEventForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,20 @@ class EditEventForm extends React.Component {
event[fieldname] = value;

// Make sure that endsAt is always >= startsAt
if (fieldname === 'startsAt' || fieldname === 'endsAt') {
if (fieldname === 'startsAt') {
const endsAt = this.state.event.endsAt;
if (!endsAt || new Date(endsAt) < new Date(value)) {
let newEndDate = new Date(value);
if (!endsAt) {
newEndDate.setHours(newEndDate.getHours() + 2);
} else {
// https://github.com/opencollective/opencollective/issues/1232
const endsAtDate = new Date(endsAt);
newEndDate = new Date(value);
newEndDate.setHours(endsAtDate.getHours());
newEndDate.setMinutes(endsAtDate.getMinutes());
}
value = newEndDate.toString();
event['endsAt'] = value;
}
}
Expand Down

0 comments on commit 9d7e271

Please sign in to comment.