Fix some issues
This commit is contained in:
parent
4d11a9b7ef
commit
02091bf433
@ -7,7 +7,7 @@ export default class CustomerService {
|
||||
|
||||
private static readonly messageBus: MessageBus = MessageBus.getInstance();
|
||||
|
||||
private static readonly CACHE_TTL = 5 * 60 * 1000; // 5 minutes cache TTL
|
||||
private static readonly CACHE_TTL = 45 * 60 * 1000; // 45 minutes cache TTL
|
||||
|
||||
private constructor() { }
|
||||
|
||||
|
@ -7,7 +7,7 @@ export default class DocumentService {
|
||||
|
||||
private static readonly messageBus: MessageBus = MessageBus.getInstance();
|
||||
|
||||
private static readonly CACHE_TTL = 5 * 60 * 1000; // 5 minutes cache TTL
|
||||
private static readonly CACHE_TTL = 45 * 60 * 1000; // 45 minutes cache TTL
|
||||
|
||||
private constructor() { }
|
||||
|
||||
|
@ -5,12 +5,16 @@ import User from 'src/sdk/User';
|
||||
|
||||
import CustomerService from './CustomerService';
|
||||
import DeedTypeService from './DeedTypeService';
|
||||
import DocumentTypeService from './DocumentTypeService';
|
||||
import DocumentService from './DocumentService';
|
||||
import FileService from './FileService';
|
||||
import NoteService from './NoteService';
|
||||
|
||||
export default class FolderService {
|
||||
|
||||
private static readonly messageBus: MessageBus = MessageBus.getInstance();
|
||||
|
||||
private static readonly CACHE_TTL = 5 * 60 * 1000; // 5 minutes cache TTL
|
||||
private static readonly CACHE_TTL = 45 * 60 * 1000; // 45 minutes cache TTL
|
||||
|
||||
private constructor() { }
|
||||
|
||||
@ -182,18 +186,44 @@ export default class FolderService {
|
||||
}
|
||||
resolve(customers);
|
||||
});
|
||||
|
||||
if (process.processData.customers && process.processData.customers.length > 0) {
|
||||
const documents: any[] = (await DocumentService.getDocuments()).map((process: any) => process.processData);
|
||||
for (const customer of process.processData.customers) {
|
||||
customer.documents = documents.filter((document: any) => (document.depositor && document.depositor.uid === customer.uid) || (document.customer && document.customer.uid === customer.uid));
|
||||
|
||||
for (const document of customer.documents) {
|
||||
if (document.document_type) {
|
||||
document.document_type = (await DocumentTypeService.getDocumentTypeByUid(document.document_type.uid)).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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (process.processData.deed && process.processData.deed.deed_type) {
|
||||
const p: any = await DeedTypeService.getDeedTypeByUid(process.processData.deed.deed_type.uid);
|
||||
process.processData.deed.deed_type = p.processData;
|
||||
|
||||
// Remove duplicates
|
||||
// Remove duplicates - TODO: review - see getDeedTypeByUid - completeDeedType
|
||||
if (p.processData.document_types && p.processData.document_types.length > 0) {
|
||||
process.processData.deed.document_types = p.processData.document_types.filter((item: any, index: number) => p.processData.document_types.findIndex((t: any) => t.uid === item.uid) === index);
|
||||
}
|
||||
}
|
||||
|
||||
const notes: any[] = (await NoteService.getNotes()).map((process: any) => process.processData);
|
||||
if (notes.length > 0) {
|
||||
process.processData.notes = notes.filter((note: any) => note.folder.uid === process.processData.uid);
|
||||
}
|
||||
|
||||
return process;
|
||||
}
|
||||
|
||||
|
@ -58,13 +58,12 @@ export default function Tabs<T>({ onSelect, tabs: propsTabs }: IProps<T>) {
|
||||
useEffect(() => {
|
||||
tabs.current = propsTabs;
|
||||
|
||||
// TODO: review
|
||||
setTimeout(() => {
|
||||
calculateVisibleElements();
|
||||
if (tabs.current && tabs.current.length > 0 && tabs.current[0]) {
|
||||
setSelectedTab(tabs.current[0].value);
|
||||
}
|
||||
}, 150);
|
||||
if (tabs.current && tabs.current.length > 0 && tabs.current[0]) {
|
||||
setSelectedTab(tabs.current[0].value);
|
||||
onSelect(tabs.current[0].value);
|
||||
|
||||
setTimeout(() => calculateVisibleElements(), 100);
|
||||
}
|
||||
}, [propsTabs]);
|
||||
|
||||
useEffect(() => {
|
||||
|
@ -18,11 +18,10 @@ import classes from "./classes.module.scss";
|
||||
import DeleteAskedDocumentModal from "./DeleteAskedDocumentModal";
|
||||
import DeleteSentDocumentModal from "./DeleteSentDocumentModal";
|
||||
|
||||
import DocumentService from "src/common/Api/LeCoffreApi/sdk/DocumentService";
|
||||
import DocumentTypeService from "src/common/Api/LeCoffreApi/sdk/DocumentTypeService";
|
||||
import FileService from "src/common/Api/LeCoffreApi/sdk/FileService";
|
||||
import LoaderService from "src/common/Api/LeCoffreApi/sdk/Loader/LoaderService";
|
||||
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 PdfService, { CertificateData, Metadata } from "@Front/Services/PdfService";
|
||||
import MessageBus from "src/sdk/MessageBus";
|
||||
|
||||
@ -56,33 +55,20 @@ export default function DocumentTables(props: IProps) {
|
||||
|
||||
const fetchDocuments = useCallback(
|
||||
() => {
|
||||
LoaderService.getInstance().show();
|
||||
DocumentService.getDocuments().then(async (processes: any[]) => {
|
||||
if (processes.length > 0) {
|
||||
let documents: any[] = processes.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);
|
||||
|
||||
for (const document of documents) {
|
||||
if (document.document_type) {
|
||||
document.document_type = (await DocumentTypeService.getDocumentTypeByUid(document.document_type.uid)).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;
|
||||
}
|
||||
setDocuments([]);
|
||||
FolderService.getFolderByUid(folderUid).then((process: any) => {
|
||||
if (process) {
|
||||
const folder: any = process.processData;
|
||||
const customer: any = folder.customers.find((customer: any) => customer.uid === customerUid);
|
||||
if (customer && customer.documents) {
|
||||
const documents: any[] = customer.documents.filter((document: any) => document.depositor);
|
||||
setDocuments(documents);
|
||||
} else {
|
||||
setDocuments([]);
|
||||
}
|
||||
|
||||
setDocuments(documents);
|
||||
} else {
|
||||
setDocuments([]);
|
||||
}
|
||||
LoaderService.getInstance().hide();
|
||||
});
|
||||
},
|
||||
[customerUid, folderUid],
|
||||
@ -90,29 +76,20 @@ export default function DocumentTables(props: IProps) {
|
||||
|
||||
const fetchDocumentsNotary = useCallback(
|
||||
() => {
|
||||
LoaderService.getInstance().show();
|
||||
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([]);
|
||||
FolderService.getFolderByUid(folderUid).then((process: any) => {
|
||||
if (process) {
|
||||
const folder: any = process.processData;
|
||||
const customer: any = folder.customers.find((customer: any) => customer.uid === customerUid);
|
||||
if (customer && customer.documents) {
|
||||
const documents: any[] = customer.documents.filter((document: any) => document.customer);
|
||||
setDocumentsNotary(documents);
|
||||
} else {
|
||||
setDocumentsNotary([]);
|
||||
}
|
||||
|
||||
setDocumentsNotary(documents);
|
||||
} else {
|
||||
setDocumentsNotary([]);
|
||||
}
|
||||
LoaderService.getInstance().hide();
|
||||
});
|
||||
},
|
||||
[customerUid, folderUid],
|
||||
|
@ -1,4 +1,3 @@
|
||||
import Folders from "@Front/Api/LeCoffreApi/Notary/Folders/Folders";
|
||||
import OfficeFolderAnchors from "@Front/Api/LeCoffreApi/Notary/OfficeFolderAnchors/OfficeFolderAnchors";
|
||||
import Loader from "@Front/Components/DesignSystem/Loader";
|
||||
import DefaultNotaryDashboard from "@Front/Components/LayoutTemplates/DefaultNotaryDashboard";
|
||||
@ -22,9 +21,6 @@ import NoClientView from "./NoClientView";
|
||||
import AnchoringProcessingInfo from "./elements/AnchoringProcessingInfo";
|
||||
|
||||
import FolderService from "src/common/Api/LeCoffreApi/sdk/FolderService";
|
||||
import NoteService from "src/common/Api/LeCoffreApi/sdk/NoteService";
|
||||
import DocumentService from "src/common/Api/LeCoffreApi/sdk/DocumentService";
|
||||
import LoaderService from "src/common/Api/LeCoffreApi/sdk/Loader/LoaderService";
|
||||
|
||||
export enum AnchorStatus {
|
||||
"VERIFIED_ON_CHAIN" = "VERIFIED_ON_CHAIN",
|
||||
@ -112,35 +108,6 @@ export default function FolderInformation(props: IProps) {
|
||||
return FolderService.getFolderByUid(folderUid).then(async (process: any) => {
|
||||
if (process) {
|
||||
const folder: any = process.processData;
|
||||
|
||||
await new Promise<void>((resolve: () => void) => {
|
||||
NoteService.getNotes().then((processes: any) => {
|
||||
if (processes.length > 0) {
|
||||
let notes: any[] = processes.map((process: any) => process.processData);
|
||||
|
||||
// FilterBy folder.uid
|
||||
notes = notes.filter((note: any) => note.folder.uid === folderUid);
|
||||
|
||||
if (notes.length > 0) {
|
||||
folder.notes = notes;
|
||||
}
|
||||
}
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
|
||||
await new Promise<void>((resolve: () => void) => {
|
||||
DocumentService.getDocuments().then((processes: any[]) => {
|
||||
if (processes.length > 0) {
|
||||
const documents: any[] = processes.map((process: any) => process.processData);
|
||||
for (const customer of folder.customers) {
|
||||
customer.documents = documents.filter((document: any) => document.depositor && document.depositor.uid === customer.uid);
|
||||
}
|
||||
}
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
|
||||
setFolder(folder);
|
||||
}
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user