Skip to content

Commit 0a390c7

Browse files
committed
feat: use query params in evaluating wizard form conditions
1 parent c549480 commit 0a390c7

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/projects/create/components/ProjectBasicDetailsForm.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import _ from 'lodash'
22
import React, { Component } from 'react'
33
import PropTypes from 'prop-types'
4+
import qs from 'query-string'
45
import cn from 'classnames'
56
import FormsyForm from 'appirio-tech-react-components/components/Formsy'
67
const Formsy = FormsyForm.Formsy
@@ -107,11 +108,20 @@ class ProjectBasicDetailsForm extends Component {
107108
}
108109

109110
if (hasDependantFields && !_.isEqual(nextProps.dirtyProject, this.props.dirtyProject)) {
111+
// get URL query params as an object
112+
const indexOfQueryStart = window.location.href.indexOf('?')
113+
const queryParams = indexOfQueryStart > -1 ? qs.parse(window.location.href.substring(indexOfQueryStart + 1)) : {}
114+
// use values from query params during conditions evaluations
115+
// so we can control for by the URL params
116+
const evaluationData = {
117+
...queryParams,
118+
...nextProps.dirtyProject
119+
}
110120
const {
111121
updatedTemplate,
112122
hidedSomeNodes,
113123
updatedSomeNodes,
114-
} = updateNodesByConditions(template, nextProps.dirtyProject, nextProps.productTemplates)
124+
} = updateNodesByConditions(template, evaluationData, nextProps.productTemplates)
115125

116126
if (updatedSomeNodes) {
117127
this.setState({

0 commit comments

Comments
 (0)