diff --git a/src/projects/actions/project.js b/src/projects/actions/project.js index 02a28bd33..8d04333df 100644 --- a/src/projects/actions/project.js +++ b/src/projects/actions/project.js @@ -203,10 +203,10 @@ export function createProject(newProject) { * * @returns {Promise<[]>} list of products */ -function getAllProjectProducts(project) { - return getProjectPhasesWithProducts(project.id) - .then((phases) => _.flatten(_.map(phases, 'products'))) -} +// function getAllProjectProducts(project, fromDB = false) { +// return getProjectPhasesWithProducts(project.id, fromDB) +// .then((phases) => _.flatten(_.map(phases, 'products'))) +// } /** * Create timeline and milestones for a product @@ -235,11 +235,12 @@ function createTimelineAndMilestoneForProduct(product, phase) { * @returns {Promise} project */ function createProductsTimelineAndMilestone(project) { - return getAllProjectProducts(project) - .then((products) => - Promise.all(products.map(createTimelineAndMilestoneForProduct)) - ) - .then(() => project) + if (project.phases) { + const products = _.flatten(_.map(project.phases, 'products')) + return Promise.all(products.map(createTimelineAndMilestoneForProduct)).then(() => project) + } else { + console.log('We did not receive the phases for the project. Hence timeline and milestones are not created') + } } export function createProduct(project, productTemplate, phases, timelines) {