@bindu-dashing/dam-solution-v2 5.8.19 → 5.8.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -42,20 +42,6 @@ const AiOutlineSortDescendingbtn = AiOutlineSortDescending;
42
42
  const AiOutlineSortAscendingbtn = AiOutlineSortAscending;
43
43
  const GrSortIcon = FaShuffle;
44
44
  const IoIosSearchIcon = IoIosSearch;
45
- // ✅ Helper to find a folder by ID in the tree
46
- const findFolderById = (tree, folderId) => {
47
- for (const node of tree) {
48
- if (node._id === folderId) {
49
- return node;
50
- }
51
- if (isArray(node.children)) {
52
- const found = findFolderById(node.children, folderId);
53
- if (found)
54
- return found;
55
- }
56
- }
57
- return null;
58
- };
59
45
  // ✅ Helper to insert children into the correct folder recursively
60
46
  const insertSubfolders = (tree, parentId, childrenToInsert) => {
61
47
  console.log('## insertSubfolders', tree, parentId, childrenToInsert);
@@ -121,28 +107,16 @@ function FolderTree({ currentRootId, expandedKeys, selectedKeys, handleExpand, s
121
107
  });
122
108
  const response = yield api.get(`${FETCH_FOLDER_URL.replace(":folderId", fid)}?isPagination=false&includeFiles=false&includeSubFoldersCount=true&fetchMainFolders=true&globalSearch=${fid == rootFolderId ? globalSearch : ""}`);
123
109
  const newFolders = get(response, "data.folders", []);
110
+ const folderInfo = get(response, "data.folder", {});
124
111
  console.log('## newFolders', response, newFolders, fid, rootFolderId, globalSearch);
125
112
  if (fid === rootFolderId) {
126
113
  setFolders(sortFoldersRecursively(newFolders, "name", sortOrder));
127
114
  }
128
115
  else {
129
- setFolders((prev) => {
130
- // Find the folder with fid in the tree
131
- const foundFolder = findFolderById(prev, fid);
132
- if (foundFolder) {
133
- // Return only the folder with fid and its updated children
134
- const sorted = sortFoldersRecursively(newFolders, "name", sortOrder);
135
- console.log('## Found folder:', foundFolder._id, 'New children:', sorted);
136
- return [Object.assign(Object.assign({}, foundFolder), { children: sorted })];
137
- }
138
- else {
139
- // If folder not found, update the entire tree (fallback)
140
- console.log('## Folder not found, updating entire tree');
141
- const cloned = cloneDeep(prev);
142
- const sorted = sortFoldersRecursively(newFolders, "name", sortOrder);
143
- return insertSubfolders(cloned, fid, sorted);
144
- }
145
- });
116
+ // Simply use folder info from API response and newFolders as children
117
+ const sorted = sortFoldersRecursively(newFolders, "name", sortOrder);
118
+ console.log('## Folder info:', folderInfo, 'New children:', sorted);
119
+ setFolders([Object.assign(Object.assign({}, folderInfo), { children: sorted })]);
146
120
  }
147
121
  setState((prevState) => {
148
122
  return Object.assign(Object.assign({}, prevState), { parentFolder: get(response, "data.folder", {}), loading: false, globalSearchValue: globalSearch || "" });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bindu-dashing/dam-solution-v2",
3
- "version": "5.8.19",
3
+ "version": "5.8.20",
4
4
  "dependencies": {
5
5
  "@ant-design/icons": "^5.0.1",
6
6
  "@emoji-mart/data": "^1.2.1",