🐛 Fixing folders order
This commit is contained in:
parent
ff3d607186
commit
6029a21760
@ -1,12 +1,12 @@
|
||||
import { IDashBoardFolder } from "@Front/Components/LayoutTemplates/DefaultNotaryDashboard";
|
||||
import Module from "@Front/Config/Module";
|
||||
import { EDocumentStatus } from "le-coffre-resources/dist/Customer/Document";
|
||||
import Link from "next/link";
|
||||
import { useRouter } from "next/router";
|
||||
import React from "react";
|
||||
|
||||
import FolderContainer from "../FolderContainer";
|
||||
import classes from "./classes.module.scss";
|
||||
import Module from "@Front/Config/Module";
|
||||
import { EDocumentStatus } from "le-coffre-resources/dist/Customer/Document";
|
||||
|
||||
type IProps = {
|
||||
folders: IDashBoardFolder[];
|
||||
@ -22,41 +22,53 @@ type IPropsClass = IProps & {
|
||||
type IState = {};
|
||||
|
||||
class FolderListClass extends React.Component<IPropsClass, IState> {
|
||||
private redirectPath: string = this.props.isArchived
|
||||
? Module.getInstance().get().modules.pages.Folder.pages.FolderArchived.pages.FolderInformation.props.path
|
||||
: Module.getInstance().get().modules.pages.Folder.pages.FolderInformation.props.path;
|
||||
public override render(): JSX.Element {
|
||||
const redirectPath: string = this.props.isArchived
|
||||
? Module.getInstance().get().modules.pages.Folder.pages.FolderArchived.pages.FolderInformation.props.path
|
||||
: Module.getInstance().get().modules.pages.Folder.pages.FolderInformation.props.path;
|
||||
return (
|
||||
<div className={classes["root"]}>
|
||||
{this.props.folders
|
||||
.sort((folder) => {
|
||||
const pendingDocuments = (folder.documents ?? []).filter(
|
||||
(document) => document.document_status === EDocumentStatus.DEPOSITED,
|
||||
);
|
||||
return pendingDocuments.length >= 1 ? -1 : 1;
|
||||
})
|
||||
.sort((folder1, folder2) => {
|
||||
return folder1.created_at! < folder2.created_at! ? -1 : 1;
|
||||
})
|
||||
.sort((folder1, folder2) => {
|
||||
return folder1.folder_number! < folder2.folder_number! ? -1 : 1;
|
||||
})
|
||||
.map((folder) => {
|
||||
return (
|
||||
<div
|
||||
onClick={this.props.onCloseLeftSide}
|
||||
key={folder.uid}
|
||||
className={folder.uid === this.props.selectedFolder ? classes["active"] : ""}>
|
||||
<Link href={redirectPath.replace("[folderUid]", folder.uid ?? "")}>
|
||||
<FolderContainer folder={folder} onSelectedFolder={this.props.onSelectedFolder} />;
|
||||
</Link>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
;
|
||||
{this.renderFolders()}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
private renderFolders(): JSX.Element[] {
|
||||
const pendingFolders = this.props.folders
|
||||
.filter((folder) => {
|
||||
const pendingDocuments = (folder.documents ?? []).filter(
|
||||
(document) => document.document_status === EDocumentStatus.DEPOSITED,
|
||||
);
|
||||
return pendingDocuments.length >= 1;
|
||||
})
|
||||
.sort((folder1, folder2) => {
|
||||
return folder1.created_at! > folder2.created_at! ? -1 : 1;
|
||||
});
|
||||
|
||||
const otherFolders = this.props.folders
|
||||
.filter((folder) => {
|
||||
const pendingDocuments = (folder.documents ?? []).filter(
|
||||
(document) => document.document_status === EDocumentStatus.DEPOSITED,
|
||||
);
|
||||
return pendingDocuments.length === 0;
|
||||
})
|
||||
.sort((folder1, folder2) => {
|
||||
return folder1.created_at! > folder2.created_at! ? -1 : 1;
|
||||
});
|
||||
|
||||
return [...pendingFolders, ...otherFolders].map((folder) => {
|
||||
return (
|
||||
<div
|
||||
onClick={this.props.onCloseLeftSide}
|
||||
key={folder.uid}
|
||||
className={folder.uid === this.props.selectedFolder ? classes["active"] : ""}>
|
||||
<Link href={this.redirectPath.replace("[folderUid]", folder.uid ?? "")}>
|
||||
<FolderContainer folder={folder} onSelectedFolder={this.props.onSelectedFolder} />;
|
||||
</Link>
|
||||
</div>
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export default function FolderList(props: IProps) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user