Anchor and certify on folder page

This commit is contained in:
Maxime Lalo 2023-09-18 15:45:22 +02:00
parent 22cf1f5b10
commit d1bb681e74
2 changed files with 90 additions and 3 deletions

View File

@ -88,3 +88,13 @@
margin-bottom: 24px; margin-bottom: 24px;
} }
} }
.validate-document-container {
.document-validating-container {
.validate-gif {
width: 100%;
height: 100%;
object-fit: contain;
}
}
}

View File

@ -13,10 +13,13 @@ import { EDocumentStatus } from "le-coffre-resources/dist/Notary/Document";
import Link from "next/link"; import Link from "next/link";
import { NextRouter, useRouter } from "next/router"; import { NextRouter, useRouter } from "next/router";
import { ChangeEvent } from "react"; import { ChangeEvent } from "react";
import Image from "next/image";
import ValidateAnchoringGif from "@Front/Assets/images/validate_anchoring.gif";
import BasePage from "../../Base"; import BasePage from "../../Base";
import classes from "./classes.module.scss"; import classes from "./classes.module.scss";
import ClientSection from "./ClientSection"; import ClientSection from "./ClientSection";
import CheckBox from "@Front/Components/DesignSystem/CheckBox";
type IProps = {}; type IProps = {};
@ -29,6 +32,8 @@ type IState = {
selectedFolder: OfficeFolder | null; selectedFolder: OfficeFolder | null;
isArchivedModalOpen: boolean; isArchivedModalOpen: boolean;
inputArchivedDescripton: string; inputArchivedDescripton: string;
isValidateModalVisible: boolean;
hasValidateAnchoring: boolean;
}; };
class FolderInformationClass extends BasePage<IPropsClass, IState> { class FolderInformationClass extends BasePage<IPropsClass, IState> {
public constructor(props: IPropsClass) { public constructor(props: IPropsClass) {
@ -37,6 +42,8 @@ class FolderInformationClass extends BasePage<IPropsClass, IState> {
selectedFolder: null, selectedFolder: null,
isArchivedModalOpen: false, isArchivedModalOpen: false,
inputArchivedDescripton: "", inputArchivedDescripton: "",
isValidateModalVisible: false,
hasValidateAnchoring: false,
}; };
this.onSelectedFolder = this.onSelectedFolder.bind(this); this.onSelectedFolder = this.onSelectedFolder.bind(this);
this.openArchivedModal = this.openArchivedModal.bind(this); this.openArchivedModal = this.openArchivedModal.bind(this);
@ -45,7 +52,9 @@ class FolderInformationClass extends BasePage<IPropsClass, IState> {
this.getCompletionNumber = this.getCompletionNumber.bind(this); this.getCompletionNumber = this.getCompletionNumber.bind(this);
this.onArchivedDescriptionInputChange = this.onArchivedDescriptionInputChange.bind(this); this.onArchivedDescriptionInputChange = this.onArchivedDescriptionInputChange.bind(this);
this.deleteFolder = this.deleteFolder.bind(this); this.deleteFolder = this.deleteFolder.bind(this);
this.anchorFolder = this.anchorFolder.bind(this); this.closeModal = this.closeModal.bind(this);
this.validateAnchoring = this.validateAnchoring.bind(this);
this.openValidateModal = this.openValidateModal.bind(this);
} }
// TODO: Message if the user has not created any folder yet // TODO: Message if the user has not created any folder yet
@ -95,7 +104,7 @@ class FolderInformationClass extends BasePage<IPropsClass, IState> {
Archiver le dossier Archiver le dossier
</Button> </Button>
{this.everyDocumentValidated() && ( {this.everyDocumentValidated() && (
<Button variant={EButtonVariant.PRIMARY} onClick={this.anchorFolder}> <Button variant={EButtonVariant.PRIMARY} onClick={this.openValidateModal}>
Ancrer le dossier Ancrer le dossier
</Button> </Button>
)} )}
@ -134,6 +143,41 @@ class FolderInformationClass extends BasePage<IPropsClass, IState> {
</div> </div>
)} )}
</div> </div>
<Confirm
isOpen={this.state.isValidateModalVisible}
onClose={this.closeModal}
onAccept={this.validateAnchoring}
closeBtn={true}
hasContainerClosable={true}
header={
this.state.hasValidateAnchoring
? "Dossier en cours de certification"
: "Êtes-vous sûr de vouloir ancrer et certifier ?"
}
cancelText={"Annuler"}
confirmText={"Confirmer"}
showButtons={!this.state.hasValidateAnchoring}>
<div className={classes["validate-document-container"]}>
{!this.state.hasValidateAnchoring && (
<Typography typo={ITypo.P_16} color={ITypoColor.BLACK} className={classes["validate-text"]}>
Afin de certifier les documents associés au dossier, cliquez sur Ancrez et certifier et les documents
seront certifiés sur la blockchain.
</Typography>
)}
{this.state.hasValidateAnchoring && (
<div className={classes["document-validating-container"]}>
<Typography typo={ITypo.P_16} color={ITypoColor.BLACK} className={classes["validate-text"]}>
Vous pouvez désormais télécharger les feuilles d'ancrage et les mettre dans la GED de votre logiciel de
rédaction d'acte.
</Typography>
<Image src={ValidateAnchoringGif} alt="Anchoring animation" className={classes["validate-gif"]} />
<div className={classes["dont-show-again"]}>
<CheckBox option={{ label: "Ne plus afficher ce message", value: false }} />
</div>
</div>
)}
</div>
</Confirm>
</DefaultNotaryDashboard> </DefaultNotaryDashboard>
); );
} }
@ -143,7 +187,40 @@ class FolderInformationClass extends BasePage<IPropsClass, IState> {
}); });
} }
private anchorFolder() {} private closeModal() {
this.setState({
isValidateModalVisible: false,
});
}
private openValidateModal() {
this.setState({
isValidateModalVisible: true,
});
}
private async validateAnchoring() {
this.setState({
hasValidateAnchoring: true,
});
try {
const timeoutDelay = 9800;
setTimeout(() => {
this.setState({
isValidateModalVisible: false,
});
}, timeoutDelay);
setTimeout(() => {
this.setState({
hasValidateAnchoring: false,
});
}, timeoutDelay + 1000);
} catch (e) {
console.error(e);
}
}
private everyDocumentValidated(): boolean { private everyDocumentValidated(): boolean {
if (!this.state.selectedFolder?.documents) return false; if (!this.state.selectedFolder?.documents) return false;