From 223e7b5c904ba355f66c3a2f6e8a7b5f4a1f26e3 Mon Sep 17 00:00:00 2001 From: Maxime Lalo Date: Tue, 9 May 2023 11:59:03 +0200 Subject: [PATCH 1/3] :sparkles: Refuse documents working --- .../SuperAdmin/Documents/Documents.ts | 3 ++- .../Layouts/Folder/ViewDocuments/index.tsx | 20 ++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/front/Api/LeCoffreApi/SuperAdmin/Documents/Documents.ts b/src/front/Api/LeCoffreApi/SuperAdmin/Documents/Documents.ts index 608bf951..72188423 100644 --- a/src/front/Api/LeCoffreApi/SuperAdmin/Documents/Documents.ts +++ b/src/front/Api/LeCoffreApi/SuperAdmin/Documents/Documents.ts @@ -13,7 +13,8 @@ export interface IGetDocumentsparams { // TODO Type getbyuid query params export type IPutDocumentsParams = { - document_status?: EDocumentStatus + document_status?: EDocumentStatus; + refused_reason?: string; }; export interface IPostDocumentsParams {} diff --git a/src/front/Components/Layouts/Folder/ViewDocuments/index.tsx b/src/front/Components/Layouts/Folder/ViewDocuments/index.tsx index 9d0ec40a..0c76aa41 100644 --- a/src/front/Components/Layouts/Folder/ViewDocuments/index.tsx +++ b/src/front/Components/Layouts/Folder/ViewDocuments/index.tsx @@ -66,6 +66,7 @@ class ViewDocumentsClass extends BasePage { this.hasPrevious = this.hasPrevious.bind(this); this.hasNext = this.hasNext.bind(this); + this.refuseDocument = this.refuseDocument.bind(this); } public override render(): JSX.Element | null { @@ -156,7 +157,7 @@ class ViewDocumentsClass extends BasePage { { return index < this.state.document!.files!.length; } + private async refuseDocument(){ + try{ + await Documents.getInstance().put(this.props.documentUid, { + document_status: EDocumentStatus.REFUSED, + refused_reason: this.state.refuseText, + }); + + this.props.router.push( + Module.getInstance() + .get() + .modules.pages.Folder.pages.FolderInformation.props.path.replace("[folderUid]", this.props.folderUid), + ); + }catch(e){ + console.error(e); + } + } + private async validateAnchoring() { this.setState({ hasValidateAnchoring: true, From 2ea53d7a84a225f9933d66c5292d7c79f48302aa Mon Sep 17 00:00:00 2001 From: Maxime Lalo Date: Tue, 9 May 2023 12:01:07 +0200 Subject: [PATCH 2/3] :bug: Fixing refused_reason --- src/front/Api/LeCoffreApi/SuperAdmin/Documents/Documents.ts | 4 ++-- src/front/Components/Layouts/Folder/ViewDocuments/index.tsx | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/front/Api/LeCoffreApi/SuperAdmin/Documents/Documents.ts b/src/front/Api/LeCoffreApi/SuperAdmin/Documents/Documents.ts index 72188423..2f74e8fd 100644 --- a/src/front/Api/LeCoffreApi/SuperAdmin/Documents/Documents.ts +++ b/src/front/Api/LeCoffreApi/SuperAdmin/Documents/Documents.ts @@ -1,4 +1,4 @@ -import { Document } from "le-coffre-resources/dist/SuperAdmin"; +import { Document, DocumentHistory } from "le-coffre-resources/dist/SuperAdmin"; import { Service } from "typedi"; import BaseSuperAdmin from "../BaseSuperAdmin"; @@ -14,7 +14,7 @@ export interface IGetDocumentsparams { export type IPutDocumentsParams = { document_status?: EDocumentStatus; - refused_reason?: string; + document_history?: Partial; }; export interface IPostDocumentsParams {} diff --git a/src/front/Components/Layouts/Folder/ViewDocuments/index.tsx b/src/front/Components/Layouts/Folder/ViewDocuments/index.tsx index 0c76aa41..a266ad95 100644 --- a/src/front/Components/Layouts/Folder/ViewDocuments/index.tsx +++ b/src/front/Components/Layouts/Folder/ViewDocuments/index.tsx @@ -249,7 +249,9 @@ class ViewDocumentsClass extends BasePage { try{ await Documents.getInstance().put(this.props.documentUid, { document_status: EDocumentStatus.REFUSED, - refused_reason: this.state.refuseText, + document_history: { + refused_reason: this.state.refuseText, + } }); this.props.router.push( From da2b372aa5cf299bd934bce5951224dad35b471b Mon Sep 17 00:00:00 2001 From: Maxime Lalo Date: Tue, 9 May 2023 15:01:34 +0200 Subject: [PATCH 3/3] :bug: Fixing refuse with back working --- src/front/Api/LeCoffreApi/SuperAdmin/Documents/Documents.ts | 4 ++-- src/front/Components/Layouts/Folder/ViewDocuments/index.tsx | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/front/Api/LeCoffreApi/SuperAdmin/Documents/Documents.ts b/src/front/Api/LeCoffreApi/SuperAdmin/Documents/Documents.ts index 2f74e8fd..72188423 100644 --- a/src/front/Api/LeCoffreApi/SuperAdmin/Documents/Documents.ts +++ b/src/front/Api/LeCoffreApi/SuperAdmin/Documents/Documents.ts @@ -1,4 +1,4 @@ -import { Document, DocumentHistory } from "le-coffre-resources/dist/SuperAdmin"; +import { Document } from "le-coffre-resources/dist/SuperAdmin"; import { Service } from "typedi"; import BaseSuperAdmin from "../BaseSuperAdmin"; @@ -14,7 +14,7 @@ export interface IGetDocumentsparams { export type IPutDocumentsParams = { document_status?: EDocumentStatus; - document_history?: Partial; + refused_reason?: string; }; export interface IPostDocumentsParams {} diff --git a/src/front/Components/Layouts/Folder/ViewDocuments/index.tsx b/src/front/Components/Layouts/Folder/ViewDocuments/index.tsx index a266ad95..f737b1bc 100644 --- a/src/front/Components/Layouts/Folder/ViewDocuments/index.tsx +++ b/src/front/Components/Layouts/Folder/ViewDocuments/index.tsx @@ -249,9 +249,7 @@ class ViewDocumentsClass extends BasePage { try{ await Documents.getInstance().put(this.props.documentUid, { document_status: EDocumentStatus.REFUSED, - document_history: { - refused_reason: this.state.refuseText, - } + refused_reason: this.state.refuseText }); this.props.router.push(