From 07a360f3383f76f94e7744f4d327223fe415c599 Mon Sep 17 00:00:00 2001 From: Maxime Lalo Date: Fri, 29 Sep 2023 19:20:32 +0200 Subject: [PATCH] :sparkles: Parcours d'ancrage ok --- .../DesignSystem/Header/Navigation/index.tsx | 1 - .../Folder/FolderInformation/index.tsx | 56 +++++++++++++------ 2 files changed, 39 insertions(+), 18 deletions(-) diff --git a/src/front/Components/DesignSystem/Header/Navigation/index.tsx b/src/front/Components/DesignSystem/Header/Navigation/index.tsx index 71106d0c..37b9b84c 100644 --- a/src/front/Components/DesignSystem/Header/Navigation/index.tsx +++ b/src/front/Components/DesignSystem/Header/Navigation/index.tsx @@ -24,7 +24,6 @@ export default function Navigation() { redirectUrl: notification.notification.redirection_url, }); }); - console.log(notifications); }, []); useEffect(() => { diff --git a/src/front/Components/Layouts/Folder/FolderInformation/index.tsx b/src/front/Components/Layouts/Folder/FolderInformation/index.tsx index 77921a72..7d113588 100644 --- a/src/front/Components/Layouts/Folder/FolderInformation/index.tsx +++ b/src/front/Components/Layouts/Folder/FolderInformation/index.tsx @@ -36,6 +36,7 @@ type IState = { isValidateModalVisible: boolean; hasValidateAnchoring: boolean; isVerifDeleteModalVisible: boolean; + isAnchored: boolean | null; }; class FolderInformationClass extends BasePage { public constructor(props: IPropsClass) { @@ -47,6 +48,7 @@ class FolderInformationClass extends BasePage { isValidateModalVisible: false, hasValidateAnchoring: false, isVerifDeleteModalVisible: false, + isAnchored: null, }; this.onSelectedFolder = this.onSelectedFolder.bind(this); this.openArchivedModal = this.openArchivedModal.bind(this); @@ -60,6 +62,7 @@ class FolderInformationClass extends BasePage { this.openValidateModal = this.openValidateModal.bind(this); this.openVerifDeleteFolder = this.openVerifDeleteFolder.bind(this); this.closeVerifDeleteFolder = this.closeVerifDeleteFolder.bind(this); + this.verifyAnchorStatus = this.verifyAnchorStatus.bind(this); } // TODO: Message if the user has not created any folder yet @@ -109,16 +112,20 @@ class FolderInformationClass extends BasePage { Archiver le dossier {this.everyDocumentValidated() && ( - - )} - {this.everyDocumentValidated() && ( - + <> + {this.state.isAnchored === null && ( + + )} + {this.state.isAnchored === true && ( + + )} + )} {!this.doesFolderHaveCustomer() && ( @@ -207,11 +214,30 @@ class FolderInformationClass extends BasePage { ); } public override async componentDidMount() { - this.setState({ - selectedFolder: (await this.getFolder()) as OfficeFolder, - }); + const selectedFolder = await this.getFolder(); + this.setState( + { + selectedFolder, + }, + () => { + this.verifyAnchorStatus(); + }, + ); } + private async verifyAnchorStatus() { + if (!this.state.selectedFolder || !this.state.selectedFolder.uid) return; + try { + const anchorStatus = await OfficeFolderAnchors.getInstance().get(this.state.selectedFolder.uid!); + this.setState({ + isAnchored: anchorStatus.status === "VERIFIED_ON_CHAIN", + }); + } catch (e) { + this.setState({ + isAnchored: null, + }); + } + } public openVerifDeleteFolder() { this.setState({ isVerifDeleteModalVisible: true, @@ -267,15 +293,11 @@ class FolderInformationClass extends BasePage { private async anchorFolder() { if (!this.state.selectedFolder?.uid) return; const anchor = await OfficeFolderAnchors.getInstance().post(this.state.selectedFolder.uid); - console.log(anchor); } private async downloadAnchoringProof(uid?: string) { if (!uid) return; - const anchor = await OfficeFolderAnchors.getInstance().get(uid); - if (anchor.status !== "VERIFIED_ON_CHAIN") return; - try { const file: Blob = await OfficeFolderAnchors.getInstance().download(uid); const url = window.URL.createObjectURL(file);