From 22cf1f5b1053df8565d7febb33ce0f86df498113 Mon Sep 17 00:00:00 2001 From: Maxime Lalo Date: Mon, 18 Sep 2023 15:35:36 +0200 Subject: [PATCH] :sparkles: Removing anchor function from documents --- .../FolderInformation/classes.module.scss | 7 ++- .../Folder/FolderInformation/index.tsx | 13 ++++ .../Layouts/Folder/ViewDocuments/index.tsx | 62 +++++-------------- 3 files changed, 31 insertions(+), 51 deletions(-) diff --git a/src/front/Components/Layouts/Folder/FolderInformation/classes.module.scss b/src/front/Components/Layouts/Folder/FolderInformation/classes.module.scss index a1052297..e4477922 100644 --- a/src/front/Components/Layouts/Folder/FolderInformation/classes.module.scss +++ b/src/front/Components/Layouts/Folder/FolderInformation/classes.module.scss @@ -57,6 +57,7 @@ .button-container { width: 100%; display: flex; + gap: 16px; text-align: center; justify-content: center; @@ -72,12 +73,12 @@ margin-left: 0; margin-top: 12px; - >* { + > * { flex: 1; } } - >* { + > * { width: 100%; } } @@ -86,4 +87,4 @@ .modal-title { margin-bottom: 24px; } -} \ No newline at end of file +} diff --git a/src/front/Components/Layouts/Folder/FolderInformation/index.tsx b/src/front/Components/Layouts/Folder/FolderInformation/index.tsx index bb6a30c5..8bd2e922 100644 --- a/src/front/Components/Layouts/Folder/FolderInformation/index.tsx +++ b/src/front/Components/Layouts/Folder/FolderInformation/index.tsx @@ -45,6 +45,7 @@ class FolderInformationClass extends BasePage { this.getCompletionNumber = this.getCompletionNumber.bind(this); this.onArchivedDescriptionInputChange = this.onArchivedDescriptionInputChange.bind(this); this.deleteFolder = this.deleteFolder.bind(this); + this.anchorFolder = this.anchorFolder.bind(this); } // TODO: Message if the user has not created any folder yet @@ -93,6 +94,11 @@ class FolderInformationClass extends BasePage { + {this.everyDocumentValidated() && ( + + )} {!this.doesFolderHaveCustomer() && ( @@ -137,6 +143,13 @@ class FolderInformationClass extends BasePage { }); } + private anchorFolder() {} + + private everyDocumentValidated(): boolean { + if (!this.state.selectedFolder?.documents) return false; + return this.state.selectedFolder?.documents.every((document) => document.document_status === EDocumentStatus.VALIDATED); + } + private async deleteFolder() { if (!this.state.selectedFolder?.uid) return; await Folders.getInstance().delete(this.state.selectedFolder.uid); diff --git a/src/front/Components/Layouts/Folder/ViewDocuments/index.tsx b/src/front/Components/Layouts/Folder/ViewDocuments/index.tsx index 81bb3a8d..68faf697 100644 --- a/src/front/Components/Layouts/Folder/ViewDocuments/index.tsx +++ b/src/front/Components/Layouts/Folder/ViewDocuments/index.tsx @@ -1,9 +1,7 @@ import LeftArrowIcon from "@Assets/Icons/left-arrow.svg"; import RightArrowIcon from "@Assets/Icons/right-arrow.svg"; import Documents from "@Front/Api/LeCoffreApi/Notary/Documents/Documents"; -import ValidateAnchoringGif from "@Front/Assets/images/validate_anchoring.gif"; import Button, { EButtonVariant } from "@Front/Components/DesignSystem/Button"; -import CheckBox from "@Front/Components/DesignSystem/CheckBox"; import FilePreview from "@Front/Components/DesignSystem/FilePreview"; import Confirm from "@Front/Components/DesignSystem/Modal/Confirm"; import Typography, { ITypo, ITypoColor } from "@Front/Components/DesignSystem/Typography"; @@ -32,7 +30,6 @@ type IState = { isRefuseModalVisible: boolean; isValidateModalVisible: boolean; refuseText: string; - hasValidateAnchoring: boolean; selectedFileIndex: number; selectedFile: File | null; validatedPercentage: number; @@ -47,7 +44,6 @@ class ViewDocumentsClass extends BasePage { isValidateModalVisible: false, isRefuseModalVisible: false, refuseText: "", - hasValidateAnchoring: false, selectedFileIndex: 0, selectedFile: null, validatedPercentage: this.getRandomPercentageForOcr(), @@ -58,7 +54,7 @@ class ViewDocumentsClass extends BasePage { this.openValidateModal = this.openValidateModal.bind(this); this.openRefuseModal = this.openRefuseModal.bind(this); this.onRefuseTextChange = this.onRefuseTextChange.bind(this); - this.validateAnchoring = this.validateAnchoring.bind(this); + this.validateDocument = this.validateDocument.bind(this); this.goToNext = this.goToNext.bind(this); this.goToPrevious = this.goToPrevious.bind(this); @@ -117,7 +113,7 @@ class ViewDocumentsClass extends BasePage { - + )} @@ -129,30 +125,16 @@ class ViewDocumentsClass extends BasePage { + confirmText={"Confirmer"}>
- {!this.state.hasValidateAnchoring && ( - - Êtes-vous sûr de vouloir ancrer ce document ? - - )} - {this.state.hasValidateAnchoring && ( -
- - Le document s'ancre dans la blockchain. - - Anchoring animation -
- -
-
- )} + + Êtes-vous sûr de vouloir valider ce document ? +
{ } } - private async validateAnchoring() { - this.setState({ - hasValidateAnchoring: true, - }); - + private async validateDocument() { try { await Documents.getInstance().put(this.props.documentUid, { document_status: EDocumentStatus.VALIDATED, }); - const timeoutDelay = 9800; - setTimeout(() => { - this.setState({ - isValidateModalVisible: false, - }); - this.props.router.push( - Module.getInstance() - .get() - .modules.pages.Folder.pages.FolderInformation.props.path.replace("[folderUid]", this.props.folderUid), - ); - }, timeoutDelay); - - setTimeout(() => { - this.setState({ - hasValidateAnchoring: false, - }); - }, timeoutDelay + 1000); + this.props.router.push( + Module.getInstance() + .get() + .modules.pages.Folder.pages.FolderInformation.props.path.replace("[folderUid]", this.props.folderUid), + ); } catch (e) { console.error(e); }