Fix some issues
This commit is contained in:
parent
0492b3e28d
commit
d4f51cec5f
@ -6,7 +6,7 @@ export default abstract class AbstractService {
|
||||
|
||||
protected static readonly messageBus: MessageBus = MessageBus.getInstance();
|
||||
|
||||
private static readonly CACHE_TTL = 45 * 60 * 1000; // 45 minutes cache TTL
|
||||
private static readonly CACHE_TTL = 60 * 60 * 1000; // 60 minutes cache TTL
|
||||
|
||||
protected constructor() { }
|
||||
|
||||
|
@ -23,7 +23,7 @@ export default class CollaboratorService extends AbstractService {
|
||||
isDeleted: 'false',
|
||||
created_at: new Date().toISOString(),
|
||||
updated_at: new Date().toISOString(),
|
||||
...collaboratorData,
|
||||
...collaboratorData
|
||||
};
|
||||
|
||||
const privateFields: string[] = Object.keys(processData);
|
||||
@ -82,11 +82,14 @@ export default class CollaboratorService extends AbstractService {
|
||||
});
|
||||
}
|
||||
|
||||
public static getCollaborators(): Promise<any[]> {
|
||||
public static getCollaborators(callback: (processes: any[]) => void, waitForAll: boolean = false): void {
|
||||
// Check if we have valid cache
|
||||
const items: any[] = this.getItems('_collaborators_');
|
||||
if (items.length > 0 && !waitForAll) {
|
||||
setTimeout(() => callback([...items]), 0);
|
||||
}
|
||||
|
||||
return this.messageBus.getProcessesDecoded((publicValues: any) =>
|
||||
this.messageBus.getProcessesDecoded((publicValues: any) =>
|
||||
publicValues['uid'] &&
|
||||
publicValues['utype'] &&
|
||||
publicValues['utype'] === 'collaborator' &&
|
||||
@ -95,18 +98,101 @@ export default class CollaboratorService extends AbstractService {
|
||||
!items.map((item: any) => item.processData.uid).includes(publicValues['uid'])
|
||||
).then(async (processes: any[]) => {
|
||||
if (processes.length === 0) {
|
||||
return items;
|
||||
return;
|
||||
}
|
||||
|
||||
const updatedItems: any[] = [...items];
|
||||
|
||||
for (let processIndex = 0; processIndex < processes.length; processIndex++) {
|
||||
let process = processes[processIndex];
|
||||
|
||||
if (!waitForAll) {
|
||||
process = await this.completeCollaborator(process, (processInProgress: any) => {
|
||||
const currentItems: any[] = [...updatedItems];
|
||||
|
||||
const existingIndex: number = currentItems.findIndex(item => item.processData?.uid === processInProgress.processData?.uid);
|
||||
if (existingIndex >= 0) {
|
||||
currentItems[existingIndex] = processInProgress;
|
||||
} else {
|
||||
currentItems.push(processInProgress);
|
||||
}
|
||||
|
||||
callback(currentItems);
|
||||
});
|
||||
} else {
|
||||
for (let process of processes) {
|
||||
process = await this.completeCollaborator(process);
|
||||
}
|
||||
|
||||
// Update cache
|
||||
this.setItem('_collaborators_', process);
|
||||
|
||||
items.push(process);
|
||||
const existingIndex: number = updatedItems.findIndex(item => item.processData?.uid === process.processData?.uid);
|
||||
if (existingIndex >= 0) {
|
||||
updatedItems[existingIndex] = process;
|
||||
} else {
|
||||
updatedItems.push(process);
|
||||
}
|
||||
return items;
|
||||
|
||||
if (!waitForAll) {
|
||||
callback([...updatedItems]);
|
||||
}
|
||||
}
|
||||
|
||||
if (waitForAll) {
|
||||
callback([...updatedItems]);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
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('.');
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}) : []);
|
||||
}, true);
|
||||
});
|
||||
}
|
||||
|
||||
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('.');
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}) : null);
|
||||
}, true);
|
||||
});
|
||||
}
|
||||
|
||||
@ -157,15 +243,23 @@ export default class CollaboratorService extends AbstractService {
|
||||
});
|
||||
}
|
||||
|
||||
private static async completeCollaborator(process: any): Promise<any> {
|
||||
private static async completeCollaborator(process: any, progressCallback?: (processInProgress: any) => void): Promise<any> {
|
||||
const progressiveProcess: any = JSON.parse(JSON.stringify(process));
|
||||
|
||||
if (process.processData.office) {
|
||||
const office: any = (await OfficeService.getOfficeByUid(process.processData.office.uid)).processData;
|
||||
process.processData.office = {
|
||||
uid: office.uid,
|
||||
idNot: office.idNot,
|
||||
crpcen: office.crpcen,
|
||||
name: office.name,
|
||||
office_status: office.office_status
|
||||
};
|
||||
|
||||
if (progressCallback) {
|
||||
progressiveProcess.processData.office = process.processData.office;
|
||||
progressCallback(JSON.parse(JSON.stringify(progressiveProcess)));
|
||||
}
|
||||
}
|
||||
|
||||
if (process.processData.role) {
|
||||
@ -174,6 +268,11 @@ export default class CollaboratorService extends AbstractService {
|
||||
uid: role.uid,
|
||||
name: role.name
|
||||
};
|
||||
|
||||
if (progressCallback) {
|
||||
progressiveProcess.processData.role = process.processData.role;
|
||||
progressCallback(JSON.parse(JSON.stringify(progressiveProcess)));
|
||||
}
|
||||
}
|
||||
|
||||
if (process.processData.office_role) {
|
||||
@ -181,13 +280,18 @@ export default class CollaboratorService extends AbstractService {
|
||||
process.processData.office_role = {
|
||||
uid: officeRole.uid,
|
||||
name: officeRole.name,
|
||||
rules: officeRole.rules.map((rule: any) => {
|
||||
rules: officeRole.rules?.map((rule: any) => {
|
||||
return {
|
||||
uid: rule.uid,
|
||||
name: rule.name
|
||||
};
|
||||
})
|
||||
};
|
||||
|
||||
if (progressCallback) {
|
||||
progressiveProcess.processData.office_role = process.processData.office_role;
|
||||
progressCallback(JSON.parse(JSON.stringify(progressiveProcess)));
|
||||
}
|
||||
}
|
||||
|
||||
return process;
|
||||
|
@ -19,7 +19,7 @@ export default class CustomerService extends AbstractService {
|
||||
isDeleted: 'false',
|
||||
created_at: new Date().toISOString(),
|
||||
updated_at: new Date().toISOString(),
|
||||
...customerData,
|
||||
...customerData
|
||||
};
|
||||
|
||||
const privateFields: string[] = Object.keys(processData);
|
||||
|
@ -3,6 +3,7 @@ import { v4 as uuidv4 } from 'uuid';
|
||||
import User from 'src/sdk/User';
|
||||
|
||||
import AbstractService from './AbstractService';
|
||||
|
||||
import DocumentTypeService from './DocumentTypeService';
|
||||
|
||||
export default class DeedTypeService extends AbstractService {
|
||||
@ -20,7 +21,7 @@ export default class DeedTypeService extends AbstractService {
|
||||
isDeleted: 'false',
|
||||
created_at: new Date().toISOString(),
|
||||
updated_at: new Date().toISOString(),
|
||||
...deedTypeData,
|
||||
...deedTypeData
|
||||
};
|
||||
|
||||
const privateFields: string[] = Object.keys(processData);
|
||||
@ -79,11 +80,14 @@ export default class DeedTypeService extends AbstractService {
|
||||
});
|
||||
}
|
||||
|
||||
public static getDeedTypes(): Promise<any[]> {
|
||||
public static getDeedTypes(callback: (processes: any[]) => void, waitForAll: boolean = false): void {
|
||||
// Check if we have valid cache
|
||||
const items: any[] = this.getItems('_deed_types_');
|
||||
if (items.length > 0 && !waitForAll) {
|
||||
setTimeout(() => callback([...items]), 0);
|
||||
}
|
||||
|
||||
return this.messageBus.getProcessesDecoded((publicValues: any) =>
|
||||
this.messageBus.getProcessesDecoded((publicValues: any) =>
|
||||
publicValues['uid'] &&
|
||||
publicValues['utype'] &&
|
||||
publicValues['utype'] === 'deedType' &&
|
||||
@ -91,22 +95,53 @@ export default class DeedTypeService extends AbstractService {
|
||||
!items.map((item: any) => item.processData.uid).includes(publicValues['uid'])
|
||||
).then(async (processes: any[]) => {
|
||||
if (processes.length === 0) {
|
||||
return items;
|
||||
return;
|
||||
}
|
||||
|
||||
const updatedItems: any[] = [...items];
|
||||
|
||||
for (let processIndex = 0; processIndex < processes.length; processIndex++) {
|
||||
let process = processes[processIndex];
|
||||
|
||||
if (!waitForAll) {
|
||||
process = await this.completeDeedType(process, (processInProgress: any) => {
|
||||
const currentItems: any[] = [...updatedItems];
|
||||
|
||||
const existingIndex: number = currentItems.findIndex(item => item.processData?.uid === processInProgress.processData?.uid);
|
||||
if (existingIndex >= 0) {
|
||||
currentItems[existingIndex] = processInProgress;
|
||||
} else {
|
||||
currentItems.push(processInProgress);
|
||||
}
|
||||
|
||||
callback(currentItems);
|
||||
});
|
||||
} else {
|
||||
for (let process of processes) {
|
||||
process = await this.completeDeedType(process);
|
||||
}
|
||||
|
||||
// Update cache
|
||||
this.setItem('_deed_types_', process);
|
||||
|
||||
items.push(process);
|
||||
const existingIndex: number = updatedItems.findIndex(item => item.processData?.uid === process.processData?.uid);
|
||||
if (existingIndex >= 0) {
|
||||
updatedItems[existingIndex] = process;
|
||||
} else {
|
||||
updatedItems.push(process);
|
||||
}
|
||||
return items;
|
||||
|
||||
if (!waitForAll) {
|
||||
callback([...updatedItems]);
|
||||
}
|
||||
}
|
||||
|
||||
if (waitForAll) {
|
||||
callback([...updatedItems]);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static getDeedTypeByUid(uid: string, includeDocumentTypes: boolean = true): Promise<any> {
|
||||
public static getDeedTypeByUid(uid: string): Promise<any> {
|
||||
// Check if we have valid cache
|
||||
const item: any = this.getItem('_deed_types_', uid);
|
||||
if (item) {
|
||||
@ -114,7 +149,14 @@ export default class DeedTypeService extends AbstractService {
|
||||
}
|
||||
|
||||
return new Promise<any>((resolve: (process: any) => void, reject: (error: string) => void) => {
|
||||
this.messageBus.getProcessesDecoded((publicValues: any) => publicValues['uid'] && publicValues['uid'] === uid && publicValues['utype'] && publicValues['utype'] === 'deedType' && publicValues['isDeleted'] && publicValues['isDeleted'] === 'false').then(async (processes: any[]) => {
|
||||
this.messageBus.getProcessesDecoded((publicValues: any) =>
|
||||
publicValues['uid'] &&
|
||||
publicValues['uid'] === uid &&
|
||||
publicValues['utype'] &&
|
||||
publicValues['utype'] === 'deedType' &&
|
||||
publicValues['isDeleted'] &&
|
||||
publicValues['isDeleted'] === 'false'
|
||||
).then(async (processes: any[]) => {
|
||||
if (processes.length === 0) {
|
||||
resolve(null);
|
||||
} else {
|
||||
@ -146,20 +188,31 @@ export default class DeedTypeService extends AbstractService {
|
||||
});
|
||||
}
|
||||
|
||||
private static async completeDeedType(process: any): Promise<any> {
|
||||
private static async completeDeedType(process: any, progressCallback?: (processInProgress: any) => void): Promise<any> {
|
||||
const progressiveProcess: any = JSON.parse(JSON.stringify(process));
|
||||
|
||||
if (process.processData.document_types && process.processData.document_types.length > 0) {
|
||||
process.processData.document_types = await new Promise<any[]>(async (resolve: (document_types: any[]) => void) => {
|
||||
let document_types: any[] = [];
|
||||
for (const document_type of process.processData.document_types) {
|
||||
document_types.push((await DocumentTypeService.getDocumentTypeByUid(document_type.uid)).processData);
|
||||
progressiveProcess.processData.document_types = [];
|
||||
if (progressCallback) {
|
||||
progressCallback(progressiveProcess);
|
||||
}
|
||||
|
||||
for (const document_type of process.processData.document_types) {
|
||||
const documentTypeData = (await DocumentTypeService.getDocumentTypeByUid(document_type.uid)).processData;
|
||||
progressiveProcess.processData.document_types.push(documentTypeData);
|
||||
|
||||
// Remove duplicates
|
||||
document_types = document_types.filter((item: any, index: number) => document_types.findIndex((t: any) => t.uid === item.uid) === index);
|
||||
resolve(document_types);
|
||||
});
|
||||
progressiveProcess.processData.document_types = progressiveProcess.processData.document_types
|
||||
.filter((item: any, index: number) => progressiveProcess.processData.document_types.findIndex((t: any) => t.uid === item.uid) === index);
|
||||
|
||||
if (progressCallback) {
|
||||
progressCallback(JSON.parse(JSON.stringify(progressiveProcess)));
|
||||
}
|
||||
}
|
||||
|
||||
return process
|
||||
process.processData.document_types = progressiveProcess.processData.document_types;
|
||||
}
|
||||
|
||||
return process;
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ export default class DocumentService extends AbstractService {
|
||||
isDeleted: 'false',
|
||||
created_at: new Date().toISOString(),
|
||||
updated_at: new Date().toISOString(),
|
||||
...documentData,
|
||||
...documentData
|
||||
};
|
||||
|
||||
const privateFields: string[] = Object.keys(processData);
|
||||
@ -80,7 +80,7 @@ export default class DocumentService extends AbstractService {
|
||||
|
||||
public static getDocuments(): Promise<any[]> {
|
||||
// Check if we have valid cache
|
||||
const items: any[] = [];//this.getItems('_documents_');
|
||||
const items: any[] = this.getItems('_documents_');
|
||||
|
||||
return this.messageBus.getProcessesDecoded((publicValues: any) =>
|
||||
publicValues['uid'] &&
|
||||
@ -108,7 +108,7 @@ export default class DocumentService extends AbstractService {
|
||||
// Check if we have valid cache
|
||||
const item: any = this.getItem('_documents_', uid);
|
||||
if (item) {
|
||||
//return Promise.resolve(item);
|
||||
return Promise.resolve(item);
|
||||
}
|
||||
|
||||
return new Promise<any>((resolve: (process: any) => void, reject: (error: string) => void) => {
|
||||
|
@ -19,7 +19,7 @@ export default class DocumentTypeService extends AbstractService {
|
||||
isDeleted: 'false',
|
||||
created_at: new Date().toISOString(),
|
||||
updated_at: new Date().toISOString(),
|
||||
...documentTypeData,
|
||||
...documentTypeData
|
||||
};
|
||||
|
||||
const privateFields: string[] = Object.keys(processData);
|
||||
|
@ -20,7 +20,7 @@ export default class FileService {
|
||||
isDeleted: 'false',
|
||||
created_at: new Date().toISOString(),
|
||||
updated_at: new Date().toISOString(),
|
||||
...fileData,
|
||||
...fileData
|
||||
};
|
||||
|
||||
const privateFields: string[] = Object.keys(processData);
|
||||
@ -83,7 +83,7 @@ export default class FileService {
|
||||
return this.messageBus.getFileByUid(uid);
|
||||
}
|
||||
|
||||
public static updateFile(process: any, newData: Partial<FileData> & { isDeleted?: string }): Promise<void> {
|
||||
public static updateFile(process: any, newData: any): Promise<void> {
|
||||
return new Promise<void>((resolve: () => void, reject: (error: string) => void) => {
|
||||
this.messageBus.updateProcess(process.processId, { updated_at: new Date().toISOString(), ...newData }, [], null).then((processUpdated: any) => {
|
||||
const newStateId: string = processUpdated.diffs[0]?.state_id;
|
||||
|
@ -26,7 +26,7 @@ export default class FolderService extends AbstractService {
|
||||
isDeleted: 'false',
|
||||
created_at: new Date().toISOString(),
|
||||
updated_at: new Date().toISOString(),
|
||||
...folderData,
|
||||
...folderData
|
||||
};
|
||||
|
||||
const privateFields: string[] = Object.keys(processData);
|
||||
@ -91,11 +91,14 @@ export default class FolderService extends AbstractService {
|
||||
});
|
||||
}
|
||||
|
||||
public static getFolders(): Promise<any[]> {
|
||||
public static getFolders(callback: (processes: any[]) => void, waitForAll: boolean = false): void {
|
||||
// Check if we have valid cache
|
||||
const items: any[] = this.getItems('_folders_');
|
||||
if (items.length > 0 && !waitForAll) {
|
||||
setTimeout(() => callback([...items]), 0);
|
||||
}
|
||||
|
||||
return this.messageBus.getProcessesDecoded((publicValues: any) =>
|
||||
this.messageBus.getProcessesDecoded((publicValues: any) =>
|
||||
publicValues['uid'] &&
|
||||
publicValues['utype'] &&
|
||||
publicValues['utype'] === 'folder' &&
|
||||
@ -104,18 +107,75 @@ export default class FolderService extends AbstractService {
|
||||
!items.map((item: any) => item.processData.uid).includes(publicValues['uid'])
|
||||
).then(async (processes: any[]) => {
|
||||
if (processes.length === 0) {
|
||||
return items;
|
||||
return;
|
||||
}
|
||||
|
||||
const updatedItems: any[] = [...items];
|
||||
|
||||
for (let processIndex = 0; processIndex < processes.length; processIndex++) {
|
||||
let process = processes[processIndex];
|
||||
|
||||
if (!waitForAll) {
|
||||
process = await this.completeFolder(process, (processInProgress: any) => {
|
||||
const currentItems: any[] = [...updatedItems];
|
||||
|
||||
const existingIndex: number = currentItems.findIndex(item => item.processData?.uid === processInProgress.processData?.uid);
|
||||
if (existingIndex >= 0) {
|
||||
currentItems[existingIndex] = processInProgress;
|
||||
} else {
|
||||
currentItems.push(processInProgress);
|
||||
}
|
||||
|
||||
callback(currentItems);
|
||||
});
|
||||
} else {
|
||||
for (let process of processes) {
|
||||
process = await this.completeFolder(process);
|
||||
}
|
||||
|
||||
// Update cache
|
||||
this.setItem('_folders_', process);
|
||||
|
||||
items.push(process);
|
||||
const existingIndex: number = updatedItems.findIndex(item => item.processData?.uid === process.processData?.uid);
|
||||
if (existingIndex >= 0) {
|
||||
updatedItems[existingIndex] = process;
|
||||
} else {
|
||||
updatedItems.push(process);
|
||||
}
|
||||
return items;
|
||||
|
||||
if (!waitForAll) {
|
||||
callback([...updatedItems]);
|
||||
}
|
||||
}
|
||||
|
||||
if (waitForAll) {
|
||||
callback([...updatedItems]);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
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('.');
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}) : []);
|
||||
}, true);
|
||||
});
|
||||
}
|
||||
|
||||
@ -174,7 +234,9 @@ export default class FolderService extends AbstractService {
|
||||
});
|
||||
}
|
||||
|
||||
private static async completeFolder(process: any): Promise<any> {
|
||||
private static async completeFolder(process: any, progressCallback?: (processInProgress: any) => void): Promise<any> {
|
||||
const progressiveProcess: any = JSON.parse(JSON.stringify(process));
|
||||
|
||||
if (process.processData.customers && process.processData.customers.length > 0) {
|
||||
process.processData.customers = await new Promise<any[]>(async (resolve: (customers: any[]) => void) => {
|
||||
const customers: any[] = [];
|
||||
@ -204,6 +266,11 @@ export default class FolderService extends AbstractService {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (progressCallback) {
|
||||
progressiveProcess.processData.customers = process.processData.customers;
|
||||
progressCallback(JSON.parse(JSON.stringify(progressiveProcess)));
|
||||
}
|
||||
}
|
||||
|
||||
if (process.processData.stakeholders && process.processData.stakeholders.length > 0) {
|
||||
@ -214,6 +281,11 @@ export default class FolderService extends AbstractService {
|
||||
}
|
||||
resolve(stakeholders);
|
||||
});
|
||||
|
||||
if (progressCallback) {
|
||||
progressiveProcess.processData.stakeholders = process.processData.stakeholders;
|
||||
progressCallback(JSON.parse(JSON.stringify(progressiveProcess)));
|
||||
}
|
||||
}
|
||||
|
||||
if (process.processData.deed && process.processData.deed.deed_type) {
|
||||
@ -224,11 +296,21 @@ export default class FolderService extends AbstractService {
|
||||
// Remove duplicates
|
||||
process.processData.deed.document_types = deed_type.document_types.filter((item: any, index: number) => deed_type.document_types.findIndex((t: any) => t.uid === item.uid) === index);
|
||||
}
|
||||
|
||||
if (progressCallback) {
|
||||
progressiveProcess.processData.deed = process.processData.deed;
|
||||
progressCallback(JSON.parse(JSON.stringify(progressiveProcess)));
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
if (progressCallback) {
|
||||
progressiveProcess.processData.notes = process.processData.notes;
|
||||
progressCallback(JSON.parse(JSON.stringify(progressiveProcess)));
|
||||
}
|
||||
}
|
||||
|
||||
return process;
|
||||
|
@ -18,7 +18,7 @@ export default class NoteService {
|
||||
isDeleted: 'false',
|
||||
created_at: new Date().toISOString(),
|
||||
updated_at: new Date().toISOString(),
|
||||
...noteData,
|
||||
...noteData
|
||||
};
|
||||
|
||||
const privateFields: string[] = Object.keys(processData);
|
||||
|
@ -20,7 +20,7 @@ export default class OfficeRibService {
|
||||
isDeleted: 'false',
|
||||
created_at: new Date().toISOString(),
|
||||
updated_at: new Date().toISOString(),
|
||||
...fileData,
|
||||
...fileData
|
||||
};
|
||||
|
||||
const privateFields: string[] = Object.keys(processData);
|
||||
|
@ -22,7 +22,7 @@ export default class OfficeRoleService extends AbstractService {
|
||||
isDeleted: 'false',
|
||||
created_at: new Date().toISOString(),
|
||||
updated_at: new Date().toISOString(),
|
||||
...roleData,
|
||||
...roleData
|
||||
};
|
||||
|
||||
const privateFields: string[] = Object.keys(processData);
|
||||
|
@ -19,7 +19,7 @@ export default class OfficeService extends AbstractService {
|
||||
isDeleted: 'false',
|
||||
created_at: new Date().toISOString(),
|
||||
updated_at: new Date().toISOString(),
|
||||
...officeData,
|
||||
...officeData
|
||||
};
|
||||
|
||||
const privateFields: string[] = Object.keys(processData);
|
||||
|
@ -21,7 +21,7 @@ export default class RoleService extends AbstractService {
|
||||
isDeleted: 'false',
|
||||
created_at: new Date().toISOString(),
|
||||
updated_at: new Date().toISOString(),
|
||||
...roleData,
|
||||
...roleData
|
||||
};
|
||||
|
||||
const privateFields: string[] = Object.keys(processData);
|
||||
|
@ -21,7 +21,7 @@ export default class RuleGroupService extends AbstractService {
|
||||
isDeleted: 'false',
|
||||
created_at: new Date().toISOString(),
|
||||
updated_at: new Date().toISOString(),
|
||||
...ruleGroupData,
|
||||
...ruleGroupData
|
||||
};
|
||||
|
||||
const privateFields: string[] = Object.keys(processData);
|
||||
|
@ -19,7 +19,7 @@ export default class RuleService extends AbstractService {
|
||||
isDeleted: 'false',
|
||||
created_at: new Date().toISOString(),
|
||||
updated_at: new Date().toISOString(),
|
||||
...ruleData,
|
||||
...ruleData
|
||||
};
|
||||
|
||||
const privateFields: string[] = Object.keys(processData);
|
||||
|
@ -16,7 +16,6 @@ export default function LogOut(props: { isCustomer?: boolean }) {
|
||||
.disconnect()
|
||||
.then(() => router.push(`https://qual-connexion.idnot.fr/user/auth/logout?sourceURL=${variables.FRONT_APP_HOST}`));
|
||||
} else {
|
||||
sessionStorage.setItem("customerIsConnected", "false");
|
||||
router.push("/");
|
||||
}
|
||||
}, [router, variables.FRONT_APP_HOST]);
|
||||
|
@ -38,7 +38,7 @@ export default function DefaultCollaboratorDashboard(props: IProps) {
|
||||
const user: any = UserStore.instance.getUser();
|
||||
const officeId: string = user.office.uid;
|
||||
|
||||
CollaboratorService.getCollaborators().then((processes: any[]) => {
|
||||
CollaboratorService.getCollaborators((processes: any[]) => {
|
||||
if (processes.length > 0) {
|
||||
let collaborators: any[] = processes.map((process: any) => process.processData);
|
||||
|
||||
|
@ -19,8 +19,8 @@ export default function DefaultCustomerDashboard(props: IProps) {
|
||||
const [folders, setFolders] = useState<OfficeFolder[]>([]);
|
||||
|
||||
useEffect(() => {
|
||||
const jwt = JwtService.getInstance().decodeCustomerJwt();
|
||||
if (!jwt) return;
|
||||
//const jwt = JwtService.getInstance().decodeCustomerJwt();
|
||||
//if (!jwt) return;
|
||||
|
||||
/*
|
||||
Folders.getInstance()
|
||||
@ -49,7 +49,7 @@ export default function DefaultCustomerDashboard(props: IProps) {
|
||||
*/
|
||||
|
||||
if (props.isReady) {
|
||||
FolderService.getFolders().then((processes: any[]) => {
|
||||
FolderService.getFolders((processes: any[]) => {
|
||||
if (processes.length > 0) {
|
||||
let folders: any[] = processes.map((process: any) => process.processData);
|
||||
|
||||
|
@ -11,12 +11,14 @@ import DeedTypeService from "src/common/Api/LeCoffreApi/sdk/DeedTypeService";
|
||||
type IProps = IPropsDashboardWithList;
|
||||
|
||||
export default function DefaultDeedTypeDashboard(props: IProps) {
|
||||
const [deedTypes, setDeedTypes] = React.useState<DeedType[] | null>(null);
|
||||
const router = useRouter();
|
||||
|
||||
const { deedTypeUid } = router.query;
|
||||
const [deedTypes, setDeedTypes] = React.useState<DeedType[] | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
DeedTypeService.getDeedTypes().then((processes: any) => {
|
||||
DeedTypeService.getDeedTypes((processes: any[]) => {
|
||||
if (processes.length > 0) {
|
||||
let deedTypes = processes.map((process: any) => process.processData);
|
||||
|
||||
// FilterBy archived_at = null or not defined
|
||||
@ -26,6 +28,7 @@ export default function DefaultDeedTypeDashboard(props: IProps) {
|
||||
deedTypes.sort((a: any, b: any) => a.name.localeCompare(b.name));
|
||||
|
||||
setDeedTypes(deedTypes);
|
||||
}
|
||||
});
|
||||
}, []);
|
||||
|
||||
|
@ -115,7 +115,7 @@ export default function DefaultNotaryDashboard(props: IProps) {
|
||||
.then((folders) => setFolders(folders));
|
||||
*/
|
||||
|
||||
FolderService.getFolders().then((processes: any[]) => {
|
||||
FolderService.getFolders((processes: any[]) => {
|
||||
if (processes.length > 0) {
|
||||
let folders: any[] = processes.map((process: any) => process.processData);
|
||||
|
||||
|
@ -1,25 +1,26 @@
|
||||
import { Office } from "le-coffre-resources/dist/SuperAdmin";
|
||||
import React, { useEffect } from "react";
|
||||
|
||||
import { useRouter } from "next/router";
|
||||
import Module from "@Front/Config/Module";
|
||||
import { IBlock } from "@Front/Components/DesignSystem/SearchBlockList/BlockList/Block";
|
||||
import DefaultDashboardWithList, { IPropsDashboardWithList } from "../DefaultDashboardWithList";
|
||||
// import Offices from "@Front/Api/LeCoffreApi/SuperAdmin/Offices/Offices";
|
||||
|
||||
import OfficeService from "src/common/Api/LeCoffreApi/sdk/OfficeService";
|
||||
|
||||
type IProps = IPropsDashboardWithList;
|
||||
|
||||
export default function DefaultOfficeDashboard(props: IProps) {
|
||||
const [offices, setOffices] = React.useState<Office[] | null>(null);
|
||||
const [offices, setOffices] = React.useState<any[] | null>(null);
|
||||
const router = useRouter();
|
||||
const { officeUid } = router.query;
|
||||
|
||||
useEffect(() => {
|
||||
/* TODO: review
|
||||
Offices.getInstance()
|
||||
.get()
|
||||
.then((offices) => setOffices(offices));
|
||||
*/
|
||||
setOffices([]);
|
||||
OfficeService.getOffices().then((processes: any[]) => {
|
||||
if (processes.length > 0) {
|
||||
const offices: any[] = processes.map((process: any) => process.processData);
|
||||
setOffices(offices);
|
||||
}
|
||||
});
|
||||
}, []);
|
||||
|
||||
const onSelectedBlock = (block: IBlock) => {
|
||||
|
@ -1,28 +1,34 @@
|
||||
// import Users, { IGetUsersparams } from "@Front/Api/LeCoffreApi/SuperAdmin/Users/Users";
|
||||
import User from "le-coffre-resources/dist/SuperAdmin";
|
||||
import React, { useEffect } from "react";
|
||||
|
||||
import { useRouter } from "next/router";
|
||||
import Module from "@Front/Config/Module";
|
||||
import { IBlock } from "@Front/Components/DesignSystem/SearchBlockList/BlockList/Block";
|
||||
import DefaultDashboardWithList, { IPropsDashboardWithList } from "../DefaultDashboardWithList";
|
||||
import UserStore from "@Front/Stores/UserStore";
|
||||
|
||||
import CollaboratorService from "src/common/Api/LeCoffreApi/sdk/CollaboratorService";
|
||||
|
||||
type IProps = IPropsDashboardWithList;
|
||||
|
||||
export default function DefaultUserDashboard(props: IProps) {
|
||||
const [users, setUsers] = React.useState<User[] | null>(null);
|
||||
const [users, setUsers] = React.useState<any[] | null>(null);
|
||||
const router = useRouter();
|
||||
const { userUid } = router.query;
|
||||
useEffect(() => {
|
||||
/* TODO: review
|
||||
const query: IGetUsersparams = {
|
||||
include: { contact: true, office_membership: true },
|
||||
};
|
||||
Users.getInstance()
|
||||
.get(query)
|
||||
.then((users) => setUsers(users));
|
||||
*/
|
||||
setUsers([]);
|
||||
const user: any = UserStore.instance.getUser();
|
||||
if (!user) return;
|
||||
const officeId: string = user.office.uid;
|
||||
|
||||
CollaboratorService.getCollaborators((processes: any[]) => {
|
||||
if (processes.length > 0) {
|
||||
let collaborators: any[] = processes.map((process: any) => process.processData);
|
||||
|
||||
// FilterBy office.uid
|
||||
collaborators = collaborators.filter((collaborator: any) => collaborator.office.uid === officeId);
|
||||
|
||||
setUsers(collaborators);
|
||||
}
|
||||
});
|
||||
}, []);
|
||||
|
||||
const onSelectedBlock = (block: IBlock) => {
|
||||
@ -39,7 +45,7 @@ export default function DefaultUserDashboard(props: IProps) {
|
||||
id: user.uid!,
|
||||
primaryText: user.contact?.first_name + " " + user.contact?.last_name,
|
||||
isActive: user.uid === userUid,
|
||||
secondaryText: user.office_membership?.crpcen + " - " + user.office_membership?.name,
|
||||
secondaryText: user.office?.crpcen + " - " + user.office?.name,
|
||||
}))
|
||||
: []
|
||||
}
|
||||
|
@ -154,7 +154,7 @@ export default function DepositDocumentComponent(props: IProps) {
|
||||
(resolve: () => void) => {
|
||||
FileService.getFileByUid(fileUid).then((res: any) => {
|
||||
if (res) {
|
||||
FileService.updateFile(res.processId, { isDeleted: 'true' }).then(() => {
|
||||
FileService.updateFile(res.processId, { isDeleted: 'true', archived_at: new Date().toISOString() }).then(() => {
|
||||
DocumentService.getDocumentByUid(document.uid!).then((process: any) => {
|
||||
if (process) {
|
||||
const document: any = process.processData;
|
||||
@ -165,7 +165,9 @@ export default function DepositDocumentComponent(props: IProps) {
|
||||
}
|
||||
files = files.filter((file: any) => file.uid !== fileUid);
|
||||
|
||||
DocumentService.updateDocument(process, { files: files, document_status: EDocumentStatus.ASKED }).then(() => resolve());
|
||||
DocumentService.updateDocument(process, { files: files, document_status: EDocumentStatus.ASKED }).then(() => {
|
||||
FolderService.refreshFolderByUid(document.folder.uid).then(() => resolve());
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -22,9 +22,6 @@ import ContactBox from "./ContactBox";
|
||||
import { EDocumentNotaryStatus } from "le-coffre-resources/dist/Notary/DocumentNotary";
|
||||
import DepositOtherDocument from "@Front/Components/DesignSystem/DepositOtherDocument";
|
||||
|
||||
import Modal from "@Front/Components/DesignSystem/Modal";
|
||||
import TextField from "@Front/Components/DesignSystem/Form/TextField";
|
||||
|
||||
import AuthModal from "src/sdk/AuthModal";
|
||||
|
||||
import FolderService from "src/common/Api/LeCoffreApi/sdk/FolderService";
|
||||
@ -47,32 +44,7 @@ export default function ClientDashboard(props: IProps) {
|
||||
const [isAddDocumentModalVisible, setIsAddDocumentModalVisible] = useState<boolean>(false);
|
||||
|
||||
const [isReady, setIsReady] = useState(false);
|
||||
const [isAuthModalOpen, setIsAuthModalOpen] = useState(false);
|
||||
const [isSmsModalOpen, setIsSmsModalOpen] = useState(true);
|
||||
const [smsCode, setSmsCode] = useState("");
|
||||
const [smsError, setSmsError] = useState("");
|
||||
|
||||
const verifySmsCode = useCallback(() => {
|
||||
if (smsCode === "1234") {
|
||||
setIsSmsModalOpen(false);
|
||||
setIsAuthModalOpen(true);
|
||||
} else {
|
||||
setSmsError("Code incorrect. Le code valide est 1234.");
|
||||
}
|
||||
}, [smsCode]);
|
||||
|
||||
useEffect(() => {
|
||||
const handleKeyPress = (e: KeyboardEvent) => {
|
||||
if (e.key === "Enter" && isSmsModalOpen) {
|
||||
verifySmsCode();
|
||||
}
|
||||
};
|
||||
|
||||
window.addEventListener("keypress", handleKeyPress);
|
||||
return () => {
|
||||
window.removeEventListener("keypress", handleKeyPress);
|
||||
};
|
||||
}, [isSmsModalOpen, smsCode, verifySmsCode]);
|
||||
const [isAuthModalOpen, setIsAuthModalOpen] = useState(true);
|
||||
|
||||
const fetchFolderAndCustomer = useCallback(async () => {
|
||||
let jwt: ICustomerJwtPayload | undefined;
|
||||
@ -345,53 +317,8 @@ export default function ClientDashboard(props: IProps) {
|
||||
setIsReady(true);
|
||||
setIsAuthModalOpen(false);
|
||||
fetchFolderAndCustomer().then(({ customer }) => fetchDocuments(customer.uid));
|
||||
|
||||
sessionStorage.setItem("customerIsConnected", "true");
|
||||
}}
|
||||
/>}
|
||||
|
||||
{isSmsModalOpen && (
|
||||
<Modal
|
||||
isOpen={isSmsModalOpen}
|
||||
onClose={() => setIsSmsModalOpen(false)}
|
||||
title="Vérification SMS"
|
||||
>
|
||||
<div className={classes["sms-modal-content"]}>
|
||||
<Typography typo={ETypo.TEXT_MD_REGULAR} color={ETypoColor.TEXT_PRIMARY}>
|
||||
Veuillez saisir le code à 4 chiffres que vous avez reçu par SMS
|
||||
</Typography>
|
||||
|
||||
<TextField
|
||||
name="smsCode"
|
||||
placeholder="Code SMS à 4 chiffres"
|
||||
value={smsCode}
|
||||
onChange={(e) => {
|
||||
const value = e.target.value;
|
||||
// Only allow digits
|
||||
if (value === "" || /^\d+$/.test(value)) {
|
||||
setSmsCode(value);
|
||||
setSmsError("");
|
||||
}
|
||||
}}
|
||||
/>
|
||||
|
||||
{smsError && (
|
||||
<Typography typo={ETypo.TEXT_SM_REGULAR} color={ETypoColor.TEXT_ACCENT}>
|
||||
{smsError}
|
||||
</Typography>
|
||||
)}
|
||||
|
||||
<div style={{ marginTop: "20px" }}>
|
||||
<Button
|
||||
variant={EButtonVariant.PRIMARY}
|
||||
onClick={verifySmsCode}
|
||||
>
|
||||
Vérifier
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</Modal>
|
||||
)}
|
||||
</DefaultCustomerDashboard>
|
||||
);
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ export default function DeedTypesInformations(props: IProps) {
|
||||
|
||||
const saveDocumentTypes = useCallback(() => {
|
||||
LoaderService.getInstance().show();
|
||||
DeedTypeService.getDeedTypeByUid(deedTypeUid as string, false).then((process: any) => {
|
||||
DeedTypeService.getDeedTypeByUid(deedTypeUid as string).then((process: any) => {
|
||||
if (process) {
|
||||
const deedType: any = process.processData;
|
||||
|
||||
|
@ -131,14 +131,14 @@ export default function CreateFolder(): JSX.Element {
|
||||
* UseEffect
|
||||
*/
|
||||
useEffect(() => {
|
||||
DeedTypeService.getDeedTypes().then((processes: any[]) => {
|
||||
DeedTypeService.getDeedTypes((processes: any[]) => {
|
||||
if (processes.length > 0) {
|
||||
const deedTypes: any[] = processes.map((process: any) => process.processData);
|
||||
setAvailableDeedTypes(deedTypes);
|
||||
}
|
||||
});
|
||||
|
||||
CollaboratorService.getCollaborators().then((processes: any[]) => {
|
||||
CollaboratorService.getCollaborators((processes: any[]) => {
|
||||
if (processes.length > 0) {
|
||||
const collaborators: any[] = processes.map((process: any) => process.processData);
|
||||
setAvailableCollaborators(collaborators);
|
||||
|
@ -4,6 +4,7 @@ import Typography, { ETypo } from "@Front/Components/DesignSystem/Typography";
|
||||
import React, { useCallback } from "react";
|
||||
|
||||
import DocumentService from "src/common/Api/LeCoffreApi/sdk/DocumentService";
|
||||
import FolderService from "src/common/Api/LeCoffreApi/sdk/FolderService";
|
||||
import LoaderService from "src/common/Api/LeCoffreApi/sdk/Loader/LoaderService";
|
||||
|
||||
type IProps = {
|
||||
@ -23,7 +24,10 @@ export default function DeleteAskedDocumentModal(props: IProps) {
|
||||
(resolve: () => void) => {
|
||||
DocumentService.getDocumentByUid(documentUid).then((process: any) => {
|
||||
if (process) {
|
||||
DocumentService.updateDocument(process, { isDeleted: 'true' }).then(() => resolve());
|
||||
const document: any = process.processData;
|
||||
DocumentService.updateDocument(process, { isDeleted: 'true', archived_at: new Date().toISOString() }).then(() => {
|
||||
FolderService.refreshFolderByUid(document.folder.uid).then(() => resolve());
|
||||
});
|
||||
}
|
||||
});
|
||||
})
|
||||
|
@ -4,6 +4,7 @@ import Typography, { ETypo } from "@Front/Components/DesignSystem/Typography";
|
||||
import React, { useCallback } from "react";
|
||||
|
||||
import DocumentService from "src/common/Api/LeCoffreApi/sdk/DocumentService";
|
||||
import FolderService from "src/common/Api/LeCoffreApi/sdk/FolderService";
|
||||
import LoaderService from "src/common/Api/LeCoffreApi/sdk/Loader/LoaderService";
|
||||
|
||||
type IProps = {
|
||||
@ -21,8 +22,10 @@ export default function DeleteSentDocumentModal(props: IProps) {
|
||||
LoaderService.getInstance().show();
|
||||
DocumentService.getDocumentByUid(documentUid).then((process: any) => {
|
||||
if (process) {
|
||||
DocumentService.updateDocument(process, { isDeleted: 'true' })
|
||||
const document: any = process.processData;
|
||||
DocumentService.updateDocument(process, { isDeleted: 'true', archived_at: new Date().toISOString() })
|
||||
.then(() => onDeleteSuccess(documentUid))
|
||||
.then(() => FolderService.refreshFolderByUid(document.folder.uid))
|
||||
.then(() => ToasterService.getInstance().success({ title: "Succès !", description: "Le document a été supprimé avec succès." }))
|
||||
.then(() => LoaderService.getInstance().hide())
|
||||
.then(onClose);
|
||||
|
@ -150,7 +150,12 @@ export default function DocumentTables(props: IProps) {
|
||||
const file = doc.files?.[0];
|
||||
if (!file) return;
|
||||
|
||||
return new Promise<void>((resolve: () => void) => {
|
||||
return new Promise<void>(async (resolve: () => void) => {
|
||||
if (!file.file_blob) {
|
||||
LoaderService.getInstance().show();
|
||||
file.file_blob = (await FileService.getFileByUid(file.uid)).processData.file_blob;
|
||||
LoaderService.getInstance().hide();
|
||||
}
|
||||
const blob = new Blob([file.file_blob.data], { type: file.file_blob.type });
|
||||
const url = URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
|
@ -28,7 +28,7 @@ export default function DeleteFolderModal(props: IProps) {
|
||||
LoaderService.getInstance().show();
|
||||
FolderService.getFolderByUid(folder.uid!).then((process: any) => {
|
||||
if (process) {
|
||||
FolderService.updateFolder(process, { isDeleted: 'true' }).then(() => {
|
||||
FolderService.updateFolder(process, { isDeleted: 'true', archived_at: new Date().toISOString() }).then(() => {
|
||||
LoaderService.getInstance().hide();
|
||||
resolve();
|
||||
});
|
||||
|
@ -1,6 +1,6 @@
|
||||
import Alert, { EAlertVariant } from "@Front/Components/DesignSystem/Alert";
|
||||
import { EButtonstyletype } from "@Front/Components/DesignSystem/Button";
|
||||
import { LockClosedIcon } from "@heroicons/react/24/outline";
|
||||
import { ArchiveBoxIcon } from "@heroicons/react/24/outline";
|
||||
|
||||
type IProps = {
|
||||
onAnchor: () => void;
|
||||
@ -13,9 +13,9 @@ export default function AnchoringAlertInfo(props: IProps) {
|
||||
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."
|
||||
firstButton={{
|
||||
children: "Ancrer et certifier",
|
||||
children: "Archiver",
|
||||
styletype: EButtonstyletype.CONTAINED,
|
||||
rightIcon: <LockClosedIcon />,
|
||||
rightIcon: <ArchiveBoxIcon />,
|
||||
onClick: onAnchor,
|
||||
}}
|
||||
variant={EAlertVariant.INFO}
|
||||
|
@ -1,11 +1,14 @@
|
||||
import Folders from "@Front/Api/LeCoffreApi/Notary/Folders/Folders";
|
||||
import Alert, { EAlertVariant } from "@Front/Components/DesignSystem/Alert";
|
||||
import { EButtonstyletype } from "@Front/Components/DesignSystem/Button";
|
||||
import Module from "@Front/Config/Module";
|
||||
import { ArchiveBoxArrowDownIcon, ArchiveBoxIcon, ArrowDownOnSquareIcon } from "@heroicons/react/24/outline";
|
||||
import EFolderStatus from "le-coffre-resources/dist/Customer/EFolderStatus";
|
||||
import { useRouter } from "next/router";
|
||||
import { useCallback } from "react";
|
||||
|
||||
import LoaderService from "src/common/Api/LeCoffreApi/sdk/Loader/LoaderService";
|
||||
import FolderService from "src/common/Api/LeCoffreApi/sdk/FolderService";
|
||||
|
||||
type IProps = {
|
||||
onDownloadAnchoringProof: () => void;
|
||||
folderUid: string;
|
||||
@ -17,11 +20,14 @@ export default function ArchiveAlertWarning(props: IProps) {
|
||||
const router = useRouter();
|
||||
|
||||
const restoreArchive = useCallback(() => {
|
||||
Folders.getInstance()
|
||||
.restore(folderUid)
|
||||
LoaderService.getInstance().show();
|
||||
FolderService.getFolderByUid(folderUid).then((process: any) => {
|
||||
if (process) {
|
||||
FolderService.updateFolder(process, { archived_at: null, archived_description: null, status: EFolderStatus.LIVE })
|
||||
.then(() => LoaderService.getInstance().hide())
|
||||
.then(() => router.push(Module.getInstance().get().modules.pages.Folder.props.path))
|
||||
.catch((e) => {
|
||||
console.warn(e);
|
||||
.catch((e) => console.error(e));
|
||||
}
|
||||
});
|
||||
}, [folderUid, router]);
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
import Folders from "@Front/Api/LeCoffreApi/Notary/Folders/Folders";
|
||||
import TextAreaField from "@Front/Components/DesignSystem/Form/TextareaField";
|
||||
import Modal from "@Front/Components/DesignSystem/Modal";
|
||||
import Typography, { ETypo } from "@Front/Components/DesignSystem/Typography";
|
||||
@ -6,6 +5,10 @@ import Module from "@Front/Config/Module";
|
||||
import { useRouter } from "next/router";
|
||||
import React, { useCallback } from "react";
|
||||
import classes from "./classes.module.scss";
|
||||
import EFolderStatus from "le-coffre-resources/dist/Customer/EFolderStatus";
|
||||
|
||||
import LoaderService from "src/common/Api/LeCoffreApi/sdk/Loader/LoaderService";
|
||||
import FolderService from "src/common/Api/LeCoffreApi/sdk/FolderService";
|
||||
|
||||
type IProps = {
|
||||
isOpen: boolean;
|
||||
@ -19,13 +22,15 @@ export default function ArchiveModal(props: IProps) {
|
||||
|
||||
const archive = useCallback(() => {
|
||||
const description = (document.querySelector("textarea[name='archived_description']") as HTMLTextAreaElement).value ?? "";
|
||||
|
||||
Folders.getInstance()
|
||||
.archive(folderUid, description)
|
||||
LoaderService.getInstance().show();
|
||||
FolderService.getFolderByUid(folderUid).then((process: any) => {
|
||||
if (process) {
|
||||
FolderService.updateFolder(process, { archived_at: new Date().toISOString(), archived_description: description, status: EFolderStatus.ARCHIVED })
|
||||
.then(() => LoaderService.getInstance().hide())
|
||||
.then(onClose)
|
||||
.then(() => router.push(Module.getInstance().get().modules.pages.Folder.props.path))
|
||||
.catch((e) => {
|
||||
console.warn(e);
|
||||
.catch((e) => console.error(e));
|
||||
}
|
||||
});
|
||||
}, [folderUid, onClose, router]);
|
||||
|
||||
|
@ -21,6 +21,7 @@ import NoClientView from "./NoClientView";
|
||||
import AnchoringProcessingInfo from "./elements/AnchoringProcessingInfo";
|
||||
|
||||
import FolderService from "src/common/Api/LeCoffreApi/sdk/FolderService";
|
||||
import EFolderStatus from "le-coffre-resources/dist/Customer/EFolderStatus";
|
||||
|
||||
export enum AnchorStatus {
|
||||
"VERIFIED_ON_CHAIN" = "VERIFIED_ON_CHAIN",
|
||||
@ -34,7 +35,7 @@ export default function FolderInformation(props: IProps) {
|
||||
const { isArchived = false } = props;
|
||||
const [anchorStatus, setAnchorStatus] = useState<AnchorStatus>(AnchorStatus.NOT_ANCHORED);
|
||||
const [isLoading, setIsLoading] = useState<boolean>(true);
|
||||
const [folder, setFolder] = useState<OfficeFolder | null>(null);
|
||||
const [folder, setFolder] = useState<any>(null);
|
||||
const anchoringModal = useOpenable();
|
||||
const downloadAnchoringProofModal = useOpenable();
|
||||
const requireAnchoringModal = useOpenable();
|
||||
@ -46,10 +47,10 @@ export default function FolderInformation(props: IProps) {
|
||||
const progress = useMemo(() => {
|
||||
let total = 0;
|
||||
let validatedDocuments = 0;
|
||||
folder?.customers?.forEach((customer) => {
|
||||
const documents = customer.documents;
|
||||
folder?.customers?.forEach((customer: any) => {
|
||||
const documents = customer.documents.filter((document: any) => document.depositor);
|
||||
total += documents?.length ?? 0;
|
||||
validatedDocuments += documents?.filter((document) => document.document_status === EDocumentStatus.VALIDATED).length ?? 0;
|
||||
validatedDocuments += documents?.filter((document: any) => document.document_status === EDocumentStatus.VALIDATED).length ?? 0;
|
||||
});
|
||||
if (total === 0) return 0;
|
||||
const percentage = (validatedDocuments / total) * 100;
|
||||
@ -138,7 +139,7 @@ export default function FolderInformation(props: IProps) {
|
||||
}, [fetchData]);
|
||||
|
||||
const onArchive = useCallback(() => {
|
||||
if (anchorStatus === AnchorStatus.NOT_ANCHORED) return requireAnchoringModal.open();
|
||||
//if (anchorStatus === AnchorStatus.NOT_ANCHORED) return requireAnchoringModal.open();
|
||||
archiveModal.open();
|
||||
}, [anchorStatus, archiveModal, requireAnchoringModal]);
|
||||
|
||||
@ -153,7 +154,7 @@ export default function FolderInformation(props: IProps) {
|
||||
anchorStatus={anchorStatus}
|
||||
isArchived={isArchived}
|
||||
/>
|
||||
{progress === 100 && anchorStatus === AnchorStatus.NOT_ANCHORED && (
|
||||
{progress === 100 && /*anchorStatus === AnchorStatus.NOT_ANCHORED*/ folder.status !== EFolderStatus.ARCHIVED && (
|
||||
<AnchoringAlertInfo onAnchor={anchoringModal.open} />
|
||||
)}
|
||||
{!isArchived && anchorStatus === AnchorStatus.VERIFIED_ON_CHAIN && (
|
||||
|
@ -83,7 +83,7 @@ export default function SendDocuments() {
|
||||
const date: Date = new Date();
|
||||
const strDate: string = `${date.getDate().toString().padStart(2, '0')}-${(date.getMonth() + 1).toString().padStart(2, '0')}-${date.getFullYear()}`;
|
||||
|
||||
const fileName: string = `${customer.contact.last_name}_${strDate}.${file.name.split('.').pop()}`;
|
||||
const fileName: string = `aplc_${customer.contact.last_name}_${strDate}.${file.name.split('.').pop()}`;
|
||||
|
||||
const arrayBuffer: ArrayBuffer = event.target.result as ArrayBuffer;
|
||||
const uint8Array: Uint8Array = new Uint8Array(arrayBuffer);
|
||||
|
@ -25,12 +25,12 @@ export default function Folder() {
|
||||
|
||||
useEffect(() => {
|
||||
// TODO: review
|
||||
FolderService.getFolders().then((processes: any[]) => {
|
||||
FolderService.getFoldersBy({ status: EFolderStatus.LIVE }).then((processes: any[]) => {
|
||||
if (processes.length > 0) {
|
||||
let folders: any[] = processes.map((process: any) => process.processData);
|
||||
|
||||
// FilterBy status
|
||||
folders = folders.filter((folder: any) => folder.status === EFolderStatus.LIVE);
|
||||
// OrderBy created_at desc
|
||||
folders = folders.sort((a: any, b: any) => new Date(b.created_at).getTime() - new Date(a.created_at).getTime());
|
||||
|
||||
if (folders.length > 0) {
|
||||
router.push(
|
||||
|
@ -275,9 +275,8 @@ export default function LoginCallBack() {
|
||||
};
|
||||
|
||||
const getCollaborator = async (collaboratorData: any) => {
|
||||
return await new Promise<any>((resolve: (role: any) => void) => {
|
||||
CollaboratorService.getCollaborators().then((processes: any[]) => {
|
||||
const collaboratorFound: any = processes.length > 0 ? processes.map((process: any) => process.processData).find((collaborator: any) => collaborator.idNot === idNotUser.idNot) : null;
|
||||
return await new Promise<any>(async (resolve: (role: any) => void) => {
|
||||
const collaboratorFound: any | null = await CollaboratorService.getCollaboratorBy({ idNot: idNotUser.idNot });
|
||||
if (collaboratorFound) {
|
||||
resolve(collaboratorFound);
|
||||
} else {
|
||||
@ -290,7 +289,6 @@ export default function LoginCallBack() {
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
|
@ -1,4 +1,3 @@
|
||||
import Offices from "@Front/Api/LeCoffreApi/SuperAdmin/Offices/Offices";
|
||||
import Typography, { ETypo, ETypoColor } from "@Front/Components/DesignSystem/Typography";
|
||||
import DefaultOfficeDashboard from "@Front/Components/LayoutTemplates/DefaultOfficeDashboard";
|
||||
import User, { Office } from "le-coffre-resources/dist/SuperAdmin";
|
||||
@ -7,6 +6,9 @@ import { useCallback, useEffect, useState } from "react";
|
||||
|
||||
import classes from "./classes.module.scss";
|
||||
|
||||
import OfficeService from "src/common/Api/LeCoffreApi/sdk/OfficeService";
|
||||
import CollaboratorService from "src/common/Api/LeCoffreApi/sdk/CollaboratorService";
|
||||
|
||||
type IProps = {};
|
||||
export default function OfficeInformations(props: IProps) {
|
||||
const router = useRouter();
|
||||
@ -19,22 +21,20 @@ export default function OfficeInformations(props: IProps) {
|
||||
useEffect(() => {
|
||||
async function getOffice() {
|
||||
if (!officeUid) return;
|
||||
const office = await Offices.getInstance().getByUid(officeUid as string, {
|
||||
q: {
|
||||
address: true,
|
||||
users: {
|
||||
include: {
|
||||
role: true,
|
||||
office_role: true,
|
||||
contact: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
const office: any = await new Promise<any>((resolve: (office: any) => void) => {
|
||||
OfficeService.getOfficeByUid(officeUid as string).then((process: any) => {
|
||||
if (process) {
|
||||
const office: any = process.processData;
|
||||
resolve(office);
|
||||
}
|
||||
});
|
||||
});
|
||||
if (!office) return;
|
||||
setOfficeSelected(office);
|
||||
|
||||
const adminUsers = office.users?.filter((user) => {
|
||||
const users: any[] = await CollaboratorService.getCollaboratorsBy({ 'office.uid': office.uid });
|
||||
|
||||
const adminUsers = users.filter((user) => {
|
||||
if (user.office_role && user.office_role.name === "admin") {
|
||||
return true;
|
||||
}
|
||||
@ -46,8 +46,9 @@ export default function OfficeInformations(props: IProps) {
|
||||
}
|
||||
return false;
|
||||
});
|
||||
setAdminUsers(adminUsers);
|
||||
|
||||
const collaboratorUsers = office.users?.filter((user) => {
|
||||
const collaboratorUsers = users.filter((user) => {
|
||||
if (user.office_role && user.office_role.name === "admin") {
|
||||
return false;
|
||||
}
|
||||
@ -59,9 +60,7 @@ export default function OfficeInformations(props: IProps) {
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
setAdminUsers(adminUsers!);
|
||||
setCollaboratorUsers(collaboratorUsers!);
|
||||
setCollaboratorUsers(collaboratorUsers);
|
||||
}
|
||||
|
||||
getOffice();
|
||||
|
@ -27,7 +27,7 @@ export default function SelectFolder() {
|
||||
return;
|
||||
}
|
||||
LoaderService.getInstance().show();
|
||||
FolderService.getFolders().then((processes: any[]) => {
|
||||
FolderService.getFolders((processes: any[]) => {
|
||||
if (processes.length > 0) {
|
||||
let folders: any[] = processes.map((process: any) => process.processData);
|
||||
|
||||
|
@ -20,6 +20,8 @@ import classes from "./classes.module.scss";
|
||||
import OfficeRoles from "@Front/Api/LeCoffreApi/Admin/OfficeRoles/OfficeRoles";
|
||||
import Loader from "@Front/Components/DesignSystem/Loader";
|
||||
|
||||
import CollaboratorService from "src/common/Api/LeCoffreApi/sdk/CollaboratorService";
|
||||
|
||||
type IProps = {};
|
||||
export default function UserInformations(props: IProps) {
|
||||
const router = useRouter();
|
||||
@ -43,6 +45,8 @@ export default function UserInformations(props: IProps) {
|
||||
const getUser = useCallback(async () => {
|
||||
if (!userUid) return;
|
||||
setIsLoading(true);
|
||||
|
||||
/*
|
||||
const user = await Users.getInstance().getByUid(userUid as string, {
|
||||
q: {
|
||||
contact: true,
|
||||
@ -61,7 +65,17 @@ export default function UserInformations(props: IProps) {
|
||||
votes: true,
|
||||
},
|
||||
});
|
||||
*/
|
||||
const user: any = await new Promise<any>((resolve: (collaborator: any) => void) => {
|
||||
CollaboratorService.getCollaboratorByUid(userUid as string).then((process: any) => {
|
||||
if (process) {
|
||||
const collaborator: any = process.processData;
|
||||
resolve(collaborator);
|
||||
}
|
||||
});
|
||||
});
|
||||
if (!user) return;
|
||||
/*
|
||||
const roles = await OfficeRoles.getInstance().get({
|
||||
where: {
|
||||
office: { uid: user.office_membership?.uid },
|
||||
@ -69,6 +83,7 @@ export default function UserInformations(props: IProps) {
|
||||
},
|
||||
});
|
||||
if (!roles) return;
|
||||
*/
|
||||
setIsLoading(false);
|
||||
setUserSelected(user);
|
||||
}, [userUid]);
|
||||
@ -286,11 +301,9 @@ export default function UserInformations(props: IProps) {
|
||||
<div>
|
||||
<Typography typo={ETypo.TEXT_SM_REGULAR}>
|
||||
{currentAppointment.choice === EVote.NOMINATE
|
||||
? `Un ou des collaborateurs souhaitent attribuer le titre de Super Admin à ce collaborateur. Il manque ${
|
||||
3 - currentAppointment.votes?.length!
|
||||
? `Un ou des collaborateurs souhaitent attribuer le titre de Super Admin à ce collaborateur. Il manque ${3 - currentAppointment.votes?.length!
|
||||
} vote(s) pour que le collaborateur se voit attribuer le titre.`
|
||||
: `Un ou des collaborateurs souhaitent retirer le titre de Super Admin à ce collaborateur. Il manque ${
|
||||
3 - currentAppointment.votes?.length!
|
||||
: `Un ou des collaborateurs souhaitent retirer le titre de Super Admin à ce collaborateur. Il manque ${3 - currentAppointment.votes?.length!
|
||||
} vote(s) pour que le collaborateur se voit retirer le titre.`}
|
||||
</Typography>
|
||||
</div>
|
||||
@ -312,8 +325,7 @@ export default function UserInformations(props: IProps) {
|
||||
onClose={closeSuperAdminModal}
|
||||
onAccept={handleSuperAdminModalAccepted}
|
||||
closeBtn
|
||||
header={`Souhaitez-vous attribuer un vote à ${
|
||||
userSelected?.contact?.first_name + " " + userSelected?.contact?.last_name
|
||||
header={`Souhaitez-vous attribuer un vote à ${userSelected?.contact?.first_name + " " + userSelected?.contact?.last_name
|
||||
} pour ${superAdminModalType === "add" ? "devenir" : "retirer son rôle de"} Super Administrateur ?`}
|
||||
confirmText={"Attribuer un vote"}
|
||||
cancelText={"Annuler"}>
|
||||
@ -331,11 +343,9 @@ export default function UserInformations(props: IProps) {
|
||||
closeBtn
|
||||
header={
|
||||
adminModalType === "add"
|
||||
? `Souhaitez-vous nommer ${
|
||||
userSelected?.contact?.first_name + " " + userSelected?.contact?.last_name
|
||||
? `Souhaitez-vous nommer ${userSelected?.contact?.first_name + " " + userSelected?.contact?.last_name
|
||||
} administrateur de son office ?`
|
||||
: `Souhaitez-vous retirer le rôle administrateur de son office à ${
|
||||
userSelected?.contact?.first_name + " " + userSelected?.contact?.last_name
|
||||
: `Souhaitez-vous retirer le rôle administrateur de son office à ${userSelected?.contact?.first_name + " " + userSelected?.contact?.last_name
|
||||
} ?`
|
||||
}
|
||||
confirmText={adminModalType === "add" ? "Ajouter" : "Retirer"}
|
||||
|
Loading…
x
Reference in New Issue
Block a user