Skip to content

Commit

Permalink
makeOptions function update
Browse files Browse the repository at this point in the history
  • Loading branch information
MVarshini committed Jan 11, 2024
1 parent 29944a1 commit 82b9814
Showing 1 changed file with 14 additions and 19 deletions.
33 changes: 14 additions & 19 deletions dashboard/src/actions/tocActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,25 +46,20 @@ export const fetchTOC =
};

const makeOptions = (data, isParent, keyPath, isDirectory) => {
const options = data.map((item) => ({
name: item.name,
id: isParent ? `${keyPath}*${item.name}` : item.name,
isDirectory,
uri: item.uri,
}));
if (isDirectory) {
options.forEach((opt) => {
opt["children"] = [];
});
} else {
data.forEach((item) => {
options.forEach((opt) => {
if (item.name === opt.name) {
opt["size"] = item.size;
}
});
});
}
const options = data.map((item) => {
const option = {
name: item.name,
id: isParent ? `${keyPath}*${item.name}` : item.name,
isDirectory,
uri: item.uri,
};
if (isDirectory) {
option.children = [];
} else {
option.size = item.size;
}
return option;
});
return options;
};
/**
Expand Down

0 comments on commit 82b9814

Please sign in to comment.