[bug] Don't count refused documents on progress bar for a folder
This commit is contained in:
parent
7065f07373
commit
bb370900bd
@ -313,10 +313,11 @@ export default function DocumentTables(props: IProps) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const progress = useMemo(() => {
|
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;
|
if (total === 0) return 0;
|
||||||
return (validatedDocuments.length / total) * 100;
|
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 <NoDocument />;
|
if (documents.length === 0 && documentsNotary.length === 0) return <NoDocument />;
|
||||||
|
|
||||||
|
@ -47,8 +47,10 @@ export default function FolderInformation(props: IProps) {
|
|||||||
let validatedDocuments = 0;
|
let validatedDocuments = 0;
|
||||||
folder?.customers?.forEach((customer) => {
|
folder?.customers?.forEach((customer) => {
|
||||||
const documents = customer.documents;
|
const documents = customer.documents;
|
||||||
total += documents?.length ?? 0;
|
// Only count documents that are not refused (still in progress)
|
||||||
validatedDocuments += documents?.filter((document) => document.document_status === EDocumentStatus.VALIDATED).length ?? 0;
|
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;
|
if (total === 0) return 0;
|
||||||
const percentage = (validatedDocuments / total) * 100;
|
const percentage = (validatedDocuments / total) * 100;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user