Can download anchoring proof when archived

This commit is contained in:
Maxime Lalo 2023-12-14 16:08:52 +01:00
parent be78f7216c
commit d27bebecb3
2 changed files with 30 additions and 4 deletions

View File

@ -59,7 +59,7 @@
display: flex; display: flex;
text-align: center; text-align: center;
justify-content: center; justify-content: center;
gap: 16px;
.delete-folder { .delete-folder {
display: flex; display: flex;
margin-left: 12px; margin-left: 12px;
@ -72,12 +72,12 @@
margin-left: 0; margin-left: 0;
margin-top: 12px; margin-top: 12px;
>* { > * {
flex: 1; flex: 1;
} }
} }
>* { > * {
width: 100%; width: 100%;
} }
} }

View File

@ -116,6 +116,13 @@ class FolderInformationClass extends BasePage<IPropsClass, IState> {
<Button variant={EButtonVariant.GHOST} onClick={this.restoreFolder}> <Button variant={EButtonVariant.GHOST} onClick={this.restoreFolder}>
Restaurer le dossier Restaurer le dossier
</Button> </Button>
{this.props.isAnchored === AnchorStatus.VERIFIED_ON_CHAIN && (
<Button
variant={EButtonVariant.PRIMARY}
onClick={() => this.downloadAnchoringProof(this.props.selectedFolder?.uid)}>
Télécharger la preuve d'ancrage
</Button>
)}
</div> </div>
</div> </div>
) : ( ) : (
@ -171,6 +178,25 @@ class FolderInformationClass extends BasePage<IPropsClass, IState> {
this.setState({ isArchivedModalOpen: false }); this.setState({ isArchivedModalOpen: false });
} }
private async downloadAnchoringProof(uid?: string) {
if (!uid) return;
try {
const file: Blob = await OfficeFolderAnchors.getInstance().download(uid);
const url = window.URL.createObjectURL(file);
const a = document.createElement("a");
a.style.display = "none";
a.href = url;
// the filename you want
a.download = `anchoring_proof_${this.props.selectedFolder?.folder_number}_${this.props.selectedFolder?.name}.zip`;
document.body.appendChild(a);
a.click();
window.URL.revokeObjectURL(url);
} catch (e) {
console.error(e);
}
}
private async getFolder(): Promise<OfficeFolder> { private async getFolder(): Promise<OfficeFolder> {
const query = { const query = {
q: { q: {