Skip to content

Commit 2a26eb9

Browse files
author
vikasrohit
authored
Merge pull request #2404 from appirio-tech/hotfix/error_in_adding_new_phase_to_old_v3_projects
Hotfix/error in adding new phase to old v3 projects
2 parents 1e55489 + c7055c9 commit 2a26eb9

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/projects/actions/project.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -280,14 +280,18 @@ export function createProduct(project, productTemplate, phases, timelines) {
280280
const lastMilestone = _.maxBy(timelineState.timeline.milestones, 'order')
281281
// calculates the start date for the new phase by adding 1 day to the end date of the milestone
282282
// we don't use end date field of milestone because it might not reflect the correct end date
283-
startDate = moment(lastMilestone.startDate).hours(0).minutes(0).seconds(0)
284-
.milliseconds(0).add(lastMilestone.duration - 1, 'days').add(1, 'days')
285-
} else {
283+
if (lastMilestone && lastMilestone.startDate) {
284+
startDate = moment(lastMilestone.startDate).hours(0).minutes(0).seconds(0)
285+
.milliseconds(0).add(lastMilestone.duration - 1, 'days').add(1, 'days')
286+
}
287+
} else if (phase && phase.startDate) {
286288
// if there is no timeline for the phase, calculates the next phase's start date by adding 1 day to the
287289
// end date of last phase, we don't use end date field of milestone because it might not reflect the
288290
// correct end date
289291
startDate = moment(phase.startDate).hours(0).minutes(0).seconds(0)
290292
.milliseconds(0).add(phase.duration - 1, 'days').add(1, 'days')
293+
} else {
294+
// do nothing, use today as start date
291295
}
292296
}
293297
// assumes 10 days as default duration, ideally we could store it at template level

0 commit comments

Comments
 (0)