Fix some issues #15

Merged
ajanin merged 1 commits from ajanin into dev 2025-07-31 19:28:05 +00:00
8 changed files with 114 additions and 54 deletions

View File

@ -98,6 +98,9 @@ export default class CollaboratorService extends AbstractService {
!items.map((item: any) => item.processData.uid).includes(publicValues['uid'])
).then(async (processes: any[]) => {
if (processes.length === 0) {
if (waitForAll) {
callback([...items]);
}
return;
}
@ -147,25 +150,32 @@ export default class CollaboratorService extends AbstractService {
public static getCollaboratorsBy(whereClause: { [path: string]: any }): Promise<any[]> {
return new Promise<any[]>((resolve: (collaborators: any[]) => void) => {
this.getCollaborators((processes: any[]) => {
resolve(processes.length > 0 ? processes.map((process: any) => process.processData).filter((collaborator: any) => {
for (const path in whereClause) {
const paths: string[] = path.split('.');
if (processes.length === 0) {
resolve([]);
} else {
resolve(processes.filter((process: any) => {
const collaborator: any = process.processData;
let value: any = collaborator;
for (let i = 0; i < paths.length; i++) {
const currentPath = paths[i];
if (!currentPath || value === undefined || value === null) {
break;
for (const path in whereClause) {
const paths: string[] = path.split('.');
let value: any = collaborator;
for (let i = 0; i < paths.length; i++) {
const currentPath = paths[i];
if (!currentPath || value === undefined || value === null) {
break;
}
value = value[currentPath];
}
if (value !== whereClause[path]) {
return false;
}
value = value[currentPath];
}
if (value !== whereClause[path]) {
return false;
}
}
return true;
}) : []);
return true;
}));
}
}, true);
});
}
@ -173,25 +183,32 @@ export default class CollaboratorService extends AbstractService {
public static getCollaboratorBy(whereClause: { [path: string]: any }): Promise<any | null> {
return new Promise<any | null>((resolve: (collaborator: any | null) => void) => {
this.getCollaborators((processes: any[]) => {
resolve(processes.length > 0 ? processes.map((process: any) => process.processData).find((collaborator: any) => {
for (const path in whereClause) {
const paths: string[] = path.split('.');
if (processes.length === 0) {
resolve(null);
} else {
resolve(processes.find((process: any) => {
const collaborator: any = process.processData;
let value: any = collaborator;
for (let i = 0; i < paths.length; i++) {
const currentPath = paths[i];
if (!currentPath || value === undefined || value === null) {
break;
for (const path in whereClause) {
const paths: string[] = path.split('.');
let value: any = collaborator;
for (let i = 0; i < paths.length; i++) {
const currentPath = paths[i];
if (!currentPath || value === undefined || value === null) {
break;
}
value = value[currentPath];
}
if (value !== whereClause[path]) {
return false;
}
value = value[currentPath];
}
if (value !== whereClause[path]) {
return false;
}
}
return true;
}) : null);
return true;
}));
}
}, true);
});
}

View File

@ -95,6 +95,9 @@ export default class DeedTypeService extends AbstractService {
!items.map((item: any) => item.processData.uid).includes(publicValues['uid'])
).then(async (processes: any[]) => {
if (processes.length === 0) {
if (waitForAll) {
callback([...items]);
}
return;
}

View File

@ -107,6 +107,9 @@ export default class FolderService extends AbstractService {
!items.map((item: any) => item.processData.uid).includes(publicValues['uid'])
).then(async (processes: any[]) => {
if (processes.length === 0) {
if (waitForAll) {
callback([...items]);
}
return;
}
@ -156,25 +159,32 @@ export default class FolderService extends AbstractService {
public static getFoldersBy(whereClause: { [path: string]: any }): Promise<any[]> {
return new Promise<any[]>((resolve: (folders: any[]) => void) => {
this.getFolders((processes: any[]) => {
resolve(processes.length > 0 ? processes.map((process: any) => process.processData).filter((folder: any) => {
for (const path in whereClause) {
const paths: string[] = path.split('.');
if (processes.length === 0) {
resolve([]);
} else {
resolve(processes.filter((process: any) => {
const folder: any = process.processData;
let value: any = folder;
for (let i = 0; i < paths.length; i++) {
const currentPath = paths[i];
if (!currentPath || value === undefined || value === null) {
break;
for (const path in whereClause) {
const paths: string[] = path.split('.');
let value: any = folder;
for (let i = 0; i < paths.length; i++) {
const currentPath = paths[i];
if (!currentPath || value === undefined || value === null) {
break;
}
value = value[currentPath];
}
if (value !== whereClause[path]) {
return false;
}
value = value[currentPath];
}
if (value !== whereClause[path]) {
return false;
}
}
return true;
}) : []);
return true;
}));
}
}, true);
});
}

View File

@ -16,6 +16,7 @@ import classes from "./classes.module.scss";
import Link from "next/link";
import Customer from "le-coffre-resources/dist/Customer";
import { DocumentNotary } from "le-coffre-resources/dist/Notary";
import { EDocumentNotaryStatus } from "le-coffre-resources/dist/Notary/DocumentNotary";
import FolderService from "src/common/Api/LeCoffreApi/sdk/FolderService";
import DocumentService from "src/common/Api/LeCoffreApi/sdk/DocumentService";
@ -133,10 +134,24 @@ export default function ReceivedDocuments() {
});
}, [folderUid, customer]);
const onDownload = useCallback((doc: any) => {
const onDownload = useCallback(async (doc: any) => {
const file = doc.files?.[0];
if (!file) return;
if (doc.document_status !== EDocumentNotaryStatus.DOWNLOADED) {
await new Promise<void>((resolve: () => void) => {
LoaderService.getInstance().show();
DocumentService.getDocumentByUid(doc.uid).then((process: any) => {
if (process) {
DocumentService.updateDocument(process, { document_status: EDocumentNotaryStatus.DOWNLOADED }).then(() => {
LoaderService.getInstance().hide();
resolve();
});
}
});
});
}
return new Promise<void>((resolve: () => void) => {
const blob = new Blob([file.file_blob.data], { type: file.file_blob.type });
const url = URL.createObjectURL(blob);
@ -158,9 +173,23 @@ export default function ReceivedDocuments() {
const zip = new JSZip();
const folder = zip.folder("documents") || zip;
documentsNotary.map((doc: any) => {
documentsNotary.map(async (doc: any) => {
const file = doc.files?.[0];
if (file) {
if (doc.document_status !== EDocumentNotaryStatus.DOWNLOADED) {
await new Promise<void>((resolve: () => void) => {
LoaderService.getInstance().show();
DocumentService.getDocumentByUid(doc.uid).then((process: any) => {
if (process) {
DocumentService.updateDocument(process, { document_status: EDocumentNotaryStatus.DOWNLOADED }).then(() => {
LoaderService.getInstance().hide();
resolve();
});
}
});
});
}
const blob = new Blob([file.file_blob.data], { type: file.file_blob.type });
folder.file(file.file_name ?? "file", blob);
}

View File

@ -54,7 +54,7 @@ export default function DeedTypesInformations(props: IProps) {
LoaderService.getInstance().show();
DeedTypeService.getDeedTypeByUid(deedTypeUid as string).then((process: any) => {
if (process) {
DeedTypeService.updateDeedType(process, { archived_at: new Date().toISOString() }).then(() => {
DeedTypeService.updateDeedType(process, { isDeleted: 'true', archived_at: new Date().toISOString() }).then(() => {
router.push(Module.getInstance().get().modules.pages.DeedTypes.props.path);
LoaderService.getInstance().hide();
});

View File

@ -10,8 +10,8 @@ export default function AnchoringAlertInfo(props: IProps) {
const { onAnchor } = props;
return (
<Alert
title="Validation et Certification du Dossier"
description="Votre dossier est désormais complet à 100%. Vous pouvez maintenant procéder à la validation et à l'ancrage des documents dans la blockchain. Cette étape garantit la sécurité et l'authenticité de vos documents."
title="Dossier complet"
description="Vous pouvez maintenant archiver le dossier."
firstButton={{
children: "Archiver",
styletype: EButtonstyletype.CONTAINED,

View File

@ -276,9 +276,9 @@ export default function LoginCallBack() {
const getCollaborator = async (collaboratorData: any) => {
return await new Promise<any>(async (resolve: (role: any) => void) => {
const collaboratorFound: any | null = await CollaboratorService.getCollaboratorBy({ idNot: idNotUser.idNot });
if (collaboratorFound) {
resolve(collaboratorFound);
const processFound: any | null = await CollaboratorService.getCollaboratorBy({ idNot: idNotUser.idNot });
if (processFound) {
resolve(processFound.processData);
} else {
const validatorId: string = '884cb36a346a79af8697559f16940141f068bdf1656f88fa0df0e9ecd7311fb8:0';
CollaboratorService.createCollaborator(collaboratorData, validatorId).then((process: any) => {

View File

@ -32,7 +32,8 @@ export default function OfficeInformations(props: IProps) {
if (!office) return;
setOfficeSelected(office);
const users: any[] = await CollaboratorService.getCollaboratorsBy({ 'office.uid': office.uid });
const users: any[] = (await CollaboratorService.getCollaboratorsBy({ 'office.uid': office.uid }))
.map((process: any) => process.processData);
const adminUsers = users.filter((user) => {
if (user.office_role && user.office_role.name === "admin") {