diff --git a/src/front/Components/Layouts/Folder/index.tsx b/src/front/Components/Layouts/Folder/index.tsx index 4bf850c6..0879e8f1 100644 --- a/src/front/Components/Layouts/Folder/index.tsx +++ b/src/front/Components/Layouts/Folder/index.tsx @@ -25,40 +25,36 @@ export default function Folder() { useEffect(() => { // TODO: review - FolderService.getFoldersBy({ status: EFolderStatus.LIVE }).then((processes: any[]) => { - if (processes.length > 0) { - let folders: any[] = processes.map((process: any) => process.processData); + FolderService.getFoldersBy({ status: EFolderStatus.LIVE }).then((processes: Record) => { + if (Object.keys(processes).length > 0) { + let folders: any[] = Object.entries(processes).map(([processId, process]) => { + const res = { + ...process, + processId: processId + }; + return res; + }); // OrderBy created_at desc folders = folders.sort((a: any, b: any) => new Date(b.created_at).getTime() - new Date(a.created_at).getTime()); if (folders.length > 0) { + const folderUid = folders[0]?.processId; + + if (!folderUid) { + return; + } + router.push( Module.getInstance() .get() - .modules.pages.Folder.pages.FolderInformation.props.path.replace("[folderUid]", folders[0].uid) + .modules.pages.Folder.pages.FolderInformation.props.path.replace("[folderUid]", folderUid as string) ); } + } else { + console.debug('[Folder] No folders found'); } }); - - /* - Folders.getInstance() - .get({ - q: { - where: { status: EFolderStatus.LIVE }, - orderBy: { created_at: "desc" }, - }, - }) - .then((folders) => { - if (folders.length > 0) - router.push( - Module.getInstance() - .get() - .modules.pages.Folder.pages.FolderInformation.props.path.replace("[folderUid]", folders[0]?.uid ?? ""), - ); - }); - */ }, [router]); return (