fix: depth in collection items

This commit is contained in:
Anoop M D
2022-03-18 22:48:05 +05:30
parent ce02906070
commit c1e93915d4
2 changed files with 23 additions and 3 deletions

View File

@@ -2,6 +2,20 @@ import each from 'lodash/each';
import find from 'lodash/find';
import cloneDeep from 'lodash/cloneDeep';
export const addDepth = (items = []) => {
const depth = (itms, initialDepth) => {
each(itms, (i) => {
i.depth = initialDepth;
if(i.items && i.items.length) {
depth(i.items, initialDepth + 1);
}
})
}
depth(items, 1);
};
export const flattenItems = (items = []) => {
const flattenedItems = [];