mirror of
https://github.com/suitenumerique/docs.git
synced 2026-10-17 21:55:31 +02:00
fixup! ✨(frontend) added subpage management and document tree features
This commit is contained in:
@@ -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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user