[Folder] Correctly load the first folder
This commit is contained in:
parent
b70516bc86
commit
5d79b3df16
@ -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<string, any>) => {
|
||||
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) {
|
||||
router.push(
|
||||
Module.getInstance()
|
||||
.get()
|
||||
.modules.pages.Folder.pages.FolderInformation.props.path.replace("[folderUid]", folders[0].uid)
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
const folderUid = folders[0]?.processId;
|
||||
|
||||
if (!folderUid) {
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
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 ?? ""),
|
||||
.modules.pages.Folder.pages.FolderInformation.props.path.replace("[folderUid]", folderUid as string)
|
||||
);
|
||||
}
|
||||
} else {
|
||||
console.debug('[Folder] No folders found');
|
||||
}
|
||||
});
|
||||
*/
|
||||
}, [router]);
|
||||
return (
|
||||
<DefaultNotaryDashboard title={"Dossier"} mobileBackText={"Liste des dossiers"}>
|
||||
|
Loading…
x
Reference in New Issue
Block a user