✨ Removing anchor function from documents
This commit is contained in:
parent
908a816707
commit
22cf1f5b10
@ -57,6 +57,7 @@
|
|||||||
.button-container {
|
.button-container {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
gap: 16px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
|
||||||
@ -72,12 +73,12 @@
|
|||||||
margin-left: 0;
|
margin-left: 0;
|
||||||
margin-top: 12px;
|
margin-top: 12px;
|
||||||
|
|
||||||
>* {
|
> * {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
>* {
|
> * {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -86,4 +87,4 @@
|
|||||||
.modal-title {
|
.modal-title {
|
||||||
margin-bottom: 24px;
|
margin-bottom: 24px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,6 +45,7 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Message if the user has not created any folder yet
|
// TODO: Message if the user has not created any folder yet
|
||||||
@ -93,6 +94,11 @@ class FolderInformationClass extends BasePage<IPropsClass, IState> {
|
|||||||
<Button variant={EButtonVariant.GHOST} onClick={this.openArchivedModal}>
|
<Button variant={EButtonVariant.GHOST} onClick={this.openArchivedModal}>
|
||||||
Archiver le dossier
|
Archiver le dossier
|
||||||
</Button>
|
</Button>
|
||||||
|
{this.everyDocumentValidated() && (
|
||||||
|
<Button variant={EButtonVariant.PRIMARY} onClick={this.anchorFolder}>
|
||||||
|
Ancrer le dossier
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
{!this.doesFolderHaveCustomer() && (
|
{!this.doesFolderHaveCustomer() && (
|
||||||
<span className={classes["delete-folder"]} onClick={this.deleteFolder}>
|
<span className={classes["delete-folder"]} onClick={this.deleteFolder}>
|
||||||
<Button variant={EButtonVariant.SECONDARY}>Supprimer le dossier</Button>
|
<Button variant={EButtonVariant.SECONDARY}>Supprimer le dossier</Button>
|
||||||
@ -137,6 +143,13 @@ class FolderInformationClass extends BasePage<IPropsClass, IState> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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() {
|
private async deleteFolder() {
|
||||||
if (!this.state.selectedFolder?.uid) return;
|
if (!this.state.selectedFolder?.uid) return;
|
||||||
await Folders.getInstance().delete(this.state.selectedFolder.uid);
|
await Folders.getInstance().delete(this.state.selectedFolder.uid);
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
import LeftArrowIcon from "@Assets/Icons/left-arrow.svg";
|
import LeftArrowIcon from "@Assets/Icons/left-arrow.svg";
|
||||||
import RightArrowIcon from "@Assets/Icons/right-arrow.svg";
|
import RightArrowIcon from "@Assets/Icons/right-arrow.svg";
|
||||||
import Documents from "@Front/Api/LeCoffreApi/Notary/Documents/Documents";
|
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 Button, { EButtonVariant } from "@Front/Components/DesignSystem/Button";
|
||||||
import CheckBox from "@Front/Components/DesignSystem/CheckBox";
|
|
||||||
import FilePreview from "@Front/Components/DesignSystem/FilePreview";
|
import FilePreview from "@Front/Components/DesignSystem/FilePreview";
|
||||||
import Confirm from "@Front/Components/DesignSystem/Modal/Confirm";
|
import Confirm from "@Front/Components/DesignSystem/Modal/Confirm";
|
||||||
import Typography, { ITypo, ITypoColor } from "@Front/Components/DesignSystem/Typography";
|
import Typography, { ITypo, ITypoColor } from "@Front/Components/DesignSystem/Typography";
|
||||||
@ -32,7 +30,6 @@ type IState = {
|
|||||||
isRefuseModalVisible: boolean;
|
isRefuseModalVisible: boolean;
|
||||||
isValidateModalVisible: boolean;
|
isValidateModalVisible: boolean;
|
||||||
refuseText: string;
|
refuseText: string;
|
||||||
hasValidateAnchoring: boolean;
|
|
||||||
selectedFileIndex: number;
|
selectedFileIndex: number;
|
||||||
selectedFile: File | null;
|
selectedFile: File | null;
|
||||||
validatedPercentage: number;
|
validatedPercentage: number;
|
||||||
@ -47,7 +44,6 @@ class ViewDocumentsClass extends BasePage<IPropsClass, IState> {
|
|||||||
isValidateModalVisible: false,
|
isValidateModalVisible: false,
|
||||||
isRefuseModalVisible: false,
|
isRefuseModalVisible: false,
|
||||||
refuseText: "",
|
refuseText: "",
|
||||||
hasValidateAnchoring: false,
|
|
||||||
selectedFileIndex: 0,
|
selectedFileIndex: 0,
|
||||||
selectedFile: null,
|
selectedFile: null,
|
||||||
validatedPercentage: this.getRandomPercentageForOcr(),
|
validatedPercentage: this.getRandomPercentageForOcr(),
|
||||||
@ -58,7 +54,7 @@ class ViewDocumentsClass extends BasePage<IPropsClass, IState> {
|
|||||||
this.openValidateModal = this.openValidateModal.bind(this);
|
this.openValidateModal = this.openValidateModal.bind(this);
|
||||||
this.openRefuseModal = this.openRefuseModal.bind(this);
|
this.openRefuseModal = this.openRefuseModal.bind(this);
|
||||||
this.onRefuseTextChange = this.onRefuseTextChange.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.goToNext = this.goToNext.bind(this);
|
||||||
this.goToPrevious = this.goToPrevious.bind(this);
|
this.goToPrevious = this.goToPrevious.bind(this);
|
||||||
|
|
||||||
@ -117,7 +113,7 @@ class ViewDocumentsClass extends BasePage<IPropsClass, IState> {
|
|||||||
<Button variant={EButtonVariant.GHOST} onClick={this.openRefuseModal}>
|
<Button variant={EButtonVariant.GHOST} onClick={this.openRefuseModal}>
|
||||||
Refuser
|
Refuser
|
||||||
</Button>
|
</Button>
|
||||||
<Button onClick={this.openValidateModal}>Valider et ancrer</Button>
|
<Button onClick={this.openValidateModal}>Valider</Button>
|
||||||
<Button disabled>Télécharger</Button>
|
<Button disabled>Télécharger</Button>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
@ -129,30 +125,16 @@ class ViewDocumentsClass extends BasePage<IPropsClass, IState> {
|
|||||||
<Confirm
|
<Confirm
|
||||||
isOpen={this.state.isValidateModalVisible}
|
isOpen={this.state.isValidateModalVisible}
|
||||||
onClose={this.closeModals}
|
onClose={this.closeModals}
|
||||||
onAccept={this.validateAnchoring}
|
onAccept={this.validateDocument}
|
||||||
closeBtn={true}
|
closeBtn={true}
|
||||||
hasContainerClosable={true}
|
hasContainerClosable={true}
|
||||||
header={this.state.hasValidateAnchoring ? "Document en cours de validation" : "Ancrer le document"}
|
header={"Valider le document ?"}
|
||||||
cancelText={"Annuler"}
|
cancelText={"Annuler"}
|
||||||
confirmText={"Confirmer"}
|
confirmText={"Confirmer"}>
|
||||||
showButtons={!this.state.hasValidateAnchoring}>
|
|
||||||
<div className={classes["validate-document-container"]}>
|
<div className={classes["validate-document-container"]}>
|
||||||
{!this.state.hasValidateAnchoring && (
|
<Typography typo={ITypo.P_16} color={ITypoColor.BLACK} className={classes["validate-text"]}>
|
||||||
<Typography typo={ITypo.P_16} color={ITypoColor.BLACK} className={classes["validate-text"]}>
|
Êtes-vous sûr de vouloir valider ce document ?
|
||||||
Êtes-vous sûr de vouloir ancrer ce document ?
|
</Typography>
|
||||||
</Typography>
|
|
||||||
)}
|
|
||||||
{this.state.hasValidateAnchoring && (
|
|
||||||
<div className={classes["document-validating-container"]}>
|
|
||||||
<Typography typo={ITypo.P_16} color={ITypoColor.BLACK} className={classes["validate-text"]}>
|
|
||||||
Le document s'ancre dans la blockchain.
|
|
||||||
</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>
|
</div>
|
||||||
</Confirm>
|
</Confirm>
|
||||||
<Confirm
|
<Confirm
|
||||||
@ -290,33 +272,17 @@ class ViewDocumentsClass extends BasePage<IPropsClass, IState> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async validateAnchoring() {
|
private async validateDocument() {
|
||||||
this.setState({
|
|
||||||
hasValidateAnchoring: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await Documents.getInstance().put(this.props.documentUid, {
|
await Documents.getInstance().put(this.props.documentUid, {
|
||||||
document_status: EDocumentStatus.VALIDATED,
|
document_status: EDocumentStatus.VALIDATED,
|
||||||
});
|
});
|
||||||
|
|
||||||
const timeoutDelay = 9800;
|
this.props.router.push(
|
||||||
setTimeout(() => {
|
Module.getInstance()
|
||||||
this.setState({
|
.get()
|
||||||
isValidateModalVisible: false,
|
.modules.pages.Folder.pages.FolderInformation.props.path.replace("[folderUid]", this.props.folderUid),
|
||||||
});
|
);
|
||||||
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);
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user