Skip to content

Commit 376455e

Browse files
author
Vikas Agarwal
committed
Github issue#1366, refCode is not being carried forward to the project
— Fixed
1 parent 34dc60c commit 376455e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/projects/create/components/ProjectWizard.jsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import _ from 'lodash'
22
import { unflatten } from 'flat'
3+
import qs from 'query-string'
34
import React, { Component, PropTypes } from 'react'
45
import { withRouter } from 'react-router-dom'
56
import { findProduct, findCategory, findProductCategory, findProductsOfCategory, getProjectCreationTemplateField } from '../../../config/projectWizard'
@@ -86,7 +87,7 @@ class ProjectWizard extends Component {
8687
}
8788
// retrieve refCode from query param
8889
// TODO give warning after truncating
89-
const refCode = _.get(location, 'query.refCode', '').trim().substr(0, PROJECT_REF_CODE_MAX_LENGTH)
90+
const refCode = _.get(qs.parse(window.location.search), 'refCode', '').trim().substr(0, PROJECT_REF_CODE_MAX_LENGTH)
9091
if (refCode.trim().length > 0) {
9192
// if refCode exists, update the updateQuery to set that refCode
9293
if (_.get(updateQuery, 'details')) {
@@ -158,9 +159,13 @@ class ProjectWizard extends Component {
158159
projectType = findProductCategory(productParam, true)
159160
// finds product object from product alias
160161
const product = findProduct(productParam, true)
162+
const refCode = _.get(qs.parse(window.location.search), 'refCode', '').trim().substr(0, PROJECT_REF_CODE_MAX_LENGTH)
161163
if (projectType) {// we can have `incomplete` as params.product
162164
updateQuery['type'] = { $set : projectType.id }
163165
updateQuery['details'] = { products : { $set: [product.id] } }
166+
if (refCode) {
167+
updateQuery.details.utm = { $set : { code : refCode } }
168+
}
164169
return WZ_STEP_FILL_PROJ_DETAILS
165170
}
166171
}

0 commit comments

Comments
 (0)