From bb370900bd62d349b2718c8d747e89d6295a239d Mon Sep 17 00:00:00 2001 From: Sosthene Date: Fri, 11 Jul 2025 13:31:51 +0200 Subject: [PATCH] [bug] Don't count refused documents on progress bar for a folder --- .../FolderInformation/ClientView/DocumentTables/index.tsx | 5 +++-- .../Components/Layouts/Folder/FolderInformation/index.tsx | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/front/Components/Layouts/Folder/FolderInformation/ClientView/DocumentTables/index.tsx b/src/front/Components/Layouts/Folder/FolderInformation/ClientView/DocumentTables/index.tsx index ebcf0bb4..00d4e558 100644 --- a/src/front/Components/Layouts/Folder/FolderInformation/ClientView/DocumentTables/index.tsx +++ b/src/front/Components/Layouts/Folder/FolderInformation/ClientView/DocumentTables/index.tsx @@ -313,10 +313,11 @@ export default function DocumentTables(props: IProps) { ); const progress = useMemo(() => { - const total = askedDocuments.length + toValidateDocuments.length + validatedDocuments.length + refusedDocuments.length; + // Exclude refused documents from total - only count documents that are still in progress + const total = askedDocuments.length + toValidateDocuments.length + validatedDocuments.length; if (total === 0) return 0; return (validatedDocuments.length / total) * 100; - }, [askedDocuments.length, refusedDocuments.length, toValidateDocuments.length, validatedDocuments.length]); + }, [askedDocuments.length, toValidateDocuments.length, validatedDocuments.length]); if (documents.length === 0 && documentsNotary.length === 0) return ; diff --git a/src/front/Components/Layouts/Folder/FolderInformation/index.tsx b/src/front/Components/Layouts/Folder/FolderInformation/index.tsx index 7dd580b0..db0d5573 100644 --- a/src/front/Components/Layouts/Folder/FolderInformation/index.tsx +++ b/src/front/Components/Layouts/Folder/FolderInformation/index.tsx @@ -47,8 +47,10 @@ export default function FolderInformation(props: IProps) { let validatedDocuments = 0; folder?.customers?.forEach((customer) => { const documents = customer.documents; - total += documents?.length ?? 0; - validatedDocuments += documents?.filter((document) => document.document_status === EDocumentStatus.VALIDATED).length ?? 0; + // Only count documents that are not refused (still in progress) + const activeDocuments = documents?.filter((document) => document.document_status !== EDocumentStatus.REFUSED) ?? []; + total += activeDocuments.length; + validatedDocuments += activeDocuments.filter((document) => document.document_status === EDocumentStatus.VALIDATED).length; }); if (total === 0) return 0; const percentage = (validatedDocuments / total) * 100;