From 8f63ab3d30a461840195aacfa4faba2869918656 Mon Sep 17 00:00:00 2001 From: Max S Date: Tue, 23 Jul 2024 12:05:46 +0200 Subject: [PATCH] :sparkles: redirect view document page --- .../ClientView/DocumentTables/index.tsx | 53 ++++++++----------- .../FolderInformation/ClientView/index.tsx | 6 ++- .../Layouts/Folder/ViewDocuments/index.tsx | 8 +-- src/front/Config/Module/development.json | 7 +++ src/front/Config/Module/preprod.json | 7 +++ src/front/Config/Module/production.json | 7 +++ src/front/Config/Module/staging.json | 7 +++ 7 files changed, 61 insertions(+), 34 deletions(-) diff --git a/src/front/Components/Layouts/Folder/FolderInformation/ClientView/DocumentTables/index.tsx b/src/front/Components/Layouts/Folder/FolderInformation/ClientView/DocumentTables/index.tsx index 4d6cbb20..2a493164 100644 --- a/src/front/Components/Layouts/Folder/FolderInformation/ClientView/DocumentTables/index.tsx +++ b/src/front/Components/Layouts/Folder/FolderInformation/ClientView/DocumentTables/index.tsx @@ -5,18 +5,20 @@ import Table from "@Front/Components/DesignSystem/Table"; import { IHead, IRowProps } from "@Front/Components/DesignSystem/Table/MuiTable"; import Tag, { ETagColor, ETagVariant } from "@Front/Components/DesignSystem/Tag"; import Typography, { ETypo, ETypoColor } from "@Front/Components/DesignSystem/Typography"; +import Module from "@Front/Config/Module"; import useOpenable from "@Front/Hooks/useOpenable"; import { ArrowDownTrayIcon, EyeIcon, TrashIcon } from "@heroicons/react/24/outline"; -import { Document, File } from "le-coffre-resources/dist/Customer"; +import { Document } from "le-coffre-resources/dist/Customer"; import { EDocumentStatus } from "le-coffre-resources/dist/Customer/Document"; +import Link from "next/link"; import { useCallback, useEffect, useMemo, useState } from "react"; import classes from "./classes.module.scss"; import DeleteAskedDocumentModal from "./DeleteAskedDocumentModal"; -import FilePreviewModal from "./FilePreviewModal"; type IProps = { documents: Document[]; + folderUid: string; }; const header: readonly IHead[] = [ @@ -46,11 +48,9 @@ const tradDocumentStatus: Record = { }; export default function DocumentTables(props: IProps) { - const { documents: documentsProps } = props; + const { documents: documentsProps, folderUid } = props; const [documents, setDocuments] = useState(documentsProps); const [documentUid, setDocumentUid] = useState(null); - const previewModal = useOpenable(); - const [file, setFile] = useState<{ file: File; blob: Blob } | null>(null); const deleteAskedOocumentModal = useOpenable(); @@ -67,19 +67,6 @@ export default function DocumentTables(props: IProps) { [deleteAskedOocumentModal], ); - const onPreview = useCallback( - (document: Document) => { - const file = document.files?.[0]; - if (!file || !file?.uid) return; - return Files.getInstance() - .download(file.uid) - .then((blob) => setFile({ file, blob })) - .then(() => previewModal.open()) - .catch((e) => console.warn(e)); - }, - [previewModal], - ); - const onDownload = useCallback((doc: Document) => { const file = doc.files?.[0]; if (!file || !file?.uid) return; @@ -136,11 +123,19 @@ export default function DocumentTables(props: IProps) { /> ), created_at: document.created_at, - actions: onPreview(document)} icon={} />, + actions: ( + + } /> + + ), }; }) .filter((document) => document !== null) as IRowProps[], - [documents, onPreview], + [documents, folderUid], ); const validatedDocuments: IRowProps[] = useMemo( @@ -161,14 +156,20 @@ export default function DocumentTables(props: IProps) { created_at: document.created_at, actions: (
- onPreview(document)} icon={} /> + + } /> + onDownload(document)} icon={} />
), }; }) .filter((document) => document !== null) as IRowProps[], - [documents, onDownload, onPreview], + [documents, folderUid, onDownload], ); const refusedDocuments: IRowProps[] = useMemo( @@ -220,14 +221,6 @@ export default function DocumentTables(props: IProps) { documentUid={documentUid} /> )} - {file && ( - - )} ); } diff --git a/src/front/Components/Layouts/Folder/FolderInformation/ClientView/index.tsx b/src/front/Components/Layouts/Folder/FolderInformation/ClientView/index.tsx index d36aca2b..a511ec8a 100644 --- a/src/front/Components/Layouts/Folder/FolderInformation/ClientView/index.tsx +++ b/src/front/Components/Layouts/Folder/FolderInformation/ClientView/index.tsx @@ -98,7 +98,11 @@ export default function ClientView(props: IProps) { )} - {doesCustomerHaveDocument ? : } + {doesCustomerHaveDocument ? ( + + ) : ( + + )} ); diff --git a/src/front/Components/Layouts/Folder/ViewDocuments/index.tsx b/src/front/Components/Layouts/Folder/ViewDocuments/index.tsx index 2fcf31db..2f6fe8cf 100644 --- a/src/front/Components/Layouts/Folder/ViewDocuments/index.tsx +++ b/src/front/Components/Layouts/Folder/ViewDocuments/index.tsx @@ -105,9 +105,11 @@ class ViewDocumentsClass extends BasePage { )}
-
- Veuillez valider le document afin de pouvoir le télécharger. -
+ {this.state.document?.document_status === EDocumentStatus.DEPOSITED && ( +
+ Veuillez valider le document afin de pouvoir le télécharger. +
+ )} {/* {this.state.document?.document_type?.name === "Document d'identité" && (
diff --git a/src/front/Config/Module/development.json b/src/front/Config/Module/development.json index 1668208d..20bc04c8 100644 --- a/src/front/Config/Module/development.json +++ b/src/front/Config/Module/development.json @@ -66,6 +66,13 @@ "labelKey": "ask_documents" } }, + "ViewDocuments": { + "enabled": true, + "props": { + "path": "/folders/[folderUid]/documents/[documentUid]", + "labelKey": "ask_documents" + } + }, "EditDescription": { "enabled": true, "props": { diff --git a/src/front/Config/Module/preprod.json b/src/front/Config/Module/preprod.json index 1668208d..20bc04c8 100644 --- a/src/front/Config/Module/preprod.json +++ b/src/front/Config/Module/preprod.json @@ -66,6 +66,13 @@ "labelKey": "ask_documents" } }, + "ViewDocuments": { + "enabled": true, + "props": { + "path": "/folders/[folderUid]/documents/[documentUid]", + "labelKey": "ask_documents" + } + }, "EditDescription": { "enabled": true, "props": { diff --git a/src/front/Config/Module/production.json b/src/front/Config/Module/production.json index 1668208d..20bc04c8 100644 --- a/src/front/Config/Module/production.json +++ b/src/front/Config/Module/production.json @@ -66,6 +66,13 @@ "labelKey": "ask_documents" } }, + "ViewDocuments": { + "enabled": true, + "props": { + "path": "/folders/[folderUid]/documents/[documentUid]", + "labelKey": "ask_documents" + } + }, "EditDescription": { "enabled": true, "props": { diff --git a/src/front/Config/Module/staging.json b/src/front/Config/Module/staging.json index 1668208d..20bc04c8 100644 --- a/src/front/Config/Module/staging.json +++ b/src/front/Config/Module/staging.json @@ -66,6 +66,13 @@ "labelKey": "ask_documents" } }, + "ViewDocuments": { + "enabled": true, + "props": { + "path": "/folders/[folderUid]/documents/[documentUid]", + "labelKey": "ask_documents" + } + }, "EditDescription": { "enabled": true, "props": {