refactor: Improve conditions readability
This commit is contained in:
committed by
Muhammad Farhan
parent
091e120224
commit
732fd28eb9
@@ -7,9 +7,9 @@ export const popuplateItem = (parentObject, itemName, statekey, metadata, defaul
|
||||
const item = _.get(metadata, itemName, null);
|
||||
|
||||
// if item is null, undefined, or empty string, use defaultValue
|
||||
const finalValue = (!_.isNil(item) && item !== '') ? item : defaultValue;
|
||||
const finalValue = (_.isNil(item) || item === '') ? defaultValue : item;
|
||||
|
||||
if (allowNull || (!_.isNil(finalValue) && finalValue !== defaultValue)) {
|
||||
if (!_.isNil(finalValue) || allowNull) {
|
||||
parent = { ...parentObject, [statekey]: finalValue };
|
||||
}
|
||||
return parent;
|
||||
|
||||
Reference in New Issue
Block a user