Validate documents (#29)

This commit is contained in:
Maxime Lalo 2023-05-09 11:49:21 +02:00 committed by GitHub
commit ad874c6c93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 18 deletions

View File

@ -2,6 +2,7 @@ import { Document } from "le-coffre-resources/dist/SuperAdmin";
import { Service } from "typedi"; import { Service } from "typedi";
import BaseSuperAdmin from "../BaseSuperAdmin"; import BaseSuperAdmin from "../BaseSuperAdmin";
import { EDocumentStatus } from "le-coffre-resources/dist/Customer/Document";
// TODO Type get query params -> Where + inclue + orderby // TODO Type get query params -> Where + inclue + orderby
export interface IGetDocumentsparams { export interface IGetDocumentsparams {
@ -11,7 +12,9 @@ export interface IGetDocumentsparams {
// TODO Type getbyuid query params // TODO Type getbyuid query params
export type IPutDocumentsParams = {}; export type IPutDocumentsParams = {
document_status?: EDocumentStatus
};
export interface IPostDocumentsParams {} export interface IPostDocumentsParams {}

View File

@ -2,6 +2,7 @@ import "reflect-metadata";
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/SuperAdmin/Documents/Documents";
import ValidateAnchoringGif from "@Front/Assets/images/validate_anchoring.gif"; 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 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 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";
import DefaultNotaryDashboard from "@Front/Components/LayoutTemplates/DefaultNotaryDashboard"; import DefaultNotaryDashboard from "@Front/Components/LayoutTemplates/DefaultNotaryDashboard";
import Module from "@Front/Config/Module";
import { Document, File } from "le-coffre-resources/dist/Customer"; import { Document, File } from "le-coffre-resources/dist/Customer";
import { EDocumentStatus } from "le-coffre-resources/dist/Customer/Document";
import Image from "next/image"; import Image from "next/image";
import { NextRouter, useRouter } from "next/router"; import { NextRouter, useRouter } from "next/router";
import React from "react"; import React from "react";
@ -18,8 +21,6 @@ import React from "react";
import BasePage from "../../Base"; import BasePage from "../../Base";
import classes from "./classes.module.scss"; import classes from "./classes.module.scss";
import OcrResult from "./OcrResult"; import OcrResult from "./OcrResult";
import { EDocumentStatus } from "le-coffre-resources/dist/Customer/Document";
import Documents from "@Front/Api/LeCoffreApi/SuperAdmin/Documents/Documents";
type IProps = {}; type IProps = {};
@ -182,18 +183,18 @@ class ViewDocumentsClass extends BasePage<IPropsClass, IState> {
} }
override async componentDidMount() { override async componentDidMount() {
try{ try {
const document = await Documents.getInstance().getByUid(this.props.documentUid, { const document = await Documents.getInstance().getByUid(this.props.documentUid, {
files: true, files: true,
document_type: true document_type: true,
}); });
this.setState({ this.setState({
document, document,
selectedFileIndex: 0, selectedFileIndex: 0,
selectedFile: document.files![0]!, selectedFile: document.files![0]!,
}); });
}catch(e){ } catch (e) {
console.error(e) console.error(e);
} }
} }
@ -243,16 +244,26 @@ class ViewDocumentsClass extends BasePage<IPropsClass, IState> {
return index < this.state.document!.files!.length; return index < this.state.document!.files!.length;
} }
private validateAnchoring() { private async validateAnchoring() {
this.setState({ this.setState({
hasValidateAnchoring: true, hasValidateAnchoring: true,
}); });
try {
await Documents.getInstance().put(this.props.documentUid, {
document_status: EDocumentStatus.VALIDATED,
});
const timeoutDelay = 9800; const timeoutDelay = 9800;
setTimeout(() => { setTimeout(() => {
this.setState({ this.setState({
isValidateModalVisible: false, isValidateModalVisible: false,
}); });
this.props.router.push(
Module.getInstance()
.get()
.modules.pages.Folder.pages.FolderInformation.props.path.replace("[folderUid]", this.props.folderUid),
);
}, timeoutDelay); }, timeoutDelay);
setTimeout(() => { setTimeout(() => {
@ -260,6 +271,9 @@ class ViewDocumentsClass extends BasePage<IPropsClass, IState> {
hasValidateAnchoring: false, hasValidateAnchoring: false,
}); });
}, timeoutDelay + 1000); }, timeoutDelay + 1000);
} catch (e) {
console.error(e);
}
} }
private onRefuseTextChange(e: React.ChangeEvent<HTMLInputElement>) { private onRefuseTextChange(e: React.ChangeEvent<HTMLInputElement>) {