integrate anchoring and proof download
This commit is contained in:
parent
c432522979
commit
10ce27683d
10
package.json
10
package.json
@ -24,7 +24,7 @@
|
||||
"eslint-config-next": "13.2.4",
|
||||
"form-data": "^4.0.0",
|
||||
"jwt-decode": "^3.1.2",
|
||||
"le-coffre-resources": "git@github.com:smart-chain-fr/leCoffre-resources.git#v2.73",
|
||||
"le-coffre-resources": "git@github.com:smart-chain-fr/leCoffre-resources.git#v2.77",
|
||||
"next": "13.2.4",
|
||||
"prettier": "^2.8.7",
|
||||
"react": "18.2.0",
|
||||
@ -32,9 +32,7 @@
|
||||
"react-select": "^5.7.2",
|
||||
"sass": "^1.59.2",
|
||||
"sharp": "^0.32.1",
|
||||
"typescript": "4.9.5"
|
||||
},
|
||||
"devDependencies": {}
|
||||
"typescript": "4.9.5",
|
||||
"uuidv4": "^6.2.13"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -0,0 +1,53 @@
|
||||
import { ContentType } from "@Front/Api/BaseApiService";
|
||||
import BaseNotary from "../BaseNotary";
|
||||
|
||||
import CookieService from "@Front/Services/CookieService/CookieService";
|
||||
|
||||
export default class OfficeFolderAnchors extends BaseNotary {
|
||||
private static instance: OfficeFolderAnchors;
|
||||
private readonly baseURl = this.namespaceUrl.concat("/anchors");
|
||||
|
||||
private constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
public static getInstance() {
|
||||
if (!this.instance) {
|
||||
return new this();
|
||||
} else {
|
||||
return this.instance;
|
||||
}
|
||||
}
|
||||
|
||||
public async get(uid: string): Promise<any> {
|
||||
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||
try {
|
||||
return await this.getRequest<any>(url);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
public async post(uid: string): Promise<any> {
|
||||
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||
try {
|
||||
return await this.postRequest<any>(url, {});
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
public async download(uid: string): Promise<any> {
|
||||
const url = new URL(this.baseURl.concat(`/download/${uid}`));
|
||||
try {
|
||||
return await this.getRequest<any>(url, undefined, ContentType.PDF, "attestation.pdf");
|
||||
} catch (err) {
|
||||
console.log("ERROR: ", err);
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
import ChevronIcon from "@Assets/Icons/chevron.svg";
|
||||
import Folders from "@Front/Api/LeCoffreApi/Notary/Folders/Folders";
|
||||
import OfficeFolderAnchors from "@Front/Api/LeCoffreApi/Notary/OfficeFolderAnchors/OfficeFolderAnchors";
|
||||
import Button, { EButtonVariant } from "@Front/Components/DesignSystem/Button";
|
||||
import FolderBoxInformation, { EFolderBoxInformationType } from "@Front/Components/DesignSystem/FolderBoxInformation";
|
||||
import TextAreaField from "@Front/Components/DesignSystem/Form/TextareaField";
|
||||
@ -112,6 +113,11 @@ class FolderInformationClass extends BasePage<IPropsClass, IState> {
|
||||
Ancrer le dossier
|
||||
</Button>
|
||||
)}
|
||||
{this.everyDocumentValidated() && (
|
||||
<Button variant={EButtonVariant.PRIMARY} onClick={() => this.downloadAnchoringProof(this.state.selectedFolder?.uid)}>
|
||||
Télécharger la preuve d'ancrage
|
||||
</Button>
|
||||
)}
|
||||
{!this.doesFolderHaveCustomer() && (
|
||||
<span className={classes["delete-folder"]} onClick={this.openVerifDeleteFolder}>
|
||||
<Button variant={EButtonVariant.SECONDARY}>Supprimer le dossier</Button>
|
||||
@ -234,6 +240,7 @@ class FolderInformationClass extends BasePage<IPropsClass, IState> {
|
||||
|
||||
try {
|
||||
const timeoutDelay = 9800;
|
||||
await this.anchorFolder();
|
||||
setTimeout(() => {
|
||||
this.setState({
|
||||
isValidateModalVisible: false,
|
||||
@ -245,6 +252,29 @@ class FolderInformationClass extends BasePage<IPropsClass, IState> {
|
||||
hasValidateAnchoring: false,
|
||||
});
|
||||
}, timeoutDelay + 1000);
|
||||
} catch (e) {
|
||||
this.setState({
|
||||
isValidateModalVisible: false,
|
||||
hasValidateAnchoring: false,
|
||||
});
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
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.transactions[0].status !== "VERIFIED_ON_CHAIN") return;
|
||||
|
||||
try {
|
||||
await OfficeFolderAnchors.getInstance().download(uid);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user