[Folder] Correctly load the first folder
This commit is contained in:
parent
b70516bc86
commit
5d79b3df16
@ -25,40 +25,36 @@ export default function Folder() {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// TODO: review
|
// TODO: review
|
||||||
FolderService.getFoldersBy({ status: EFolderStatus.LIVE }).then((processes: any[]) => {
|
FolderService.getFoldersBy({ status: EFolderStatus.LIVE }).then((processes: Record<string, any>) => {
|
||||||
if (processes.length > 0) {
|
if (Object.keys(processes).length > 0) {
|
||||||
let folders: any[] = processes.map((process: any) => process.processData);
|
let folders: any[] = Object.entries(processes).map(([processId, process]) => {
|
||||||
|
const res = {
|
||||||
|
...process,
|
||||||
|
processId: processId
|
||||||
|
};
|
||||||
|
return res;
|
||||||
|
});
|
||||||
|
|
||||||
// OrderBy created_at desc
|
// OrderBy created_at desc
|
||||||
folders = folders.sort((a: any, b: any) => new Date(b.created_at).getTime() - new Date(a.created_at).getTime());
|
folders = folders.sort((a: any, b: any) => new Date(b.created_at).getTime() - new Date(a.created_at).getTime());
|
||||||
|
|
||||||
if (folders.length > 0) {
|
if (folders.length > 0) {
|
||||||
router.push(
|
const folderUid = folders[0]?.processId;
|
||||||
Module.getInstance()
|
|
||||||
.get()
|
if (!folderUid) {
|
||||||
.modules.pages.Folder.pages.FolderInformation.props.path.replace("[folderUid]", folders[0].uid)
|
return;
|
||||||
);
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
/*
|
|
||||||
Folders.getInstance()
|
|
||||||
.get({
|
|
||||||
q: {
|
|
||||||
where: { status: EFolderStatus.LIVE },
|
|
||||||
orderBy: { created_at: "desc" },
|
|
||||||
},
|
|
||||||
})
|
|
||||||
.then((folders) => {
|
|
||||||
if (folders.length > 0)
|
|
||||||
router.push(
|
router.push(
|
||||||
Module.getInstance()
|
Module.getInstance()
|
||||||
.get()
|
.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]);
|
}, [router]);
|
||||||
return (
|
return (
|
||||||
<DefaultNotaryDashboard title={"Dossier"} mobileBackText={"Liste des dossiers"}>
|
<DefaultNotaryDashboard title={"Dossier"} mobileBackText={"Liste des dossiers"}>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user