refactor: clean code related with removing the _path suffix

This commit is contained in:
Sérgio Salgado 2021-08-03 19:00:52 +01:00 committed by Josh Harvey
parent edaedd556b
commit b96bff158f

View file

@ -270,12 +270,12 @@ function updateOverride (fields) {
'us_ssn'
]
const removePathSuffix = _.map(_.replace('_path', ''))
const getPairs = _.map(f => [`${f}_override`, 'automatic'])
const updatedFields = _.intersection(updateableFields, _.keys(fields))
const overrideFields = _.fromPairs(_.map(f =>
_.endsWith('_path', f)
? [`${_.replace('_path', '_override', f)}`, 'automatic']
: [`${f}_override`, 'automatic']
, updatedFields))
console.log('updatedFields', updatedFields)
const overrideFields = _.compose(_.fromPairs, getPairs, removePathSuffix)(updatedFields)
return _.merge(fields, overrideFields)
}