From 235a3c607cb0845b83863c86af5a1511e00964df Mon Sep 17 00:00:00 2001 From: Maxime Lalo Date: Wed, 26 Apr 2023 11:11:20 +0200 Subject: [PATCH] :bug: File name when validated or pending --- .../Document/DocumentNotary/index.tsx | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/front/Components/DesignSystem/Document/DocumentNotary/index.tsx b/src/front/Components/DesignSystem/Document/DocumentNotary/index.tsx index 66374d71..768ab0a0 100644 --- a/src/front/Components/DesignSystem/Document/DocumentNotary/index.tsx +++ b/src/front/Components/DesignSystem/Document/DocumentNotary/index.tsx @@ -16,6 +16,7 @@ type IProps = { document_type: Document["document_type"]; document_status: Document["document_status"]; folder: Document["folder"]; + files?: Document["files"]; }; openDeletionModal?: (uid: Document["uid"]) => void; }; @@ -37,13 +38,31 @@ class DocumentNotaryClass extends React.Component {
{this.props.document?.document_type?.name} - Aucun document déposé + {this.getDocumentsTitle()}
{this.renderIcon()}
); } + private getDocumentsTitle(){ + const documentFiles = this.props.document.files; + if(documentFiles){ + if(documentFiles.length === 1){ + const fileName = documentFiles[0]?.file_path?.split("/").pop(); + if(fileName && fileName.length > 20){ + return `${fileName.substr(0, 7)}...${fileName.substr(fileName.length - 7, fileName.length)}`; + }else{ + return fileName; + } + }else{ + return `${documentFiles.length} documents déposés`; + } + }else{ + return "Aucun document déposé"; + } + } + private onClick() { if (this.props.document.document_status !== "VALIDATED" && this.props.document.document_status !== "PENDING") return; this.props.router.push(`/folders/${this.props.document.folder.uid}/documents/${this.props.document.uid}`);