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