From 0a3be835a93e0c805c3646604ecd7ff659d5c75b Mon Sep 17 00:00:00 2001 From: Sosthene Date: Fri, 12 Sep 2025 12:54:55 +0200 Subject: [PATCH] Fix Dashboard with folders --- .../DefaultNotaryDashboard/index.tsx | 40 +++++++--- .../ClientView/ClientBox/index.tsx | 7 +- .../FolderInformation/ClientView/index.tsx | 7 +- .../Folder/FolderInformation/index.tsx | 78 ++++++------------- 4 files changed, 60 insertions(+), 72 deletions(-) diff --git a/src/front/Components/LayoutTemplates/DefaultNotaryDashboard/index.tsx b/src/front/Components/LayoutTemplates/DefaultNotaryDashboard/index.tsx index f7161440..8697c8d9 100644 --- a/src/front/Components/LayoutTemplates/DefaultNotaryDashboard/index.tsx +++ b/src/front/Components/LayoutTemplates/DefaultNotaryDashboard/index.tsx @@ -9,6 +9,7 @@ import { useRouter } from "next/router"; import DefaultDashboardWithList, { IPropsDashboardWithList } from "../DefaultDashboardWithList"; import FolderService from "src/common/Api/LeCoffreApi/sdk/FolderService"; +import { idAsUrl } from "@Front/Utils/ProcessIdUtils"; type IProps = IPropsDashboardWithList & { isArchived?: boolean; @@ -25,11 +26,11 @@ export default function DefaultNotaryDashboard(props: IProps) { : Module.getInstance().get().modules.pages.Folder.pages.FolderInformation.props.path; const getBlocks = useCallback( - (folders: OfficeFolder[]): IBlock[] => { + (folders: any[]): IBlock[] => { const pendingFolders = folders .filter((folder) => { const pendingDocuments = (folder.documents ?? []).filter( - (document) => document.document_status === EDocumentStatus.DEPOSITED, + (document: any) => document.document_status === EDocumentStatus.DEPOSITED, ); return pendingDocuments.length >= 1; }) @@ -40,7 +41,7 @@ export default function DefaultNotaryDashboard(props: IProps) { const otherFolders = folders .filter((folder) => { const pendingDocuments = (folder.documents ?? []).filter( - (document) => document.document_status === EDocumentStatus.DEPOSITED, + (document: any) => document.document_status === EDocumentStatus.DEPOSITED, ); return pendingDocuments.length === 0; }) @@ -48,15 +49,18 @@ export default function DefaultNotaryDashboard(props: IProps) { return folder1.created_at! > folder2.created_at! ? -1 : 1; }); - return [...pendingFolders, ...otherFolders].map((folder) => { - return { - id: folder.uid!, + const blocks = [...pendingFolders, ...otherFolders].map((folder) => { + const res = { + id: idAsUrl(folder.processId), primaryText: folder.name, secondaryText: folder.folder_number, - isActive: folderUid === folder.uid, - showAlert: folder.documents?.some((document) => document.document_status === EDocumentStatus.DEPOSITED), + isActive: folderUid === idAsUrl(folder.processId), + showAlert: folder.documents?.some((document: any) => document.document_status === EDocumentStatus.DEPOSITED), }; + return res; }); + + return blocks; }, [folderUid], ); @@ -115,14 +119,26 @@ export default function DefaultNotaryDashboard(props: IProps) { .then((folders) => setFolders(folders)); */ - FolderService.getFolders((processes: any[]) => { - if (processes.length > 0) { - let folders: any[] = processes.map((process: any) => process.processData); + FolderService.getFolders((processes: Record) => { + if (Object.keys(processes).length > 0) { + let folders: any[] = Object.entries(processes).map(([processId, process]) => { + const res = { + ...process, + processId: processId + }; + return res; + }); + // FilterBy status - folders = folders.filter((folder: any) => folder.status === targetedStatus); + folders = folders.filter((folder: any) => { + const matches = folder.status === targetedStatus; + return matches; + }); setFolders(folders); + } else { + console.debug('[DefaultNotaryDashboard] No processes found'); } }); }, [isArchived]); diff --git a/src/front/Components/Layouts/Folder/FolderInformation/ClientView/ClientBox/index.tsx b/src/front/Components/Layouts/Folder/FolderInformation/ClientView/ClientBox/index.tsx index 540b49aa..482703e3 100644 --- a/src/front/Components/Layouts/Folder/FolderInformation/ClientView/ClientBox/index.tsx +++ b/src/front/Components/Layouts/Folder/FolderInformation/ClientView/ClientBox/index.tsx @@ -33,9 +33,10 @@ export default function ClientBox(props: IProps) { const handleDelete = useCallback( (customerUid: string) => { LoaderService.getInstance().show(); - DocumentService.getDocuments().then((processes: any[]) => { - if (processes.length > 0) { - let documents: any[] = processes.map((process: any) => process.processData); + DocumentService.getDocuments().then((processes: Record) => { + const processArray = Object.values(processes); + if (processArray.length > 0) { + let documents: any[] = processArray.map((process: any) => process.processData); // FilterBy folder.uid & depositor.uid documents = documents.filter((document: any) => document.folder.uid === folderUid && document.depositor && document.depositor.uid === customerUid); diff --git a/src/front/Components/Layouts/Folder/FolderInformation/ClientView/index.tsx b/src/front/Components/Layouts/Folder/FolderInformation/ClientView/index.tsx index 0375752c..3957452a 100644 --- a/src/front/Components/Layouts/Folder/FolderInformation/ClientView/index.tsx +++ b/src/front/Components/Layouts/Folder/FolderInformation/ClientView/index.tsx @@ -1,11 +1,9 @@ -import Folders from "@Front/Api/LeCoffreApi/Notary/Folders/Folders"; import Button, { EButtonSize, EButtonstyletype, EButtonVariant } from "@Front/Components/DesignSystem/Button"; import Tabs from "@Front/Components/Elements/Tabs"; import Module from "@Front/Config/Module"; import { DocumentIcon, UserPlusIcon } from "@heroicons/react/24/outline"; import Customer from "le-coffre-resources/dist/Customer"; import { EDocumentStatus } from "le-coffre-resources/dist/Customer/Document"; -import { OfficeFolder } from "le-coffre-resources/dist/Notary"; import Link from "next/link"; import { useCallback, useMemo, useState } from "react"; @@ -18,9 +16,10 @@ import EmailReminder from "./EmailReminder"; import FolderService from "src/common/Api/LeCoffreApi/sdk/FolderService"; import LoaderService from "src/common/Api/LeCoffreApi/sdk/Loader/LoaderService"; import MessageBus from "src/sdk/MessageBus"; +import { idAsUrl } from "@Front/Utils/ProcessIdUtils"; type IProps = { - folder: { processId: string, FolderData: OfficeFolder}; + folder: any; anchorStatus: AnchorStatus; }; @@ -92,7 +91,7 @@ export default function ClientView(props: IProps) { + .modules.pages.Folder.pages.AddClient.props.path.replace("[folderUid]", idAsUrl(folder.processId) ?? "")}>