@@ -72,6 +72,7 @@ class CreateContainer extends React.Component {
7272 this . createProject = this . createProject . bind ( this )
7373 this . onLeave = this . onLeave . bind ( this )
7474 this . closeWizard = this . closeWizard . bind ( this )
75+ this . prepareProjectForCreation = this . prepareProjectForCreation . bind ( this )
7576 }
7677
7778 componentWillReceiveProps ( nextProps ) {
@@ -126,7 +127,10 @@ class CreateContainer extends React.Component {
126127 const incompleteProjectStr = window . localStorage . getItem ( LS_INCOMPLETE_PROJECT )
127128 if ( incompleteProjectStr ) {
128129 const incompleteProject = JSON . parse ( incompleteProjectStr )
130+ const incompleteProjectTemplateKey = _ . get ( incompleteProject , 'details.products[0]' )
129131 if ( match . path === '/new-project-callback' && ! processing && userRoles && userRoles . length > 0 ) {
132+ const projectTemplate = getProjectTemplateByKey ( templates . projectTemplates , incompleteProjectTemplateKey )
133+ this . prepareProjectForCreation ( incompleteProject , projectTemplate )
130134 // if project wizard is loaded after redirection from register page
131135 // TODO should we validate the project again?
132136 console . log ( 'calling createProjectAction...' )
@@ -176,6 +180,32 @@ class CreateContainer extends React.Component {
176180 // }
177181 }
178182
183+ /**
184+ * Helper method to add additional details required to create project
185+ *
186+ * @param {Object } project project data captured from user
187+ * @param {Object } projectTemplate project template to be used
188+ */
189+ prepareProjectForCreation ( project , projectTemplate ) {
190+ const gaClickId = Cookies . get ( GA_CLICK_ID )
191+ const gaClientId = Cookies . get ( GA_CLIENT_ID )
192+ if ( gaClientId || gaClickId ) {
193+ const googleAnalytics = { }
194+ if ( gaClickId !== 'null' ) {
195+ googleAnalytics [ GA_CLICK_ID ] = gaClickId
196+ }
197+ if ( gaClientId !== 'null' ) {
198+ googleAnalytics [ GA_CLIENT_ID ] = gaClientId
199+ }
200+ _ . set ( project , 'details.utm.google' , googleAnalytics )
201+ }
202+ if ( projectTemplate ) {
203+ project . version = 'v3'
204+ project . templateId = projectTemplate . id
205+ project . type = projectTemplate . category
206+ }
207+ }
208+
179209 /**
180210 * Creates new project if user is already logged in, otherwise, redirects user for registration/login.
181211 */
@@ -185,24 +215,7 @@ class CreateContainer extends React.Component {
185215
186216 this . setState ( { creatingProject : true } , ( ) => {
187217 if ( this . props . userRoles && this . props . userRoles . length > 0 ) {
188- // if user is logged in and has a valid role, create project
189- // uses dirtyProject from the state as it has the latest changes from the user
190- // this.props.createProjectAction(project)
191- const gaClickId = Cookies . get ( GA_CLICK_ID )
192- const gaClientId = Cookies . get ( GA_CLIENT_ID )
193- if ( gaClientId || gaClickId ) {
194- const googleAnalytics = { }
195- if ( gaClickId !== 'null' ) {
196- googleAnalytics [ GA_CLICK_ID ] = gaClickId
197- }
198- if ( gaClientId !== 'null' ) {
199- googleAnalytics [ GA_CLIENT_ID ] = gaClientId
200- }
201- _ . set ( project , 'details.utm.google' , googleAnalytics )
202- }
203- project . version = 'v3'
204- project . templateId = projectTemplate . id
205- project . type = projectTemplate . category
218+ this . prepareProjectForCreation ( project , projectTemplate )
206219 this . props . createProjectAction ( project )
207220 } else {
208221 // redirect to registration/login page
0 commit comments