|
1 | 1 | import _ from 'lodash' |
2 | 2 | import { unflatten } from 'flat' |
| 3 | +import qs from 'query-string' |
3 | 4 | import React, { Component, PropTypes } from 'react' |
4 | 5 | import { withRouter } from 'react-router-dom' |
5 | 6 | import { findProduct, findCategory, findProductCategory, findProductsOfCategory, getProjectCreationTemplateField } from '../../../config/projectWizard' |
@@ -86,7 +87,7 @@ class ProjectWizard extends Component { |
86 | 87 | } |
87 | 88 | // retrieve refCode from query param |
88 | 89 | // 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) |
90 | 91 | if (refCode.trim().length > 0) { |
91 | 92 | // if refCode exists, update the updateQuery to set that refCode |
92 | 93 | if (_.get(updateQuery, 'details')) { |
@@ -158,9 +159,13 @@ class ProjectWizard extends Component { |
158 | 159 | projectType = findProductCategory(productParam, true) |
159 | 160 | // finds product object from product alias |
160 | 161 | const product = findProduct(productParam, true) |
| 162 | + const refCode = _.get(qs.parse(window.location.search), 'refCode', '').trim().substr(0, PROJECT_REF_CODE_MAX_LENGTH) |
161 | 163 | if (projectType) {// we can have `incomplete` as params.product |
162 | 164 | updateQuery['type'] = { $set : projectType.id } |
163 | 165 | updateQuery['details'] = { products : { $set: [product.id] } } |
| 166 | + if (refCode) { |
| 167 | + updateQuery.details.utm = { $set : { code : refCode } } |
| 168 | + } |
164 | 169 | return WZ_STEP_FILL_PROJ_DETAILS |
165 | 170 | } |
166 | 171 | } |
|
0 commit comments