diff --git a/src/front/Api/LeCoffreApi/SuperAdmin/Documents/Documents.ts b/src/front/Api/LeCoffreApi/SuperAdmin/Documents/Documents.ts index d9a9e3d7..608bf951 100644 --- a/src/front/Api/LeCoffreApi/SuperAdmin/Documents/Documents.ts +++ b/src/front/Api/LeCoffreApi/SuperAdmin/Documents/Documents.ts @@ -2,6 +2,7 @@ import { Document } from "le-coffre-resources/dist/SuperAdmin"; import { Service } from "typedi"; import BaseSuperAdmin from "../BaseSuperAdmin"; +import { EDocumentStatus } from "le-coffre-resources/dist/Customer/Document"; // TODO Type get query params -> Where + inclue + orderby export interface IGetDocumentsparams { @@ -11,7 +12,9 @@ export interface IGetDocumentsparams { // TODO Type getbyuid query params -export type IPutDocumentsParams = {}; +export type IPutDocumentsParams = { + document_status?: EDocumentStatus +}; export interface IPostDocumentsParams {} diff --git a/src/front/Components/Layouts/Folder/ViewDocuments/index.tsx b/src/front/Components/Layouts/Folder/ViewDocuments/index.tsx index db1fe2be..9d0ec40a 100644 --- a/src/front/Components/Layouts/Folder/ViewDocuments/index.tsx +++ b/src/front/Components/Layouts/Folder/ViewDocuments/index.tsx @@ -2,6 +2,7 @@ import "reflect-metadata"; import LeftArrowIcon from "@Assets/Icons/left-arrow.svg"; import RightArrowIcon from "@Assets/Icons/right-arrow.svg"; +import Documents from "@Front/Api/LeCoffreApi/SuperAdmin/Documents/Documents"; import ValidateAnchoringGif from "@Front/Assets/images/validate_anchoring.gif"; import Button, { EButtonVariant } from "@Front/Components/DesignSystem/Button"; import CheckBox from "@Front/Components/DesignSystem/CheckBox"; @@ -10,7 +11,9 @@ import InputField from "@Front/Components/DesignSystem/Form/Elements/InputField" import Confirm from "@Front/Components/DesignSystem/Modal/Confirm"; import Typography, { ITypo, ITypoColor } from "@Front/Components/DesignSystem/Typography"; import DefaultNotaryDashboard from "@Front/Components/LayoutTemplates/DefaultNotaryDashboard"; +import Module from "@Front/Config/Module"; import { Document, File } from "le-coffre-resources/dist/Customer"; +import { EDocumentStatus } from "le-coffre-resources/dist/Customer/Document"; import Image from "next/image"; import { NextRouter, useRouter } from "next/router"; import React from "react"; @@ -18,8 +21,6 @@ import React from "react"; import BasePage from "../../Base"; import classes from "./classes.module.scss"; import OcrResult from "./OcrResult"; -import { EDocumentStatus } from "le-coffre-resources/dist/Customer/Document"; -import Documents from "@Front/Api/LeCoffreApi/SuperAdmin/Documents/Documents"; type IProps = {}; @@ -182,18 +183,18 @@ class ViewDocumentsClass extends BasePage { } override async componentDidMount() { - try{ + try { const document = await Documents.getInstance().getByUid(this.props.documentUid, { files: true, - document_type: true + document_type: true, }); this.setState({ document, selectedFileIndex: 0, selectedFile: document.files![0]!, }); - }catch(e){ - console.error(e) + } catch (e) { + console.error(e); } } @@ -243,23 +244,36 @@ class ViewDocumentsClass extends BasePage { return index < this.state.document!.files!.length; } - private validateAnchoring() { + private async validateAnchoring() { this.setState({ hasValidateAnchoring: true, }); - const timeoutDelay = 9800; - setTimeout(() => { - this.setState({ - isValidateModalVisible: false, + try { + await Documents.getInstance().put(this.props.documentUid, { + document_status: EDocumentStatus.VALIDATED, }); - }, timeoutDelay); - setTimeout(() => { - this.setState({ - hasValidateAnchoring: false, - }); - }, timeoutDelay + 1000); + const timeoutDelay = 9800; + setTimeout(() => { + this.setState({ + isValidateModalVisible: false, + }); + 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) { + console.error(e); + } } private onRefuseTextChange(e: React.ChangeEvent) {