Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/config/projectWizard/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,10 @@ function getFilteredBuildingBlocks(priceConfig, buildingBlocks, preparedConditio
}
}
_.forEach(filterdBlocks, fb => {
const bb = buildingBlocks[fb]
const bb = {
...buildingBlocks[fb],
buildingBlockKey: fb,
}
matchedBlocks.push(bb)
})
})
Expand Down
21 changes: 17 additions & 4 deletions src/projects/create/containers/CreateContainer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { ViewTypes } from 'appirio-tech-react-components/components/Wizard/Wizar
import './CreateContainer.scss'
import ProjectTypeIcon from '../../../components/ProjectTypeIcon'
import { getNewProjectLink } from '../../../helpers/projectHelper'
import { getProductEstimate } from '../../../config/projectWizard'

import {
CREATE_PROJECT_FAILURE,
Expand Down Expand Up @@ -136,9 +137,11 @@ class CreateContainer extends React.Component {
componentWillMount() {
const { processing, userRoles, match, history,
templates } = this.props
let projectTemplate
// if we are on the project page validate project param
if (match.path === '/new-project/:project?/:status?') {
const project = match.params.project
projectTemplate = getProjectTemplateByAlias(templates.projectTemplates, project)

if (
// if project is defined in URL
Expand All @@ -149,7 +152,7 @@ class CreateContainer extends React.Component {
// project templates are loaded
templates.projectTemplates &&
// if project template doesn't exist
!getProjectTemplateByAlias(templates.projectTemplates, project)
!projectTemplate
) {
history.replace('/404')
}
Expand All @@ -163,7 +166,12 @@ class CreateContainer extends React.Component {
// if project wizard is loaded after redirection from register page
// TODO should we validate the project again?
console.log('calling createProjectAction...')
this.props.createProjectAction(incompleteProject, PROJECT_STATUS_IN_REVIEW)
const projectEstimation = getProductEstimate(projectTemplate, incompleteProject)
const projectWithEstimation = {
...incompleteProject,
estimation: _.get(projectEstimation, 'estimateBlocks', []),
}
this.props.createProjectAction(projectWithEstimation, PROJECT_STATUS_IN_REVIEW)
}
} else {
// if there is not incomplete project, clear the exisitng project from the redux state
Expand Down Expand Up @@ -241,12 +249,17 @@ class CreateContainer extends React.Component {
*/
createProject(project) {
const { templates: { projectTemplates }} = this.props
const projectTemplate = _.find(projectTemplates, _.get(project, 'templateId'))
const projectTemplate = _.find(projectTemplates, { id: _.get(project, 'templateId') })

this.setState({ creatingProject: true }, () => {
if (this.props.userRoles && this.props.userRoles.length > 0) {
this.prepareProjectForCreation(project, projectTemplate)
this.props.createProjectAction(project)
const projectEstimation = getProductEstimate(projectTemplate, project)
const projectWithEstimation = {
...project,
estimation: _.get(projectEstimation, 'estimateBlocks', []),
}
this.props.createProjectAction(projectWithEstimation)
} else {
// redirect to registration/login page
const retUrl = window.location.origin + '/new-project-callback'
Expand Down