Skip to content

Commit 57c9d58

Browse files
author
Vikas Agarwal
committed
Github issue#1290, Incomplete project is dropping ref code
— Fixed the case when user selects, ‘Create New Project’ from the incomplete project screen.
1 parent 6bba30c commit 57c9d58

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/projects/create/components/ProjectWizard.jsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,13 +191,18 @@ class ProjectWizard extends Component {
191191
}
192192
}
193193

194+
getRefCodeFromURL() {
195+
return _.get(qs.parse(window.location.search), 'refCode', '').trim().substr(0, PROJECT_REF_CODE_MAX_LENGTH)
196+
}
197+
194198
/**
195199
* Removed incomplete project from the local storage and resets the state. Also, moves wizard to the first step.
196200
*/
197201
removeIncompleteProject() {
198202
const { onStepChange } = this.props
199203
// remove incomplete project from local storage
200204
window.localStorage.removeItem(LS_INCOMPLETE_PROJECT)
205+
// following code assumes that componentDidMount has already updated state with correct project and product types
201206
const projectType = _.get(this.state.project, 'type')
202207
const product = _.get(this.state.project, 'details.products[0]')
203208
let wizardStep = WZ_STEP_SELECT_PROJ_TYPE
@@ -209,6 +214,10 @@ class ProjectWizard extends Component {
209214
project = { type: projectType, details: { products: [] } }
210215
wizardStep = WZ_STEP_SELECT_PROD_TYPE
211216
}
217+
const refCode = this.getRefCodeFromURL()
218+
if (refCode) {
219+
project.details.utm = { code : refCode}
220+
}
212221
this.setState({
213222
project: _.merge({}, project),
214223
dirtyProject: _.merge({}, project),

0 commit comments

Comments
 (0)