From 27b8db0a7f1e5fbabd134de707c2159d2818da33 Mon Sep 17 00:00:00 2001 From: Maxime Lalo Date: Thu, 27 Apr 2023 12:41:20 +0200 Subject: [PATCH] :bug: Folder percentage working --- .../Layouts/Folder/FolderInformation/index.tsx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/front/Components/Layouts/Folder/FolderInformation/index.tsx b/src/front/Components/Layouts/Folder/FolderInformation/index.tsx index 40ec666a..7ee451c9 100644 --- a/src/front/Components/Layouts/Folder/FolderInformation/index.tsx +++ b/src/front/Components/Layouts/Folder/FolderInformation/index.tsx @@ -15,6 +15,7 @@ import { useRouter } from "next/router"; import BasePage from "../../Base"; import classes from "./classes.module.scss"; import ClientSection from "./ClientSection"; +import { EDocumentStatus } from "le-coffre-resources/dist/Notary/Document"; type IProps = {}; @@ -37,6 +38,7 @@ class FolderInformationClass extends BasePage { this.onSelectedFolder = this.onSelectedFolder.bind(this); this.openArchivedModal = this.openArchivedModal.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 @@ -66,7 +68,7 @@ class FolderInformationClass extends BasePage {
- +
{this.doesFolderHaveCustomer() && } @@ -119,6 +121,16 @@ class FolderInformationClass extends BasePage { } } + 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 { return this.state.selectedFolder?.office_folder_has_customers !== undefined; }