Fix some bugs - continue
This commit is contained in:
parent
f9abdd31cd
commit
39c14ff490
@ -25,6 +25,7 @@ export default class CustomerService {
|
||||
const privateFields: string[] = Object.keys(processData);
|
||||
privateFields.splice(privateFields.indexOf('uid'), 1);
|
||||
privateFields.splice(privateFields.indexOf('utype'), 1);
|
||||
privateFields.splice(privateFields.indexOf('isDeleted'), 1);
|
||||
|
||||
const roles: any = {
|
||||
demiurge: {
|
||||
@ -78,12 +79,12 @@ export default class CustomerService {
|
||||
}
|
||||
|
||||
public static getCustomers(): Promise<any[]> {
|
||||
return this.messageBus.getProcessesDecoded((publicValues: any) => publicValues['uid'] && publicValues['utype'] && publicValues['utype'] === 'customer');
|
||||
return this.messageBus.getProcessesDecoded((publicValues: any) => publicValues['uid'] && publicValues['utype'] && publicValues['utype'] === 'customer' && publicValues['isDeleted'] && publicValues['isDeleted'] === 'false');
|
||||
}
|
||||
|
||||
public static getCustomerByUid(uid: string): Promise<any> {
|
||||
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').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) {
|
||||
resolve(null);
|
||||
} else {
|
||||
@ -96,7 +97,7 @@ export default class CustomerService {
|
||||
|
||||
public static updateCustomer(process: any, newData: any): Promise<void> {
|
||||
return new Promise<void>((resolve: () => void, reject: (error: string) => void) => {
|
||||
this.messageBus.updateProcess(process.processId, 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;
|
||||
this.messageBus.notifyUpdate(process.processId, newStateId).then(() => {
|
||||
this.messageBus.validateState(process.processId, newStateId).then((_stateValidated) => {
|
||||
|
@ -27,6 +27,7 @@ export default class DeedTypeService {
|
||||
const privateFields: string[] = Object.keys(processData);
|
||||
privateFields.splice(privateFields.indexOf('uid'), 1);
|
||||
privateFields.splice(privateFields.indexOf('utype'), 1);
|
||||
privateFields.splice(privateFields.indexOf('isDeleted'), 1);
|
||||
|
||||
const roles: any = {
|
||||
demiurge: {
|
||||
@ -80,12 +81,12 @@ export default class DeedTypeService {
|
||||
}
|
||||
|
||||
public static getDeedTypes(): Promise<any[]> {
|
||||
return this.messageBus.getProcessesDecoded((publicValues: any) => publicValues['uid'] && publicValues['utype'] && publicValues['utype'] === 'deedType');
|
||||
return this.messageBus.getProcessesDecoded((publicValues: any) => publicValues['uid'] && publicValues['utype'] && publicValues['utype'] === 'deedType' && publicValues['isDeleted'] && publicValues['isDeleted'] === 'false');
|
||||
}
|
||||
|
||||
public static getDeedTypeByUid(uid: string, includeDocumentTypes: boolean = true): Promise<any> {
|
||||
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').then(async (processes: any[]) => {
|
||||
this.messageBus.getProcessesDecoded((publicValues: any) => publicValues['uid'] && publicValues['uid'] === uid && publicValues['utype'] && publicValues['utype'] === 'deedType' && publicValues['isDeleted'] && publicValues['isDeleted'] === 'false').then(async (processes: any[]) => {
|
||||
if (processes.length === 0) {
|
||||
resolve(null);
|
||||
} else {
|
||||
@ -112,7 +113,7 @@ export default class DeedTypeService {
|
||||
|
||||
public static updateDeedType(process: any, newData: any): Promise<void> {
|
||||
return new Promise<void>((resolve: () => void, reject: (error: string) => void) => {
|
||||
this.messageBus.updateProcess(process.processId, 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;
|
||||
this.messageBus.notifyUpdate(process.processId, newStateId).then(() => {
|
||||
this.messageBus.validateState(process.processId, newStateId).then((_stateValidated) => {
|
||||
|
@ -25,6 +25,7 @@ export default class DocumentService {
|
||||
const privateFields: string[] = Object.keys(processData);
|
||||
privateFields.splice(privateFields.indexOf('uid'), 1);
|
||||
privateFields.splice(privateFields.indexOf('utype'), 1);
|
||||
privateFields.splice(privateFields.indexOf('isDeleted'), 1);
|
||||
|
||||
const roles: any = {
|
||||
demiurge: {
|
||||
@ -78,12 +79,12 @@ export default class DocumentService {
|
||||
}
|
||||
|
||||
public static getDocuments(): Promise<any[]> {
|
||||
return this.messageBus.getProcessesDecoded((publicValues: any) => publicValues['uid'] && publicValues['utype'] && publicValues['utype'] === 'document');
|
||||
return this.messageBus.getProcessesDecoded((publicValues: any) => publicValues['uid'] && publicValues['utype'] && publicValues['utype'] === 'document' && publicValues['isDeleted'] && publicValues['isDeleted'] === 'false');
|
||||
}
|
||||
|
||||
public static getDocumentByUid(uid: string): Promise<any> {
|
||||
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').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) {
|
||||
resolve(null);
|
||||
} else {
|
||||
@ -96,7 +97,7 @@ export default class DocumentService {
|
||||
|
||||
public static updateDocument(process: any, newData: any): Promise<void> {
|
||||
return new Promise<void>((resolve: () => void, reject: (error: string) => void) => {
|
||||
this.messageBus.updateProcess(process.processId, 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;
|
||||
this.messageBus.notifyUpdate(process.processId, newStateId).then(() => {
|
||||
this.messageBus.validateState(process.processId, newStateId).then((_stateValidated) => {
|
||||
|
@ -25,6 +25,7 @@ export default class DocumentTypeService {
|
||||
const privateFields: string[] = Object.keys(processData);
|
||||
privateFields.splice(privateFields.indexOf('uid'), 1);
|
||||
privateFields.splice(privateFields.indexOf('utype'), 1);
|
||||
privateFields.splice(privateFields.indexOf('isDeleted'), 1);
|
||||
|
||||
const roles: any = {
|
||||
demiurge: {
|
||||
@ -78,12 +79,12 @@ export default class DocumentTypeService {
|
||||
}
|
||||
|
||||
public static getDocumentTypes(): Promise<any[]> {
|
||||
return this.messageBus.getProcessesDecoded((publicValues: any) => publicValues['uid'] && publicValues['utype'] && publicValues['utype'] === 'documentType');
|
||||
return this.messageBus.getProcessesDecoded((publicValues: any) => publicValues['uid'] && publicValues['utype'] && publicValues['utype'] === 'documentType' && publicValues['isDeleted'] && publicValues['isDeleted'] === 'false');
|
||||
}
|
||||
|
||||
public static getDocumentTypeByUid(uid: string): Promise<any> {
|
||||
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'] === 'documentType').then((processes: any[]) => {
|
||||
this.messageBus.getProcessesDecoded((publicValues: any) => publicValues['uid'] && publicValues['uid'] === uid && publicValues['utype'] && publicValues['utype'] === 'documentType' && publicValues['isDeleted'] && publicValues['isDeleted'] === 'false').then((processes: any[]) => {
|
||||
if (processes.length === 0) {
|
||||
resolve(null);
|
||||
} else {
|
||||
@ -96,7 +97,7 @@ export default class DocumentTypeService {
|
||||
|
||||
public static updateDocumentType(process: any, newData: any): Promise<void> {
|
||||
return new Promise<void>((resolve: () => void, reject: (error: string) => void) => {
|
||||
this.messageBus.updateProcess(process.processId, 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;
|
||||
this.messageBus.notifyUpdate(process.processId, newStateId).then(() => {
|
||||
this.messageBus.validateState(process.processId, newStateId).then((_stateValidated) => {
|
||||
|
@ -25,6 +25,7 @@ export default class FileService {
|
||||
const privateFields: string[] = Object.keys(processData);
|
||||
privateFields.splice(privateFields.indexOf('uid'), 1);
|
||||
privateFields.splice(privateFields.indexOf('utype'), 1);
|
||||
privateFields.splice(privateFields.indexOf('isDeleted'), 1);
|
||||
|
||||
const roles: any = {
|
||||
demiurge: {
|
||||
@ -78,12 +79,12 @@ export default class FileService {
|
||||
}
|
||||
|
||||
public static getFiles(): Promise<any[]> {
|
||||
return this.messageBus.getProcessesDecoded((publicValues: any) => publicValues['uid'] && publicValues['utype'] && publicValues['utype'] === 'file');
|
||||
return this.messageBus.getProcessesDecoded((publicValues: any) => publicValues['uid'] && publicValues['utype'] && publicValues['utype'] === 'file' && publicValues['isDeleted'] && publicValues['isDeleted'] === 'false');
|
||||
}
|
||||
|
||||
public static getFileByUid(uid: string): Promise<any> {
|
||||
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'] === 'file').then(async (processes: any[]) => {
|
||||
this.messageBus.getProcessesDecoded((publicValues: any) => publicValues['uid'] && publicValues['uid'] === uid && publicValues['utype'] && publicValues['utype'] === 'file' && publicValues['isDeleted'] && publicValues['isDeleted'] === 'false').then(async (processes: any[]) => {
|
||||
if (processes.length === 0) {
|
||||
resolve(null);
|
||||
} else {
|
||||
@ -96,7 +97,7 @@ export default class FileService {
|
||||
|
||||
public static updateFile(process: any, newData: any): Promise<void> {
|
||||
return new Promise<void>((resolve: () => void, reject: (error: string) => void) => {
|
||||
this.messageBus.updateProcess(process.processId, 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;
|
||||
this.messageBus.notifyUpdate(process.processId, newStateId).then(() => {
|
||||
this.messageBus.validateState(process.processId, newStateId).then((_stateValidated) => {
|
||||
|
@ -28,6 +28,7 @@ export default class FolderService {
|
||||
const privateFields: string[] = Object.keys(processData);
|
||||
privateFields.splice(privateFields.indexOf('uid'), 1);
|
||||
privateFields.splice(privateFields.indexOf('utype'), 1);
|
||||
privateFields.splice(privateFields.indexOf('isDeleted'), 1);
|
||||
|
||||
const roles: any = {
|
||||
demiurge: {
|
||||
@ -87,12 +88,12 @@ export default class FolderService {
|
||||
}
|
||||
|
||||
public static getFolders(): Promise<any[]> {
|
||||
return this.messageBus.getProcessesDecoded((publicValues: any) => publicValues['uid'] && publicValues['utype'] && publicValues['utype'] === 'folder');
|
||||
return this.messageBus.getProcessesDecoded((publicValues: any) => publicValues['uid'] && publicValues['utype'] && publicValues['utype'] === 'folder' && publicValues['isDeleted'] && publicValues['isDeleted'] === 'false');
|
||||
}
|
||||
|
||||
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) => {
|
||||
this.messageBus.getProcessesDecoded((publicValues: any) => publicValues['uid'] && publicValues['uid'] === uid && publicValues['utype'] && publicValues['utype'] === 'folder').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) {
|
||||
resolve(null);
|
||||
} else {
|
||||
@ -124,7 +125,7 @@ export default class FolderService {
|
||||
|
||||
public static updateFolder(process: any, newData: any): Promise<void> {
|
||||
return new Promise<void>((resolve: () => void, reject: (error: string) => void) => {
|
||||
this.messageBus.updateProcess(process.processId, 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;
|
||||
this.messageBus.notifyUpdate(process.processId, newStateId).then(() => {
|
||||
this.messageBus.validateState(process.processId, newStateId).then((_stateValidated) => {
|
||||
|
110
src/common/Api/LeCoffreApi/sdk/NoteService.ts
Normal file
110
src/common/Api/LeCoffreApi/sdk/NoteService.ts
Normal file
@ -0,0 +1,110 @@
|
||||
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
|
||||
import MessageBus from 'src/sdk/MessageBus';
|
||||
import User from 'src/sdk/User';
|
||||
|
||||
export default class NoteService {
|
||||
|
||||
private static readonly messageBus: MessageBus = MessageBus.getInstance();
|
||||
|
||||
private constructor() { }
|
||||
|
||||
public static createNote(noteData: any, validatorId: string): Promise<any> {
|
||||
const ownerId = User.getInstance().getPairingId()!;
|
||||
|
||||
const processData: any = {
|
||||
uid: uuidv4(),
|
||||
utype: 'note',
|
||||
isDeleted: 'false',
|
||||
created_at: new Date().toISOString(),
|
||||
updated_at: new Date().toISOString(),
|
||||
...noteData,
|
||||
};
|
||||
|
||||
const privateFields: string[] = Object.keys(processData);
|
||||
privateFields.splice(privateFields.indexOf('uid'), 1);
|
||||
privateFields.splice(privateFields.indexOf('utype'), 1);
|
||||
privateFields.splice(privateFields.indexOf('isDeleted'), 1);
|
||||
|
||||
const roles: any = {
|
||||
demiurge: {
|
||||
members: [...[ownerId], validatorId],
|
||||
validation_rules: [],
|
||||
storages: []
|
||||
},
|
||||
owner: {
|
||||
members: [ownerId],
|
||||
validation_rules: [
|
||||
{
|
||||
quorum: 0.5,
|
||||
fields: [...privateFields, 'roles', 'uid', 'utype'],
|
||||
min_sig_member: 1,
|
||||
},
|
||||
],
|
||||
storages: []
|
||||
},
|
||||
validator: {
|
||||
members: [validatorId],
|
||||
validation_rules: [
|
||||
{
|
||||
quorum: 0.5,
|
||||
fields: ['idCertified', 'roles'],
|
||||
min_sig_member: 1,
|
||||
},
|
||||
{
|
||||
quorum: 0.0,
|
||||
fields: [...privateFields],
|
||||
min_sig_member: 0,
|
||||
},
|
||||
],
|
||||
storages: []
|
||||
},
|
||||
apophis: {
|
||||
members: [ownerId],
|
||||
validation_rules: [],
|
||||
storages: []
|
||||
}
|
||||
};
|
||||
|
||||
return new Promise<any>((resolve: (processCreated: any) => void, reject: (error: string) => void) => {
|
||||
this.messageBus.createProcess(processData, privateFields, roles).then((processCreated: any) => {
|
||||
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) => {
|
||||
resolve(processCreated);
|
||||
}).catch(reject);
|
||||
}).catch(reject);
|
||||
}).catch(reject);
|
||||
});
|
||||
}
|
||||
|
||||
public static getNotes(): Promise<any[]> {
|
||||
return this.messageBus.getProcessesDecoded((publicValues: any) => publicValues['uid'] && publicValues['utype'] && publicValues['utype'] === 'note' && publicValues['isDeleted'] && publicValues['isDeleted'] === 'false');
|
||||
}
|
||||
|
||||
public static getNoteByUid(uid: string): Promise<any> {
|
||||
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'] === 'note' && publicValues['isDeleted'] && publicValues['isDeleted'] === 'false').then((processes: any[]) => {
|
||||
if (processes.length === 0) {
|
||||
resolve(null);
|
||||
} else {
|
||||
const process: any = processes[0];
|
||||
resolve(process);
|
||||
}
|
||||
}).catch(reject);
|
||||
});
|
||||
}
|
||||
|
||||
public static updateNote(process: any, newData: any): Promise<void> {
|
||||
return new Promise<void>((resolve: () => void, reject: (error: string) => void) => {
|
||||
this.messageBus.updateProcess(process.processId, { updated_at: new Date().toISOString(), ...newData }, [], null).then((processUpdated: any) => {
|
||||
const newStateId: string = processUpdated.diffs[0]?.state_id;
|
||||
this.messageBus.notifyUpdate(process.processId, newStateId).then(() => {
|
||||
this.messageBus.validateState(process.processId, newStateId).then((_stateValidated) => {
|
||||
resolve();
|
||||
}).catch(reject);
|
||||
}).catch(reject);
|
||||
}).catch(reject);
|
||||
});
|
||||
}
|
||||
}
|
@ -4,7 +4,6 @@ import { Document } from "le-coffre-resources/dist/Customer";
|
||||
import { useCallback, useMemo, useState } from "react";
|
||||
|
||||
import classes from "./classes.module.scss";
|
||||
import Files from "@Front/Api/LeCoffreApi/Customer/Files/Files";
|
||||
import { EDocumentStatus } from "le-coffre-resources/dist/Customer/Document";
|
||||
import { ToasterService } from "@Front/Components/DesignSystem/Toaster";
|
||||
import Confirm from "@Front/Components/DesignSystem/OldModal/Confirm";
|
||||
@ -93,21 +92,19 @@ export default function DepositDocumentComponent(props: IProps) {
|
||||
(resolve: () => void) => {
|
||||
FileService.getFileByUid(filedUid).then((process: any) => {
|
||||
if (process) {
|
||||
FileService.updateFile(process, { isDeleted: 'true' }).then(() => resolve());
|
||||
FileService.updateFile(process, { isDeleted: 'true' }).then(() => {
|
||||
DocumentService.getDocumentByUid(document.uid!).then((process: any) => {
|
||||
if (process) {
|
||||
DocumentService.updateDocument(process, { document_status: EDocumentStatus.ASKED }).then(() => resolve());
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
})
|
||||
.then(onChange)
|
||||
.then(() => ToasterService.getInstance().success({ title: "Succès !", description: "Fichier supprimé avec succès!" }))
|
||||
.catch((error) => ToasterService.getInstance().error({ title: "Erreur !", description: error.message }));
|
||||
|
||||
/* TODO: review
|
||||
return Files.getInstance()
|
||||
.delete(filedUid)
|
||||
.then(onChange)
|
||||
.then(() => ToasterService.getInstance().success({ title: "Succès !", description: "Fichier supprimé avec succès!" }))
|
||||
.catch((error) => ToasterService.getInstance().error({ title: "Erreur !", description: error.message }));
|
||||
*/
|
||||
},
|
||||
[onChange],
|
||||
);
|
||||
|
@ -1,94 +0,0 @@
|
||||
import React, { useEffect, useState, useRef } from 'react';
|
||||
import Modal from '@Front/Components/DesignSystem/Modal';
|
||||
import Typography, { ETypo } from '@Front/Components/DesignSystem/Typography';
|
||||
import Button, { EButtonstyletype, EButtonVariant } from '@Front/Components/DesignSystem/Button';
|
||||
|
||||
interface FormModalProps {
|
||||
isOpen: boolean;
|
||||
onClose: () => void;
|
||||
onSubmit: (file: File) => void;
|
||||
}
|
||||
|
||||
export default function FormModal({ isOpen, onClose, onSubmit }: FormModalProps) {
|
||||
const [selectedFile, setSelectedFile] = useState<File | null>(null);
|
||||
const fileInputRef = useRef<HTMLInputElement>(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (!isOpen) {
|
||||
setSelectedFile(null);
|
||||
if (fileInputRef.current) {
|
||||
fileInputRef.current.value = '';
|
||||
}
|
||||
}
|
||||
}, [isOpen]);
|
||||
|
||||
const handleFileChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const files = e.target.files;
|
||||
if (files && files.length > 0 && files[0] instanceof File) {
|
||||
setSelectedFile(files[0]);
|
||||
}
|
||||
};
|
||||
|
||||
const handleButtonClick = () => {
|
||||
if (fileInputRef.current) {
|
||||
fileInputRef.current.click();
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Modal
|
||||
isOpen={isOpen}
|
||||
onClose={onClose}
|
||||
title='Ajouter un document'
|
||||
>
|
||||
<div style={{ padding: '20px 0' }}>
|
||||
<div style={{ marginBottom: '20px' }}>
|
||||
<Typography typo={ETypo.TEXT_MD_SEMIBOLD} className="mb-2">
|
||||
Document
|
||||
</Typography>
|
||||
<div style={{ display: 'flex', alignItems: 'center' }}>
|
||||
<input
|
||||
ref={fileInputRef}
|
||||
type="file"
|
||||
accept="application/pdf"
|
||||
onChange={handleFileChange}
|
||||
style={{ display: 'none' }}
|
||||
/>
|
||||
<Button
|
||||
variant={EButtonVariant.SECONDARY}
|
||||
styletype={EButtonstyletype.OUTLINED}
|
||||
onClick={handleButtonClick}
|
||||
>
|
||||
Sélectionner un fichier PDF
|
||||
</Button>
|
||||
{selectedFile && (
|
||||
<div className="ml-3">
|
||||
<Typography typo={ETypo.TEXT_MD_REGULAR}>
|
||||
{selectedFile.name}
|
||||
</Typography>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style={{ display: 'flex', justifyContent: 'flex-end', gap: '12px', marginTop: '20px' }}>
|
||||
<Button
|
||||
variant={EButtonVariant.SECONDARY}
|
||||
styletype={EButtonstyletype.OUTLINED}
|
||||
onClick={onClose}
|
||||
>
|
||||
Annuler
|
||||
</Button>
|
||||
<Button
|
||||
variant={EButtonVariant.PRIMARY}
|
||||
styletype={EButtonstyletype.CONTAINED}
|
||||
onClick={() => selectedFile && onSubmit(selectedFile)}
|
||||
disabled={!selectedFile}
|
||||
>
|
||||
Enregistrer
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</Modal>
|
||||
);
|
||||
}
|
@ -26,7 +26,6 @@ import { EDocumentNotaryStatus } from "le-coffre-resources/dist/Notary/DocumentN
|
||||
import DepositOtherDocument from "@Front/Components/DesignSystem/DepositOtherDocument";
|
||||
|
||||
import AuthModal from "src/sdk/AuthModal";
|
||||
//import FormModal from "./FormModal";
|
||||
|
||||
import FolderService from "src/common/Api/LeCoffreApi/sdk/FolderService";
|
||||
import DocumentService from "src/common/Api/LeCoffreApi/sdk/DocumentService";
|
||||
@ -47,11 +46,15 @@ export default function ClientDashboard(props: IProps) {
|
||||
const [isAddDocumentModalVisible, setIsAddDocumentModalVisible] = useState<boolean>(false);
|
||||
|
||||
const [isAuthModalOpen, setIsAuthModalOpen] = useState(false);
|
||||
//const [isFormModalOpen, setIsFormModalOpen] = useState(false);
|
||||
|
||||
const fetchFolderAndCustomer = useCallback(async () => {
|
||||
let jwt: ICustomerJwtPayload | undefined;
|
||||
if (typeof document !== "undefined") {
|
||||
jwt = JwtService.getInstance().decodeCustomerJwt();
|
||||
}
|
||||
|
||||
// TODO: review
|
||||
const { folder, customer, file } = await new Promise<any>((resolve) => {
|
||||
const { folder, customer } = await new Promise<any>((resolve) => {
|
||||
FolderService.getFolderByUid(folderUid as string).then((process: any) => {
|
||||
if (process) {
|
||||
const folder: any = process.processData;
|
||||
@ -63,34 +66,6 @@ export default function ClientDashboard(props: IProps) {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/*
|
||||
MessageBus.getInstance().getFolders().then(async (folders) => {
|
||||
const folder: any = folders.find((folder: any) => folder.processData.uid === folderUid as string);
|
||||
if (folder) {
|
||||
const customer = folder.processData.customers
|
||||
.map((customer: any) => MapUtils.toJson(customer))
|
||||
.find((customer: any) => customer.uid === profileUid as string);
|
||||
|
||||
const file = await new Promise<any>((resolve: (file: any) => void) => {
|
||||
MessageBus.getInstance().getFiles().then((files: any) => {
|
||||
if (!files || files.length === 0) {
|
||||
resolve(null);
|
||||
} else {
|
||||
const file: any = files.find((file: any) => file.processData.folderUid === folderUid as string && file.processData.profileUid === profileUid as string);
|
||||
if (file) {
|
||||
resolve(file);
|
||||
} else {
|
||||
resolve(null);
|
||||
}
|
||||
}
|
||||
}).catch(() => resolve(null));
|
||||
});
|
||||
|
||||
resolve({ folder: folder.processData, customer, file: file ? file.processData : null });
|
||||
}
|
||||
});
|
||||
*/
|
||||
});
|
||||
|
||||
setCustomer(customer);
|
||||
@ -101,11 +76,6 @@ export default function ClientDashboard(props: IProps) {
|
||||
return { folder, customer };
|
||||
|
||||
/*
|
||||
let jwt: ICustomerJwtPayload | undefined;
|
||||
if (typeof document !== "undefined") {
|
||||
jwt = JwtService.getInstance().decodeCustomerJwt();
|
||||
}
|
||||
|
||||
const folder = await Folders.getInstance().getByUid(folderUid as string, {
|
||||
q: {
|
||||
office: true,
|
||||
@ -140,7 +110,7 @@ export default function ClientDashboard(props: IProps) {
|
||||
}, [folderUid]);
|
||||
|
||||
const fetchDocuments = useCallback(
|
||||
(customerUid: string | undefined) => {
|
||||
async (customerUid: string | undefined) => {
|
||||
/*
|
||||
const query: IGetDocumentsparams = {
|
||||
where: { depositor: { uid: customerUid }, folder_uid: folderUid as string },
|
||||
@ -166,15 +136,14 @@ export default function ClientDashboard(props: IProps) {
|
||||
.then((documents) => setDocuments(documents));
|
||||
*/
|
||||
|
||||
const files: any[] = (await FileService.getFiles()).map((p: any) => p.processData);
|
||||
|
||||
return DocumentService.getDocuments().then(async (processes: any[]) => {
|
||||
if (processes.length > 0) {
|
||||
const documents: any[] = processes.map((process: any) => process.processData);
|
||||
let documents: any[] = processes.map((process: any) => process.processData);
|
||||
|
||||
const files: any[] = (await FileService.getFiles())
|
||||
.map((p: any) => p.processData)
|
||||
.filter((file: any) => file.isDeleted === 'false');
|
||||
|
||||
// TODO: review - customerUid
|
||||
// FilterBy folder_uid
|
||||
documents = documents.filter((document: any) => document.folder.uid === folderUid);
|
||||
|
||||
for (const document of documents) {
|
||||
const p: any = await DocumentTypeService.getDocumentTypeByUid(document.document_type.uid);
|
||||
@ -222,23 +191,6 @@ export default function ClientDashboard(props: IProps) {
|
||||
setIsAddDocumentModalVisible(true);
|
||||
}, []);
|
||||
|
||||
/*
|
||||
const onDownloadFile = useCallback(() => {
|
||||
if (!file) {
|
||||
return;
|
||||
}
|
||||
const blob = new Blob([file.file.data], { type: file.file.type });
|
||||
const url = URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = 'document.pdf';
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
document.body.removeChild(a);
|
||||
URL.revokeObjectURL(url);
|
||||
}, [file]);
|
||||
*/
|
||||
|
||||
const renderBox = useCallback(() => {
|
||||
return (
|
||||
<DepositOtherDocument
|
||||
@ -267,19 +219,6 @@ export default function ClientDashboard(props: IProps) {
|
||||
<Typography typo={ETypo.TITLE_H4} color={ETypoColor.TEXT_PRIMARY}>
|
||||
Bonjour {customer?.contact?.first_name.concat(" ", customer?.contact?.last_name)}
|
||||
</Typography>
|
||||
|
||||
{/*
|
||||
{file && (
|
||||
<Button
|
||||
variant={EButtonVariant.SECONDARY}
|
||||
styletype={EButtonstyletype.OUTLINED}
|
||||
onClick={() => onDownloadFile()}
|
||||
>
|
||||
Télécharger le document
|
||||
</Button>
|
||||
)}
|
||||
*/}
|
||||
|
||||
<Tag color={ETagColor.INFO} label={folder?.deed?.deed_type?.name ?? ""} />
|
||||
<div className={classes["office-container"]}>
|
||||
<Typography typo={ETypo.TEXT_MD_REGULAR} color={ETypoColor.TEXT_SECONDARY}>
|
||||
@ -372,57 +311,8 @@ export default function ClientDashboard(props: IProps) {
|
||||
isOpen={isAuthModalOpen}
|
||||
onClose={() => {
|
||||
setIsAuthModalOpen(false);
|
||||
/*
|
||||
setTimeout(() => {
|
||||
setIsFormModalOpen(true);
|
||||
}, 500);
|
||||
*/
|
||||
}}
|
||||
/>}
|
||||
|
||||
{/*
|
||||
<FormModal
|
||||
isOpen={isFormModalOpen}
|
||||
onClose={() => setIsFormModalOpen(false)}
|
||||
onSubmit={(file: any) => {
|
||||
if (file) {
|
||||
const reader = new FileReader();
|
||||
reader.onload = (event) => {
|
||||
if (event.target?.result) {
|
||||
const arrayBuffer = event.target.result as ArrayBuffer;
|
||||
const uint8Array = new Uint8Array(arrayBuffer);
|
||||
|
||||
const fileBlob = {
|
||||
type: file.type,
|
||||
data: uint8Array
|
||||
};
|
||||
|
||||
const fileData = {
|
||||
uid: uuidv4(),
|
||||
utype_ff: 'file',
|
||||
folderUid: folderUid as string,
|
||||
profileUid: profileUid as string,
|
||||
file: fileBlob
|
||||
}
|
||||
|
||||
/ *
|
||||
MessageBus.getInstance().isReady().then(() => {
|
||||
MessageBus.getInstance().createFile(fileData, [], []).then((processCreated: any) => {
|
||||
MessageBus.getInstance().notifyUpdate(processCreated.processId, processCreated.process.states[0].state_id).then(() => {
|
||||
MessageBus.getInstance().validateState(processCreated.processId, processCreated.process.states[0].state_id).then((_stateValidated: any) => {
|
||||
setIsFormModalOpen(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
* /
|
||||
}
|
||||
};
|
||||
reader.readAsArrayBuffer(file);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
*/}
|
||||
</div>
|
||||
</DefaultCustomerDashboard>
|
||||
);
|
||||
|
@ -1,6 +1,5 @@
|
||||
import ChevronIcon from "@Assets/Icons/chevron.svg";
|
||||
import PenICon from "@Assets/Icons/pen.svg";
|
||||
import DeedTypes from "@Front/Api/LeCoffreApi/Notary/DeedTypes/DeedTypes";
|
||||
import Button, { EButtonstyletype, EButtonVariant } from "@Front/Components/DesignSystem/Button";
|
||||
import { IOption } from "@Front/Components/DesignSystem/Dropdown/DropdownMenu/DropdownOption";
|
||||
import Form from "@Front/Components/DesignSystem/Form";
|
||||
@ -51,14 +50,13 @@ export default function DeedTypesInformations(props: IProps) {
|
||||
}, []);
|
||||
|
||||
const deleteDeedType = useCallback(async () => {
|
||||
await DeedTypes.getInstance().put(
|
||||
deedTypeUid as string,
|
||||
DeedType.hydrate<DeedType>({
|
||||
uid: deedTypeUid as string,
|
||||
archived_at: new Date(),
|
||||
}),
|
||||
);
|
||||
DeedTypeService.getDeedTypeByUid(deedTypeUid as string).then((process: any) => {
|
||||
if (process) {
|
||||
DeedTypeService.updateDeedType(process, { archived_at: new Date().toISOString() }).then(() => {
|
||||
router.push(Module.getInstance().get().modules.pages.DeedTypes.props.path);
|
||||
});
|
||||
}
|
||||
});
|
||||
}, [deedTypeUid, router]);
|
||||
|
||||
useEffect(() => {
|
||||
@ -119,7 +117,6 @@ export default function DeedTypesInformations(props: IProps) {
|
||||
DeedTypeService.updateDeedType(process, { document_types: document_types }).then(() => {
|
||||
closeSaveModal();
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
}, [closeSaveModal, deedTypeUid, selectedDocuments]);
|
||||
|
@ -13,10 +13,10 @@ import BasePage from "../../Base";
|
||||
import classes from "./classes.module.scss";
|
||||
import Customer from "le-coffre-resources/dist/Customer";
|
||||
import Note from "le-coffre-resources/dist/Customer/Note";
|
||||
import Notes from "@Front/Api/LeCoffreApi/Customer/Notes/Notes";
|
||||
|
||||
import FolderService from "src/common/Api/LeCoffreApi/sdk/FolderService";
|
||||
import CustomerService from "src/common/Api/LeCoffreApi/sdk/CustomerService";
|
||||
import NoteService from "src/common/Api/LeCoffreApi/sdk/NoteService";
|
||||
|
||||
type IProps = {};
|
||||
|
||||
@ -108,14 +108,22 @@ class CreateCustomerNoteClass extends BasePage<IPropsClass, IState> {
|
||||
if (!this.state.folder || !this.state.customer) {
|
||||
throw new Error("Folder or customer not found");
|
||||
}
|
||||
const note = {
|
||||
content: values["content"],
|
||||
folder: this.state.folder,
|
||||
customer: this.state.customer,
|
||||
};
|
||||
|
||||
await Notes.getInstance().post(note);
|
||||
// TODO: review
|
||||
const noteData: any = {
|
||||
content: values["content"],
|
||||
folder: {
|
||||
uid: this.state.folder.uid
|
||||
},
|
||||
customer: {
|
||||
uid: this.state.customer.uid
|
||||
}
|
||||
};
|
||||
const validatorId: string = '884cb36a346a79af8697559f16940141f068bdf1656f88fa0df0e9ecd7311fb8:0';
|
||||
|
||||
NoteService.createNote(noteData, validatorId).then(() => {
|
||||
this.props.router.push(this.backwardPath);
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
|
@ -12,7 +12,8 @@ import { useCallback } from "react";
|
||||
import { AnchorStatus } from "../..";
|
||||
import classes from "./classes.module.scss";
|
||||
import DeleteCustomerModal from "./DeleteCustomerModal";
|
||||
import Documents from "@Front/Api/LeCoffreApi/Notary/Documents/Documents";
|
||||
|
||||
import DocumentService from "src/common/Api/LeCoffreApi/sdk/DocumentService";
|
||||
|
||||
type IProps = {
|
||||
customer: Customer;
|
||||
@ -35,17 +36,25 @@ export default function ClientBox(props: IProps) {
|
||||
}, [customer.uid, folderUid]);
|
||||
|
||||
const handleDelete = useCallback(
|
||||
async (customerUid: string) => {
|
||||
console.log(customer);
|
||||
const documents = await Documents.getInstance().get({ where: { depositor_uid: customerUid, folder_uid: folderUid } });
|
||||
console.log(documents);
|
||||
(customerUid: string) => {
|
||||
DocumentService.getDocuments().then((processes: any[]) => {
|
||||
if (processes.length > 0) {
|
||||
let documents: any[] = processes.map((process: any) => process.processData);
|
||||
|
||||
// FilterBy depositor_uid & folder_uid
|
||||
documents = documents.filter((document: any) => document.depositor.uid === customerUid && document.folder.uid === folderUid);
|
||||
|
||||
if (documents && documents.length > 0) {
|
||||
closeDeleteModal();
|
||||
openErrorModal();
|
||||
return;
|
||||
}
|
||||
|
||||
props.onDelete(customerUid);
|
||||
} else {
|
||||
props.onDelete(customerUid);
|
||||
}
|
||||
});
|
||||
},
|
||||
[closeDeleteModal, customer.documents, openErrorModal, props, customer, folderUid],
|
||||
);
|
||||
|
@ -1,9 +1,10 @@
|
||||
import Documents from "@Front/Api/LeCoffreApi/Notary/Documents/Documents";
|
||||
import Modal from "@Front/Components/DesignSystem/Modal";
|
||||
import { ToasterService } from "@Front/Components/DesignSystem/Toaster";
|
||||
import Typography, { ETypo } from "@Front/Components/DesignSystem/Typography";
|
||||
import React, { useCallback } from "react";
|
||||
|
||||
import DocumentService from "src/common/Api/LeCoffreApi/sdk/DocumentService";
|
||||
|
||||
type IProps = {
|
||||
documentUid: string;
|
||||
isOpen: boolean;
|
||||
@ -16,8 +17,14 @@ export default function DeleteAskedDocumentModal(props: IProps) {
|
||||
|
||||
const onDelete = useCallback(
|
||||
() =>
|
||||
Documents.getInstance()
|
||||
.delete(documentUid)
|
||||
new Promise<void>(
|
||||
(resolve: () => void) => {
|
||||
DocumentService.getDocumentByUid(documentUid).then((process: any) => {
|
||||
if (process) {
|
||||
DocumentService.updateDocument(process, { isDeleted: 'true' }).then(() => resolve());
|
||||
}
|
||||
});
|
||||
})
|
||||
.then(() => onDeleteSuccess(documentUid))
|
||||
.then(() => ToasterService.getInstance().success({ title: "Succès !", description: "Le document a été supprimé avec succès." }))
|
||||
.then(onClose)
|
||||
|
@ -25,6 +25,8 @@ import DeleteSentDocumentModal from "./DeleteSentDocumentModal";
|
||||
import DocumentService from "src/common/Api/LeCoffreApi/sdk/DocumentService";
|
||||
import DocumentTypeService from "src/common/Api/LeCoffreApi/sdk/DocumentTypeService";
|
||||
|
||||
import MessageBus from "src/sdk/MessageBus";
|
||||
|
||||
type IProps = {
|
||||
customerUid: string;
|
||||
folderUid: string;
|
||||
@ -54,7 +56,9 @@ export default function DocumentTables(props: IProps) {
|
||||
const deleteSentDocumentModal = useOpenable();
|
||||
|
||||
const fetchDocuments = useCallback(
|
||||
() =>
|
||||
() => {
|
||||
setDocuments([]);
|
||||
|
||||
DocumentService.getDocuments().then(async (processes: any[]) => {
|
||||
if (processes.length > 0) {
|
||||
let documents: any[] = processes.map((process: any) => process.processData);
|
||||
@ -62,24 +66,26 @@ export default function DocumentTables(props: IProps) {
|
||||
// FilterBy folder.uid & depositor.uid
|
||||
documents = documents.filter((document: any) => document.folder.uid === folderUid && document.depositor.uid === customerUid);
|
||||
|
||||
const ps: any[] = await MessageBus.getInstance().getFiles();
|
||||
|
||||
for (const document of documents) {
|
||||
const documentTypeUid: string = document.document_type.uid;
|
||||
|
||||
const p: any = await DocumentTypeService.getDocumentTypeByUid(documentTypeUid);
|
||||
document.document_type = p.processData;
|
||||
const p1: any = await DocumentTypeService.getDocumentTypeByUid(documentTypeUid);
|
||||
document.document_type = p1.processData;
|
||||
|
||||
const p2: any = ps.find((p2: any) => p2.processData.document.get('uid') === document.uid);
|
||||
if (p2) {
|
||||
document.files = [p2.processData];
|
||||
}
|
||||
}
|
||||
|
||||
setDocuments(documents);
|
||||
} else {
|
||||
setDocuments([]);
|
||||
}
|
||||
})
|
||||
/*
|
||||
Documents.getInstance()
|
||||
.get({
|
||||
where: { folder: { uid: folderUid }, depositor: { uid: customerUid } },
|
||||
include: { files: true, document_type: true },
|
||||
})
|
||||
.then(setDocuments)
|
||||
.catch(console.warn)*/,
|
||||
},
|
||||
[customerUid, folderUid],
|
||||
);
|
||||
|
||||
@ -116,21 +122,23 @@ export default function DocumentTables(props: IProps) {
|
||||
[deleteSentDocumentModal],
|
||||
);
|
||||
|
||||
const onDownload = useCallback((doc: Document) => {
|
||||
const onDownload = useCallback((doc: any /* Document */) => {
|
||||
const file = doc.files?.[0];
|
||||
if (!file || !file?.uid) return;
|
||||
if (!file) return;
|
||||
|
||||
return Files.getInstance()
|
||||
.download(file.uid)
|
||||
.then((blob) => {
|
||||
return new Promise<void>((resolve: () => void) => {
|
||||
const blob = new Blob([file.fileBlob.data], { type: file.fileBlob.type });
|
||||
const url = URL.createObjectURL(blob);
|
||||
const a = document.createElement("a");
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = file.file_name ?? "file";
|
||||
a.download = file.file_name;
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
document.body.removeChild(a);
|
||||
URL.revokeObjectURL(url);
|
||||
})
|
||||
.catch((e) => console.warn(e));
|
||||
|
||||
resolve();
|
||||
}).catch((e) => console.warn(e));
|
||||
}, []);
|
||||
|
||||
const onDownloadFileNotary = useCallback((doc: DocumentNotary) => {
|
||||
|
@ -7,14 +7,15 @@ import Customer from "le-coffre-resources/dist/Customer";
|
||||
import { EDocumentStatus } from "le-coffre-resources/dist/Customer/Document";
|
||||
import { OfficeFolder } from "le-coffre-resources/dist/Notary";
|
||||
import Link from "next/link";
|
||||
import { useCallback, useEffect, useMemo, useState } from "react";
|
||||
import { useCallback, useMemo, useState } from "react";
|
||||
|
||||
import { AnchorStatus } from "..";
|
||||
import classes from "./classes.module.scss";
|
||||
import ClientBox from "./ClientBox";
|
||||
import DocumentTables from "./DocumentTables";
|
||||
import EmailReminder from "./EmailReminder";
|
||||
import DocumentsNotary from "@Front/Api/LeCoffreApi/Notary/DocumentsNotary/DocumentsNotary";
|
||||
|
||||
import FolderService from "src/common/Api/LeCoffreApi/sdk/FolderService";
|
||||
|
||||
type IProps = {
|
||||
folder: OfficeFolder;
|
||||
@ -59,26 +60,21 @@ export default function ClientView(props: IProps) {
|
||||
);
|
||||
|
||||
const handleClientDelete = useCallback(
|
||||
async (customerUid: string) => {
|
||||
(customerUid: string) => {
|
||||
if (!folder.uid) return;
|
||||
const documentsNotary = await DocumentsNotary.getInstance().get({
|
||||
where: { customer: { uid: customerUid }, folder: { uid: folder.uid } },
|
||||
});
|
||||
|
||||
if (documentsNotary.length > 0) {
|
||||
documentsNotary.forEach(async (doc) => {
|
||||
await DocumentsNotary.getInstance().delete(doc.uid!);
|
||||
FolderService.getFolderByUid(folder.uid, false, false).then((process: any) => {
|
||||
if (process) {
|
||||
const folder: any = process.processData;
|
||||
|
||||
// FilterBy customerUid
|
||||
const customers = folder.customers.filter((uid: string) => uid !== customerUid);
|
||||
|
||||
FolderService.updateFolder(process, { customers: customers }).then(() => {
|
||||
window.location.reload();
|
||||
});
|
||||
}
|
||||
|
||||
Folders.getInstance().put(
|
||||
folder.uid,
|
||||
OfficeFolder.hydrate<OfficeFolder>({
|
||||
...folder,
|
||||
customers: folder.customers?.filter((customer: any) => customer.uid !== customerUid),
|
||||
}),
|
||||
);
|
||||
window.location.reload();
|
||||
});
|
||||
},
|
||||
[folder],
|
||||
);
|
||||
|
@ -1,4 +1,3 @@
|
||||
import Folders from "@Front/Api/LeCoffreApi/Notary/Folders/Folders";
|
||||
import Modal from "@Front/Components/DesignSystem/Modal";
|
||||
import Typography, { ETypo } from "@Front/Components/DesignSystem/Typography";
|
||||
import Module from "@Front/Config/Module";
|
||||
@ -6,7 +5,7 @@ import { OfficeFolder } from "le-coffre-resources/dist/Notary";
|
||||
import { useRouter } from "next/router";
|
||||
import React, { useCallback } from "react";
|
||||
|
||||
import MessageBus from "src/sdk/MessageBus";
|
||||
import FolderService from "src/common/Api/LeCoffreApi/sdk/FolderService";
|
||||
|
||||
type IProps = {
|
||||
isOpen: boolean;
|
||||
@ -23,16 +22,16 @@ export default function DeleteFolderModal(props: IProps) {
|
||||
if ((folder?.customers?.length ?? 0) > 0 || (folder?.documents?.length ?? 0) > 0)
|
||||
return console.warn("Cannot delete folder with customers or documents");
|
||||
|
||||
/* TODO: review
|
||||
return Folders.getInstance()
|
||||
.delete(folder.uid)
|
||||
return new Promise<void>(
|
||||
(resolve: () => void) => {
|
||||
FolderService.getFolderByUid(folder.uid!).then((process: any) => {
|
||||
if (process) {
|
||||
FolderService.updateFolder(process, { isDeleted: 'true' }).then(() => resolve());
|
||||
}
|
||||
});
|
||||
})
|
||||
.then(() => router.push(Module.getInstance().get().modules.pages.Folder.props.path))
|
||||
.then(onClose);
|
||||
*/
|
||||
|
||||
MessageBus.getInstance().isReady().then(() => {
|
||||
//MessageBus.getInstance().deleteFolder(folder.uid).then(() => router.push(Module.getInstance().get().modules.pages.Folder.props.path)).then(onClose);
|
||||
});
|
||||
}, [folder, router, onClose]);
|
||||
|
||||
return (
|
||||
|
@ -22,6 +22,7 @@ import NoClientView from "./NoClientView";
|
||||
import AnchoringProcessingInfo from "./elements/AnchoringProcessingInfo";
|
||||
|
||||
import FolderService from "src/common/Api/LeCoffreApi/sdk/FolderService";
|
||||
import NoteService from "src/common/Api/LeCoffreApi/sdk/NoteService";
|
||||
|
||||
export enum AnchorStatus {
|
||||
"VERIFIED_ON_CHAIN" = "VERIFIED_ON_CHAIN",
|
||||
@ -109,7 +110,22 @@ export default function FolderInformation(props: IProps) {
|
||||
return FolderService.getFolderByUid(folderUid).then((process: any) => {
|
||||
if (process) {
|
||||
const folder: any = process.processData;
|
||||
|
||||
NoteService.getNotes().then((processes: any) => {
|
||||
if (processes.length > 0) {
|
||||
let notes: any[] = processes.map((process: any) => process.processData);
|
||||
|
||||
// FilterBy folder.uid
|
||||
notes = notes.filter((note: any) => note.folder.uid === folderUid);
|
||||
|
||||
if (notes.length > 0) {
|
||||
folder.notes = notes;
|
||||
}
|
||||
}
|
||||
|
||||
setFolder(folder);
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
}, [folderUid]);
|
||||
|
@ -11,7 +11,8 @@ import { NextRouter, useRouter } from "next/router";
|
||||
import BasePage from "../../Base";
|
||||
import classes from "./classes.module.scss";
|
||||
import Note from "le-coffre-resources/dist/Customer/Note";
|
||||
import Notes from "@Front/Api/LeCoffreApi/Customer/Notes/Notes";
|
||||
|
||||
import NoteService from "src/common/Api/LeCoffreApi/sdk/NoteService";
|
||||
|
||||
type IProps = {};
|
||||
|
||||
@ -66,13 +67,10 @@ class UpdateCustomerNoteClass extends BasePage<IPropsClass, IState> {
|
||||
}
|
||||
|
||||
public override async componentDidMount() {
|
||||
const query = {
|
||||
q: {
|
||||
customer: "true",
|
||||
folder: "true",
|
||||
},
|
||||
};
|
||||
const note = await Notes.getInstance().getByUid(this.props.noteUid, query);
|
||||
NoteService.getNoteByUid(this.props.noteUid).then((process: any) => {
|
||||
if (process) {
|
||||
const note: any = process.processData;
|
||||
|
||||
// const folder = await Folders.getInstance().getByUid(this.props.folderUid, { note: true });
|
||||
//get the note of the folder that has customer_uid = this.props.customer.uid
|
||||
// const folderNote = folder.notes?.find((note) => note.customer?.uid === this.props.customerUid);
|
||||
@ -83,18 +81,19 @@ class UpdateCustomerNoteClass extends BasePage<IPropsClass, IState> {
|
||||
.modules.pages.Folder.pages.FolderInformation.props.path.replace("[folderUid]", note.folder?.uid!),
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private async onFormSubmit(e: React.FormEvent<HTMLFormElement> | null, values: { [key: string]: string }) {
|
||||
try {
|
||||
const note = {
|
||||
content: values["content"],
|
||||
};
|
||||
NoteService.getNoteByUid(this.props.noteUid).then((process: any) => {
|
||||
if (process) {
|
||||
|
||||
await Notes.getInstance().put(this.props.noteUid, note);
|
||||
NoteService.updateNote(process, { content: values["content"] }).then(() => {
|
||||
this.props.router.push(this.state.backwardPath);
|
||||
|
||||
// await Folders.getInstance().put(this.props.folderUid, values);
|
||||
// this.props.router.push(this.backwardPath);
|
||||
});
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
import LeftArrowIcon from "@Assets/Icons/left-arrow.svg";
|
||||
import RightArrowIcon from "@Assets/Icons/right-arrow.svg";
|
||||
import Documents from "@Front/Api/LeCoffreApi/Notary/Documents/Documents";
|
||||
import Button, { EButtonstyletype, EButtonVariant } from "@Front/Components/DesignSystem/Button";
|
||||
import FilePreview from "@Front/Components/DesignSystem/FilePreview";
|
||||
import Confirm from "@Front/Components/DesignSystem/OldModal/Confirm";
|
||||
@ -15,12 +14,11 @@ import React from "react";
|
||||
|
||||
import BasePage from "../../Base";
|
||||
import classes from "./classes.module.scss";
|
||||
import Files from "@Front/Api/LeCoffreApi/Notary/Files/Files";
|
||||
import TextAreaField from "@Front/Components/DesignSystem/Form/TextareaField";
|
||||
import MessageBox from "@Front/Components/Elements/MessageBox";
|
||||
|
||||
import DocumentService from "src/common/Api/LeCoffreApi/sdk/DocumentService";
|
||||
import FileService from "src/common/Api/LeCoffreApi/sdk/FileService";
|
||||
|
||||
import MessageBus from "src/sdk/MessageBus";
|
||||
|
||||
type IProps = {};
|
||||
@ -217,16 +215,12 @@ class ViewDocumentsClass extends BasePage<IPropsClass, IState> {
|
||||
if (process) {
|
||||
const document: any = process.processData;
|
||||
|
||||
const processes: any[] = await MessageBus.getInstance().getFiles();
|
||||
const process1: any = processes.find((process: any) => process.processData.document.get('uid') === document.uid);
|
||||
const ps: any[] = await MessageBus.getInstance().getFiles();
|
||||
const p: any = ps.find((p: any) => p.processData.document.get('uid') === document.uid);
|
||||
if (p) {
|
||||
|
||||
/*
|
||||
const files: any[] = (await FileService.getFiles())
|
||||
.map((p: any) => p.processData)
|
||||
.filter((file: any) => file.isDeleted === 'false');
|
||||
*/
|
||||
|
||||
document.files = [process1.processData];
|
||||
document.files = [p.processData];
|
||||
}
|
||||
|
||||
resolve(document);
|
||||
}
|
||||
@ -282,24 +276,8 @@ class ViewDocumentsClass extends BasePage<IPropsClass, IState> {
|
||||
a.click();
|
||||
document.body.removeChild(a);
|
||||
URL.revokeObjectURL(url);
|
||||
|
||||
}
|
||||
|
||||
/* TODO: review
|
||||
private downloadFile() {
|
||||
if (!this.state.fileBlob) return;
|
||||
const url = window.URL.createObjectURL(this.state.fileBlob);
|
||||
const a = document.createElement("a");
|
||||
a.style.display = "none";
|
||||
a.href = url;
|
||||
// the filename you want
|
||||
a.download = this.state.selectedFile?.file_name as string;
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
window.URL.revokeObjectURL(url);
|
||||
}
|
||||
*/
|
||||
|
||||
private getRandomPercentageForOcr() {
|
||||
// find diff
|
||||
let difference = 100 - 90;
|
||||
@ -360,8 +338,9 @@ class ViewDocumentsClass extends BasePage<IPropsClass, IState> {
|
||||
|
||||
private async refuseDocument() {
|
||||
try {
|
||||
await Documents.getInstance().refuse(this.props.documentUid, this.state.refuseText);
|
||||
|
||||
DocumentService.getDocumentByUid(this.props.documentUid).then((process: any) => {
|
||||
if (process) {
|
||||
DocumentService.updateDocument(process, { document_status: EDocumentStatus.REFUSED, refused_reason: this.state.refuseText }).then(() => {
|
||||
this.props.router.push(
|
||||
Module.getInstance()
|
||||
.get()
|
||||
@ -369,6 +348,9 @@ class ViewDocumentsClass extends BasePage<IPropsClass, IState> {
|
||||
"?customerUid=" +
|
||||
this.state.document?.depositor?.uid,
|
||||
);
|
||||
});
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
@ -376,10 +358,9 @@ class ViewDocumentsClass extends BasePage<IPropsClass, IState> {
|
||||
|
||||
private async validateDocument() {
|
||||
try {
|
||||
await Documents.getInstance().put(this.props.documentUid, {
|
||||
document_status: EDocumentStatus.VALIDATED,
|
||||
});
|
||||
|
||||
DocumentService.getDocumentByUid(this.props.documentUid).then((process: any) => {
|
||||
if (process) {
|
||||
DocumentService.updateDocument(process, { document_status: EDocumentStatus.VALIDATED }).then(() => {
|
||||
this.props.router.push(
|
||||
Module.getInstance()
|
||||
.get()
|
||||
@ -387,6 +368,9 @@ class ViewDocumentsClass extends BasePage<IPropsClass, IState> {
|
||||
"?customerUid=" +
|
||||
this.state.document?.depositor?.uid,
|
||||
);
|
||||
});
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
|
@ -100,89 +100,6 @@ export default class MessageBus {
|
||||
});
|
||||
}
|
||||
|
||||
public createFile(fileData: any, stakeholdersId: string[], customersId: string[]): Promise<any> {
|
||||
return new Promise<any>((resolve: (processCreated: any) => void, reject: (error: string) => void) => {
|
||||
this.checkToken().then(() => {
|
||||
const messageId = `CREATE_FILE_${uuidv4()}`;
|
||||
|
||||
const unsubscribe = EventBus.getInstance().on('PROCESS_CREATED', (responseId: string, processCreated: any) => {
|
||||
if (responseId !== messageId) {
|
||||
return;
|
||||
}
|
||||
unsubscribe();
|
||||
resolve(processCreated);
|
||||
});
|
||||
|
||||
const unsubscribeError = EventBus.getInstance().on('ERROR_PROCESS_CREATED', (responseId: string, error: string) => {
|
||||
if (responseId !== messageId) {
|
||||
return;
|
||||
}
|
||||
unsubscribeError();
|
||||
reject(error);
|
||||
});
|
||||
|
||||
const user = User.getInstance();
|
||||
const accessToken = user.getAccessToken()!;
|
||||
|
||||
const ownerId = user.getPairingId()!;
|
||||
const fileDataFields: string[] = Object.keys(fileData);
|
||||
|
||||
this.sendMessage({
|
||||
type: 'CREATE_PROCESS',
|
||||
processData: fileData,
|
||||
privateFields: fileDataFields,
|
||||
roles: {
|
||||
demiurge: {
|
||||
members: [ownerId],
|
||||
validation_rules: [],
|
||||
storages: []
|
||||
},
|
||||
owner: {
|
||||
members: [ownerId],
|
||||
validation_rules: [
|
||||
{
|
||||
quorum: 0.5,
|
||||
fields: [...fileDataFields, 'roles'],
|
||||
min_sig_member: 1,
|
||||
},
|
||||
],
|
||||
storages: []
|
||||
},
|
||||
stakeholders: {
|
||||
members: stakeholdersId,
|
||||
validation_rules: [
|
||||
{
|
||||
quorum: 0.5,
|
||||
fields: ['documents', 'motes'],
|
||||
min_sig_member: 1,
|
||||
},
|
||||
],
|
||||
storages: []
|
||||
},
|
||||
customers: {
|
||||
members: customersId,
|
||||
validation_rules: [
|
||||
{
|
||||
quorum: 0.0,
|
||||
fields: fileDataFields,
|
||||
min_sig_member: 0.0,
|
||||
},
|
||||
],
|
||||
storages: []
|
||||
},
|
||||
apophis: {
|
||||
members: [ownerId],
|
||||
validation_rules: [],
|
||||
storages: []
|
||||
}
|
||||
},
|
||||
accessToken,
|
||||
messageId
|
||||
});
|
||||
}).catch(console.error);
|
||||
});
|
||||
}
|
||||
|
||||
public getFiles(): Promise<any> {
|
||||
return new Promise<any>((resolve: (files: any[]) => void, reject: (error: string) => void) => {
|
||||
this.getProcesses().then(async (processes: any) => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user