WIP Добвил обновление Основных данных в БД
This commit is contained in:
21
src/shared/utils/changesObjects.js
Normal file
21
src/shared/utils/changesObjects.js
Normal file
@@ -0,0 +1,21 @@
|
||||
export function removeEmptyFields(obj) {
|
||||
let resultObj = {};
|
||||
Object.keys(obj)
|
||||
.filter(
|
||||
(key) => obj[key] !== undefined && obj[key] !== null && obj[key] !== ""
|
||||
)
|
||||
.forEach((key) => {
|
||||
resultObj[key] = obj[key];
|
||||
});
|
||||
return resultObj;
|
||||
}
|
||||
|
||||
export function getObjectChangeField(objInit, objUpdate) {
|
||||
const resultObj = {};
|
||||
Object.keys(objUpdate).forEach((key) => {
|
||||
if (objUpdate[key] !== objInit[key]) {
|
||||
resultObj[key] = objUpdate[key];
|
||||
}
|
||||
});
|
||||
return resultObj;
|
||||
}
|
||||
Reference in New Issue
Block a user