Skip to content
This repository has been archived by the owner on Sep 23, 2021. It is now read-only.

Commit

Permalink
refactor(dashboard): create a function to get nested objects
Browse files Browse the repository at this point in the history
Signed-off-by: Gianfranco Manganiello <gmanganiello@teclib.com>
  • Loading branch information
Gianfranco97 committed Oct 18, 2018
1 parent 0b93514 commit af29a9f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
5 changes: 1 addition & 4 deletions src/containers/SearchEngine/components/QueryBuilder/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import PropTypes from 'prop-types'
import itemtype from 'shared/itemtype'
import { flatten, unflatten } from 'shared/flat'
import I18n from 'shared/i18n'
import getNestedObject from 'shared/getNestedObject'
import createFieldList from '../../actions/createFieldList'
import Group from './Group'

Expand Down Expand Up @@ -164,10 +165,6 @@ class QueryBuilder extends PureComponent {
[type]: unflatten(flat)[type],
})
} else {
function getNestedObject(nestedObj, pathArr) {
return pathArr.reduce((obj, key) => ((obj && obj[key] !== 'undefined') ? obj[key] : undefined), nestedObj)
}

const rule = getNestedObject(newRules, id)

function getObject(element, rule) {
Expand Down
3 changes: 3 additions & 0 deletions src/shared/getNestedObject/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default (nestedObj, pathArr) => (
pathArr.reduce((obj, key) => ((obj && obj[key] !== 'undefined') ? obj[key] : undefined), nestedObj)
)

0 comments on commit af29a9f

Please sign in to comment.