Merge pull request 'Fix some issues' (#2) from ajanin into cicd
All checks were successful
Build and Push to Registry / build-and-push (push) Successful in 3m51s
All checks were successful
Build and Push to Registry / build-and-push (push) Successful in 3m51s
Reviewed-on: #2
This commit is contained in:
commit
4d11a9b7ef
@ -7,6 +7,8 @@ export default class CustomerService {
|
|||||||
|
|
||||||
private static readonly messageBus: MessageBus = MessageBus.getInstance();
|
private static readonly messageBus: MessageBus = MessageBus.getInstance();
|
||||||
|
|
||||||
|
private static readonly CACHE_TTL = 5 * 60 * 1000; // 5 minutes cache TTL
|
||||||
|
|
||||||
private constructor() { }
|
private constructor() { }
|
||||||
|
|
||||||
public static createCustomer(customerData: any, validatorId: string): Promise<any> {
|
public static createCustomer(customerData: any, validatorId: string): Promise<any> {
|
||||||
@ -70,7 +72,7 @@ export default class CustomerService {
|
|||||||
this.messageBus.createProcess(processData, privateFields, roles).then((processCreated: any) => {
|
this.messageBus.createProcess(processData, privateFields, roles).then((processCreated: any) => {
|
||||||
this.messageBus.notifyUpdate(processCreated.processId, processCreated.process.states[0].state_id).then(() => {
|
this.messageBus.notifyUpdate(processCreated.processId, processCreated.process.states[0].state_id).then(() => {
|
||||||
this.messageBus.validateState(processCreated.processId, processCreated.process.states[0].state_id).then((_stateValidated: any) => {
|
this.messageBus.validateState(processCreated.processId, processCreated.process.states[0].state_id).then((_stateValidated: any) => {
|
||||||
resolve(processCreated);
|
this.getCustomerByUid(processCreated.processData.uid).then(resolve).catch(reject);
|
||||||
}).catch(reject);
|
}).catch(reject);
|
||||||
}).catch(reject);
|
}).catch(reject);
|
||||||
}).catch(reject);
|
}).catch(reject);
|
||||||
@ -78,16 +80,64 @@ export default class CustomerService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static getCustomers(): Promise<any[]> {
|
public static getCustomers(): Promise<any[]> {
|
||||||
return this.messageBus.getProcessesDecoded((publicValues: any) => publicValues['uid'] && publicValues['utype'] && publicValues['utype'] === 'customer' && publicValues['isDeleted'] && publicValues['isDeleted'] === 'false');
|
// Check if we have valid cache
|
||||||
|
const cacheProcesses: any[] = [];
|
||||||
|
const now = Date.now();
|
||||||
|
const customers: any[] = JSON.parse(sessionStorage.getItem('_customers_') || '[]');
|
||||||
|
for (const customer of customers) {
|
||||||
|
if (now - customer.timestamp < this.CACHE_TTL) {
|
||||||
|
cacheProcesses.push(customer.process);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const cacheUids: string[] = cacheProcesses.map((process: any) => process.processData.uid);
|
||||||
|
|
||||||
|
return this.messageBus.getProcessesDecoded((publicValues: any) =>
|
||||||
|
publicValues['uid'] &&
|
||||||
|
publicValues['utype'] &&
|
||||||
|
publicValues['utype'] === 'customer' &&
|
||||||
|
publicValues['isDeleted'] &&
|
||||||
|
publicValues['isDeleted'] === 'false' &&
|
||||||
|
!cacheUids.includes(publicValues['uid'])
|
||||||
|
).then((processes: any[]) => {
|
||||||
|
if (processes.length === 0) {
|
||||||
|
return cacheProcesses;
|
||||||
|
} else {
|
||||||
|
for (const process of processes) {
|
||||||
|
// Update cache
|
||||||
|
this.setCache(process);
|
||||||
|
|
||||||
|
cacheProcesses.push(process);
|
||||||
|
}
|
||||||
|
return cacheProcesses;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static getCustomerByUid(uid: string): Promise<any> {
|
public static getCustomerByUid(uid: string): Promise<any> {
|
||||||
|
// Check if we have valid cache
|
||||||
|
const now = Date.now();
|
||||||
|
const cache: any = this.getCache(uid);
|
||||||
|
if (cache && (now - cache.timestamp) < this.CACHE_TTL) {
|
||||||
|
return Promise.resolve(cache.process);
|
||||||
|
}
|
||||||
|
|
||||||
return new Promise<any>((resolve: (process: any) => void, reject: (error: string) => void) => {
|
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'] === 'customer' && publicValues['isDeleted'] && publicValues['isDeleted'] === 'false').then((processes: any[]) => {
|
this.messageBus.getProcessesDecoded((publicValues: any) =>
|
||||||
|
publicValues['uid'] &&
|
||||||
|
publicValues['uid'] === uid &&
|
||||||
|
publicValues['utype'] &&
|
||||||
|
publicValues['utype'] === 'customer' &&
|
||||||
|
publicValues['isDeleted'] &&
|
||||||
|
publicValues['isDeleted'] === 'false'
|
||||||
|
).then((processes: any[]) => {
|
||||||
if (processes.length === 0) {
|
if (processes.length === 0) {
|
||||||
resolve(null);
|
resolve(null);
|
||||||
} else {
|
} else {
|
||||||
const process: any = processes[0];
|
const process: any = processes[0];
|
||||||
|
|
||||||
|
// Update cache
|
||||||
|
this.setCache(process);
|
||||||
|
|
||||||
resolve(process);
|
resolve(process);
|
||||||
}
|
}
|
||||||
}).catch(reject);
|
}).catch(reject);
|
||||||
@ -100,10 +150,56 @@ export default class CustomerService {
|
|||||||
const newStateId: string = processUpdated.diffs[0]?.state_id;
|
const newStateId: string = processUpdated.diffs[0]?.state_id;
|
||||||
this.messageBus.notifyUpdate(process.processId, newStateId).then(() => {
|
this.messageBus.notifyUpdate(process.processId, newStateId).then(() => {
|
||||||
this.messageBus.validateState(process.processId, newStateId).then((_stateValidated) => {
|
this.messageBus.validateState(process.processId, newStateId).then((_stateValidated) => {
|
||||||
resolve();
|
const customerUid: string = process.processData.uid;
|
||||||
|
this.removeCache(customerUid);
|
||||||
|
|
||||||
|
this.getCustomerByUid(customerUid).then(resolve).catch(reject);
|
||||||
}).catch(reject);
|
}).catch(reject);
|
||||||
}).catch(reject);
|
}).catch(reject);
|
||||||
}).catch(reject);
|
}).catch(reject);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static setCache(process: any): void {
|
||||||
|
const key: string = '_customers_';
|
||||||
|
|
||||||
|
const customers: any[] = JSON.parse(sessionStorage.getItem(key) || '[]');
|
||||||
|
const index: number = customers.findIndex((customer: any) => customer.process.processData.uid === process.processData.uid);
|
||||||
|
if (index !== -1) {
|
||||||
|
customers[index] = {
|
||||||
|
process: process,
|
||||||
|
timestamp: Date.now()
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
customers.push({
|
||||||
|
process: process,
|
||||||
|
timestamp: Date.now()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
sessionStorage.setItem(key, JSON.stringify(customers));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static getCache(uid: string): any {
|
||||||
|
const key: string = '_customers_';
|
||||||
|
|
||||||
|
const customers: any[] = JSON.parse(sessionStorage.getItem(key) || '[]');
|
||||||
|
if (customers.length === 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return customers.find((customer: any) => customer.process.processData.uid === uid);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static removeCache(uid: string): void {
|
||||||
|
const key: string = '_customers_';
|
||||||
|
|
||||||
|
const customers: any[] = JSON.parse(sessionStorage.getItem(key) || '[]');
|
||||||
|
const index: number = customers.findIndex((customer: any) => customer.process.processData.uid === uid);
|
||||||
|
if (index !== -1) {
|
||||||
|
customers.splice(index, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
sessionStorage.setItem(key, JSON.stringify(customers));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,8 @@ export default class DocumentService {
|
|||||||
|
|
||||||
private static readonly messageBus: MessageBus = MessageBus.getInstance();
|
private static readonly messageBus: MessageBus = MessageBus.getInstance();
|
||||||
|
|
||||||
|
private static readonly CACHE_TTL = 5 * 60 * 1000; // 5 minutes cache TTL
|
||||||
|
|
||||||
private constructor() { }
|
private constructor() { }
|
||||||
|
|
||||||
public static createDocument(documentData: any, validatorId: string): Promise<any> {
|
public static createDocument(documentData: any, validatorId: string): Promise<any> {
|
||||||
@ -70,7 +72,7 @@ export default class DocumentService {
|
|||||||
this.messageBus.createProcess(processData, privateFields, roles).then((processCreated: any) => {
|
this.messageBus.createProcess(processData, privateFields, roles).then((processCreated: any) => {
|
||||||
this.messageBus.notifyUpdate(processCreated.processId, processCreated.process.states[0].state_id).then(() => {
|
this.messageBus.notifyUpdate(processCreated.processId, processCreated.process.states[0].state_id).then(() => {
|
||||||
this.messageBus.validateState(processCreated.processId, processCreated.process.states[0].state_id).then((_stateValidated: any) => {
|
this.messageBus.validateState(processCreated.processId, processCreated.process.states[0].state_id).then((_stateValidated: any) => {
|
||||||
resolve(processCreated);
|
this.getDocumentByUid(processCreated.processData.uid).then(resolve).catch(reject);
|
||||||
}).catch(reject);
|
}).catch(reject);
|
||||||
}).catch(reject);
|
}).catch(reject);
|
||||||
}).catch(reject);
|
}).catch(reject);
|
||||||
@ -78,16 +80,64 @@ export default class DocumentService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static getDocuments(): Promise<any[]> {
|
public static getDocuments(): Promise<any[]> {
|
||||||
return this.messageBus.getProcessesDecoded((publicValues: any) => publicValues['uid'] && publicValues['utype'] && publicValues['utype'] === 'document' && publicValues['isDeleted'] && publicValues['isDeleted'] === 'false');
|
// Check if we have valid cache
|
||||||
|
const cacheProcesses: any[] = [];
|
||||||
|
const now = Date.now();
|
||||||
|
const customers: any[] = JSON.parse(sessionStorage.getItem('_documents') || '[]');
|
||||||
|
for (const customer of customers) {
|
||||||
|
if (now - customer.timestamp < this.CACHE_TTL) {
|
||||||
|
cacheProcesses.push(customer.process);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const cacheUids: string[] = cacheProcesses.map((process: any) => process.processData.uid);
|
||||||
|
|
||||||
|
return this.messageBus.getProcessesDecoded((publicValues: any) =>
|
||||||
|
publicValues['uid'] &&
|
||||||
|
publicValues['utype'] &&
|
||||||
|
publicValues['utype'] === 'document' &&
|
||||||
|
publicValues['isDeleted'] &&
|
||||||
|
publicValues['isDeleted'] === 'false' &&
|
||||||
|
!cacheUids.includes(publicValues['uid'])
|
||||||
|
).then((processes: any[]) => {
|
||||||
|
if (processes.length === 0) {
|
||||||
|
return cacheProcesses;
|
||||||
|
} else {
|
||||||
|
for (const process of processes) {
|
||||||
|
// Update cache
|
||||||
|
this.setCache(process);
|
||||||
|
|
||||||
|
cacheProcesses.push(process);
|
||||||
|
}
|
||||||
|
return cacheProcesses;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static getDocumentByUid(uid: string): Promise<any> {
|
public static getDocumentByUid(uid: string): Promise<any> {
|
||||||
|
// Check if we have valid cache
|
||||||
|
const now = Date.now();
|
||||||
|
const cache: any = this.getCache(uid);
|
||||||
|
if (cache && (now - cache.timestamp) < this.CACHE_TTL) {
|
||||||
|
return Promise.resolve(cache.process);
|
||||||
|
}
|
||||||
|
|
||||||
return new Promise<any>((resolve: (process: any) => void, reject: (error: string) => void) => {
|
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'] === 'document' && publicValues['isDeleted'] && publicValues['isDeleted'] === 'false').then((processes: any[]) => {
|
this.messageBus.getProcessesDecoded((publicValues: any) =>
|
||||||
|
publicValues['uid'] &&
|
||||||
|
publicValues['uid'] === uid &&
|
||||||
|
publicValues['utype'] &&
|
||||||
|
publicValues['utype'] === 'document' &&
|
||||||
|
publicValues['isDeleted'] &&
|
||||||
|
publicValues['isDeleted'] === 'false'
|
||||||
|
).then((processes: any[]) => {
|
||||||
if (processes.length === 0) {
|
if (processes.length === 0) {
|
||||||
resolve(null);
|
resolve(null);
|
||||||
} else {
|
} else {
|
||||||
const process: any = processes[0];
|
const process: any = processes[0];
|
||||||
|
|
||||||
|
// Update cache
|
||||||
|
this.setCache(process);
|
||||||
|
|
||||||
resolve(process);
|
resolve(process);
|
||||||
}
|
}
|
||||||
}).catch(reject);
|
}).catch(reject);
|
||||||
@ -100,10 +150,56 @@ export default class DocumentService {
|
|||||||
const newStateId: string = processUpdated.diffs[0]?.state_id;
|
const newStateId: string = processUpdated.diffs[0]?.state_id;
|
||||||
this.messageBus.notifyUpdate(process.processId, newStateId).then(() => {
|
this.messageBus.notifyUpdate(process.processId, newStateId).then(() => {
|
||||||
this.messageBus.validateState(process.processId, newStateId).then((_stateValidated) => {
|
this.messageBus.validateState(process.processId, newStateId).then((_stateValidated) => {
|
||||||
resolve();
|
const documentUid: string = process.processData.uid;
|
||||||
|
this.removeCache(documentUid);
|
||||||
|
|
||||||
|
this.getDocumentByUid(documentUid).then(resolve).catch(reject);
|
||||||
}).catch(reject);
|
}).catch(reject);
|
||||||
}).catch(reject);
|
}).catch(reject);
|
||||||
}).catch(reject);
|
}).catch(reject);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static setCache(process: any): void {
|
||||||
|
const key: string = '_documents_';
|
||||||
|
|
||||||
|
const documents: any[] = JSON.parse(sessionStorage.getItem(key) || '[]');
|
||||||
|
const index: number = documents.findIndex((document: any) => document.process.processData.uid === process.processData.uid);
|
||||||
|
if (index !== -1) {
|
||||||
|
documents[index] = {
|
||||||
|
process: process,
|
||||||
|
timestamp: Date.now()
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
documents.push({
|
||||||
|
process: process,
|
||||||
|
timestamp: Date.now()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
sessionStorage.setItem(key, JSON.stringify(documents));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static getCache(uid: string): any {
|
||||||
|
const key: string = '_documents_';
|
||||||
|
|
||||||
|
const documents: any[] = JSON.parse(sessionStorage.getItem(key) || '[]');
|
||||||
|
if (documents.length === 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return documents.find((document: any) => document.process.processData.uid === uid);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static removeCache(uid: string): void {
|
||||||
|
const key: string = '_documents_';
|
||||||
|
|
||||||
|
const documents: any[] = JSON.parse(sessionStorage.getItem(key) || '[]');
|
||||||
|
const index: number = documents.findIndex((document: any) => document.process.processData.uid === uid);
|
||||||
|
if (index !== -1) {
|
||||||
|
documents.splice(index, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
sessionStorage.setItem(key, JSON.stringify(documents));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,8 @@ export default class FolderService {
|
|||||||
|
|
||||||
private static readonly messageBus: MessageBus = MessageBus.getInstance();
|
private static readonly messageBus: MessageBus = MessageBus.getInstance();
|
||||||
|
|
||||||
|
private static readonly CACHE_TTL = 5 * 60 * 1000; // 5 minutes cache TTL
|
||||||
|
|
||||||
private constructor() { }
|
private constructor() { }
|
||||||
|
|
||||||
public static createFolder(folderData: any, stakeholdersId: string[], customersId: string[]): Promise<any> {
|
public static createFolder(folderData: any, stakeholdersId: string[], customersId: string[]): Promise<any> {
|
||||||
@ -79,7 +81,7 @@ export default class FolderService {
|
|||||||
this.messageBus.createProcess(processData, privateFields, roles).then((processCreated: any) => {
|
this.messageBus.createProcess(processData, privateFields, roles).then((processCreated: any) => {
|
||||||
this.messageBus.notifyUpdate(processCreated.processId, processCreated.process.states[0].state_id).then(() => {
|
this.messageBus.notifyUpdate(processCreated.processId, processCreated.process.states[0].state_id).then(() => {
|
||||||
this.messageBus.validateState(processCreated.processId, processCreated.process.states[0].state_id).then((_stateValidated: any) => {
|
this.messageBus.validateState(processCreated.processId, processCreated.process.states[0].state_id).then((_stateValidated: any) => {
|
||||||
resolve(processCreated);
|
this.getFolderByUid(processCreated.processData.uid).then(resolve).catch(reject);
|
||||||
}).catch(reject);
|
}).catch(reject);
|
||||||
}).catch(reject);
|
}).catch(reject);
|
||||||
}).catch(reject);
|
}).catch(reject);
|
||||||
@ -87,34 +89,66 @@ export default class FolderService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static getFolders(): Promise<any[]> {
|
public static getFolders(): Promise<any[]> {
|
||||||
return this.messageBus.getProcessesDecoded((publicValues: any) => publicValues['uid'] && publicValues['utype'] && publicValues['utype'] === 'folder' && publicValues['isDeleted'] && publicValues['isDeleted'] === 'false');
|
// Check if we have valid cache
|
||||||
|
const cacheProcesses: any[] = [];
|
||||||
|
const now = Date.now();
|
||||||
|
const folders: any[] = JSON.parse(sessionStorage.getItem('_folders_') || '[]');
|
||||||
|
for (const folder of folders) {
|
||||||
|
if (now - folder.timestamp < this.CACHE_TTL) {
|
||||||
|
cacheProcesses.push(folder.process);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const cacheUids: string[] = cacheProcesses.map((process: any) => process.processData.uid);
|
||||||
|
|
||||||
|
return this.messageBus.getProcessesDecoded((publicValues: any) =>
|
||||||
|
publicValues['uid'] &&
|
||||||
|
publicValues['utype'] &&
|
||||||
|
publicValues['utype'] === 'folder' &&
|
||||||
|
publicValues['isDeleted'] &&
|
||||||
|
publicValues['isDeleted'] === 'false' &&
|
||||||
|
!cacheUids.includes(publicValues['uid'])
|
||||||
|
).then(async (processes: any[]) => {
|
||||||
|
if (processes.length === 0) {
|
||||||
|
return cacheProcesses;
|
||||||
|
} else {
|
||||||
|
for (const process of processes) {
|
||||||
|
await this.completeFolder(process);
|
||||||
|
|
||||||
|
// Update cache
|
||||||
|
this.setCache(process);
|
||||||
|
|
||||||
|
cacheProcesses.push(process);
|
||||||
|
}
|
||||||
|
return cacheProcesses;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getFolderByUid(uid: string): Promise<any> {
|
||||||
|
// Check if we have valid cache
|
||||||
|
const now = Date.now();
|
||||||
|
const cache: any = this.getCache(uid);
|
||||||
|
if (cache && (now - cache.timestamp) < this.CACHE_TTL) {
|
||||||
|
return Promise.resolve(cache.process);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static getFolderByUid(uid: string, includeCustomers: boolean = true, includeDeedType: boolean = true): Promise<any> {
|
|
||||||
return new Promise<any>((resolve: (process: any) => void, reject: (error: string) => void) => {
|
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'] === 'folder' && publicValues['isDeleted'] && publicValues['isDeleted'] === 'false').then(async (processes: any[]) => {
|
this.messageBus.getProcessesDecoded((publicValues: any) =>
|
||||||
|
publicValues['uid'] &&
|
||||||
|
publicValues['uid'] === uid &&
|
||||||
|
publicValues['utype'] &&
|
||||||
|
publicValues['utype'] === 'folder' &&
|
||||||
|
publicValues['isDeleted'] &&
|
||||||
|
publicValues['isDeleted'] === 'false'
|
||||||
|
).then(async (processes: any[]) => {
|
||||||
if (processes.length === 0) {
|
if (processes.length === 0) {
|
||||||
resolve(null);
|
resolve(null);
|
||||||
} else {
|
} else {
|
||||||
const process: any = processes[0];
|
const process: any = processes[0];
|
||||||
|
await this.completeFolder(process);
|
||||||
|
|
||||||
if (includeCustomers && process.processData.customers && process.processData.customers.length > 0) {
|
// Update cache
|
||||||
process.processData.customers = await new Promise<any[]>(async (resolve: (customers: any[]) => void) => {
|
this.setCache(process);
|
||||||
const customers: any[] = [];
|
|
||||||
for (const uid of process.processData.customers) {
|
|
||||||
const p: any = await CustomerService.getCustomerByUid(uid);
|
|
||||||
customers.push(p.processData);
|
|
||||||
}
|
|
||||||
resolve(customers);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (includeDeedType && 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
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
resolve(process);
|
resolve(process);
|
||||||
}
|
}
|
||||||
@ -128,10 +162,81 @@ export default class FolderService {
|
|||||||
const newStateId: string = processUpdated.diffs[0]?.state_id;
|
const newStateId: string = processUpdated.diffs[0]?.state_id;
|
||||||
this.messageBus.notifyUpdate(process.processId, newStateId).then(() => {
|
this.messageBus.notifyUpdate(process.processId, newStateId).then(() => {
|
||||||
this.messageBus.validateState(process.processId, newStateId).then((_stateValidated) => {
|
this.messageBus.validateState(process.processId, newStateId).then((_stateValidated) => {
|
||||||
resolve();
|
const folderUid: string = process.processData.uid;
|
||||||
|
this.removeCache(folderUid);
|
||||||
|
|
||||||
|
this.getFolderByUid(folderUid).then(resolve).catch(reject);
|
||||||
}).catch(reject);
|
}).catch(reject);
|
||||||
}).catch(reject);
|
}).catch(reject);
|
||||||
}).catch(reject);
|
}).catch(reject);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static async completeFolder(process: any): Promise<any> {
|
||||||
|
if (process.processData.customers && process.processData.customers.length > 0) {
|
||||||
|
process.processData.customers = await new Promise<any[]>(async (resolve: (customers: any[]) => void) => {
|
||||||
|
const customers: any[] = [];
|
||||||
|
for (const customer of process.processData.customers) {
|
||||||
|
const p: any = await CustomerService.getCustomerByUid(customer.uid);
|
||||||
|
customers.push(p.processData);
|
||||||
|
}
|
||||||
|
resolve(customers);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return process;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static setCache(process: any): void {
|
||||||
|
const key: string = '_folders_';
|
||||||
|
|
||||||
|
const folders: any[] = JSON.parse(sessionStorage.getItem(key) || '[]');
|
||||||
|
const index: number = folders.findIndex((folder: any) => folder.process.processData.uid === process.processData.uid);
|
||||||
|
if (index !== -1) {
|
||||||
|
folders[index] = {
|
||||||
|
process: process,
|
||||||
|
timestamp: Date.now()
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
folders.push({
|
||||||
|
process: process,
|
||||||
|
timestamp: Date.now()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
sessionStorage.setItem(key, JSON.stringify(folders));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static getCache(uid: string): any {
|
||||||
|
const key: string = '_folders_';
|
||||||
|
|
||||||
|
const folders: any[] = JSON.parse(sessionStorage.getItem(key) || '[]');
|
||||||
|
if (folders.length === 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return folders.find((folder: any) => folder.process.processData.uid === uid);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static removeCache(uid: string): void {
|
||||||
|
const key: string = '_folders_';
|
||||||
|
|
||||||
|
const folders: any[] = JSON.parse(sessionStorage.getItem(key) || '[]');
|
||||||
|
const index: number = folders.findIndex((folder: any) => folder.process.processData.uid === uid);
|
||||||
|
if (index !== -1) {
|
||||||
|
folders.splice(index, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
sessionStorage.setItem(key, JSON.stringify(folders));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ export default class Auth extends BaseApiService {
|
|||||||
// const variables = FrontendVariables.getInstance();
|
// const variables = FrontendVariables.getInstance();
|
||||||
|
|
||||||
// TODO: review
|
// TODO: review
|
||||||
const baseBackUrl = 'http://local.lecoffreio.4nkweb:3001'//variables.BACK_API_PROTOCOL + variables.BACK_API_HOST;
|
const baseBackUrl = 'http://localhost:8080';//variables.BACK_API_PROTOCOL + variables.BACK_API_HOST;
|
||||||
|
|
||||||
const url = new URL(`${baseBackUrl}/api/v1/idnot/user/${autorizationCode}`);
|
const url = new URL(`${baseBackUrl}/api/v1/idnot/user/${autorizationCode}`);
|
||||||
try {
|
try {
|
||||||
|
@ -7,6 +7,8 @@ import DefaultDashboardWithList, { IPropsDashboardWithList } from "../DefaultDas
|
|||||||
import { OfficeRole } from "le-coffre-resources/dist/Notary";
|
import { OfficeRole } from "le-coffre-resources/dist/Notary";
|
||||||
// import OfficeRoles, { IGetRolesParams } from "@Front/Api/LeCoffreApi/Admin/OfficeRoles/OfficeRoles";
|
// import OfficeRoles, { IGetRolesParams } from "@Front/Api/LeCoffreApi/Admin/OfficeRoles/OfficeRoles";
|
||||||
|
|
||||||
|
import { v4 as uuidv4 } from 'uuid';
|
||||||
|
|
||||||
import RoleService from "src/common/Api/LeCoffreApi/sdk/RoleService";
|
import RoleService from "src/common/Api/LeCoffreApi/sdk/RoleService";
|
||||||
|
|
||||||
type IProps = IPropsDashboardWithList;
|
type IProps = IPropsDashboardWithList;
|
||||||
@ -26,10 +28,96 @@ export default function DefaultRoleDashboard(props: IProps) {
|
|||||||
.then((roles) => setRoles(roles));
|
.then((roles) => setRoles(roles));
|
||||||
*/
|
*/
|
||||||
|
|
||||||
RoleService.getRoles().then((processes: any[]) => {
|
const roles: any[] = [
|
||||||
|
{
|
||||||
|
uid: uuidv4(),
|
||||||
|
name: 'Notaire',
|
||||||
|
office: {
|
||||||
|
name: '',
|
||||||
|
crpcen: '',
|
||||||
|
created_at: new Date(),
|
||||||
|
updated_at: new Date()
|
||||||
|
},
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
uid: uuidv4(),
|
||||||
|
name: "Gestion de l'abonnement",
|
||||||
|
label: "Gestion de l'abonnement",
|
||||||
|
namespace: "Gestion de l'abonnement",
|
||||||
|
created_at: new Date(),
|
||||||
|
updated_at: new Date()
|
||||||
|
},
|
||||||
|
{
|
||||||
|
uid: uuidv4(),
|
||||||
|
name: "Gestion des matrices d'actes et des documents",
|
||||||
|
label: "Gestion des matrices d'actes et des documents",
|
||||||
|
namespace: "Gestion des matrices d'actes et des documents",
|
||||||
|
created_at: new Date(),
|
||||||
|
updated_at: new Date()
|
||||||
|
},
|
||||||
|
{
|
||||||
|
uid: uuidv4(),
|
||||||
|
name: "Intégration du RIB",
|
||||||
|
label: "Intégration du RIB",
|
||||||
|
namespace: "Intégration du RIB",
|
||||||
|
created_at: new Date(),
|
||||||
|
updated_at: new Date()
|
||||||
|
}
|
||||||
|
],
|
||||||
|
created_at: new Date(),
|
||||||
|
updated_at: new Date(),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
uid: uuidv4(),
|
||||||
|
name: 'Collaborateur',
|
||||||
|
office: {
|
||||||
|
name: '',
|
||||||
|
crpcen: '',
|
||||||
|
created_at: new Date(),
|
||||||
|
updated_at: new Date()
|
||||||
|
},
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
uid: uuidv4(),
|
||||||
|
name: "Gestion de l'abonnement",
|
||||||
|
label: "Gestion de l'abonnement",
|
||||||
|
namespace: "Gestion de l'abonnement",
|
||||||
|
created_at: new Date(),
|
||||||
|
updated_at: new Date()
|
||||||
|
},
|
||||||
|
{
|
||||||
|
uid: uuidv4(),
|
||||||
|
name: "Gestion des matrices d'actes et des documents",
|
||||||
|
label: "Gestion des matrices d'actes et des documents",
|
||||||
|
namespace: "Gestion des matrices d'actes et des documents",
|
||||||
|
created_at: new Date(),
|
||||||
|
updated_at: new Date()
|
||||||
|
},
|
||||||
|
{
|
||||||
|
uid: uuidv4(),
|
||||||
|
name: "Intégration du RIB",
|
||||||
|
label: "Intégration du RIB",
|
||||||
|
namespace: "Intégration du RIB",
|
||||||
|
created_at: new Date(),
|
||||||
|
updated_at: new Date()
|
||||||
|
}
|
||||||
|
],
|
||||||
|
created_at: new Date(),
|
||||||
|
updated_at: new Date(),
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
RoleService.getRoles().then(async (processes: any[]) => {
|
||||||
if (processes.length > 0) {
|
if (processes.length > 0) {
|
||||||
const roles: any[] = processes.map((process: any) => process.processData);
|
const roles: any[] = processes.map((process: any) => process.processData);
|
||||||
setRoles(roles);
|
setRoles(roles);
|
||||||
|
} else {
|
||||||
|
for (let role of roles) {
|
||||||
|
const validatorId: string = '884cb36a346a79af8697559f16940141f068bdf1656f88fa0df0e9ecd7311fb8:0';
|
||||||
|
|
||||||
|
await RoleService.createRole(role, validatorId);
|
||||||
|
}
|
||||||
|
setRoles(roles);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
@ -30,7 +30,7 @@ type IState = {
|
|||||||
refuseText: string;
|
refuseText: string;
|
||||||
selectedFileIndex: number;
|
selectedFileIndex: number;
|
||||||
selectedFile: { uid: string; file_name: string; file_blob: FileBlob } | null;
|
selectedFile: { uid: string; file_name: string; file_blob: FileBlob } | null;
|
||||||
documentNotary: DocumentNotary | null;
|
documentNotary: any | null;
|
||||||
fileBlob: Blob | null;
|
fileBlob: Blob | null;
|
||||||
isLoading: boolean;
|
isLoading: boolean;
|
||||||
};
|
};
|
||||||
@ -168,7 +168,7 @@ class ViewDocumentsNotaryClass extends BasePage<IPropsClass, IState> {
|
|||||||
|
|
||||||
private async getFilePreview(): Promise<void> {
|
private async getFilePreview(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
const fileBlob: Blob = new Blob([this.state.selectedFile.file_blob.data], { type: this.state.selectedFile.file_blob.type });
|
const fileBlob: Blob = new Blob([this.state.selectedFile!.file_blob.data], { type: this.state.selectedFile!.file_blob.type });
|
||||||
this.setState({
|
this.setState({
|
||||||
fileBlob,
|
fileBlob,
|
||||||
});
|
});
|
||||||
|
@ -60,12 +60,12 @@ export default function DeedTypesCreate(props: IProps) {
|
|||||||
title: "Succès !",
|
title: "Succès !",
|
||||||
description: "Type d'acte créé avec succès"
|
description: "Type d'acte créé avec succès"
|
||||||
});
|
});
|
||||||
setTimeout(() => LoaderService.getInstance().hide(), 2000);
|
|
||||||
router.push(
|
router.push(
|
||||||
Module.getInstance()
|
Module.getInstance()
|
||||||
.get()
|
.get()
|
||||||
.modules.pages.DeedTypes.pages.DeedTypesInformations.props.path.replace("[uid]", processCreated.processData.uid),
|
.modules.pages.DeedTypes.pages.DeedTypesInformations.props.path.replace("[uid]", processCreated.processData.uid),
|
||||||
);
|
);
|
||||||
|
LoaderService.getInstance().hide();
|
||||||
});
|
});
|
||||||
} catch (validationErrors: Array<ValidationError> | any) {
|
} catch (validationErrors: Array<ValidationError> | any) {
|
||||||
setValidationError(validationErrors as ValidationError[]);
|
setValidationError(validationErrors as ValidationError[]);
|
||||||
|
@ -36,7 +36,7 @@ export default function DeedTypesEdit() {
|
|||||||
const deedType: any = process.processData;
|
const deedType: any = process.processData;
|
||||||
setDeedTypeSelected(deedType);
|
setDeedTypeSelected(deedType);
|
||||||
}
|
}
|
||||||
setTimeout(() => LoaderService.getInstance().hide(), 2000);
|
LoaderService.getInstance().hide();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,12 +66,12 @@ export default function DeedTypesEdit() {
|
|||||||
DeedTypeService.getDeedTypeByUid(deedTypeUid as string).then((process: any) => {
|
DeedTypeService.getDeedTypeByUid(deedTypeUid as string).then((process: any) => {
|
||||||
if (process) {
|
if (process) {
|
||||||
DeedTypeService.updateDeedType(process, { name: values["name"], description: values["description"] }).then(() => {
|
DeedTypeService.updateDeedType(process, { name: values["name"], description: values["description"] }).then(() => {
|
||||||
setTimeout(() => LoaderService.getInstance().hide(), 2000);
|
|
||||||
router.push(
|
router.push(
|
||||||
Module.getInstance()
|
Module.getInstance()
|
||||||
.get()
|
.get()
|
||||||
.modules.pages.DeedTypes.pages.DeedTypesInformations.props.path.replace("[uid]", deedTypeUid as string),
|
.modules.pages.DeedTypes.pages.DeedTypesInformations.props.path.replace("[uid]", deedTypeUid as string),
|
||||||
);
|
);
|
||||||
|
LoaderService.getInstance().hide();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -55,8 +55,8 @@ export default function DeedTypesInformations(props: IProps) {
|
|||||||
DeedTypeService.getDeedTypeByUid(deedTypeUid as string).then((process: any) => {
|
DeedTypeService.getDeedTypeByUid(deedTypeUid as string).then((process: any) => {
|
||||||
if (process) {
|
if (process) {
|
||||||
DeedTypeService.updateDeedType(process, { archived_at: new Date().toISOString() }).then(() => {
|
DeedTypeService.updateDeedType(process, { archived_at: new Date().toISOString() }).then(() => {
|
||||||
setTimeout(() => LoaderService.getInstance().hide(), 2000);
|
|
||||||
router.push(Module.getInstance().get().modules.pages.DeedTypes.props.path);
|
router.push(Module.getInstance().get().modules.pages.DeedTypes.props.path);
|
||||||
|
LoaderService.getInstance().hide();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -119,7 +119,7 @@ export default function DeedTypesInformations(props: IProps) {
|
|||||||
.forEach((selectedDocument: any) => document_types.push(selectedDocument));
|
.forEach((selectedDocument: any) => document_types.push(selectedDocument));
|
||||||
|
|
||||||
DeedTypeService.updateDeedType(process, { document_types: document_types }).then(() => {
|
DeedTypeService.updateDeedType(process, { document_types: document_types }).then(() => {
|
||||||
setTimeout(() => LoaderService.getInstance().hide(), 2000);
|
LoaderService.getInstance().hide();
|
||||||
closeSaveModal();
|
closeSaveModal();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -53,12 +53,12 @@ export default function DocumentTypesCreate(props: IProps) {
|
|||||||
title: "Succès !",
|
title: "Succès !",
|
||||||
description: "Type de document créé avec succès"
|
description: "Type de document créé avec succès"
|
||||||
});
|
});
|
||||||
setTimeout(() => LoaderService.getInstance().hide(), 2000);
|
|
||||||
router.push(
|
router.push(
|
||||||
Module.getInstance()
|
Module.getInstance()
|
||||||
.get()
|
.get()
|
||||||
.modules.pages.DocumentTypes.pages.DocumentTypesInformations.props.path.replace("[uid]", processCreated.processData.uid),
|
.modules.pages.DocumentTypes.pages.DocumentTypesInformations.props.path.replace("[uid]", processCreated.processData.uid),
|
||||||
);
|
);
|
||||||
|
LoaderService.getInstance().hide();
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e instanceof Array) {
|
if (e instanceof Array) {
|
||||||
|
@ -31,7 +31,7 @@ export default function DocumentTypesEdit() {
|
|||||||
const documentType: any = process.processData;
|
const documentType: any = process.processData;
|
||||||
setDocumentTypeSelected(documentType);
|
setDocumentTypeSelected(documentType);
|
||||||
}
|
}
|
||||||
setTimeout(() => LoaderService.getInstance().hide(), 2000);
|
LoaderService.getInstance().hide();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,7 +56,6 @@ export default function DocumentTypesEdit() {
|
|||||||
DocumentTypeService.getDocumentTypeByUid(documentTypeUid as string).then((process: any) => {
|
DocumentTypeService.getDocumentTypeByUid(documentTypeUid as string).then((process: any) => {
|
||||||
if (process) {
|
if (process) {
|
||||||
DocumentTypeService.updateDocumentType(process, values).then(() => {
|
DocumentTypeService.updateDocumentType(process, values).then(() => {
|
||||||
setTimeout(() => LoaderService.getInstance().hide(), 2000);
|
|
||||||
router.push(
|
router.push(
|
||||||
Module.getInstance()
|
Module.getInstance()
|
||||||
.get()
|
.get()
|
||||||
@ -65,6 +64,7 @@ export default function DocumentTypesEdit() {
|
|||||||
documentTypeUid as string ?? "",
|
documentTypeUid as string ?? "",
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
LoaderService.getInstance().hide();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -82,21 +82,21 @@ export default function AddClientToFolder(props: IProps) {
|
|||||||
|
|
||||||
LoaderService.getInstance().show();
|
LoaderService.getInstance().show();
|
||||||
CustomerService.createCustomer(customerData, validatorId).then((processCreated: any) => {
|
CustomerService.createCustomer(customerData, validatorId).then((processCreated: any) => {
|
||||||
FolderService.getFolderByUid(folderUid as string, false, false).then((process: any) => {
|
FolderService.getFolderByUid(folderUid as string).then((process: any) => {
|
||||||
if (process) {
|
if (process) {
|
||||||
let customers: any[] = process.processData.customers;
|
const customers: any[] = [];
|
||||||
if (!customers) {
|
for (const customerUid of process.processData.customers.map((customer: any) => customer.uid)) {
|
||||||
customers = [];
|
customers.push({ uid: customerUid });
|
||||||
}
|
}
|
||||||
customers.push(processCreated.processData.uid);
|
customers.push({ uid: processCreated.processData.uid });
|
||||||
|
|
||||||
FolderService.updateFolder(process, { customers: customers }).then(() => {
|
FolderService.updateFolder(process, { customers: customers }).then(() => {
|
||||||
ToasterService.getInstance().success({
|
ToasterService.getInstance().success({
|
||||||
title: "Succès !",
|
title: "Succès !",
|
||||||
description: "Client ajouté avec succès au dossier"
|
description: "Client ajouté avec succès au dossier"
|
||||||
});
|
});
|
||||||
setTimeout(() => LoaderService.getInstance().hide(), 2000);
|
|
||||||
router.push(`/folders/${folderUid}`);
|
router.push(`/folders/${folderUid}`);
|
||||||
|
LoaderService.getInstance().hide();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -108,17 +108,20 @@ export default function AddClientToFolder(props: IProps) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
LoaderService.getInstance().show();
|
LoaderService.getInstance().show();
|
||||||
FolderService.getFolderByUid(folderUid as string, false, false).then((process: any) => {
|
FolderService.getFolderByUid(folderUid as string).then((process: any) => {
|
||||||
if (process) {
|
if (process) {
|
||||||
const customers: any[] = customersToLink.map((customer: any) => customer.uid);
|
const customers: any[] = [];
|
||||||
|
for (const customerUid of customersToLink.map((customer: any) => customer.uid)) {
|
||||||
|
customers.push({ uid: customerUid });
|
||||||
|
}
|
||||||
|
|
||||||
FolderService.updateFolder(process, { customers: customers }).then(() => {
|
FolderService.updateFolder(process, { customers: customers }).then(() => {
|
||||||
ToasterService.getInstance().success({
|
ToasterService.getInstance().success({
|
||||||
title: "Succès !",
|
title: "Succès !",
|
||||||
description: selectedCustomers.length > 1 ? "Clients associés avec succès au dossier" : "Client associé avec succès au dossier"
|
description: selectedCustomers.length > 1 ? "Clients associés avec succès au dossier" : "Client associé avec succès au dossier"
|
||||||
});
|
});
|
||||||
setTimeout(() => LoaderService.getInstance().hide(), 2000);
|
|
||||||
router.push(`/folders/${folderUid}`);
|
router.push(`/folders/${folderUid}`);
|
||||||
|
LoaderService.getInstance().hide();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -18,7 +18,6 @@ import backgroundImage from "@Assets/images/background_refonte.svg";
|
|||||||
import FolderService from "src/common/Api/LeCoffreApi/sdk/FolderService";
|
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 LoaderService from "src/common/Api/LeCoffreApi/sdk/Loader/LoaderService";
|
import LoaderService from "src/common/Api/LeCoffreApi/sdk/Loader/LoaderService";
|
||||||
import { DocumentData } from "../FolderInformation/ClientView/DocumentTables/types";
|
|
||||||
|
|
||||||
export default function AskDocuments() {
|
export default function AskDocuments() {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
@ -106,7 +105,7 @@ export default function AskDocuments() {
|
|||||||
|
|
||||||
// If those UIDs are already asked, filter them to not show them in the list and only
|
// If those UIDs are already asked, filter them to not show them in the list and only
|
||||||
// show the documents that are not asked yet
|
// show the documents that are not asked yet
|
||||||
const documentTypes = folder.deed!.document_types!.filter((documentType) => {
|
const documentTypes = folder.deed?.document_types?.filter((documentType) => {
|
||||||
if (userDocumentTypesUids.includes(documentType!.uid!)) return false;
|
if (userDocumentTypesUids.includes(documentType!.uid!)) return false;
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
@ -103,9 +103,9 @@ export default function CreateFolder(): JSX.Element {
|
|||||||
title: "Succès !",
|
title: "Succès !",
|
||||||
description: "Dossier créé avec succès"
|
description: "Dossier créé avec succès"
|
||||||
});
|
});
|
||||||
setTimeout(() => LoaderService.getInstance().hide(), 2000);
|
|
||||||
const folderUid: string = processCreated.processData.uid;
|
const folderUid: string = processCreated.processData.uid;
|
||||||
router.push(`/folders/${folderUid}`);
|
router.push(`/folders/${folderUid}`);
|
||||||
|
LoaderService.getInstance().hide();
|
||||||
});
|
});
|
||||||
} catch (backError) {
|
} catch (backError) {
|
||||||
if (!Array.isArray(backError)) return;
|
if (!Array.isArray(backError)) return;
|
||||||
|
@ -64,12 +64,6 @@ export default function DocumentTables(props: IProps) {
|
|||||||
// FilterBy folder.uid & depositor.uid
|
// FilterBy folder.uid & depositor.uid
|
||||||
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);
|
||||||
|
|
||||||
console.log('[DocumentTables] fetchDocuments: all documents for this folder/customer:', documents.map(doc => ({
|
|
||||||
uid: doc.uid,
|
|
||||||
status: doc.document_status,
|
|
||||||
type: doc.document_type?.name
|
|
||||||
})));
|
|
||||||
|
|
||||||
for (const document of documents) {
|
for (const document of documents) {
|
||||||
if (document.document_type) {
|
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;
|
||||||
@ -187,7 +181,6 @@ export default function DocumentTables(props: IProps) {
|
|||||||
|
|
||||||
const onDownloadCertificate = useCallback(async (doc: any) => {
|
const onDownloadCertificate = useCallback(async (doc: any) => {
|
||||||
try {
|
try {
|
||||||
console.log('[DocumentTables] onDownloadCertificate: doc', doc);
|
|
||||||
const certificateData: CertificateData = {
|
const certificateData: CertificateData = {
|
||||||
customer: {
|
customer: {
|
||||||
firstName: doc.depositor.first_name || doc.depositor.firstName || "N/A",
|
firstName: doc.depositor.first_name || doc.depositor.firstName || "N/A",
|
||||||
@ -221,13 +214,11 @@ export default function DocumentTables(props: IProps) {
|
|||||||
// Process only the files for this specific document
|
// Process only the files for this specific document
|
||||||
for (const file of documentProcess.processData.files) {
|
for (const file of documentProcess.processData.files) {
|
||||||
const fileProcess = await FileService.getFileByUid(file.uid);
|
const fileProcess = await FileService.getFileByUid(file.uid);
|
||||||
console.log('[DocumentTables] onDownloadCertificate: fileProcess', fileProcess);
|
|
||||||
|
|
||||||
const hash = fileProcess.lastUpdatedFileState.pcd_commitment.file_blob;
|
const hash = fileProcess.lastUpdatedFileState.pcd_commitment.file_blob;
|
||||||
certificateData.documentHash = hash;
|
certificateData.documentHash = hash;
|
||||||
|
|
||||||
const proof = await MessageBus.getInstance().generateMerkleProof(fileProcess.lastUpdatedFileState, 'file_blob');
|
const proof = await MessageBus.getInstance().generateMerkleProof(fileProcess.lastUpdatedFileState, 'file_blob');
|
||||||
console.log('[DocumentTables] onDownloadCertificate: proof', proof);
|
|
||||||
|
|
||||||
const metadata: Metadata = {
|
const metadata: Metadata = {
|
||||||
fileName: fileProcess.processData.file_name,
|
fileName: fileProcess.processData.file_name,
|
||||||
@ -242,8 +233,6 @@ export default function DocumentTables(props: IProps) {
|
|||||||
certificateData.metadata = metadata;
|
certificateData.metadata = metadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('[DocumentTables] onDownloadCertificate: certificateData', certificateData);
|
|
||||||
|
|
||||||
await PdfService.getInstance().downloadCertificate(certificateData);
|
await PdfService.getInstance().downloadCertificate(certificateData);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error downloading certificate:', error);
|
console.error('Error downloading certificate:', error);
|
||||||
|
@ -64,7 +64,7 @@ export default function ClientView(props: IProps) {
|
|||||||
(customerUid: string) => {
|
(customerUid: string) => {
|
||||||
if (!folder.uid) return;
|
if (!folder.uid) return;
|
||||||
LoaderService.getInstance().show();
|
LoaderService.getInstance().show();
|
||||||
FolderService.getFolderByUid(folder.uid, false, false).then((process: any) => {
|
FolderService.getFolderByUid(folder.uid).then((process: any) => {
|
||||||
if (process) {
|
if (process) {
|
||||||
const folder: any = process.processData;
|
const folder: any = process.processData;
|
||||||
|
|
||||||
@ -72,7 +72,7 @@ export default function ClientView(props: IProps) {
|
|||||||
const customers = folder.customers.filter((uid: string) => uid !== customerUid);
|
const customers = folder.customers.filter((uid: string) => uid !== customerUid);
|
||||||
|
|
||||||
FolderService.updateFolder(process, { customers: customers }).then(() => {
|
FolderService.updateFolder(process, { customers: customers }).then(() => {
|
||||||
setTimeout(() => LoaderService.getInstance().hide(), 2000);
|
LoaderService.getInstance().hide();
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ export default function DeleteFolderModal(props: IProps) {
|
|||||||
FolderService.getFolderByUid(folder.uid!).then((process: any) => {
|
FolderService.getFolderByUid(folder.uid!).then((process: any) => {
|
||||||
if (process) {
|
if (process) {
|
||||||
FolderService.updateFolder(process, { isDeleted: 'true' }).then(() => {
|
FolderService.updateFolder(process, { isDeleted: 'true' }).then(() => {
|
||||||
setTimeout(() => LoaderService.getInstance().hide(), 2000);
|
LoaderService.getInstance().hide();
|
||||||
resolve();
|
resolve();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -109,7 +109,6 @@ export default function FolderInformation(props: IProps) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// TODO: review
|
// TODO: review
|
||||||
LoaderService.getInstance().show();
|
|
||||||
return FolderService.getFolderByUid(folderUid).then(async (process: any) => {
|
return FolderService.getFolderByUid(folderUid).then(async (process: any) => {
|
||||||
if (process) {
|
if (process) {
|
||||||
const folder: any = process.processData;
|
const folder: any = process.processData;
|
||||||
@ -143,7 +142,6 @@ export default function FolderInformation(props: IProps) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
setFolder(folder);
|
setFolder(folder);
|
||||||
setTimeout(() => LoaderService.getInstance().hide(), 2000);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}, [folderUid]);
|
}, [folderUid]);
|
||||||
|
@ -41,7 +41,7 @@ export default function UpdateClient() {
|
|||||||
if (process) {
|
if (process) {
|
||||||
const customer: any = process.processData;
|
const customer: any = process.processData;
|
||||||
setCustomer(customer);
|
setCustomer(customer);
|
||||||
setTimeout(() => LoaderService.getInstance().hide(), 2000);
|
LoaderService.getInstance().hide();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -77,8 +77,8 @@ export default function UpdateClient() {
|
|||||||
if (process) {
|
if (process) {
|
||||||
// TODO: review - address
|
// TODO: review - address
|
||||||
CustomerService.updateCustomer(process, { contact: contact }).then(() => {
|
CustomerService.updateCustomer(process, { contact: contact }).then(() => {
|
||||||
setTimeout(() => LoaderService.getInstance().hide(), 2000);
|
|
||||||
router.push(backwardPath);
|
router.push(backwardPath);
|
||||||
|
LoaderService.getInstance().hide();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -54,10 +54,10 @@ export default function UpdateFolderMetadata() {
|
|||||||
FolderService.getFolderByUid(folderUid).then((process: any) => {
|
FolderService.getFolderByUid(folderUid).then((process: any) => {
|
||||||
if (process) {
|
if (process) {
|
||||||
FolderService.updateFolder(process, { ...values, deed: { uid: values["deed"] } }).then(() => {
|
FolderService.updateFolder(process, { ...values, deed: { uid: values["deed"] } }).then(() => {
|
||||||
setTimeout(() => LoaderService.getInstance().hide(), 2000);
|
|
||||||
router.push(Module.getInstance()
|
router.push(Module.getInstance()
|
||||||
.get()
|
.get()
|
||||||
.modules.pages.Folder.pages.FolderInformation.props.path.replace("[folderUid]", folderUid));
|
.modules.pages.Folder.pages.FolderInformation.props.path.replace("[folderUid]", folderUid));
|
||||||
|
LoaderService.getInstance().hide();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -75,7 +75,7 @@ export default function UpdateFolderMetadata() {
|
|||||||
if (process) {
|
if (process) {
|
||||||
const folder: any = process.processData;
|
const folder: any = process.processData;
|
||||||
setSelectedFolder(folder);
|
setSelectedFolder(folder);
|
||||||
setTimeout(() => LoaderService.getInstance().hide(), 2000);
|
LoaderService.getInstance().hide();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}, [folderUid]);
|
}, [folderUid]);
|
||||||
|
@ -64,9 +64,9 @@ export default function RolesCreate(props: IProps) {
|
|||||||
title: "Succès !",
|
title: "Succès !",
|
||||||
description: "Rôle créé avec succès"
|
description: "Rôle créé avec succès"
|
||||||
});
|
});
|
||||||
setTimeout(() => LoaderService.getInstance().hide(), 2000);
|
|
||||||
const role: any = processCreated.processData;
|
const role: any = processCreated.processData;
|
||||||
router.push(Module.getInstance().get().modules.pages.Roles.pages.RolesInformations.props.path.replace("[uid]", role.uid!));
|
router.push(Module.getInstance().get().modules.pages.Roles.pages.RolesInformations.props.path.replace("[uid]", role.uid!));
|
||||||
|
LoaderService.getInstance().hide();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ export default function RolesInformations() {
|
|||||||
if (process) {
|
if (process) {
|
||||||
const role: any = process.processData;
|
const role: any = process.processData;
|
||||||
resolve(role);
|
resolve(role);
|
||||||
setTimeout(() => LoaderService.getInstance().hide(), 2000);
|
LoaderService.getInstance().hide();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
@ -69,6 +69,8 @@ export default function RolesInformations() {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
const rulesGroups: RulesGroup[] = [
|
const rulesGroups: RulesGroup[] = [
|
||||||
{
|
{
|
||||||
uid: 'toto',
|
uid: 'toto',
|
||||||
@ -87,12 +89,14 @@ export default function RolesInformations() {
|
|||||||
updated_at: new Date(),
|
updated_at: new Date(),
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
*/
|
||||||
|
|
||||||
if (!role) return;
|
if (!role) return;
|
||||||
setRoleSelected(role);
|
setRoleSelected(role);
|
||||||
|
|
||||||
// TODO: review
|
// TODO: review
|
||||||
if (!role.rules) return;
|
if (!role.rules) return;
|
||||||
|
/*
|
||||||
const rulesCheckboxes = rulesGroups
|
const rulesCheckboxes = rulesGroups
|
||||||
.map((ruleGroup) => {
|
.map((ruleGroup) => {
|
||||||
if (ruleGroup.rules?.every((rule) => role.rules?.find((r: any) => r.uid === rule.uid))) {
|
if (ruleGroup.rules?.every((rule) => role.rules?.find((r: any) => r.uid === rule.uid))) {
|
||||||
@ -106,6 +110,8 @@ export default function RolesInformations() {
|
|||||||
const selectAll = rulesCheckboxes.every((rule) => rule.checked);
|
const selectAll = rulesCheckboxes.every((rule) => rule.checked);
|
||||||
setSelectAll(selectAll);
|
setSelectAll(selectAll);
|
||||||
setRulesGroupsCheckboxes(rulesCheckboxes);
|
setRulesGroupsCheckboxes(rulesCheckboxes);
|
||||||
|
*/
|
||||||
|
setRulesGroupsCheckboxes(role.rules);
|
||||||
}
|
}
|
||||||
|
|
||||||
getUser();
|
getUser();
|
||||||
|
@ -300,8 +300,6 @@ export default class PdfService {
|
|||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const fileReader = new FileReader();
|
const fileReader = new FileReader();
|
||||||
|
|
||||||
console.log("certificateFile", certificateFile);
|
|
||||||
|
|
||||||
fileReader.onload = async () => {
|
fileReader.onload = async () => {
|
||||||
try {
|
try {
|
||||||
// Read the metadata and get the validation data from the keywords
|
// Read the metadata and get the validation data from the keywords
|
||||||
@ -312,8 +310,6 @@ export default class PdfService {
|
|||||||
throw new Error("No keywords found in certificate");
|
throw new Error("No keywords found in certificate");
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(keywords);
|
|
||||||
|
|
||||||
if (keywords.length !== 3) {
|
if (keywords.length !== 3) {
|
||||||
throw new Error("Invalid keywords found in certificate");
|
throw new Error("Invalid keywords found in certificate");
|
||||||
}
|
}
|
||||||
@ -326,11 +322,6 @@ export default class PdfService {
|
|||||||
throw new Error("Invalid keywords found in certificate");
|
throw new Error("Invalid keywords found in certificate");
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("documentHash", documentHash);
|
|
||||||
console.log("commitmentId", commitmentId);
|
|
||||||
console.log("merkleProof", merkleProof);
|
|
||||||
|
|
||||||
|
|
||||||
resolve({ documentHash, commitmentId, merkleProof });
|
resolve({ documentHash, commitmentId, merkleProof });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
reject(error);
|
reject(error);
|
||||||
|
@ -23,7 +23,7 @@ export default class WatermarkService {
|
|||||||
return await this.addWatermarkToPdf(file);
|
return await this.addWatermarkToPdf(file);
|
||||||
} else {
|
} else {
|
||||||
// For other file types, return the original file
|
// For other file types, return the original file
|
||||||
console.log(`Watermark not supported for file type: ${fileType}`);
|
console.warn(`Watermark not supported for file type: ${fileType}`);
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
@ -6,6 +6,7 @@ import EventBus from './EventBus';
|
|||||||
import User from './User';
|
import User from './User';
|
||||||
|
|
||||||
import MapUtils from './MapUtils';
|
import MapUtils from './MapUtils';
|
||||||
|
|
||||||
import { FileBlob } from '../front/Api/Entities/types';
|
import { FileBlob } from '../front/Api/Entities/types';
|
||||||
|
|
||||||
export default class MessageBus {
|
export default class MessageBus {
|
||||||
@ -768,9 +769,6 @@ export default class MessageBus {
|
|||||||
console.error('[MessageBus] sendMessage: iframe not found');
|
console.error('[MessageBus] sendMessage: iframe not found');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (message.type === 'VALIDATE_MERKLE_PROOF') {
|
|
||||||
console.log('[MessageBus] sendMessage:', message);
|
|
||||||
}
|
|
||||||
iframe.contentWindow?.postMessage(message, targetOrigin);
|
iframe.contentWindow?.postMessage(message, targetOrigin);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -807,8 +805,6 @@ export default class MessageBus {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const message = event.data;
|
const message = event.data;
|
||||||
// console.log('[MessageBus] handleMessage:', message);
|
|
||||||
|
|
||||||
switch (message.type) {
|
switch (message.type) {
|
||||||
case 'LISTENING':
|
case 'LISTENING':
|
||||||
this.isListening = true;
|
this.isListening = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user