Fix somes issues
This commit is contained in:
parent
d3e13bd801
commit
e4c440d6df
@ -14,10 +14,12 @@ import classNames from "classnames";
|
|||||||
|
|
||||||
import Button, { EButtonstyletype, EButtonVariant } from "../Button";
|
import Button, { EButtonstyletype, EButtonVariant } from "../Button";
|
||||||
import Confirm from "../OldModal/Confirm";
|
import Confirm from "../OldModal/Confirm";
|
||||||
import Documents from "@Front/Api/LeCoffreApi/Customer/Documents/Documents";
|
|
||||||
import Files from "@Front/Api/LeCoffreApi/Customer/Files/Files";
|
|
||||||
import Alert from "../OldModal/Alert";
|
import Alert from "../OldModal/Alert";
|
||||||
|
|
||||||
|
import DocumentService from "src/common/Api/LeCoffreApi/sdk/DocumentService";
|
||||||
|
import LoaderService from "src/common/Api/LeCoffreApi/sdk/Loader/LoaderService";
|
||||||
|
import FileService from "src/common/Api/LeCoffreApi/sdk/FileService";
|
||||||
|
|
||||||
type IProps = {
|
type IProps = {
|
||||||
onChange?: (files: File[]) => void;
|
onChange?: (files: File[]) => void;
|
||||||
open: boolean;
|
open: boolean;
|
||||||
@ -206,18 +208,30 @@ export default class DepositOtherDocument extends React.Component<IProps, IState
|
|||||||
this.setState({
|
this.setState({
|
||||||
isLoading: true,
|
isLoading: true,
|
||||||
});
|
});
|
||||||
const filesArray = this.state.currentFiles;
|
|
||||||
|
|
||||||
|
const filesArray = this.state.currentFiles;
|
||||||
if (!filesArray) return;
|
if (!filesArray) return;
|
||||||
let documentCreated: Document = {} as Document;
|
|
||||||
|
LoaderService.getInstance().show();
|
||||||
|
let documentCreated: any;
|
||||||
try {
|
try {
|
||||||
documentCreated = await Documents.getInstance().post({
|
documentCreated = await new Promise<any>((resolve: (document: any) => void) => {
|
||||||
|
const documentTypeData: any = {
|
||||||
folder: {
|
folder: {
|
||||||
uid: this.props.folder_uid,
|
uid: this.props.folder_uid,
|
||||||
},
|
},
|
||||||
depositor: {
|
depositor: {
|
||||||
uid: this.props.customer_uid,
|
uid: this.props.customer_uid,
|
||||||
},
|
}
|
||||||
|
};
|
||||||
|
const validatorId: string = '884cb36a346a79af8697559f16940141f068bdf1656f88fa0df0e9ecd7311fb8:0';
|
||||||
|
|
||||||
|
DocumentService.createDocument(documentTypeData, validatorId).then((processCreated: any) => {
|
||||||
|
if (processCreated) {
|
||||||
|
const document: any = processCreated.processData;
|
||||||
|
resolve(document);
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.setState({ showFailedDocument: "Le dossier est vérifié aucune modification n'est acceptée", isLoading: false });
|
this.setState({ showFailedDocument: "Le dossier est vérifié aucune modification n'est acceptée", isLoading: false });
|
||||||
@ -225,16 +239,46 @@ export default class DepositOtherDocument extends React.Component<IProps, IState
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (let i = 0; i < filesArray.length; i++) {
|
for (let i = 0; i < filesArray.length; i++) {
|
||||||
const formData = new FormData();
|
const file = filesArray[i]!.file;
|
||||||
formData.append("file", filesArray[i]!.file, filesArray[i]!.fileName);
|
await new Promise<void>((resolve: () => void) => {
|
||||||
const query = JSON.stringify({ document: { uid: documentCreated.uid } });
|
const reader = new FileReader();
|
||||||
formData.append("q", query);
|
reader.onload = (event) => {
|
||||||
try {
|
if (event.target?.result) {
|
||||||
await Files.getInstance().post(formData);
|
const arrayBuffer = event.target.result as ArrayBuffer;
|
||||||
} catch (e) {
|
const uint8Array = new Uint8Array(arrayBuffer);
|
||||||
this.setState({ showFailedUploaded: "Le fichier ne correspond pas aux critères demandés", isLoading: false });
|
|
||||||
return;
|
const fileBlob: any = {
|
||||||
|
type: file.type,
|
||||||
|
data: uint8Array
|
||||||
|
};
|
||||||
|
|
||||||
|
const fileData: any = {
|
||||||
|
file_blob: fileBlob,
|
||||||
|
file_name: file.name
|
||||||
|
};
|
||||||
|
const validatorId: string = '884cb36a346a79af8697559f16940141f068bdf1656f88fa0df0e9ecd7311fb8:0';
|
||||||
|
|
||||||
|
FileService.createFile(fileData, validatorId).then((processCreated: any) => {
|
||||||
|
const fileUid: string = processCreated.processData.uid;
|
||||||
|
|
||||||
|
DocumentService.getDocumentByUid(documentCreated.uid).then((process: any) => {
|
||||||
|
if (process) {
|
||||||
|
const document: any = process.processData;
|
||||||
|
|
||||||
|
let files: any[] = document.files;
|
||||||
|
if (!files) {
|
||||||
|
files = [];
|
||||||
}
|
}
|
||||||
|
files.push({ uid: fileUid });
|
||||||
|
|
||||||
|
DocumentService.updateDocument(process, { files: files, document_status: EDocumentStatus.DEPOSITED }).then(() => resolve());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
reader.readAsArrayBuffer(file);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
|
@ -14,7 +14,7 @@ type IProps = IPropsDashboardWithList & {};
|
|||||||
|
|
||||||
export default function DefaultCustomerDashboard(props: IProps) {
|
export default function DefaultCustomerDashboard(props: IProps) {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { folderUid } = router.query;
|
const { folderUid, profileUid } = router.query;
|
||||||
const [folders, setFolders] = useState<OfficeFolder[]>([]);
|
const [folders, setFolders] = useState<OfficeFolder[]>([]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -61,7 +61,9 @@ export default function DefaultCustomerDashboard(props: IProps) {
|
|||||||
router.push(
|
router.push(
|
||||||
Module.getInstance()
|
Module.getInstance()
|
||||||
.get()
|
.get()
|
||||||
.modules.pages.ClientDashboard.props.path.replace("[folderUid]", folder.uid ?? ""),
|
.modules.pages.ClientDashboard.props.path
|
||||||
|
.replace("[folderUid]", folder.uid ?? "")
|
||||||
|
.replace("[profileUid]", profileUid as string ?? ""),
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
return <DefaultDashboardWithList {...props} onSelectedBlock={onSelectedBlock} blocks={getBlocks(folders)} headerConnected={false} />;
|
return <DefaultDashboardWithList {...props} onSelectedBlock={onSelectedBlock} blocks={getBlocks(folders)} headerConnected={false} />;
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
import DocumentsNotary from "@Front/Api/LeCoffreApi/Customer/DocumentsNotary/DocumentsNotary";
|
|
||||||
import FilesNotary from "@Front/Api/LeCoffreApi/Customer/FilesNotary/Files";
|
|
||||||
import Button, { EButtonSize, EButtonstyletype, EButtonVariant } from "@Front/Components/DesignSystem/Button";
|
import Button, { EButtonSize, EButtonstyletype, EButtonVariant } from "@Front/Components/DesignSystem/Button";
|
||||||
import IconButton from "@Front/Components/DesignSystem/IconButton";
|
import IconButton from "@Front/Components/DesignSystem/IconButton";
|
||||||
import Table from "@Front/Components/DesignSystem/Table";
|
import Table from "@Front/Components/DesignSystem/Table";
|
||||||
@ -16,10 +14,14 @@ import { useRouter } from "next/router";
|
|||||||
import React, { useCallback, useEffect, useState } from "react";
|
import React, { useCallback, useEffect, useState } from "react";
|
||||||
import classes from "./classes.module.scss";
|
import classes from "./classes.module.scss";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import Folders from "@Front/Api/LeCoffreApi/Customer/Folders/Folders";
|
|
||||||
import Customer from "le-coffre-resources/dist/Customer";
|
import Customer from "le-coffre-resources/dist/Customer";
|
||||||
import { DocumentNotary } from "le-coffre-resources/dist/Notary";
|
import { DocumentNotary } from "le-coffre-resources/dist/Notary";
|
||||||
|
|
||||||
|
import FolderService from "src/common/Api/LeCoffreApi/sdk/FolderService";
|
||||||
|
import DocumentService from "src/common/Api/LeCoffreApi/sdk/DocumentService";
|
||||||
|
import FileService from "src/common/Api/LeCoffreApi/sdk/FileService";
|
||||||
|
import LoaderService from "src/common/Api/LeCoffreApi/sdk/Loader/LoaderService";
|
||||||
|
|
||||||
const header: readonly IHead[] = [
|
const header: readonly IHead[] = [
|
||||||
{
|
{
|
||||||
key: "name",
|
key: "name",
|
||||||
@ -47,6 +49,26 @@ export default function ReceivedDocuments() {
|
|||||||
jwt = JwtService.getInstance().decodeCustomerJwt();
|
jwt = JwtService.getInstance().decodeCustomerJwt();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: review
|
||||||
|
LoaderService.getInstance().show();
|
||||||
|
const folder: any = await new Promise<any>((resolve: (folder: any) => void) => {
|
||||||
|
FolderService.getFolderByUid(folderUid as string).then((process: any) => {
|
||||||
|
if (process) {
|
||||||
|
const folder: any = process.processData;
|
||||||
|
resolve(folder);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
//const customer = folder?.customers?.find((customer) => customer.contact?.email === jwt?.email);
|
||||||
|
const customer = folder?.customers?.[0];
|
||||||
|
if (!customer) throw new Error("Customer not found");
|
||||||
|
|
||||||
|
setCustomer(customer);
|
||||||
|
|
||||||
|
return { folder, customer };
|
||||||
|
|
||||||
|
/*
|
||||||
const folder = await Folders.getInstance().getByUid(folderUid as string, {
|
const folder = await Folders.getInstance().getByUid(folderUid as string, {
|
||||||
q: {
|
q: {
|
||||||
office: true,
|
office: true,
|
||||||
@ -76,32 +98,58 @@ export default function ReceivedDocuments() {
|
|||||||
setCustomer(customer);
|
setCustomer(customer);
|
||||||
|
|
||||||
return { folder, customer };
|
return { folder, customer };
|
||||||
|
*/
|
||||||
}, [folderUid]);
|
}, [folderUid]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetchFolderAndCustomer();
|
fetchFolderAndCustomer();
|
||||||
|
}, [folderUid]); // Ne dépend que de folderUid
|
||||||
|
|
||||||
|
// Effet séparé pour charger les documents lorsque customer change
|
||||||
|
useEffect(() => {
|
||||||
const customerUid = customer?.uid;
|
const customerUid = customer?.uid;
|
||||||
if (!folderUid || !customerUid) return;
|
if (!folderUid || !customerUid) return;
|
||||||
DocumentsNotary.getInstance()
|
|
||||||
.get({ where: { folder: { uid: folderUid }, customer: { uid: customerUid } }, include: { files: true } })
|
|
||||||
.then((documentsNotary) => setDocumentsNotary(documentsNotary));
|
|
||||||
}, [folderUid, customer, fetchFolderAndCustomer]);
|
|
||||||
|
|
||||||
const onDownload = useCallback((doc: DocumentNotary) => {
|
DocumentService.getDocuments().then(async (processes: any[]) => {
|
||||||
|
if (processes.length > 0) {
|
||||||
|
let documents: any[] = processes.map((process: any) => process.processData);
|
||||||
|
|
||||||
|
// FilterBy folder.uid & customer.uid
|
||||||
|
documents = documents.filter((document: any) => document.folder.uid === folderUid && document.customer && document.customer.uid === customerUid);
|
||||||
|
|
||||||
|
for (const document of documents) {
|
||||||
|
if (document.files && document.files.length > 0) {
|
||||||
|
const files: any[] = [];
|
||||||
|
for (const file of document.files) {
|
||||||
|
files.push((await FileService.getFileByUid(file.uid)).processData);
|
||||||
|
}
|
||||||
|
document.files = files;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setDocumentsNotary(documents);
|
||||||
|
LoaderService.getInstance().hide();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, [folderUid, customer]);
|
||||||
|
|
||||||
|
const onDownload = useCallback((doc: any) => {
|
||||||
const file = doc.files?.[0];
|
const file = doc.files?.[0];
|
||||||
if (!file || !file?.uid || !doc.uid) return;
|
if (!file) return;
|
||||||
|
|
||||||
return FilesNotary.getInstance()
|
return new Promise<void>((resolve: () => void) => {
|
||||||
.download(file.uid, doc.uid)
|
const blob = new Blob([file.file_blob.data], { type: file.file_blob.type });
|
||||||
.then((blob) => {
|
|
||||||
const url = URL.createObjectURL(blob);
|
const url = URL.createObjectURL(blob);
|
||||||
const a = document.createElement("a");
|
const a = document.createElement('a');
|
||||||
a.href = url;
|
a.href = url;
|
||||||
a.download = file.file_name ?? "file";
|
a.download = file.file_name;
|
||||||
|
document.body.appendChild(a);
|
||||||
a.click();
|
a.click();
|
||||||
|
document.body.removeChild(a);
|
||||||
URL.revokeObjectURL(url);
|
URL.revokeObjectURL(url);
|
||||||
})
|
|
||||||
.catch((e) => console.warn(e));
|
resolve();
|
||||||
|
}).catch((e) => console.warn(e));
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const onDownloadAll = useCallback(async () => {
|
const onDownloadAll = useCallback(async () => {
|
||||||
@ -110,16 +158,14 @@ export default function ReceivedDocuments() {
|
|||||||
const zip = new JSZip();
|
const zip = new JSZip();
|
||||||
const folder = zip.folder("documents") || zip;
|
const folder = zip.folder("documents") || zip;
|
||||||
|
|
||||||
const downloadPromises = documentsNotary.map(async (doc) => {
|
documentsNotary.map((doc: any) => {
|
||||||
const file = doc.files?.[0];
|
const file = doc.files?.[0];
|
||||||
if (file && file.uid && doc.uid) {
|
if (file) {
|
||||||
const blob = await FilesNotary.getInstance().download(file.uid, doc.uid);
|
const blob = new Blob([file.file_blob.data], { type: file.file_blob.type });
|
||||||
folder.file(file.file_name ?? "file", blob);
|
folder.file(file.file_name ?? "file", blob);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
await Promise.all(downloadPromises);
|
|
||||||
|
|
||||||
zip.generateAsync({ type: "blob" })
|
zip.generateAsync({ type: "blob" })
|
||||||
.then((blob: any) => {
|
.then((blob: any) => {
|
||||||
saveAs(blob, "documents.zip");
|
saveAs(blob, "documents.zip");
|
||||||
|
@ -10,9 +10,12 @@ 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 DocumentsNotary from "@Front/Api/LeCoffreApi/Customer/DocumentsNotary/DocumentsNotary";
|
|
||||||
import DefaultTemplate from "@Front/Components/LayoutTemplates/DefaultTemplate";
|
import DefaultTemplate from "@Front/Components/LayoutTemplates/DefaultTemplate";
|
||||||
import FilesNotary from "@Front/Api/LeCoffreApi/Customer/FilesNotary/Files";
|
|
||||||
|
import DocumentService from "src/common/Api/LeCoffreApi/sdk/DocumentService";
|
||||||
|
import FileService from "src/common/Api/LeCoffreApi/sdk/FileService";
|
||||||
|
import LoaderService from "src/common/Api/LeCoffreApi/sdk/Loader/LoaderService";
|
||||||
|
|
||||||
type IProps = {};
|
type IProps = {};
|
||||||
type IPropsClass = {
|
type IPropsClass = {
|
||||||
@ -123,11 +126,26 @@ class ViewDocumentsNotaryClass extends BasePage<IPropsClass, IState> {
|
|||||||
|
|
||||||
override async componentDidMount() {
|
override async componentDidMount() {
|
||||||
try {
|
try {
|
||||||
const documentNotary = await DocumentsNotary.getInstance().getByUid(this.props.documentUid, {
|
LoaderService.getInstance().show();
|
||||||
files: true,
|
const documentNotary: any = await new Promise<any>((resolve: (document: any) => void) => {
|
||||||
folder: true,
|
DocumentService.getDocumentByUid(this.props.documentUid).then(async (process: any) => {
|
||||||
depositor: true,
|
if (process) {
|
||||||
|
const document: any = process.processData;
|
||||||
|
|
||||||
|
if (document.files && document.files.length > 0) {
|
||||||
|
const files: any[] = [];
|
||||||
|
for (const file of document.files) {
|
||||||
|
files.push((await FileService.getFileByUid(file.uid)).processData);
|
||||||
|
}
|
||||||
|
document.files = files;
|
||||||
|
}
|
||||||
|
|
||||||
|
resolve(document);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
LoaderService.getInstance().hide();
|
||||||
|
|
||||||
this.setState(
|
this.setState(
|
||||||
{
|
{
|
||||||
documentNotary,
|
documentNotary,
|
||||||
@ -149,8 +167,7 @@ class ViewDocumentsNotaryClass extends BasePage<IPropsClass, IState> {
|
|||||||
|
|
||||||
private async getFilePreview(): Promise<void> {
|
private async getFilePreview(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
const fileBlob: Blob = await FilesNotary.getInstance().download(this.state.selectedFile?.uid as string, this.props.documentUid);
|
const fileBlob: Blob = new Blob([this.state.selectedFile.file_blob.data], { type: this.state.selectedFile.file_blob.type });
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
fileBlob,
|
fileBlob,
|
||||||
});
|
});
|
||||||
|
@ -10,7 +10,6 @@ import { DocumentNotary, OfficeFolder as OfficeFolderNotary } from "le-coffre-re
|
|||||||
import classes from "./classes.module.scss";
|
import classes from "./classes.module.scss";
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
import JwtService, { ICustomerJwtPayload } from "@Front/Services/JwtService/JwtService";
|
import JwtService, { ICustomerJwtPayload } from "@Front/Services/JwtService/JwtService";
|
||||||
import Folders from "@Front/Api/LeCoffreApi/Customer/Folders/Folders";
|
|
||||||
|
|
||||||
import Tag, { ETagColor } from "@Front/Components/DesignSystem/Tag";
|
import Tag, { ETagColor } from "@Front/Components/DesignSystem/Tag";
|
||||||
import DefaultCustomerDashboard from "@Front/Components/LayoutTemplates/DefaultCustomerDashboard";
|
import DefaultCustomerDashboard from "@Front/Components/LayoutTemplates/DefaultCustomerDashboard";
|
||||||
@ -21,7 +20,6 @@ import Module from "@Front/Config/Module";
|
|||||||
import Separator, { ESeperatorColor, ESeperatorDirection } from "@Front/Components/DesignSystem/Separator";
|
import Separator, { ESeperatorColor, ESeperatorDirection } from "@Front/Components/DesignSystem/Separator";
|
||||||
import NotificationBox from "@Front/Components/DesignSystem/NotificationBox";
|
import NotificationBox from "@Front/Components/DesignSystem/NotificationBox";
|
||||||
import ContactBox from "./ContactBox";
|
import ContactBox from "./ContactBox";
|
||||||
import DocumentsNotary from "@Front/Api/LeCoffreApi/Customer/DocumentsNotary/DocumentsNotary";
|
|
||||||
import { EDocumentNotaryStatus } from "le-coffre-resources/dist/Notary/DocumentNotary";
|
import { EDocumentNotaryStatus } from "le-coffre-resources/dist/Notary/DocumentNotary";
|
||||||
import DepositOtherDocument from "@Front/Components/DesignSystem/DepositOtherDocument";
|
import DepositOtherDocument from "@Front/Components/DesignSystem/DepositOtherDocument";
|
||||||
|
|
||||||
@ -31,6 +29,7 @@ import FolderService from "src/common/Api/LeCoffreApi/sdk/FolderService";
|
|||||||
import DocumentService from "src/common/Api/LeCoffreApi/sdk/DocumentService";
|
import DocumentService from "src/common/Api/LeCoffreApi/sdk/DocumentService";
|
||||||
import DocumentTypeService from "src/common/Api/LeCoffreApi/sdk/DocumentTypeService";
|
import DocumentTypeService from "src/common/Api/LeCoffreApi/sdk/DocumentTypeService";
|
||||||
import FileService from "src/common/Api/LeCoffreApi/sdk/FileService";
|
import FileService from "src/common/Api/LeCoffreApi/sdk/FileService";
|
||||||
|
import LoaderService from "src/common/Api/LeCoffreApi/sdk/Loader/LoaderService";
|
||||||
|
|
||||||
type IProps = {};
|
type IProps = {};
|
||||||
|
|
||||||
@ -54,6 +53,7 @@ export default function ClientDashboard(props: IProps) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: review
|
// TODO: review
|
||||||
|
LoaderService.getInstance().show();
|
||||||
const { folder, customer } = await new Promise<any>((resolve) => {
|
const { folder, customer } = await new Promise<any>((resolve) => {
|
||||||
FolderService.getFolderByUid(folderUid as string).then((process: any) => {
|
FolderService.getFolderByUid(folderUid as string).then((process: any) => {
|
||||||
if (process) {
|
if (process) {
|
||||||
@ -72,6 +72,7 @@ export default function ClientDashboard(props: IProps) {
|
|||||||
setFolder(folder);
|
setFolder(folder);
|
||||||
|
|
||||||
setIsAuthModalOpen(true);
|
setIsAuthModalOpen(true);
|
||||||
|
LoaderService.getInstance().hide();
|
||||||
|
|
||||||
return { folder, customer };
|
return { folder, customer };
|
||||||
|
|
||||||
@ -111,40 +112,19 @@ export default function ClientDashboard(props: IProps) {
|
|||||||
|
|
||||||
const fetchDocuments = useCallback(
|
const fetchDocuments = useCallback(
|
||||||
async (customerUid: string | undefined) => {
|
async (customerUid: string | undefined) => {
|
||||||
/* TODO: review
|
LoaderService.getInstance().show();
|
||||||
const query: IGetDocumentsparams = {
|
return new Promise<void>((resolve: () => void) => {
|
||||||
where: { depositor: { uid: customerUid }, folder_uid: folderUid as string },
|
DocumentService.getDocuments().then(async (processes: any[]) => {
|
||||||
include: {
|
|
||||||
files: true,
|
|
||||||
document_history: true,
|
|
||||||
document_type: true,
|
|
||||||
depositor: true,
|
|
||||||
folder: {
|
|
||||||
include: {
|
|
||||||
customers: {
|
|
||||||
include: {
|
|
||||||
contact: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
return Documents.getInstance()
|
|
||||||
.get(query)
|
|
||||||
.then((documents) => setDocuments(documents));
|
|
||||||
*/
|
|
||||||
|
|
||||||
return DocumentService.getDocuments().then(async (processes: any[]) => {
|
|
||||||
if (processes.length > 0) {
|
if (processes.length > 0) {
|
||||||
let documents: any[] = processes.map((process: any) => process.processData);
|
let documents: any[] = processes.map((process: any) => process.processData);
|
||||||
|
|
||||||
// FilterBy folder_uid
|
// FilterBy folder.uid & depositor.uid
|
||||||
documents = documents.filter((document: any) => document.folder.uid === folderUid && document.depositor);
|
documents = documents.filter((document: any) => document.folder.uid === folderUid && document.depositor && document.depositor.uid === customerUid);
|
||||||
|
|
||||||
for (const document of documents) {
|
for (const document of documents) {
|
||||||
|
if (document.document_type) {
|
||||||
document.document_type = (await DocumentTypeService.getDocumentTypeByUid(document.document_type.uid)).processData;
|
document.document_type = (await DocumentTypeService.getDocumentTypeByUid(document.document_type.uid)).processData;
|
||||||
|
}
|
||||||
|
|
||||||
if (document.files && document.files.length > 0) {
|
if (document.files && document.files.length > 0) {
|
||||||
const files: any[] = [];
|
const files: any[] = [];
|
||||||
@ -157,6 +137,9 @@ export default function ClientDashboard(props: IProps) {
|
|||||||
|
|
||||||
setDocuments(documents);
|
setDocuments(documents);
|
||||||
}
|
}
|
||||||
|
LoaderService.getInstance().hide();
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
[folderUid],
|
[folderUid],
|
||||||
@ -170,12 +153,28 @@ export default function ClientDashboard(props: IProps) {
|
|||||||
const customerUid = customer?.uid;
|
const customerUid = customer?.uid;
|
||||||
if (!folderUid || !customerUid) return;
|
if (!folderUid || !customerUid) return;
|
||||||
|
|
||||||
/* TODO: review
|
LoaderService.getInstance().show();
|
||||||
DocumentsNotary.getInstance()
|
DocumentService.getDocuments().then(async (processes: any[]) => {
|
||||||
.get({ where: { folder: { uid: folderUid }, customer: { uid: customerUid } }, include: { files: true } })
|
if (processes.length > 0) {
|
||||||
.then((documentsNotary) => setDocumentsNotary(documentsNotary));
|
let documents: any[] = processes.map((process: any) => process.processData);
|
||||||
*/
|
|
||||||
|
|
||||||
|
// FilterBy folder.uid & customer.uid
|
||||||
|
documents = documents.filter((document: any) => document.folder.uid === folderUid && document.customer && document.customer.uid === customerUid);
|
||||||
|
|
||||||
|
for (const document of documents) {
|
||||||
|
if (document.files && document.files.length > 0) {
|
||||||
|
const files: any[] = [];
|
||||||
|
for (const file of document.files) {
|
||||||
|
files.push((await FileService.getFileByUid(file.uid)).processData);
|
||||||
|
}
|
||||||
|
document.files = files;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setDocumentsNotary(documents);
|
||||||
|
LoaderService.getInstance().hide();
|
||||||
|
}
|
||||||
|
});
|
||||||
}, [folderUid, customer?.uid]);
|
}, [folderUid, customer?.uid]);
|
||||||
|
|
||||||
const documentsNotaryNotRead = useMemo(
|
const documentsNotaryNotRead = useMemo(
|
||||||
|
@ -62,7 +62,9 @@ export default function DocumentTables(props: IProps) {
|
|||||||
documents = documents.filter((document: any) => document.folder.uid === folderUid && document.depositor && document.depositor.uid === customerUid);
|
documents = documents.filter((document: any) => document.folder.uid === folderUid && document.depositor && document.depositor.uid === customerUid);
|
||||||
|
|
||||||
for (const document of documents) {
|
for (const document of documents) {
|
||||||
|
if (document.document_type) {
|
||||||
document.document_type = (await DocumentTypeService.getDocumentTypeByUid(document.document_type.uid)).processData;
|
document.document_type = (await DocumentTypeService.getDocumentTypeByUid(document.document_type.uid)).processData;
|
||||||
|
}
|
||||||
|
|
||||||
if (document.files && document.files.length > 0) {
|
if (document.files && document.files.length > 0) {
|
||||||
const files: any[] = [];
|
const files: any[] = [];
|
||||||
|
@ -6,7 +6,7 @@ import Confirm from "@Front/Components/DesignSystem/OldModal/Confirm";
|
|||||||
import Typography, { ETypo, ETypoColor } from "@Front/Components/DesignSystem/Typography";
|
import Typography, { ETypo, ETypoColor } 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 Module from "@Front/Config/Module";
|
||||||
import { Document, File } from "le-coffre-resources/dist/Notary";
|
import { Document } from "le-coffre-resources/dist/Notary";
|
||||||
import { EDocumentStatus } from "le-coffre-resources/dist/Notary/Document";
|
import { EDocumentStatus } from "le-coffre-resources/dist/Notary/Document";
|
||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
import { NextRouter, useRouter } from "next/router";
|
import { NextRouter, useRouter } from "next/router";
|
||||||
|
@ -153,6 +153,10 @@ export default class MessageBus {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (const key of Object.keys(publicDataDecoded)) {
|
||||||
|
processData[key] = publicDataDecoded[key];
|
||||||
|
}
|
||||||
|
|
||||||
if (!file) {
|
if (!file) {
|
||||||
file = {
|
file = {
|
||||||
processId,
|
processId,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user