fixup! ✨(frontend) added subpage management and document tree features

This commit is contained in:
Nathan Panchout
2025-03-24 08:55:38 +01:00
parent 0a6502a77d
commit aadd6d9ec3
2 changed files with 10 additions and 1 deletions
@@ -60,6 +60,7 @@ export const DocTree = ({ initialTargetId }: DocTreeProps) => {
});
};
serialize(children);
console.log(children);
treeData?.tree.resetTree(children);
setInitialOpenState(initialOpenState);
@@ -49,7 +49,7 @@ export const DocTreeProvider: React.FC<DocTreeProviderProps> = ({
},
async (docId) => {
const doc = await getDocChildren({ docId: docId });
return doc.results ?? [];
return subPageToTree(doc.results ?? []);
},
);
@@ -84,3 +84,11 @@ export const useDocTreeData = (): DocTreeContextType | undefined => {
}
return context;
};
export const subPageToTree = (children: Doc[]): TreeViewDataType<Doc>[] => {
children.forEach((child) => {
child.childrenCount = child.numchild ?? 0;
subPageToTree(child.children ?? []);
});
return children;
};