🐛 Folder percentage working

This commit is contained in:
Maxime Lalo 2023-04-27 12:41:20 +02:00
parent 6bb370a716
commit 27b8db0a7f

View File

@ -15,6 +15,7 @@ import { useRouter } from "next/router";
import BasePage from "../../Base"; import BasePage from "../../Base";
import classes from "./classes.module.scss"; import classes from "./classes.module.scss";
import ClientSection from "./ClientSection"; import ClientSection from "./ClientSection";
import { EDocumentStatus } from "le-coffre-resources/dist/Notary/Document";
type IProps = {}; type IProps = {};
@ -37,6 +38,7 @@ class FolderInformationClass extends BasePage<IPropsClass, IState> {
this.onSelectedFolder = this.onSelectedFolder.bind(this); this.onSelectedFolder = this.onSelectedFolder.bind(this);
this.openArchivedModal = this.openArchivedModal.bind(this); this.openArchivedModal = this.openArchivedModal.bind(this);
this.closeArchivedModal = this.closeArchivedModal.bind(this); this.closeArchivedModal = this.closeArchivedModal.bind(this);
this.getCompletionNumber = this.getCompletionNumber.bind(this);
} }
// TODO: Message if the user has not created any folder yet // TODO: Message if the user has not created any folder yet
@ -66,7 +68,7 @@ class FolderInformationClass extends BasePage<IPropsClass, IState> {
<FolderBoxInformation folder={this.state.selectedFolder} type={EFolderBoxInformationType.DESCRIPTION} /> <FolderBoxInformation folder={this.state.selectedFolder} type={EFolderBoxInformationType.DESCRIPTION} />
</div> </div>
<div className={classes["progress-bar"]}> <div className={classes["progress-bar"]}>
<QuantityProgressBar title="Complétion du dossier" total={100} currentNumber={34} /> <QuantityProgressBar title="Complétion du dossier" total={100} currentNumber={this.getCompletionNumber()} />
</div> </div>
{this.doesFolderHaveCustomer() && <ClientSection folder={this.state.selectedFolder} />} {this.doesFolderHaveCustomer() && <ClientSection folder={this.state.selectedFolder} />}
</div> </div>
@ -119,6 +121,16 @@ class FolderInformationClass extends BasePage<IPropsClass, IState> {
} }
} }
private getCompletionNumber(){
const documents = this.state.selectedFolder?.documents;
if(!documents) return 0;
const totalDocuments = documents.length;
const askedDocuments = documents.filter((document) => document.document_status === EDocumentStatus.ASKED).length;
const depositedDocuments = totalDocuments - askedDocuments;
const percentage = (depositedDocuments / totalDocuments) * 100;
return isNaN(percentage) ? 0 : percentage;
}
private doesFolderHaveCustomer(): boolean { private doesFolderHaveCustomer(): boolean {
return this.state.selectedFolder?.office_folder_has_customers !== undefined; return this.state.selectedFolder?.office_folder_has_customers !== undefined;
} }