refactor: clean code related with removing the _path suffix
This commit is contained in:
parent
edaedd556b
commit
b96bff158f
1 changed files with 5 additions and 5 deletions
|
|
@ -270,12 +270,12 @@ function updateOverride (fields) {
|
||||||
'us_ssn'
|
'us_ssn'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
const removePathSuffix = _.map(_.replace('_path', ''))
|
||||||
|
const getPairs = _.map(f => [`${f}_override`, 'automatic'])
|
||||||
|
|
||||||
const updatedFields = _.intersection(updateableFields, _.keys(fields))
|
const updatedFields = _.intersection(updateableFields, _.keys(fields))
|
||||||
const overrideFields = _.fromPairs(_.map(f =>
|
console.log('updatedFields', updatedFields)
|
||||||
_.endsWith('_path', f)
|
const overrideFields = _.compose(_.fromPairs, getPairs, removePathSuffix)(updatedFields)
|
||||||
? [`${_.replace('_path', '_override', f)}`, 'automatic']
|
|
||||||
: [`${f}_override`, 'automatic']
|
|
||||||
, updatedFields))
|
|
||||||
|
|
||||||
return _.merge(fields, overrideFields)
|
return _.merge(fields, overrideFields)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue