Compare commits
No commits in common. "a351c1814cc6c29057d73a6db9a85848e0010a48" and "4e8dbcbf1783a4544461fd321a80fc5af02d7bda" have entirely different histories.
a351c1814c
...
4e8dbcbf17
@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
import { v4 as uuidv4 } from 'uuid';
|
import { v4 as uuidv4 } from 'uuid';
|
||||||
|
|
||||||
import MessageBus from 'src/sdk/MessageBus';
|
import MessageBus from 'src/sdk/MessageBus';
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
import { v4 as uuidv4 } from 'uuid';
|
import { v4 as uuidv4 } from 'uuid';
|
||||||
|
|
||||||
import MessageBus from 'src/sdk/MessageBus';
|
import MessageBus from 'src/sdk/MessageBus';
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
import { v4 as uuidv4 } from 'uuid';
|
import { v4 as uuidv4 } from 'uuid';
|
||||||
|
|
||||||
import MessageBus from 'src/sdk/MessageBus';
|
import MessageBus from 'src/sdk/MessageBus';
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
import { v4 as uuidv4 } from 'uuid';
|
import { v4 as uuidv4 } from 'uuid';
|
||||||
|
|
||||||
import MessageBus from 'src/sdk/MessageBus';
|
import MessageBus from 'src/sdk/MessageBus';
|
||||||
@ -9,7 +10,7 @@ export default class DocumentTypeService {
|
|||||||
|
|
||||||
private constructor() { }
|
private constructor() { }
|
||||||
|
|
||||||
public static createDocumentType(documentTypeData: any, validatorId: string): Promise<any> {
|
public static createDocumentType(documentData: any, validatorId: string): Promise<any> {
|
||||||
const ownerId = User.getInstance().getPairingId()!;
|
const ownerId = User.getInstance().getPairingId()!;
|
||||||
|
|
||||||
const processData: any = {
|
const processData: any = {
|
||||||
@ -18,7 +19,7 @@ export default class DocumentTypeService {
|
|||||||
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,
|
...documentData,
|
||||||
};
|
};
|
||||||
|
|
||||||
const privateFields: string[] = Object.keys(processData);
|
const privateFields: string[] = Object.keys(processData);
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
import { v4 as uuidv4 } from 'uuid';
|
import { v4 as uuidv4 } from 'uuid';
|
||||||
|
|
||||||
import MessageBus from 'src/sdk/MessageBus';
|
import MessageBus from 'src/sdk/MessageBus';
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
import { v4 as uuidv4 } from 'uuid';
|
import { v4 as uuidv4 } from 'uuid';
|
||||||
|
|
||||||
import MessageBus from 'src/sdk/MessageBus';
|
import MessageBus from 'src/sdk/MessageBus';
|
||||||
|
@ -1,45 +0,0 @@
|
|||||||
class LoaderService {
|
|
||||||
private static instance: LoaderService;
|
|
||||||
private _isVisible: boolean = false;
|
|
||||||
private _callbacks: Array<(isVisible: boolean) => void> = [];
|
|
||||||
|
|
||||||
private constructor() { }
|
|
||||||
|
|
||||||
public static getInstance(): LoaderService {
|
|
||||||
if (!LoaderService.instance) {
|
|
||||||
LoaderService.instance = new LoaderService();
|
|
||||||
}
|
|
||||||
return LoaderService.instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public show(): void {
|
|
||||||
this._isVisible = true;
|
|
||||||
this._notifySubscribers();
|
|
||||||
}
|
|
||||||
|
|
||||||
public hide(): void {
|
|
||||||
this._isVisible = false;
|
|
||||||
this._notifySubscribers();
|
|
||||||
}
|
|
||||||
|
|
||||||
public get isVisible(): boolean {
|
|
||||||
return this._isVisible;
|
|
||||||
}
|
|
||||||
|
|
||||||
public subscribe(callback: (isVisible: boolean) => void): () => void {
|
|
||||||
this._callbacks.push(callback);
|
|
||||||
|
|
||||||
// Return unsubscribe function
|
|
||||||
return () => {
|
|
||||||
this._callbacks = this._callbacks.filter(cb => cb !== callback);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
private _notifySubscribers(): void {
|
|
||||||
this._callbacks.forEach(callback => {
|
|
||||||
callback(this._isVisible);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default LoaderService;
|
|
@ -1,38 +0,0 @@
|
|||||||
@keyframes spin {
|
|
||||||
to {
|
|
||||||
transform: rotate(1turn);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.loader-container {
|
|
||||||
position: fixed;
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
right: 0;
|
|
||||||
bottom: 0;
|
|
||||||
background-color: rgba(255, 255, 255, 0.7);
|
|
||||||
z-index: 9999;
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.loader {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: center;
|
|
||||||
background-color: white;
|
|
||||||
padding: 2rem;
|
|
||||||
border-radius: 8px;
|
|
||||||
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
|
|
||||||
}
|
|
||||||
|
|
||||||
.message {
|
|
||||||
margin-top: 1rem;
|
|
||||||
font-size: 1rem;
|
|
||||||
color: #333;
|
|
||||||
}
|
|
||||||
|
|
||||||
.spinner {
|
|
||||||
animation: spin 1s infinite linear;
|
|
||||||
}
|
|
@ -1,37 +0,0 @@
|
|||||||
import React, { useEffect, useState } from "react";
|
|
||||||
|
|
||||||
import { ArrowPathIcon } from "@heroicons/react/24/outline";
|
|
||||||
|
|
||||||
import LoaderService from "./LoaderService";
|
|
||||||
import classes from "./classes.module.scss";
|
|
||||||
|
|
||||||
// Composant fusionné qui gère à la fois l'abonnement au service et l'affichage
|
|
||||||
const Loader: React.FC = () => {
|
|
||||||
const [isVisible, setIsVisible] = useState(false);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
// S'abonner aux changements d'état du loader
|
|
||||||
const unsubscribe = LoaderService.getInstance().subscribe((visible) => {
|
|
||||||
setIsVisible(visible);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Nettoyage de l'abonnement
|
|
||||||
return () => {
|
|
||||||
unsubscribe();
|
|
||||||
};
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
// Ne rien afficher si le loader n'est pas visible
|
|
||||||
if (!isVisible) return null;
|
|
||||||
|
|
||||||
// Affichage du loader avec overlay
|
|
||||||
return (
|
|
||||||
<div className={classes["loader-container"]}>
|
|
||||||
<div className={classes["loader"]}>
|
|
||||||
<ArrowPathIcon className={classes["spinner"]} width={40} />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Loader;
|
|
@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
import { v4 as uuidv4 } from 'uuid';
|
import { v4 as uuidv4 } from 'uuid';
|
||||||
|
|
||||||
import MessageBus from 'src/sdk/MessageBus';
|
import MessageBus from 'src/sdk/MessageBus';
|
||||||
|
@ -1,109 +0,0 @@
|
|||||||
import { v4 as uuidv4 } from 'uuid';
|
|
||||||
|
|
||||||
import MessageBus from 'src/sdk/MessageBus';
|
|
||||||
import User from 'src/sdk/User';
|
|
||||||
|
|
||||||
export default class RoleService {
|
|
||||||
|
|
||||||
private static readonly messageBus: MessageBus = MessageBus.getInstance();
|
|
||||||
|
|
||||||
private constructor() { }
|
|
||||||
|
|
||||||
public static createRole(roleData: any, validatorId: string): Promise<any> {
|
|
||||||
const ownerId = User.getInstance().getPairingId()!;
|
|
||||||
|
|
||||||
const processData: any = {
|
|
||||||
uid: uuidv4(),
|
|
||||||
utype: 'role',
|
|
||||||
isDeleted: 'false',
|
|
||||||
created_at: new Date().toISOString(),
|
|
||||||
updated_at: new Date().toISOString(),
|
|
||||||
...roleData,
|
|
||||||
};
|
|
||||||
|
|
||||||
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 getRoles(): Promise<any[]> {
|
|
||||||
return this.messageBus.getProcessesDecoded((publicValues: any) => publicValues['uid'] && publicValues['utype'] && publicValues['utype'] === 'role' && publicValues['isDeleted'] && publicValues['isDeleted'] === 'false');
|
|
||||||
}
|
|
||||||
|
|
||||||
public static getRoleByUid(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'] === 'role' && publicValues['isDeleted'] && publicValues['isDeleted'] === 'false').then(async (processes: any[]) => {
|
|
||||||
if (processes.length === 0) {
|
|
||||||
resolve(null);
|
|
||||||
} else {
|
|
||||||
const process: any = processes[0];
|
|
||||||
resolve(process);
|
|
||||||
}
|
|
||||||
}).catch(reject);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public static updateRole(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);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
@ -14,12 +14,10 @@ import classNames from "classnames";
|
|||||||
|
|
||||||
import Button, { EButtonstyletype, EButtonVariant } from "../Button";
|
import Button, { EButtonstyletype, EButtonVariant } from "../Button";
|
||||||
import Confirm from "../OldModal/Confirm";
|
import Confirm from "../OldModal/Confirm";
|
||||||
|
import Documents from "@Front/Api/LeCoffreApi/Customer/Documents/Documents";
|
||||||
|
import Files from "@Front/Api/LeCoffreApi/Customer/Files/Files";
|
||||||
import Alert from "../OldModal/Alert";
|
import Alert from "../OldModal/Alert";
|
||||||
|
|
||||||
import DocumentService from "src/common/Api/LeCoffreApi/sdk/DocumentService";
|
|
||||||
import LoaderService from "src/common/Api/LeCoffreApi/sdk/Loader/LoaderService";
|
|
||||||
import FileService from "src/common/Api/LeCoffreApi/sdk/FileService";
|
|
||||||
|
|
||||||
type IProps = {
|
type IProps = {
|
||||||
onChange?: (files: File[]) => void;
|
onChange?: (files: File[]) => void;
|
||||||
open: boolean;
|
open: boolean;
|
||||||
@ -208,30 +206,18 @@ export default class DepositOtherDocument extends React.Component<IProps, IState
|
|||||||
this.setState({
|
this.setState({
|
||||||
isLoading: true,
|
isLoading: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
const filesArray = this.state.currentFiles;
|
const filesArray = this.state.currentFiles;
|
||||||
if (!filesArray) return;
|
|
||||||
|
|
||||||
LoaderService.getInstance().show();
|
if (!filesArray) return;
|
||||||
let documentCreated: any;
|
let documentCreated: Document = {} as Document;
|
||||||
try {
|
try {
|
||||||
documentCreated = await new Promise<any>((resolve: (document: any) => void) => {
|
documentCreated = await Documents.getInstance().post({
|
||||||
const documentTypeData: any = {
|
|
||||||
folder: {
|
folder: {
|
||||||
uid: this.props.folder_uid,
|
uid: this.props.folder_uid,
|
||||||
},
|
},
|
||||||
depositor: {
|
depositor: {
|
||||||
uid: this.props.customer_uid,
|
uid: this.props.customer_uid,
|
||||||
}
|
},
|
||||||
};
|
|
||||||
const validatorId: string = '884cb36a346a79af8697559f16940141f068bdf1656f88fa0df0e9ecd7311fb8:0';
|
|
||||||
|
|
||||||
DocumentService.createDocument(documentTypeData, validatorId).then((processCreated: any) => {
|
|
||||||
if (processCreated) {
|
|
||||||
const document: any = processCreated.processData;
|
|
||||||
resolve(document);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.setState({ showFailedDocument: "Le dossier est vérifié aucune modification n'est acceptée", isLoading: false });
|
this.setState({ showFailedDocument: "Le dossier est vérifié aucune modification n'est acceptée", isLoading: false });
|
||||||
@ -239,46 +225,16 @@ export default class DepositOtherDocument extends React.Component<IProps, IState
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (let i = 0; i < filesArray.length; i++) {
|
for (let i = 0; i < filesArray.length; i++) {
|
||||||
const file = filesArray[i]!.file;
|
const formData = new FormData();
|
||||||
await new Promise<void>((resolve: () => void) => {
|
formData.append("file", filesArray[i]!.file, filesArray[i]!.fileName);
|
||||||
const reader = new FileReader();
|
const query = JSON.stringify({ document: { uid: documentCreated.uid } });
|
||||||
reader.onload = (event) => {
|
formData.append("q", query);
|
||||||
if (event.target?.result) {
|
try {
|
||||||
const arrayBuffer = event.target.result as ArrayBuffer;
|
await Files.getInstance().post(formData);
|
||||||
const uint8Array = new Uint8Array(arrayBuffer);
|
} catch (e) {
|
||||||
|
this.setState({ showFailedUploaded: "Le fichier ne correspond pas aux critères demandés", isLoading: false });
|
||||||
const fileBlob: any = {
|
return;
|
||||||
type: file.type,
|
|
||||||
data: uint8Array
|
|
||||||
};
|
|
||||||
|
|
||||||
const fileData: any = {
|
|
||||||
file_blob: fileBlob,
|
|
||||||
file_name: file.name
|
|
||||||
};
|
|
||||||
const validatorId: string = '884cb36a346a79af8697559f16940141f068bdf1656f88fa0df0e9ecd7311fb8:0';
|
|
||||||
|
|
||||||
FileService.createFile(fileData, validatorId).then((processCreated: any) => {
|
|
||||||
const fileUid: string = processCreated.processData.uid;
|
|
||||||
|
|
||||||
DocumentService.getDocumentByUid(documentCreated.uid).then((process: any) => {
|
|
||||||
if (process) {
|
|
||||||
const document: any = process.processData;
|
|
||||||
|
|
||||||
let files: any[] = document.files;
|
|
||||||
if (!files) {
|
|
||||||
files = [];
|
|
||||||
}
|
}
|
||||||
files.push({ uid: fileUid });
|
|
||||||
|
|
||||||
DocumentService.updateDocument(process, { files: files, document_status: EDocumentStatus.DEPOSITED }).then(() => resolve());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
reader.readAsArrayBuffer(file);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
|
@ -31,7 +31,6 @@ export default function Navigation() {
|
|||||||
*/
|
*/
|
||||||
const anchors = [] as any[];
|
const anchors = [] as any[];
|
||||||
|
|
||||||
/* TODO: review
|
|
||||||
try {
|
try {
|
||||||
for (const anchor of anchors) {
|
for (const anchor of anchors) {
|
||||||
await OfficeFolderAnchors.getInstance().getByUid(anchor.folder?.uid as string);
|
await OfficeFolderAnchors.getInstance().getByUid(anchor.folder?.uid as string);
|
||||||
@ -39,7 +38,6 @@ export default function Navigation() {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const getNotifications = useCallback(async () => {
|
const getNotifications = useCallback(async () => {
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import Folders from "@Front/Api/LeCoffreApi/Customer/Folders/Folders";
|
||||||
import { IBlock } from "@Front/Components/DesignSystem/SearchBlockList/BlockList/Block";
|
import { IBlock } from "@Front/Components/DesignSystem/SearchBlockList/BlockList/Block";
|
||||||
import Module from "@Front/Config/Module";
|
import Module from "@Front/Config/Module";
|
||||||
import JwtService from "@Front/Services/JwtService/JwtService";
|
import JwtService from "@Front/Services/JwtService/JwtService";
|
||||||
@ -13,7 +14,7 @@ type IProps = IPropsDashboardWithList & {};
|
|||||||
|
|
||||||
export default function DefaultCustomerDashboard(props: IProps) {
|
export default function DefaultCustomerDashboard(props: IProps) {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { folderUid, profileUid } = router.query;
|
const { folderUid } = router.query;
|
||||||
const [folders, setFolders] = useState<OfficeFolder[]>([]);
|
const [folders, setFolders] = useState<OfficeFolder[]>([]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -60,9 +61,7 @@ export default function DefaultCustomerDashboard(props: IProps) {
|
|||||||
router.push(
|
router.push(
|
||||||
Module.getInstance()
|
Module.getInstance()
|
||||||
.get()
|
.get()
|
||||||
.modules.pages.ClientDashboard.props.path
|
.modules.pages.ClientDashboard.props.path.replace("[folderUid]", folder.uid ?? ""),
|
||||||
.replace("[folderUid]", folder.uid ?? "")
|
|
||||||
.replace("[profileUid]", profileUid as string ?? ""),
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
return <DefaultDashboardWithList {...props} onSelectedBlock={onSelectedBlock} blocks={getBlocks(folders)} headerConnected={false} />;
|
return <DefaultDashboardWithList {...props} onSelectedBlock={onSelectedBlock} blocks={getBlocks(folders)} headerConnected={false} />;
|
||||||
|
@ -7,8 +7,6 @@ import DefaultDashboardWithList, { IPropsDashboardWithList } from "../DefaultDas
|
|||||||
import { OfficeRole } from "le-coffre-resources/dist/Notary";
|
import { OfficeRole } from "le-coffre-resources/dist/Notary";
|
||||||
import OfficeRoles, { IGetRolesParams } from "@Front/Api/LeCoffreApi/Admin/OfficeRoles/OfficeRoles";
|
import OfficeRoles, { IGetRolesParams } from "@Front/Api/LeCoffreApi/Admin/OfficeRoles/OfficeRoles";
|
||||||
|
|
||||||
import RoleService from "src/common/Api/LeCoffreApi/sdk/RoleService";
|
|
||||||
|
|
||||||
type IProps = IPropsDashboardWithList;
|
type IProps = IPropsDashboardWithList;
|
||||||
|
|
||||||
export default function DefaultRoleDashboard(props: IProps) {
|
export default function DefaultRoleDashboard(props: IProps) {
|
||||||
@ -25,13 +23,7 @@ export default function DefaultRoleDashboard(props: IProps) {
|
|||||||
.get(query)
|
.get(query)
|
||||||
.then((roles) => setRoles(roles));
|
.then((roles) => setRoles(roles));
|
||||||
*/
|
*/
|
||||||
|
setRoles([]);
|
||||||
RoleService.getRoles().then((processes: any[]) => {
|
|
||||||
if (processes.length > 0) {
|
|
||||||
const roles: any[] = processes.map((process: any) => process.processData);
|
|
||||||
setRoles(roles);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const onSelectedBlock = (block: IBlock) => {
|
const onSelectedBlock = (block: IBlock) => {
|
||||||
|
@ -110,8 +110,7 @@ export default function DepositDocumentComponent(props: IProps) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const onOpenModal = useCallback(async () => {
|
const onOpenModal = useCallback(async () => {
|
||||||
if (document.document_status !== "REFUSED") return;
|
const refused_reason = document.document_history?.find((history: any) => history.document_status === "REFUSED")?.refused_reason;
|
||||||
const refused_reason = document.refused_reason;
|
|
||||||
if (!refused_reason) return;
|
if (!refused_reason) return;
|
||||||
setRefusedReason(refused_reason);
|
setRefusedReason(refused_reason);
|
||||||
setIsModalOpen(true);
|
setIsModalOpen(true);
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import DocumentsNotary from "@Front/Api/LeCoffreApi/Customer/DocumentsNotary/DocumentsNotary";
|
||||||
|
import FilesNotary from "@Front/Api/LeCoffreApi/Customer/FilesNotary/Files";
|
||||||
import Button, { EButtonSize, EButtonstyletype, EButtonVariant } from "@Front/Components/DesignSystem/Button";
|
import Button, { EButtonSize, EButtonstyletype, EButtonVariant } from "@Front/Components/DesignSystem/Button";
|
||||||
import IconButton from "@Front/Components/DesignSystem/IconButton";
|
import IconButton from "@Front/Components/DesignSystem/IconButton";
|
||||||
import Table from "@Front/Components/DesignSystem/Table";
|
import Table from "@Front/Components/DesignSystem/Table";
|
||||||
@ -14,14 +16,10 @@ import { useRouter } from "next/router";
|
|||||||
import React, { useCallback, useEffect, useState } from "react";
|
import React, { useCallback, useEffect, useState } from "react";
|
||||||
import classes from "./classes.module.scss";
|
import classes from "./classes.module.scss";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
|
import Folders from "@Front/Api/LeCoffreApi/Customer/Folders/Folders";
|
||||||
import Customer from "le-coffre-resources/dist/Customer";
|
import Customer from "le-coffre-resources/dist/Customer";
|
||||||
import { DocumentNotary } from "le-coffre-resources/dist/Notary";
|
import { DocumentNotary } from "le-coffre-resources/dist/Notary";
|
||||||
|
|
||||||
import FolderService from "src/common/Api/LeCoffreApi/sdk/FolderService";
|
|
||||||
import DocumentService from "src/common/Api/LeCoffreApi/sdk/DocumentService";
|
|
||||||
import FileService from "src/common/Api/LeCoffreApi/sdk/FileService";
|
|
||||||
import LoaderService from "src/common/Api/LeCoffreApi/sdk/Loader/LoaderService";
|
|
||||||
|
|
||||||
const header: readonly IHead[] = [
|
const header: readonly IHead[] = [
|
||||||
{
|
{
|
||||||
key: "name",
|
key: "name",
|
||||||
@ -49,26 +47,6 @@ export default function ReceivedDocuments() {
|
|||||||
jwt = JwtService.getInstance().decodeCustomerJwt();
|
jwt = JwtService.getInstance().decodeCustomerJwt();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: review
|
|
||||||
LoaderService.getInstance().show();
|
|
||||||
const folder: any = await new Promise<any>((resolve: (folder: any) => void) => {
|
|
||||||
FolderService.getFolderByUid(folderUid as string).then((process: any) => {
|
|
||||||
if (process) {
|
|
||||||
const folder: any = process.processData;
|
|
||||||
resolve(folder);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
//const customer = folder?.customers?.find((customer) => customer.contact?.email === jwt?.email);
|
|
||||||
const customer = folder?.customers?.[0];
|
|
||||||
if (!customer) throw new Error("Customer not found");
|
|
||||||
|
|
||||||
setCustomer(customer);
|
|
||||||
|
|
||||||
return { folder, customer };
|
|
||||||
|
|
||||||
/*
|
|
||||||
const folder = await Folders.getInstance().getByUid(folderUid as string, {
|
const folder = await Folders.getInstance().getByUid(folderUid as string, {
|
||||||
q: {
|
q: {
|
||||||
office: true,
|
office: true,
|
||||||
@ -98,58 +76,32 @@ export default function ReceivedDocuments() {
|
|||||||
setCustomer(customer);
|
setCustomer(customer);
|
||||||
|
|
||||||
return { folder, customer };
|
return { folder, customer };
|
||||||
*/
|
|
||||||
}, [folderUid]);
|
}, [folderUid]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetchFolderAndCustomer();
|
fetchFolderAndCustomer();
|
||||||
}, [folderUid]); // Ne dépend que de folderUid
|
|
||||||
|
|
||||||
// Effet séparé pour charger les documents lorsque customer change
|
|
||||||
useEffect(() => {
|
|
||||||
const customerUid = customer?.uid;
|
const customerUid = customer?.uid;
|
||||||
if (!folderUid || !customerUid) return;
|
if (!folderUid || !customerUid) return;
|
||||||
|
DocumentsNotary.getInstance()
|
||||||
|
.get({ where: { folder: { uid: folderUid }, customer: { uid: customerUid } }, include: { files: true } })
|
||||||
|
.then((documentsNotary) => setDocumentsNotary(documentsNotary));
|
||||||
|
}, [folderUid, customer, fetchFolderAndCustomer]);
|
||||||
|
|
||||||
DocumentService.getDocuments().then(async (processes: any[]) => {
|
const onDownload = useCallback((doc: DocumentNotary) => {
|
||||||
if (processes.length > 0) {
|
|
||||||
let documents: any[] = processes.map((process: any) => process.processData);
|
|
||||||
|
|
||||||
// FilterBy folder.uid & customer.uid
|
|
||||||
documents = documents.filter((document: any) => document.folder.uid === folderUid && document.customer && document.customer.uid === customerUid);
|
|
||||||
|
|
||||||
for (const document of documents) {
|
|
||||||
if (document.files && document.files.length > 0) {
|
|
||||||
const files: any[] = [];
|
|
||||||
for (const file of document.files) {
|
|
||||||
files.push((await FileService.getFileByUid(file.uid)).processData);
|
|
||||||
}
|
|
||||||
document.files = files;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
setDocumentsNotary(documents);
|
|
||||||
LoaderService.getInstance().hide();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}, [folderUid, customer]);
|
|
||||||
|
|
||||||
const onDownload = useCallback((doc: any) => {
|
|
||||||
const file = doc.files?.[0];
|
const file = doc.files?.[0];
|
||||||
if (!file) return;
|
if (!file || !file?.uid || !doc.uid) return;
|
||||||
|
|
||||||
return new Promise<void>((resolve: () => void) => {
|
return FilesNotary.getInstance()
|
||||||
const blob = new Blob([file.file_blob.data], { type: file.file_blob.type });
|
.download(file.uid, doc.uid)
|
||||||
|
.then((blob) => {
|
||||||
const url = URL.createObjectURL(blob);
|
const url = URL.createObjectURL(blob);
|
||||||
const a = document.createElement('a');
|
const a = document.createElement("a");
|
||||||
a.href = url;
|
a.href = url;
|
||||||
a.download = file.file_name;
|
a.download = file.file_name ?? "file";
|
||||||
document.body.appendChild(a);
|
|
||||||
a.click();
|
a.click();
|
||||||
document.body.removeChild(a);
|
|
||||||
URL.revokeObjectURL(url);
|
URL.revokeObjectURL(url);
|
||||||
|
})
|
||||||
resolve();
|
.catch((e) => console.warn(e));
|
||||||
}).catch((e) => console.warn(e));
|
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const onDownloadAll = useCallback(async () => {
|
const onDownloadAll = useCallback(async () => {
|
||||||
@ -158,14 +110,16 @@ export default function ReceivedDocuments() {
|
|||||||
const zip = new JSZip();
|
const zip = new JSZip();
|
||||||
const folder = zip.folder("documents") || zip;
|
const folder = zip.folder("documents") || zip;
|
||||||
|
|
||||||
documentsNotary.map((doc: any) => {
|
const downloadPromises = documentsNotary.map(async (doc) => {
|
||||||
const file = doc.files?.[0];
|
const file = doc.files?.[0];
|
||||||
if (file) {
|
if (file && file.uid && doc.uid) {
|
||||||
const blob = new Blob([file.file_blob.data], { type: file.file_blob.type });
|
const blob = await FilesNotary.getInstance().download(file.uid, doc.uid);
|
||||||
folder.file(file.file_name ?? "file", blob);
|
folder.file(file.file_name ?? "file", blob);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
await Promise.all(downloadPromises);
|
||||||
|
|
||||||
zip.generateAsync({ type: "blob" })
|
zip.generateAsync({ type: "blob" })
|
||||||
.then((blob: any) => {
|
.then((blob: any) => {
|
||||||
saveAs(blob, "documents.zip");
|
saveAs(blob, "documents.zip");
|
||||||
|
@ -10,12 +10,9 @@ import React from "react";
|
|||||||
|
|
||||||
import BasePage from "../../Base";
|
import BasePage from "../../Base";
|
||||||
import classes from "./classes.module.scss";
|
import classes from "./classes.module.scss";
|
||||||
|
import DocumentsNotary from "@Front/Api/LeCoffreApi/Customer/DocumentsNotary/DocumentsNotary";
|
||||||
import DefaultTemplate from "@Front/Components/LayoutTemplates/DefaultTemplate";
|
import DefaultTemplate from "@Front/Components/LayoutTemplates/DefaultTemplate";
|
||||||
|
import FilesNotary from "@Front/Api/LeCoffreApi/Customer/FilesNotary/Files";
|
||||||
import DocumentService from "src/common/Api/LeCoffreApi/sdk/DocumentService";
|
|
||||||
import FileService from "src/common/Api/LeCoffreApi/sdk/FileService";
|
|
||||||
import LoaderService from "src/common/Api/LeCoffreApi/sdk/Loader/LoaderService";
|
|
||||||
|
|
||||||
type IProps = {};
|
type IProps = {};
|
||||||
type IPropsClass = {
|
type IPropsClass = {
|
||||||
@ -126,26 +123,11 @@ class ViewDocumentsNotaryClass extends BasePage<IPropsClass, IState> {
|
|||||||
|
|
||||||
override async componentDidMount() {
|
override async componentDidMount() {
|
||||||
try {
|
try {
|
||||||
LoaderService.getInstance().show();
|
const documentNotary = await DocumentsNotary.getInstance().getByUid(this.props.documentUid, {
|
||||||
const documentNotary: any = await new Promise<any>((resolve: (document: any) => void) => {
|
files: true,
|
||||||
DocumentService.getDocumentByUid(this.props.documentUid).then(async (process: any) => {
|
folder: true,
|
||||||
if (process) {
|
depositor: true,
|
||||||
const document: any = process.processData;
|
|
||||||
|
|
||||||
if (document.files && document.files.length > 0) {
|
|
||||||
const files: any[] = [];
|
|
||||||
for (const file of document.files) {
|
|
||||||
files.push((await FileService.getFileByUid(file.uid)).processData);
|
|
||||||
}
|
|
||||||
document.files = files;
|
|
||||||
}
|
|
||||||
|
|
||||||
resolve(document);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
});
|
|
||||||
LoaderService.getInstance().hide();
|
|
||||||
|
|
||||||
this.setState(
|
this.setState(
|
||||||
{
|
{
|
||||||
documentNotary,
|
documentNotary,
|
||||||
@ -167,7 +149,8 @@ class ViewDocumentsNotaryClass extends BasePage<IPropsClass, IState> {
|
|||||||
|
|
||||||
private async getFilePreview(): Promise<void> {
|
private async getFilePreview(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
const fileBlob: Blob = new Blob([this.state.selectedFile.file_blob.data], { type: this.state.selectedFile.file_blob.type });
|
const fileBlob: Blob = await FilesNotary.getInstance().download(this.state.selectedFile?.uid as string, this.props.documentUid);
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
fileBlob,
|
fileBlob,
|
||||||
});
|
});
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
import Documents, { IGetDocumentsparams } from "@Front/Api/LeCoffreApi/Customer/Documents/Documents";
|
||||||
|
|
||||||
import Typography, { ETypo, ETypoColor } from "@Front/Components/DesignSystem/Typography";
|
import Typography, { ETypo, ETypoColor } from "@Front/Components/DesignSystem/Typography";
|
||||||
|
|
||||||
@ -9,6 +10,7 @@ import { DocumentNotary, OfficeFolder as OfficeFolderNotary } from "le-coffre-re
|
|||||||
import classes from "./classes.module.scss";
|
import classes from "./classes.module.scss";
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
import JwtService, { ICustomerJwtPayload } from "@Front/Services/JwtService/JwtService";
|
import JwtService, { ICustomerJwtPayload } from "@Front/Services/JwtService/JwtService";
|
||||||
|
import Folders from "@Front/Api/LeCoffreApi/Customer/Folders/Folders";
|
||||||
|
|
||||||
import Tag, { ETagColor } from "@Front/Components/DesignSystem/Tag";
|
import Tag, { ETagColor } from "@Front/Components/DesignSystem/Tag";
|
||||||
import DefaultCustomerDashboard from "@Front/Components/LayoutTemplates/DefaultCustomerDashboard";
|
import DefaultCustomerDashboard from "@Front/Components/LayoutTemplates/DefaultCustomerDashboard";
|
||||||
@ -19,19 +21,16 @@ import Module from "@Front/Config/Module";
|
|||||||
import Separator, { ESeperatorColor, ESeperatorDirection } from "@Front/Components/DesignSystem/Separator";
|
import Separator, { ESeperatorColor, ESeperatorDirection } from "@Front/Components/DesignSystem/Separator";
|
||||||
import NotificationBox from "@Front/Components/DesignSystem/NotificationBox";
|
import NotificationBox from "@Front/Components/DesignSystem/NotificationBox";
|
||||||
import ContactBox from "./ContactBox";
|
import ContactBox from "./ContactBox";
|
||||||
|
import DocumentsNotary from "@Front/Api/LeCoffreApi/Customer/DocumentsNotary/DocumentsNotary";
|
||||||
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";
|
||||||
import DocumentService from "src/common/Api/LeCoffreApi/sdk/DocumentService";
|
import DocumentService from "src/common/Api/LeCoffreApi/sdk/DocumentService";
|
||||||
import DocumentTypeService from "src/common/Api/LeCoffreApi/sdk/DocumentTypeService";
|
import DocumentTypeService from "src/common/Api/LeCoffreApi/sdk/DocumentTypeService";
|
||||||
import FileService from "src/common/Api/LeCoffreApi/sdk/FileService";
|
import FileService from "src/common/Api/LeCoffreApi/sdk/FileService";
|
||||||
import LoaderService from "src/common/Api/LeCoffreApi/sdk/Loader/LoaderService";
|
|
||||||
|
|
||||||
type IProps = {};
|
type IProps = {};
|
||||||
|
|
||||||
@ -47,30 +46,6 @@ export default function ClientDashboard(props: IProps) {
|
|||||||
const [isAddDocumentModalVisible, setIsAddDocumentModalVisible] = useState<boolean>(false);
|
const [isAddDocumentModalVisible, setIsAddDocumentModalVisible] = useState<boolean>(false);
|
||||||
|
|
||||||
const [isAuthModalOpen, setIsAuthModalOpen] = useState(false);
|
const [isAuthModalOpen, setIsAuthModalOpen] = useState(false);
|
||||||
const [isSmsModalOpen, setIsSmsModalOpen] = useState(false);
|
|
||||||
const [smsCode, setSmsCode] = useState("");
|
|
||||||
const [smsError, setSmsError] = useState("");
|
|
||||||
|
|
||||||
const verifySmsCode = useCallback(() => {
|
|
||||||
if (smsCode === "1234") {
|
|
||||||
setIsSmsModalOpen(false);
|
|
||||||
} 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;
|
||||||
@ -79,7 +54,6 @@ export default function ClientDashboard(props: IProps) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: review
|
// TODO: review
|
||||||
LoaderService.getInstance().show();
|
|
||||||
const { folder, customer } = await new Promise<any>((resolve) => {
|
const { folder, customer } = await new Promise<any>((resolve) => {
|
||||||
FolderService.getFolderByUid(folderUid as string).then((process: any) => {
|
FolderService.getFolderByUid(folderUid as string).then((process: any) => {
|
||||||
if (process) {
|
if (process) {
|
||||||
@ -98,7 +72,6 @@ export default function ClientDashboard(props: IProps) {
|
|||||||
setFolder(folder);
|
setFolder(folder);
|
||||||
|
|
||||||
setIsAuthModalOpen(true);
|
setIsAuthModalOpen(true);
|
||||||
LoaderService.getInstance().hide();
|
|
||||||
|
|
||||||
return { folder, customer };
|
return { folder, customer };
|
||||||
|
|
||||||
@ -138,19 +111,40 @@ export default function ClientDashboard(props: IProps) {
|
|||||||
|
|
||||||
const fetchDocuments = useCallback(
|
const fetchDocuments = useCallback(
|
||||||
async (customerUid: string | undefined) => {
|
async (customerUid: string | undefined) => {
|
||||||
LoaderService.getInstance().show();
|
/* TODO: review
|
||||||
return new Promise<void>((resolve: () => void) => {
|
const query: IGetDocumentsparams = {
|
||||||
DocumentService.getDocuments().then(async (processes: any[]) => {
|
where: { depositor: { uid: customerUid }, folder_uid: folderUid as string },
|
||||||
|
include: {
|
||||||
|
files: true,
|
||||||
|
document_history: true,
|
||||||
|
document_type: true,
|
||||||
|
depositor: true,
|
||||||
|
folder: {
|
||||||
|
include: {
|
||||||
|
customers: {
|
||||||
|
include: {
|
||||||
|
contact: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
return Documents.getInstance()
|
||||||
|
.get(query)
|
||||||
|
.then((documents) => setDocuments(documents));
|
||||||
|
*/
|
||||||
|
|
||||||
|
return DocumentService.getDocuments().then(async (processes: any[]) => {
|
||||||
if (processes.length > 0) {
|
if (processes.length > 0) {
|
||||||
let documents: any[] = processes.map((process: any) => process.processData);
|
let documents: any[] = processes.map((process: any) => process.processData);
|
||||||
|
|
||||||
// FilterBy folder.uid & depositor.uid
|
// FilterBy folder_uid
|
||||||
documents = documents.filter((document: any) => document.folder.uid === folderUid && document.depositor && document.depositor.uid === customerUid);
|
documents = documents.filter((document: any) => document.folder.uid === folderUid);
|
||||||
|
|
||||||
for (const document of documents) {
|
for (const document of documents) {
|
||||||
if (document.document_type) {
|
|
||||||
document.document_type = (await DocumentTypeService.getDocumentTypeByUid(document.document_type.uid)).processData;
|
document.document_type = (await DocumentTypeService.getDocumentTypeByUid(document.document_type.uid)).processData;
|
||||||
}
|
|
||||||
|
|
||||||
if (document.files && document.files.length > 0) {
|
if (document.files && document.files.length > 0) {
|
||||||
const files: any[] = [];
|
const files: any[] = [];
|
||||||
@ -163,9 +157,6 @@ export default function ClientDashboard(props: IProps) {
|
|||||||
|
|
||||||
setDocuments(documents);
|
setDocuments(documents);
|
||||||
}
|
}
|
||||||
LoaderService.getInstance().hide();
|
|
||||||
resolve();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
[folderUid],
|
[folderUid],
|
||||||
@ -179,28 +170,12 @@ export default function ClientDashboard(props: IProps) {
|
|||||||
const customerUid = customer?.uid;
|
const customerUid = customer?.uid;
|
||||||
if (!folderUid || !customerUid) return;
|
if (!folderUid || !customerUid) return;
|
||||||
|
|
||||||
LoaderService.getInstance().show();
|
/* TODO: review
|
||||||
DocumentService.getDocuments().then(async (processes: any[]) => {
|
DocumentsNotary.getInstance()
|
||||||
if (processes.length > 0) {
|
.get({ where: { folder: { uid: folderUid }, customer: { uid: customerUid } }, include: { files: true } })
|
||||||
let documents: any[] = processes.map((process: any) => process.processData);
|
.then((documentsNotary) => setDocumentsNotary(documentsNotary));
|
||||||
|
*/
|
||||||
|
|
||||||
// FilterBy folder.uid & customer.uid
|
|
||||||
documents = documents.filter((document: any) => document.folder.uid === folderUid && document.customer && document.customer.uid === customerUid);
|
|
||||||
|
|
||||||
for (const document of documents) {
|
|
||||||
if (document.files && document.files.length > 0) {
|
|
||||||
const files: any[] = [];
|
|
||||||
for (const file of document.files) {
|
|
||||||
files.push((await FileService.getFileByUid(file.uid)).processData);
|
|
||||||
}
|
|
||||||
document.files = files;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
setDocumentsNotary(documents);
|
|
||||||
LoaderService.getInstance().hide();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}, [folderUid, customer?.uid]);
|
}, [folderUid, customer?.uid]);
|
||||||
|
|
||||||
const documentsNotaryNotRead = useMemo(
|
const documentsNotaryNotRead = useMemo(
|
||||||
@ -337,52 +312,8 @@ export default function ClientDashboard(props: IProps) {
|
|||||||
isOpen={isAuthModalOpen}
|
isOpen={isAuthModalOpen}
|
||||||
onClose={() => {
|
onClose={() => {
|
||||||
setIsAuthModalOpen(false);
|
setIsAuthModalOpen(false);
|
||||||
setIsSmsModalOpen(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>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
</DefaultCustomerDashboard>
|
</DefaultCustomerDashboard>
|
||||||
);
|
);
|
||||||
|
@ -5,7 +5,6 @@ import TextField from "@Front/Components/DesignSystem/Form/TextField";
|
|||||||
import Confirm from "@Front/Components/DesignSystem/OldModal/Confirm";
|
import Confirm from "@Front/Components/DesignSystem/OldModal/Confirm";
|
||||||
import Typography, { ETypo } from "@Front/Components/DesignSystem/Typography";
|
import Typography, { ETypo } from "@Front/Components/DesignSystem/Typography";
|
||||||
import DefaultDeedTypesDashboard from "@Front/Components/LayoutTemplates/DefaultDeedTypeDashboard";
|
import DefaultDeedTypesDashboard from "@Front/Components/LayoutTemplates/DefaultDeedTypeDashboard";
|
||||||
import { ToasterService } from "@Front/Components/DesignSystem/Toaster";
|
|
||||||
import Module from "@Front/Config/Module";
|
import Module from "@Front/Config/Module";
|
||||||
import JwtService from "@Front/Services/JwtService/JwtService";
|
import JwtService from "@Front/Services/JwtService/JwtService";
|
||||||
import { DeedType, Office } from "le-coffre-resources/dist/Admin";
|
import { DeedType, Office } from "le-coffre-resources/dist/Admin";
|
||||||
@ -16,7 +15,6 @@ import classes from "./classes.module.scss";
|
|||||||
import { validateOrReject, ValidationError } from "class-validator";
|
import { validateOrReject, ValidationError } from "class-validator";
|
||||||
|
|
||||||
import DeedTypeService from "src/common/Api/LeCoffreApi/sdk/DeedTypeService";
|
import DeedTypeService from "src/common/Api/LeCoffreApi/sdk/DeedTypeService";
|
||||||
import LoaderService from "src/common/Api/LeCoffreApi/sdk/Loader/LoaderService";
|
|
||||||
|
|
||||||
type IProps = {};
|
type IProps = {};
|
||||||
export default function DeedTypesCreate(props: IProps) {
|
export default function DeedTypesCreate(props: IProps) {
|
||||||
@ -54,13 +52,7 @@ export default function DeedTypesCreate(props: IProps) {
|
|||||||
};
|
};
|
||||||
const validatorId: string = '884cb36a346a79af8697559f16940141f068bdf1656f88fa0df0e9ecd7311fb8:0';
|
const validatorId: string = '884cb36a346a79af8697559f16940141f068bdf1656f88fa0df0e9ecd7311fb8:0';
|
||||||
|
|
||||||
LoaderService.getInstance().show();
|
|
||||||
DeedTypeService.createDeedType(deedTypeData, validatorId).then((processCreated: any) => {
|
DeedTypeService.createDeedType(deedTypeData, validatorId).then((processCreated: any) => {
|
||||||
ToasterService.getInstance().success({
|
|
||||||
title: "Succès !",
|
|
||||||
description: "Type d'acte créé avec succès"
|
|
||||||
});
|
|
||||||
setTimeout(() => LoaderService.getInstance().hide(), 2000);
|
|
||||||
router.push(
|
router.push(
|
||||||
Module.getInstance()
|
Module.getInstance()
|
||||||
.get()
|
.get()
|
||||||
|
@ -14,9 +14,6 @@ import { ValidationError } from "class-validator";
|
|||||||
|
|
||||||
import classes from "./classes.module.scss";
|
import classes from "./classes.module.scss";
|
||||||
|
|
||||||
import DeedTypeService from "src/common/Api/LeCoffreApi/sdk/DeedTypeService";
|
|
||||||
import LoaderService from "src/common/Api/LeCoffreApi/sdk/Loader/LoaderService";
|
|
||||||
|
|
||||||
export default function DeedTypesEdit() {
|
export default function DeedTypesEdit() {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
let { deedTypeUid } = router.query;
|
let { deedTypeUid } = router.query;
|
||||||
@ -30,14 +27,12 @@ export default function DeedTypesEdit() {
|
|||||||
setHasChanged(false);
|
setHasChanged(false);
|
||||||
async function getDeedType() {
|
async function getDeedType() {
|
||||||
if (!deedTypeUid) return;
|
if (!deedTypeUid) return;
|
||||||
LoaderService.getInstance().show();
|
const deedType = await DeedTypes.getInstance().getByUid(deedTypeUid as string, {
|
||||||
DeedTypeService.getDeedTypeByUid(deedTypeUid as string).then((process: any) => {
|
q: {
|
||||||
if (process) {
|
document_types: true,
|
||||||
const deedType: any = process.processData;
|
},
|
||||||
setDeedTypeSelected(deedType);
|
|
||||||
}
|
|
||||||
setTimeout(() => LoaderService.getInstance().hide(), 2000);
|
|
||||||
});
|
});
|
||||||
|
setDeedTypeSelected(deedType);
|
||||||
}
|
}
|
||||||
|
|
||||||
getDeedType();
|
getDeedType();
|
||||||
@ -62,19 +57,19 @@ export default function DeedTypesEdit() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
LoaderService.getInstance().show();
|
await DeedTypes.getInstance().put(
|
||||||
DeedTypeService.getDeedTypeByUid(deedTypeUid as string).then((process: any) => {
|
deedTypeUid as string,
|
||||||
if (process) {
|
DeedType.hydrate<DeedType>({
|
||||||
DeedTypeService.updateDeedType(process, { name: values["name"], description: values["description"] }).then(() => {
|
uid: deedTypeUid as string,
|
||||||
setTimeout(() => LoaderService.getInstance().hide(), 2000);
|
name: values["name"],
|
||||||
|
description: values["description"],
|
||||||
|
}),
|
||||||
|
);
|
||||||
router.push(
|
router.push(
|
||||||
Module.getInstance()
|
Module.getInstance()
|
||||||
.get()
|
.get()
|
||||||
.modules.pages.DeedTypes.pages.DeedTypesInformations.props.path.replace("[uid]", deedTypeUid as string),
|
.modules.pages.DeedTypes.pages.DeedTypesInformations.props.path.replace("[uid]", deedTypeUid as string),
|
||||||
);
|
);
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} catch (validationErrors) {
|
} catch (validationErrors) {
|
||||||
if (!Array.isArray(validationErrors)) return;
|
if (!Array.isArray(validationErrors)) return;
|
||||||
setValidationError(validationErrors as ValidationError[]);
|
setValidationError(validationErrors as ValidationError[]);
|
||||||
|
@ -20,7 +20,6 @@ import classes from "./classes.module.scss";
|
|||||||
|
|
||||||
import DeedTypeService from "src/common/Api/LeCoffreApi/sdk/DeedTypeService";
|
import DeedTypeService from "src/common/Api/LeCoffreApi/sdk/DeedTypeService";
|
||||||
import DocumentTypeService from "src/common/Api/LeCoffreApi/sdk/DocumentTypeService";
|
import DocumentTypeService from "src/common/Api/LeCoffreApi/sdk/DocumentTypeService";
|
||||||
import LoaderService from "src/common/Api/LeCoffreApi/sdk/Loader/LoaderService";
|
|
||||||
|
|
||||||
type IProps = {};
|
type IProps = {};
|
||||||
export default function DeedTypesInformations(props: IProps) {
|
export default function DeedTypesInformations(props: IProps) {
|
||||||
@ -51,11 +50,9 @@ export default function DeedTypesInformations(props: IProps) {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const deleteDeedType = useCallback(async () => {
|
const deleteDeedType = useCallback(async () => {
|
||||||
LoaderService.getInstance().show();
|
|
||||||
DeedTypeService.getDeedTypeByUid(deedTypeUid as string).then((process: any) => {
|
DeedTypeService.getDeedTypeByUid(deedTypeUid as string).then((process: any) => {
|
||||||
if (process) {
|
if (process) {
|
||||||
DeedTypeService.updateDeedType(process, { archived_at: new Date().toISOString() }).then(() => {
|
DeedTypeService.updateDeedType(process, { archived_at: new Date().toISOString() }).then(() => {
|
||||||
setTimeout(() => LoaderService.getInstance().hide(), 2000);
|
|
||||||
router.push(Module.getInstance().get().modules.pages.DeedTypes.props.path);
|
router.push(Module.getInstance().get().modules.pages.DeedTypes.props.path);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -106,7 +103,6 @@ export default function DeedTypesInformations(props: IProps) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const saveDocumentTypes = useCallback(() => {
|
const saveDocumentTypes = useCallback(() => {
|
||||||
LoaderService.getInstance().show();
|
|
||||||
DeedTypeService.getDeedTypeByUid(deedTypeUid as string, false).then((process: any) => {
|
DeedTypeService.getDeedTypeByUid(deedTypeUid as string, false).then((process: any) => {
|
||||||
if (process) {
|
if (process) {
|
||||||
const deedType: any = process.processData;
|
const deedType: any = process.processData;
|
||||||
@ -119,7 +115,6 @@ export default function DeedTypesInformations(props: IProps) {
|
|||||||
.forEach((selectedDocument: any) => document_types.push(selectedDocument));
|
.forEach((selectedDocument: any) => document_types.push(selectedDocument));
|
||||||
|
|
||||||
DeedTypeService.updateDeedType(process, { document_types: document_types }).then(() => {
|
DeedTypeService.updateDeedType(process, { document_types: document_types }).then(() => {
|
||||||
setTimeout(() => LoaderService.getInstance().hide(), 2000);
|
|
||||||
closeSaveModal();
|
closeSaveModal();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ import TextAreaField from "@Front/Components/DesignSystem/Form/TextareaField";
|
|||||||
import TextField from "@Front/Components/DesignSystem/Form/TextField";
|
import TextField from "@Front/Components/DesignSystem/Form/TextField";
|
||||||
import Typography, { ETypo } from "@Front/Components/DesignSystem/Typography";
|
import Typography, { ETypo } from "@Front/Components/DesignSystem/Typography";
|
||||||
import DefaultDocumentTypesDashboard from "@Front/Components/LayoutTemplates/DefaultDocumentTypesDashboard";
|
import DefaultDocumentTypesDashboard from "@Front/Components/LayoutTemplates/DefaultDocumentTypesDashboard";
|
||||||
import { ToasterService } from "@Front/Components/DesignSystem/Toaster";
|
|
||||||
import Module from "@Front/Config/Module";
|
import Module from "@Front/Config/Module";
|
||||||
import JwtService from "@Front/Services/JwtService/JwtService";
|
import JwtService from "@Front/Services/JwtService/JwtService";
|
||||||
import { validateOrReject, ValidationError } from "class-validator";
|
import { validateOrReject, ValidationError } from "class-validator";
|
||||||
@ -15,7 +14,6 @@ import { useCallback, useState } from "react";
|
|||||||
import classes from "./classes.module.scss";
|
import classes from "./classes.module.scss";
|
||||||
|
|
||||||
import DocumentTypeService from "src/common/Api/LeCoffreApi/sdk/DocumentTypeService";
|
import DocumentTypeService from "src/common/Api/LeCoffreApi/sdk/DocumentTypeService";
|
||||||
import LoaderService from "src/common/Api/LeCoffreApi/sdk/Loader/LoaderService";
|
|
||||||
|
|
||||||
type IProps = {};
|
type IProps = {};
|
||||||
export default function DocumentTypesCreate(props: IProps) {
|
export default function DocumentTypesCreate(props: IProps) {
|
||||||
@ -39,7 +37,7 @@ export default function DocumentTypesCreate(props: IProps) {
|
|||||||
});
|
});
|
||||||
await validateOrReject(documentFormModel, { groups: ["createDocumentType"] });
|
await validateOrReject(documentFormModel, { groups: ["createDocumentType"] });
|
||||||
|
|
||||||
const documentTypeData: any = {
|
const documentData: any = {
|
||||||
...values,
|
...values,
|
||||||
office: {
|
office: {
|
||||||
uid: officeId,
|
uid: officeId,
|
||||||
@ -47,13 +45,7 @@ export default function DocumentTypesCreate(props: IProps) {
|
|||||||
};
|
};
|
||||||
const validatorId: string = '884cb36a346a79af8697559f16940141f068bdf1656f88fa0df0e9ecd7311fb8:0';
|
const validatorId: string = '884cb36a346a79af8697559f16940141f068bdf1656f88fa0df0e9ecd7311fb8:0';
|
||||||
|
|
||||||
LoaderService.getInstance().show();
|
DocumentTypeService.createDocumentType(documentData, validatorId).then((processCreated: any) => {
|
||||||
DocumentTypeService.createDocumentType(documentTypeData, validatorId).then((processCreated: any) => {
|
|
||||||
ToasterService.getInstance().success({
|
|
||||||
title: "Succès !",
|
|
||||||
description: "Type de document créé avec succès"
|
|
||||||
});
|
|
||||||
setTimeout(() => LoaderService.getInstance().hide(), 2000);
|
|
||||||
router.push(
|
router.push(
|
||||||
Module.getInstance()
|
Module.getInstance()
|
||||||
.get()
|
.get()
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import DocumentTypes from "@Front/Api/LeCoffreApi/Notary/DocumentTypes/DocumentTypes";
|
||||||
import Button, { EButtonstyletype, EButtonVariant } from "@Front/Components/DesignSystem/Button";
|
import Button, { EButtonstyletype, EButtonVariant } from "@Front/Components/DesignSystem/Button";
|
||||||
import Form from "@Front/Components/DesignSystem/Form";
|
import Form from "@Front/Components/DesignSystem/Form";
|
||||||
import TextAreaField from "@Front/Components/DesignSystem/Form/TextareaField";
|
import TextAreaField from "@Front/Components/DesignSystem/Form/TextareaField";
|
||||||
@ -12,9 +13,6 @@ import { useCallback, useEffect, useState } from "react";
|
|||||||
|
|
||||||
import classes from "./classes.module.scss";
|
import classes from "./classes.module.scss";
|
||||||
|
|
||||||
import DocumentTypeService from "src/common/Api/LeCoffreApi/sdk/DocumentTypeService";
|
|
||||||
import LoaderService from "src/common/Api/LeCoffreApi/sdk/Loader/LoaderService";
|
|
||||||
|
|
||||||
export default function DocumentTypesEdit() {
|
export default function DocumentTypesEdit() {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
let { documentTypeUid } = router.query;
|
let { documentTypeUid } = router.query;
|
||||||
@ -25,14 +23,10 @@ export default function DocumentTypesEdit() {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
async function getDocumentType() {
|
async function getDocumentType() {
|
||||||
if (!documentTypeUid) return;
|
if (!documentTypeUid) return;
|
||||||
LoaderService.getInstance().show();
|
const documentType = await DocumentTypes.getInstance().getByUid(documentTypeUid as string, {
|
||||||
DocumentTypeService.getDocumentTypeByUid(documentTypeUid as string).then((process: any) => {
|
_count: true,
|
||||||
if (process) {
|
|
||||||
const documentType: any = process.processData;
|
|
||||||
setDocumentTypeSelected(documentType);
|
|
||||||
}
|
|
||||||
setTimeout(() => LoaderService.getInstance().hide(), 2000);
|
|
||||||
});
|
});
|
||||||
|
setDocumentTypeSelected(documentType);
|
||||||
}
|
}
|
||||||
|
|
||||||
getDocumentType();
|
getDocumentType();
|
||||||
@ -52,22 +46,16 @@ export default function DocumentTypesEdit() {
|
|||||||
setValidationError(validationErrors as ValidationError[]);
|
setValidationError(validationErrors as ValidationError[]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
LoaderService.getInstance().show();
|
|
||||||
DocumentTypeService.getDocumentTypeByUid(documentTypeUid as string).then((process: any) => {
|
const documentTypeUpdated = await DocumentTypes.getInstance().put(documentTypeUid as string, documentToUpdate);
|
||||||
if (process) {
|
|
||||||
DocumentTypeService.updateDocumentType(process, values).then(() => {
|
|
||||||
setTimeout(() => LoaderService.getInstance().hide(), 2000);
|
|
||||||
router.push(
|
router.push(
|
||||||
Module.getInstance()
|
Module.getInstance()
|
||||||
.get()
|
.get()
|
||||||
.modules.pages.DocumentTypes.pages.DocumentTypesInformations.props.path.replace(
|
.modules.pages.DocumentTypes.pages.DocumentTypesInformations.props.path.replace(
|
||||||
"[uid]",
|
"[uid]",
|
||||||
documentTypeUid as string ?? "",
|
documentTypeUpdated.uid ?? "",
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} catch (validationErrors: Array<ValidationError> | any) {
|
} catch (validationErrors: Array<ValidationError> | any) {
|
||||||
if (!Array.isArray(validationErrors)) return;
|
if (!Array.isArray(validationErrors)) return;
|
||||||
setValidationError(validationErrors as ValidationError[]);
|
setValidationError(validationErrors as ValidationError[]);
|
||||||
|
@ -7,7 +7,6 @@ import RadioBox from "@Front/Components/DesignSystem/RadioBox";
|
|||||||
import Typography, { ETypo } from "@Front/Components/DesignSystem/Typography";
|
import Typography, { ETypo } from "@Front/Components/DesignSystem/Typography";
|
||||||
import BackArrow from "@Front/Components/Elements/BackArrow";
|
import BackArrow from "@Front/Components/Elements/BackArrow";
|
||||||
import Module from "@Front/Config/Module";
|
import Module from "@Front/Config/Module";
|
||||||
import { ToasterService } from "@Front/Components/DesignSystem/Toaster";
|
|
||||||
import { ValidationError } from "class-validator";
|
import { ValidationError } from "class-validator";
|
||||||
import { ECivility } from "le-coffre-resources/dist/Customer/Contact";
|
import { ECivility } from "le-coffre-resources/dist/Customer/Contact";
|
||||||
import { Contact, Customer } from "le-coffre-resources/dist/Notary";
|
import { Contact, Customer } from "le-coffre-resources/dist/Notary";
|
||||||
@ -18,7 +17,6 @@ import classes from "./classes.module.scss";
|
|||||||
import { useCallback, useEffect, useState } from "react";
|
import { useCallback, useEffect, useState } from "react";
|
||||||
import DefaultDoubleSidePage from "@Front/Components/LayoutTemplates/DefaultDoubleSidePage";
|
import DefaultDoubleSidePage from "@Front/Components/LayoutTemplates/DefaultDoubleSidePage";
|
||||||
|
|
||||||
import LoaderService from "src/common/Api/LeCoffreApi/sdk/Loader/LoaderService";
|
|
||||||
import CustomerService from "src/common/Api/LeCoffreApi/sdk/CustomerService";
|
import CustomerService from "src/common/Api/LeCoffreApi/sdk/CustomerService";
|
||||||
import FolderService from "src/common/Api/LeCoffreApi/sdk/FolderService";
|
import FolderService from "src/common/Api/LeCoffreApi/sdk/FolderService";
|
||||||
|
|
||||||
@ -80,7 +78,6 @@ export default function AddClientToFolder(props: IProps) {
|
|||||||
};
|
};
|
||||||
const validatorId: string = '884cb36a346a79af8697559f16940141f068bdf1656f88fa0df0e9ecd7311fb8:0';
|
const validatorId: string = '884cb36a346a79af8697559f16940141f068bdf1656f88fa0df0e9ecd7311fb8:0';
|
||||||
|
|
||||||
LoaderService.getInstance().show();
|
|
||||||
CustomerService.createCustomer(customerData, validatorId).then((processCreated: any) => {
|
CustomerService.createCustomer(customerData, validatorId).then((processCreated: any) => {
|
||||||
FolderService.getFolderByUid(folderUid as string, false, false).then((process: any) => {
|
FolderService.getFolderByUid(folderUid as string, false, false).then((process: any) => {
|
||||||
if (process) {
|
if (process) {
|
||||||
@ -91,11 +88,6 @@ export default function AddClientToFolder(props: IProps) {
|
|||||||
customers.push(processCreated.processData.uid);
|
customers.push(processCreated.processData.uid);
|
||||||
|
|
||||||
FolderService.updateFolder(process, { customers: customers }).then(() => {
|
FolderService.updateFolder(process, { customers: customers }).then(() => {
|
||||||
ToasterService.getInstance().success({
|
|
||||||
title: "Succès !",
|
|
||||||
description: "Client ajouté avec succès au dossier"
|
|
||||||
});
|
|
||||||
setTimeout(() => LoaderService.getInstance().hide(), 2000);
|
|
||||||
router.push(`/folders/${folderUid}`);
|
router.push(`/folders/${folderUid}`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -107,17 +99,11 @@ export default function AddClientToFolder(props: IProps) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
LoaderService.getInstance().show();
|
|
||||||
FolderService.getFolderByUid(folderUid as string, false, false).then((process: any) => {
|
FolderService.getFolderByUid(folderUid as string, false, false).then((process: any) => {
|
||||||
if (process) {
|
if (process) {
|
||||||
const customers: any[] = customersToLink.map((customer: any) => customer.uid);
|
const customers: any[] = customersToLink.map((customer: any) => customer.uid);
|
||||||
|
|
||||||
FolderService.updateFolder(process, { customers: customers }).then(() => {
|
FolderService.updateFolder(process, { customers: customers }).then(() => {
|
||||||
ToasterService.getInstance().success({
|
|
||||||
title: "Succès !",
|
|
||||||
description: selectedCustomers.length > 1 ? "Clients associés avec succès au dossier" : "Client associé avec succès au dossier"
|
|
||||||
});
|
|
||||||
setTimeout(() => LoaderService.getInstance().hide(), 2000);
|
|
||||||
router.push(`/folders/${folderUid}`);
|
router.push(`/folders/${folderUid}`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -156,7 +142,6 @@ export default function AddClientToFolder(props: IProps) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const loadCustomers = useCallback(async () => {
|
const loadCustomers = useCallback(async () => {
|
||||||
LoaderService.getInstance().show();
|
|
||||||
CustomerService.getCustomers().then(async (processes: any[]) => {
|
CustomerService.getCustomers().then(async (processes: any[]) => {
|
||||||
const availableCustomers: any[] = processes.map((process: any) => process.processData);
|
const availableCustomers: any[] = processes.map((process: any) => process.processData);
|
||||||
|
|
||||||
@ -177,8 +162,6 @@ export default function AddClientToFolder(props: IProps) {
|
|||||||
setExistingCustomers(existingCustomers);
|
setExistingCustomers(existingCustomers);
|
||||||
setIsLoaded(true);
|
setIsLoaded(true);
|
||||||
setSelectedOption(selectedOption);
|
setSelectedOption(selectedOption);
|
||||||
|
|
||||||
LoaderService.getInstance().hide();
|
|
||||||
});
|
});
|
||||||
}, [folderUid, getFolderPreSelectedCustomers]);
|
}, [folderUid, getFolderPreSelectedCustomers]);
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import Deeds from "@Front/Api/LeCoffreApi/Notary/Deeds/Deeds";
|
||||||
|
import DocumentTypes from "@Front/Api/LeCoffreApi/Notary/DocumentTypes/DocumentTypes";
|
||||||
import { IOption } from "@Front/Components/DesignSystem/Dropdown/DropdownMenu/DropdownOption";
|
import { IOption } from "@Front/Components/DesignSystem/Dropdown/DropdownMenu/DropdownOption";
|
||||||
import AutocompleteMultiSelectField from "@Front/Components/DesignSystem/Form/AutocompleteMultiSelectField";
|
import AutocompleteMultiSelectField from "@Front/Components/DesignSystem/Form/AutocompleteMultiSelectField";
|
||||||
import { IOption as IFormOption } from "@Front/Components/DesignSystem/Form/SelectFieldOld";
|
import { IOption as IFormOption } from "@Front/Components/DesignSystem/Form/SelectFieldOld";
|
||||||
@ -5,14 +7,12 @@ import TextAreaField from "@Front/Components/DesignSystem/Form/TextareaField";
|
|||||||
import TextField from "@Front/Components/DesignSystem/Form/TextField";
|
import TextField from "@Front/Components/DesignSystem/Form/TextField";
|
||||||
import Modal from "@Front/Components/DesignSystem/Modal";
|
import Modal from "@Front/Components/DesignSystem/Modal";
|
||||||
import RadioBox from "@Front/Components/DesignSystem/RadioBox";
|
import RadioBox from "@Front/Components/DesignSystem/RadioBox";
|
||||||
import { OfficeFolder } from "le-coffre-resources/dist/Notary";
|
import { DocumentType, OfficeFolder } from "le-coffre-resources/dist/Notary";
|
||||||
import { ChangeEvent, useCallback, useEffect, useState } from "react";
|
import { ChangeEvent, useCallback, useEffect, useState } from "react";
|
||||||
|
|
||||||
import classes from "./classes.module.scss";
|
import classes from "./classes.module.scss";
|
||||||
|
|
||||||
import DocumentTypeService from "src/common/Api/LeCoffreApi/sdk/DocumentTypeService";
|
import DocumentTypeService from "src/common/Api/LeCoffreApi/sdk/DocumentTypeService";
|
||||||
import DeedTypeService from "src/common/Api/LeCoffreApi/sdk/DeedTypeService";
|
|
||||||
import LoaderService from "src/common/Api/LeCoffreApi/sdk/Loader/LoaderService";
|
|
||||||
|
|
||||||
type IProps = {
|
type IProps = {
|
||||||
isCreateDocumentModalVisible: boolean;
|
isCreateDocumentModalVisible: boolean;
|
||||||
@ -75,38 +75,18 @@ export default function ParameterDocuments(props: IProps) {
|
|||||||
const addDocument = useCallback(async () => {
|
const addDocument = useCallback(async () => {
|
||||||
if (addOrEditDocument === "add") {
|
if (addOrEditDocument === "add") {
|
||||||
try {
|
try {
|
||||||
LoaderService.getInstance().show();
|
const documentType = await DocumentTypes.getInstance().post({
|
||||||
|
|
||||||
const documentTypeData: any = {
|
|
||||||
name: documentName,
|
name: documentName,
|
||||||
private_description: visibleDescription,
|
private_description: visibleDescription,
|
||||||
office: {
|
office: {
|
||||||
uid: props.folder.office!.uid!,
|
uid: props.folder.office!.uid!,
|
||||||
},
|
},
|
||||||
public_description: visibleDescription,
|
public_description: visibleDescription,
|
||||||
};
|
|
||||||
const validatorId: string = '884cb36a346a79af8697559f16940141f068bdf1656f88fa0df0e9ecd7311fb8:0';
|
|
||||||
|
|
||||||
const documentType: any = await new Promise<any>((resolve: (documentType: any) => void) => {
|
|
||||||
DocumentTypeService.createDocumentType(documentTypeData, validatorId).then((processCreated: any) => {
|
|
||||||
const documentType: any = processCreated.processData;
|
|
||||||
resolve(documentType);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const oldDocumentsType = props.folder.deed?.document_types!;
|
const oldDocumentsType = props.folder.deed?.document_types!;
|
||||||
|
await Deeds.getInstance().put(props.folder.deed?.uid!, {
|
||||||
await new Promise<void>((resolve: () => void) => {
|
document_types: [...oldDocumentsType, documentType],
|
||||||
DeedTypeService.getDeedTypeByUid(props.folder.deed?.deed_type?.uid!).then((process: any) => {
|
|
||||||
if (process) {
|
|
||||||
DeedTypeService.updateDeedType(process, {
|
|
||||||
document_types: [
|
|
||||||
...oldDocumentsType.map((document: any) => ({ uid: document.uid })),
|
|
||||||
{ uid: documentType.uid }
|
|
||||||
]
|
|
||||||
}).then(() => resolve());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Create a new document type in the format expected by the parent component
|
// Create a new document type in the format expected by the parent component
|
||||||
@ -120,44 +100,28 @@ export default function ParameterDocuments(props: IProps) {
|
|||||||
props.onDocumentsUpdated([newDocumentType]);
|
props.onDocumentsUpdated([newDocumentType]);
|
||||||
}
|
}
|
||||||
|
|
||||||
LoaderService.getInstance().hide();
|
|
||||||
handleClose();
|
handleClose();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
LoaderService.getInstance().show();
|
|
||||||
|
|
||||||
const oldDocumentsType = props.folder.deed?.document_types!;
|
const oldDocumentsType = props.folder.deed?.document_types!;
|
||||||
await new Promise<void>((resolve: () => void) => {
|
await Deeds.getInstance().put(props.folder.deed?.uid!, {
|
||||||
DeedTypeService.getDeedTypeByUid(props.folder.deed?.deed_type?.uid!).then((process: any) => {
|
|
||||||
if (process) {
|
|
||||||
DeedTypeService.updateDeedType(process, {
|
|
||||||
document_types: [
|
document_types: [
|
||||||
...oldDocumentsType.map((document: any) => ({ uid: document.uid })),
|
...oldDocumentsType,
|
||||||
...selectedDocuments.map((document: any) => ({ uid: document.id as string }))
|
...selectedDocuments.map((document) => DocumentType.hydrate<DocumentType>({ uid: document.id as string })),
|
||||||
]
|
],
|
||||||
}).then(() => resolve());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Get the full document details for the selected documents
|
// Get the full document details for the selected documents
|
||||||
const documentsById = await Promise.all(
|
const documentsById = await Promise.all(
|
||||||
selectedDocuments.map(async (doc) => {
|
selectedDocuments.map(async (doc) => {
|
||||||
const documentType: any = await new Promise<any>((resolve: (documentType: any) => void) => {
|
const fullDoc = await DocumentTypes.getInstance().getByUid(doc.id as string);
|
||||||
DocumentTypeService.getDocumentTypeByUid(doc.id as string).then((process: any) => {
|
|
||||||
if (process) {
|
|
||||||
const documentType: any = process.processData;
|
|
||||||
resolve(documentType);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
return {
|
return {
|
||||||
label: documentType.name!,
|
label: fullDoc.name!,
|
||||||
value: documentType.uid!,
|
value: fullDoc.uid!,
|
||||||
description: documentType.private_description!,
|
description: fullDoc.private_description!,
|
||||||
} as IFormOption;
|
} as IFormOption;
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
@ -166,7 +130,6 @@ export default function ParameterDocuments(props: IProps) {
|
|||||||
props.onDocumentsUpdated(documentsById);
|
props.onDocumentsUpdated(documentsById);
|
||||||
}
|
}
|
||||||
|
|
||||||
LoaderService.getInstance().hide();
|
|
||||||
handleClose();
|
handleClose();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
|
@ -17,7 +17,6 @@ import backgroundImage from "@Assets/images/background_refonte.svg";
|
|||||||
|
|
||||||
import FolderService from "src/common/Api/LeCoffreApi/sdk/FolderService";
|
import FolderService from "src/common/Api/LeCoffreApi/sdk/FolderService";
|
||||||
import DocumentService from "src/common/Api/LeCoffreApi/sdk/DocumentService";
|
import DocumentService from "src/common/Api/LeCoffreApi/sdk/DocumentService";
|
||||||
import LoaderService from "src/common/Api/LeCoffreApi/sdk/Loader/LoaderService";
|
|
||||||
|
|
||||||
export default function AskDocuments() {
|
export default function AskDocuments() {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
@ -59,8 +58,8 @@ export default function AskDocuments() {
|
|||||||
) => {
|
) => {
|
||||||
try {
|
try {
|
||||||
// TODO: review
|
// TODO: review
|
||||||
LoaderService.getInstance().show();
|
|
||||||
const documentAsked: [] = values["document_types"] as [];
|
const documentAsked: [] = values["document_types"] as [];
|
||||||
|
|
||||||
for (let i = 0; i < documentAsked.length; i++) {
|
for (let i = 0; i < documentAsked.length; i++) {
|
||||||
const documentData: any = {
|
const documentData: any = {
|
||||||
folder: {
|
folder: {
|
||||||
@ -78,6 +77,7 @@ export default function AskDocuments() {
|
|||||||
|
|
||||||
await DocumentService.createDocument(documentData, validatorId);
|
await DocumentService.createDocument(documentData, validatorId);
|
||||||
}
|
}
|
||||||
|
|
||||||
router.push(
|
router.push(
|
||||||
Module.getInstance()
|
Module.getInstance()
|
||||||
.get()
|
.get()
|
||||||
@ -127,13 +127,11 @@ export default function AskDocuments() {
|
|||||||
|
|
||||||
const loadData = useCallback(async () => {
|
const loadData = useCallback(async () => {
|
||||||
try {
|
try {
|
||||||
LoaderService.getInstance().show();
|
|
||||||
FolderService.getFolderByUid(folderUid as string).then(async (process: any) => {
|
FolderService.getFolderByUid(folderUid as string).then(async (process: any) => {
|
||||||
if (process) {
|
if (process) {
|
||||||
const folder: any = process.processData;
|
const folder: any = process.processData;
|
||||||
setFolder(folder);
|
setFolder(folder);
|
||||||
setDocumentTypes(await getAvailableDocuments(folder));
|
setDocumentTypes(await getAvailableDocuments(folder));
|
||||||
LoaderService.getInstance().hide();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -17,7 +17,6 @@ import Note from "le-coffre-resources/dist/Customer/Note";
|
|||||||
import FolderService from "src/common/Api/LeCoffreApi/sdk/FolderService";
|
import FolderService from "src/common/Api/LeCoffreApi/sdk/FolderService";
|
||||||
import CustomerService from "src/common/Api/LeCoffreApi/sdk/CustomerService";
|
import CustomerService from "src/common/Api/LeCoffreApi/sdk/CustomerService";
|
||||||
import NoteService from "src/common/Api/LeCoffreApi/sdk/NoteService";
|
import NoteService from "src/common/Api/LeCoffreApi/sdk/NoteService";
|
||||||
import LoaderService from "src/common/Api/LeCoffreApi/sdk/Loader/LoaderService";
|
|
||||||
|
|
||||||
type IProps = {};
|
type IProps = {};
|
||||||
|
|
||||||
@ -84,8 +83,6 @@ class CreateCustomerNoteClass extends BasePage<IPropsClass, IState> {
|
|||||||
const customer = await Customers.getInstance().getByUid(this.props.customerUid);
|
const customer = await Customers.getInstance().getByUid(this.props.customerUid);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
LoaderService.getInstance().show();
|
|
||||||
|
|
||||||
const folder: any = await FolderService.getFolderByUid(this.props.folderUid).then((process: any) => {
|
const folder: any = await FolderService.getFolderByUid(this.props.folderUid).then((process: any) => {
|
||||||
if (process) {
|
if (process) {
|
||||||
const folder: any = process.processData;
|
const folder: any = process.processData;
|
||||||
@ -100,8 +97,6 @@ class CreateCustomerNoteClass extends BasePage<IPropsClass, IState> {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
LoaderService.getInstance().hide();
|
|
||||||
|
|
||||||
//get the note of the folder that has customer_uid = this.props.customer.uid
|
//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);
|
// const folderNote = folder.notes?.find((note) => note.customer?.uid === this.props.customerUid);
|
||||||
// this.setState({ note, folder: note.office_folder || null, customer: note.customer || null });
|
// this.setState({ note, folder: note.office_folder || null, customer: note.customer || null });
|
||||||
@ -126,7 +121,6 @@ class CreateCustomerNoteClass extends BasePage<IPropsClass, IState> {
|
|||||||
};
|
};
|
||||||
const validatorId: string = '884cb36a346a79af8697559f16940141f068bdf1656f88fa0df0e9ecd7311fb8:0';
|
const validatorId: string = '884cb36a346a79af8697559f16940141f068bdf1656f88fa0df0e9ecd7311fb8:0';
|
||||||
|
|
||||||
LoaderService.getInstance().show();
|
|
||||||
NoteService.createNote(noteData, validatorId).then(() => {
|
NoteService.createNote(noteData, validatorId).then(() => {
|
||||||
this.props.router.push(this.backwardPath);
|
this.props.router.push(this.backwardPath);
|
||||||
});
|
});
|
||||||
|
@ -8,7 +8,6 @@ import TextAreaField from "@Front/Components/DesignSystem/Form/TextareaField";
|
|||||||
import TextField from "@Front/Components/DesignSystem/Form/TextField";
|
import TextField from "@Front/Components/DesignSystem/Form/TextField";
|
||||||
import RadioBox from "@Front/Components/DesignSystem/RadioBox";
|
import RadioBox from "@Front/Components/DesignSystem/RadioBox";
|
||||||
import Typography, { ETypo, ETypoColor } from "@Front/Components/DesignSystem/Typography";
|
import Typography, { ETypo, ETypoColor } from "@Front/Components/DesignSystem/Typography";
|
||||||
import { ToasterService } from "@Front/Components/DesignSystem/Toaster";
|
|
||||||
import BackArrow from "@Front/Components/Elements/BackArrow";
|
import BackArrow from "@Front/Components/Elements/BackArrow";
|
||||||
import DefaultDoubleSidePage from "@Front/Components/LayoutTemplates/DefaultDoubleSidePage";
|
import DefaultDoubleSidePage from "@Front/Components/LayoutTemplates/DefaultDoubleSidePage";
|
||||||
import JwtService from "@Front/Services/JwtService/JwtService";
|
import JwtService from "@Front/Services/JwtService/JwtService";
|
||||||
@ -23,7 +22,6 @@ import classes from "./classes.module.scss";
|
|||||||
|
|
||||||
import FolderService from "src/common/Api/LeCoffreApi/sdk/FolderService";
|
import FolderService from "src/common/Api/LeCoffreApi/sdk/FolderService";
|
||||||
import DeedTypeService from "src/common/Api/LeCoffreApi/sdk/DeedTypeService";
|
import DeedTypeService from "src/common/Api/LeCoffreApi/sdk/DeedTypeService";
|
||||||
import LoaderService from "src/common/Api/LeCoffreApi/sdk/Loader/LoaderService";
|
|
||||||
|
|
||||||
export default function CreateFolder(): JSX.Element {
|
export default function CreateFolder(): JSX.Element {
|
||||||
/**
|
/**
|
||||||
@ -97,13 +95,7 @@ export default function CreateFolder(): JSX.Element {
|
|||||||
status: EFolderStatus.LIVE
|
status: EFolderStatus.LIVE
|
||||||
};
|
};
|
||||||
|
|
||||||
LoaderService.getInstance().show();
|
|
||||||
FolderService.createFolder(folderData, [], []).then((processCreated: any) => {
|
FolderService.createFolder(folderData, [], []).then((processCreated: any) => {
|
||||||
ToasterService.getInstance().success({
|
|
||||||
title: "Succès !",
|
|
||||||
description: "Dossier créé avec succès"
|
|
||||||
});
|
|
||||||
setTimeout(() => LoaderService.getInstance().hide(), 2000);
|
|
||||||
const folderUid: string = processCreated.processData.uid;
|
const folderUid: string = processCreated.processData.uid;
|
||||||
router.push(`/folders/${folderUid}`);
|
router.push(`/folders/${folderUid}`);
|
||||||
});
|
});
|
||||||
|
@ -14,7 +14,6 @@ import classes from "./classes.module.scss";
|
|||||||
import DeleteCustomerModal from "./DeleteCustomerModal";
|
import DeleteCustomerModal from "./DeleteCustomerModal";
|
||||||
|
|
||||||
import DocumentService from "src/common/Api/LeCoffreApi/sdk/DocumentService";
|
import DocumentService from "src/common/Api/LeCoffreApi/sdk/DocumentService";
|
||||||
import LoaderService from "src/common/Api/LeCoffreApi/sdk/Loader/LoaderService";
|
|
||||||
|
|
||||||
type IProps = {
|
type IProps = {
|
||||||
customer: Customer;
|
customer: Customer;
|
||||||
@ -38,13 +37,12 @@ export default function ClientBox(props: IProps) {
|
|||||||
|
|
||||||
const handleDelete = useCallback(
|
const handleDelete = useCallback(
|
||||||
(customerUid: string) => {
|
(customerUid: string) => {
|
||||||
LoaderService.getInstance().show();
|
|
||||||
DocumentService.getDocuments().then((processes: any[]) => {
|
DocumentService.getDocuments().then((processes: any[]) => {
|
||||||
if (processes.length > 0) {
|
if (processes.length > 0) {
|
||||||
let documents: any[] = processes.map((process: any) => process.processData);
|
let documents: any[] = processes.map((process: any) => process.processData);
|
||||||
|
|
||||||
// FilterBy folder.uid & depositor.uid
|
// FilterBy depositor_uid & folder_uid
|
||||||
documents = documents.filter((document: any) => document.folder.uid === folderUid && document.depositor && document.depositor.uid === customerUid);
|
documents = documents.filter((document: any) => document.depositor.uid === customerUid && document.folder.uid === folderUid);
|
||||||
|
|
||||||
if (documents && documents.length > 0) {
|
if (documents && documents.length > 0) {
|
||||||
closeDeleteModal();
|
closeDeleteModal();
|
||||||
|
@ -4,7 +4,6 @@ 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 LoaderService from "src/common/Api/LeCoffreApi/sdk/Loader/LoaderService";
|
|
||||||
|
|
||||||
type IProps = {
|
type IProps = {
|
||||||
documentUid: string;
|
documentUid: string;
|
||||||
@ -17,8 +16,7 @@ export default function DeleteAskedDocumentModal(props: IProps) {
|
|||||||
const { isOpen, onClose, documentUid, onDeleteSuccess } = props;
|
const { isOpen, onClose, documentUid, onDeleteSuccess } = props;
|
||||||
|
|
||||||
const onDelete = useCallback(
|
const onDelete = useCallback(
|
||||||
() => {
|
() =>
|
||||||
LoaderService.getInstance().show();
|
|
||||||
new Promise<void>(
|
new Promise<void>(
|
||||||
(resolve: () => void) => {
|
(resolve: () => void) => {
|
||||||
DocumentService.getDocumentByUid(documentUid).then((process: any) => {
|
DocumentService.getDocumentByUid(documentUid).then((process: any) => {
|
||||||
@ -29,10 +27,8 @@ export default function DeleteAskedDocumentModal(props: IProps) {
|
|||||||
})
|
})
|
||||||
.then(() => onDeleteSuccess(documentUid))
|
.then(() => onDeleteSuccess(documentUid))
|
||||||
.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(onClose)
|
.then(onClose)
|
||||||
.catch((error) => console.warn(error));
|
.catch((error) => console.warn(error)),
|
||||||
},
|
|
||||||
[documentUid, onClose, onDeleteSuccess],
|
[documentUid, onClose, onDeleteSuccess],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
|
import DocumentsNotary from "@Front/Api/LeCoffreApi/Notary/DocumentsNotary/DocumentsNotary";
|
||||||
import Modal from "@Front/Components/DesignSystem/Modal";
|
import Modal from "@Front/Components/DesignSystem/Modal";
|
||||||
import { ToasterService } from "@Front/Components/DesignSystem/Toaster";
|
import { ToasterService } from "@Front/Components/DesignSystem/Toaster";
|
||||||
import Typography, { ETypo } from "@Front/Components/DesignSystem/Typography";
|
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 LoaderService from "src/common/Api/LeCoffreApi/sdk/Loader/LoaderService";
|
|
||||||
|
|
||||||
type IProps = {
|
type IProps = {
|
||||||
documentUid: string;
|
documentUid: string;
|
||||||
isOpen: boolean;
|
isOpen: boolean;
|
||||||
@ -17,18 +15,13 @@ export default function DeleteSentDocumentModal(props: IProps) {
|
|||||||
const { isOpen, onClose, documentUid, onDeleteSuccess } = props;
|
const { isOpen, onClose, documentUid, onDeleteSuccess } = props;
|
||||||
|
|
||||||
const onDelete = useCallback(
|
const onDelete = useCallback(
|
||||||
() => {
|
() =>
|
||||||
LoaderService.getInstance().show();
|
DocumentsNotary.getInstance()
|
||||||
DocumentService.getDocumentByUid(documentUid).then((process: any) => {
|
.delete(documentUid)
|
||||||
if (process) {
|
|
||||||
DocumentService.updateDocument(process, { isDeleted: 'true' })
|
|
||||||
.then(() => onDeleteSuccess(documentUid))
|
.then(() => onDeleteSuccess(documentUid))
|
||||||
.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(onClose)
|
||||||
.then(onClose);
|
.catch((error) => console.warn(error)),
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
[documentUid, onClose, onDeleteSuccess],
|
[documentUid, onClose, onDeleteSuccess],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import DocumentsNotary from "@Front/Api/LeCoffreApi/Notary/DocumentsNotary/DocumentsNotary";
|
||||||
|
import FilesNotary from "@Front/Api/LeCoffreApi/Notary/FilesNotary/Files";
|
||||||
import CircleProgress from "@Front/Components/DesignSystem/CircleProgress";
|
import CircleProgress from "@Front/Components/DesignSystem/CircleProgress";
|
||||||
import IconButton from "@Front/Components/DesignSystem/IconButton";
|
import IconButton from "@Front/Components/DesignSystem/IconButton";
|
||||||
import Table from "@Front/Components/DesignSystem/Table";
|
import Table from "@Front/Components/DesignSystem/Table";
|
||||||
@ -8,6 +10,7 @@ import Module from "@Front/Config/Module";
|
|||||||
import useOpenable from "@Front/Hooks/useOpenable";
|
import useOpenable from "@Front/Hooks/useOpenable";
|
||||||
import { ArrowDownTrayIcon, EyeIcon, TrashIcon } from "@heroicons/react/24/outline";
|
import { ArrowDownTrayIcon, EyeIcon, TrashIcon } from "@heroicons/react/24/outline";
|
||||||
import { useMediaQuery } from "@mui/material";
|
import { useMediaQuery } from "@mui/material";
|
||||||
|
import { Document } from "le-coffre-resources/dist/Customer";
|
||||||
import { EDocumentStatus } from "le-coffre-resources/dist/Customer/Document";
|
import { EDocumentStatus } from "le-coffre-resources/dist/Customer/Document";
|
||||||
import DocumentNotary, { EDocumentNotaryStatus } from "le-coffre-resources/dist/Notary/DocumentNotary";
|
import DocumentNotary, { EDocumentNotaryStatus } from "le-coffre-resources/dist/Notary/DocumentNotary";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
@ -21,7 +24,6 @@ import DeleteSentDocumentModal from "./DeleteSentDocumentModal";
|
|||||||
import DocumentService from "src/common/Api/LeCoffreApi/sdk/DocumentService";
|
import DocumentService from "src/common/Api/LeCoffreApi/sdk/DocumentService";
|
||||||
import DocumentTypeService from "src/common/Api/LeCoffreApi/sdk/DocumentTypeService";
|
import DocumentTypeService from "src/common/Api/LeCoffreApi/sdk/DocumentTypeService";
|
||||||
import FileService from "src/common/Api/LeCoffreApi/sdk/FileService";
|
import FileService from "src/common/Api/LeCoffreApi/sdk/FileService";
|
||||||
import LoaderService from "src/common/Api/LeCoffreApi/sdk/Loader/LoaderService";
|
|
||||||
|
|
||||||
type IProps = {
|
type IProps = {
|
||||||
customerUid: string;
|
customerUid: string;
|
||||||
@ -42,7 +44,7 @@ const tradDocumentsNotaryStatus: Record<EDocumentNotaryStatus, string> = {
|
|||||||
|
|
||||||
export default function DocumentTables(props: IProps) {
|
export default function DocumentTables(props: IProps) {
|
||||||
const { folderUid, customerUid } = props;
|
const { folderUid, customerUid } = props;
|
||||||
const [documents, setDocuments] = useState<any[]>([]);
|
const [documents, setDocuments] = useState<Document[]>([]);
|
||||||
const [documentsNotary, setDocumentsNotary] = useState<DocumentNotary[]>([]);
|
const [documentsNotary, setDocumentsNotary] = useState<DocumentNotary[]>([]);
|
||||||
const [focusedDocumentUid, setFocusedDocumentUid] = useState<string | null>(null);
|
const [focusedDocumentUid, setFocusedDocumentUid] = useState<string | null>(null);
|
||||||
|
|
||||||
@ -53,18 +55,17 @@ export default function DocumentTables(props: IProps) {
|
|||||||
|
|
||||||
const fetchDocuments = useCallback(
|
const fetchDocuments = useCallback(
|
||||||
() => {
|
() => {
|
||||||
LoaderService.getInstance().show();
|
setDocuments([]);
|
||||||
|
|
||||||
DocumentService.getDocuments().then(async (processes: any[]) => {
|
DocumentService.getDocuments().then(async (processes: any[]) => {
|
||||||
if (processes.length > 0) {
|
if (processes.length > 0) {
|
||||||
let documents: any[] = processes.map((process: any) => process.processData);
|
let documents: any[] = processes.map((process: any) => process.processData);
|
||||||
|
|
||||||
// FilterBy folder.uid & depositor.uid
|
// FilterBy folder.uid & depositor.uid
|
||||||
documents = documents.filter((document: any) => document.folder.uid === folderUid && document.depositor && document.depositor.uid === customerUid);
|
documents = documents.filter((document: any) => document.folder.uid === folderUid && document.depositor.uid === customerUid);
|
||||||
|
|
||||||
for (const document of documents) {
|
for (const document of documents) {
|
||||||
if (document.document_type) {
|
|
||||||
document.document_type = (await DocumentTypeService.getDocumentTypeByUid(document.document_type.uid)).processData;
|
document.document_type = (await DocumentTypeService.getDocumentTypeByUid(document.document_type.uid)).processData;
|
||||||
}
|
|
||||||
|
|
||||||
if (document.files && document.files.length > 0) {
|
if (document.files && document.files.length > 0) {
|
||||||
const files: any[] = [];
|
const files: any[] = [];
|
||||||
@ -79,45 +80,24 @@ export default function DocumentTables(props: IProps) {
|
|||||||
} else {
|
} else {
|
||||||
setDocuments([]);
|
setDocuments([]);
|
||||||
}
|
}
|
||||||
LoaderService.getInstance().hide();
|
})
|
||||||
});
|
|
||||||
},
|
},
|
||||||
[customerUid, folderUid],
|
[customerUid, folderUid],
|
||||||
);
|
);
|
||||||
|
|
||||||
const fetchDocumentsNotary = useCallback(
|
const fetchDocumentsNotary = useCallback(
|
||||||
() => {
|
() =>
|
||||||
LoaderService.getInstance().show();
|
DocumentsNotary.getInstance()
|
||||||
DocumentService.getDocuments().then(async (processes: any[]) => {
|
.get({ where: { folder: { uid: folderUid }, customer: { uid: customerUid } }, include: { files: true } })
|
||||||
if (processes.length > 0) {
|
.then(setDocumentsNotary)
|
||||||
let documents: any[] = processes.map((process: any) => process.processData);
|
.catch(console.warn),
|
||||||
|
|
||||||
// FilterBy folder.uid & customer.uid
|
|
||||||
documents = documents.filter((document: any) => document.folder.uid === folderUid && document.customer && document.customer.uid === customerUid);
|
|
||||||
|
|
||||||
for (const document of documents) {
|
|
||||||
if (document.files && document.files.length > 0) {
|
|
||||||
const files: any[] = [];
|
|
||||||
for (const file of document.files) {
|
|
||||||
files.push((await FileService.getFileByUid(file.uid)).processData);
|
|
||||||
}
|
|
||||||
document.files = files;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
setDocumentsNotary(documents);
|
|
||||||
} else {
|
|
||||||
setDocumentsNotary([]);
|
|
||||||
}
|
|
||||||
LoaderService.getInstance().hide();
|
|
||||||
});
|
|
||||||
},
|
|
||||||
[customerUid, folderUid],
|
[customerUid, folderUid],
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
// TODO: review
|
||||||
fetchDocuments();
|
fetchDocuments();
|
||||||
fetchDocumentsNotary();
|
//fetchDocumentsNotary();
|
||||||
}, [fetchDocuments, fetchDocumentsNotary]);
|
}, [fetchDocuments, fetchDocumentsNotary]);
|
||||||
|
|
||||||
const openDeleteAskedDocumentModal = useCallback(
|
const openDeleteAskedDocumentModal = useCallback(
|
||||||
@ -157,23 +137,21 @@ export default function DocumentTables(props: IProps) {
|
|||||||
}).catch((e) => console.warn(e));
|
}).catch((e) => console.warn(e));
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const onDownloadFileNotary = useCallback((doc: any) => {
|
const onDownloadFileNotary = useCallback((doc: DocumentNotary) => {
|
||||||
const file = doc.files?.[0];
|
const file = doc.files?.[0];
|
||||||
if (!file) return;
|
if (!file || !file?.uid) return;
|
||||||
|
|
||||||
return new Promise<void>((resolve: () => void) => {
|
return FilesNotary.getInstance()
|
||||||
const blob = new Blob([file.file_blob.data], { type: file.file_blob.type });
|
.download(file.uid)
|
||||||
|
.then((blob) => {
|
||||||
const url = URL.createObjectURL(blob);
|
const url = URL.createObjectURL(blob);
|
||||||
const a = document.createElement('a');
|
const a = document.createElement("a");
|
||||||
a.href = url;
|
a.href = url;
|
||||||
a.download = file.file_name;
|
a.download = file.file_name ?? "file";
|
||||||
document.body.appendChild(a);
|
|
||||||
a.click();
|
a.click();
|
||||||
document.body.removeChild(a);
|
|
||||||
URL.revokeObjectURL(url);
|
URL.revokeObjectURL(url);
|
||||||
|
})
|
||||||
resolve();
|
.catch((e) => console.warn(e));
|
||||||
}).catch((e) => console.warn(e));
|
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const askedDocuments: IRowProps[] = useMemo(
|
const askedDocuments: IRowProps[] = useMemo(
|
||||||
@ -183,25 +161,21 @@ export default function DocumentTables(props: IProps) {
|
|||||||
if (document.document_status !== EDocumentStatus.ASKED) return null;
|
if (document.document_status !== EDocumentStatus.ASKED) return null;
|
||||||
return {
|
return {
|
||||||
key: document.uid,
|
key: document.uid,
|
||||||
document_type: { sx: { width: 300 }, content: document.document_type?.name ?? "_" },
|
document_type: { sx: { width: 400 }, content: document.document_type?.name ?? "_" },
|
||||||
document_status: {
|
document_status: {
|
||||||
sx: { width: 107 },
|
sx: { width: 107 },
|
||||||
content: (
|
content: (
|
||||||
<Tag
|
<Tag
|
||||||
color={ETagColor.INFO}
|
color={ETagColor.INFO}
|
||||||
variant={ETagVariant.SEMI_BOLD}
|
variant={ETagVariant.SEMI_BOLD}
|
||||||
label={tradDocumentStatus[document.document_status as EDocumentStatus].toUpperCase()}
|
label={tradDocumentStatus[document.document_status].toUpperCase()}
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
date: {
|
date: {
|
||||||
sx: { width: 120 },
|
sx: { width: 107 },
|
||||||
content: document.created_at ? new Date(document.created_at).toLocaleDateString() : "_",
|
content: document.created_at ? new Date(document.created_at).toLocaleDateString() : "_",
|
||||||
},
|
},
|
||||||
file: {
|
|
||||||
sx: { width: 120 },
|
|
||||||
content: "_",
|
|
||||||
},
|
|
||||||
actions: {
|
actions: {
|
||||||
sx: { width: 76 },
|
sx: { width: 76 },
|
||||||
content: (
|
content: (
|
||||||
@ -223,25 +197,21 @@ export default function DocumentTables(props: IProps) {
|
|||||||
if (document.document_status !== EDocumentStatus.DEPOSITED) return null;
|
if (document.document_status !== EDocumentStatus.DEPOSITED) return null;
|
||||||
return {
|
return {
|
||||||
key: document.uid,
|
key: document.uid,
|
||||||
document_type: { sx: { width: 300 }, content: document.document_type?.name ?? "_" },
|
document_type: { sx: { width: 400 }, content: document.document_type?.name ?? "_" },
|
||||||
document_status: {
|
document_status: {
|
||||||
sx: { width: 107 },
|
sx: { width: 107 },
|
||||||
content: (
|
content: (
|
||||||
<Tag
|
<Tag
|
||||||
color={ETagColor.WARNING}
|
color={ETagColor.WARNING}
|
||||||
variant={ETagVariant.SEMI_BOLD}
|
variant={ETagVariant.SEMI_BOLD}
|
||||||
label={tradDocumentStatus[document.document_status as EDocumentStatus].toUpperCase()}
|
label={tradDocumentStatus[document.document_status].toUpperCase()}
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
date: {
|
date: {
|
||||||
sx: { width: 120 },
|
sx: { width: 107 },
|
||||||
content: document.updated_at ? new Date(document.updated_at).toLocaleDateString() : "_",
|
content: document.updated_at ? new Date(document.updated_at).toLocaleDateString() : "_",
|
||||||
},
|
},
|
||||||
file: {
|
|
||||||
sx: { width: 120 },
|
|
||||||
content: document.files?.[0]?.file_name ?? "_",
|
|
||||||
},
|
|
||||||
actions: {
|
actions: {
|
||||||
sx: { width: 76 },
|
sx: { width: 76 },
|
||||||
content: (
|
content: (
|
||||||
@ -269,25 +239,21 @@ export default function DocumentTables(props: IProps) {
|
|||||||
if (document.document_status !== EDocumentStatus.VALIDATED) return null;
|
if (document.document_status !== EDocumentStatus.VALIDATED) return null;
|
||||||
return {
|
return {
|
||||||
key: document.uid,
|
key: document.uid,
|
||||||
document_type: { sx: { width: 300 }, content: document.document_type?.name ?? "_" },
|
document_type: { sx: { width: 400 }, content: document.document_type?.name ?? "_" },
|
||||||
document_status: {
|
document_status: {
|
||||||
sx: { width: 107 },
|
sx: { width: 107 },
|
||||||
content: (
|
content: (
|
||||||
<Tag
|
<Tag
|
||||||
color={ETagColor.SUCCESS}
|
color={ETagColor.SUCCESS}
|
||||||
variant={ETagVariant.SEMI_BOLD}
|
variant={ETagVariant.SEMI_BOLD}
|
||||||
label={tradDocumentStatus[document.document_status as EDocumentStatus].toUpperCase()}
|
label={tradDocumentStatus[document.document_status].toUpperCase()}
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
date: {
|
date: {
|
||||||
sx: { width: 120 },
|
sx: { width: 107 },
|
||||||
content: document.updated_at ? new Date(document.updated_at).toLocaleDateString() : "_",
|
content: document.updated_at ? new Date(document.updated_at).toLocaleDateString() : "_",
|
||||||
},
|
},
|
||||||
file: {
|
|
||||||
sx: { width: 120 },
|
|
||||||
content: document.files?.[0]?.file_name ?? "_",
|
|
||||||
},
|
|
||||||
actions: {
|
actions: {
|
||||||
sx: { width: 76 },
|
sx: { width: 76 },
|
||||||
content: (
|
content: (
|
||||||
@ -316,25 +282,21 @@ export default function DocumentTables(props: IProps) {
|
|||||||
if (document.document_status !== EDocumentStatus.REFUSED) return null;
|
if (document.document_status !== EDocumentStatus.REFUSED) return null;
|
||||||
return {
|
return {
|
||||||
key: document.uid,
|
key: document.uid,
|
||||||
document_type: { sx: { width: 300 }, content: document.document_type?.name ?? "_" },
|
document_type: { sx: { width: 400 }, content: document.document_type?.name ?? "_" },
|
||||||
document_status: {
|
document_status: {
|
||||||
sx: { width: 107 },
|
sx: { width: 107 },
|
||||||
content: (
|
content: (
|
||||||
<Tag
|
<Tag
|
||||||
color={ETagColor.ERROR}
|
color={ETagColor.ERROR}
|
||||||
variant={ETagVariant.SEMI_BOLD}
|
variant={ETagVariant.SEMI_BOLD}
|
||||||
label={tradDocumentStatus[document.document_status as EDocumentStatus].toUpperCase()}
|
label={tradDocumentStatus[document.document_status].toUpperCase()}
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
date: {
|
date: {
|
||||||
sx: { width: 120 },
|
sx: { width: 107 },
|
||||||
content: document.updated_at ? new Date(document.updated_at).toLocaleDateString() : "_",
|
content: document.updated_at ? new Date(document.updated_at).toLocaleDateString() : "_",
|
||||||
},
|
},
|
||||||
file: {
|
|
||||||
sx: { width: 120 },
|
|
||||||
content: document.files?.[0]?.file_name ?? "_",
|
|
||||||
},
|
|
||||||
actions: { sx: { width: 76 }, content: "" },
|
actions: { sx: { width: 76 }, content: "" },
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
@ -349,7 +311,7 @@ export default function DocumentTables(props: IProps) {
|
|||||||
return {
|
return {
|
||||||
key: document.uid,
|
key: document.uid,
|
||||||
document_type: {
|
document_type: {
|
||||||
sx: { width: 300 },
|
sx: { width: 400 },
|
||||||
content: formatName(document.files?.[0]?.file_name?.split(".")?.[0] ?? "") || "_",
|
content: formatName(document.files?.[0]?.file_name?.split(".")?.[0] ?? "") || "_",
|
||||||
},
|
},
|
||||||
document_status: {
|
document_status: {
|
||||||
@ -357,13 +319,9 @@ export default function DocumentTables(props: IProps) {
|
|||||||
content: getTagForSentDocument(document.document_status as EDocumentNotaryStatus),
|
content: getTagForSentDocument(document.document_status as EDocumentNotaryStatus),
|
||||||
},
|
},
|
||||||
date: {
|
date: {
|
||||||
sx: { width: 120 },
|
sx: { width: 107 },
|
||||||
content: document.updated_at ? new Date(document.updated_at).toLocaleDateString() : "_",
|
content: document.updated_at ? new Date(document.updated_at).toLocaleDateString() : "_",
|
||||||
},
|
},
|
||||||
file: {
|
|
||||||
sx: { width: 120 },
|
|
||||||
content: document.files?.[0]?.file_name ?? "_",
|
|
||||||
},
|
|
||||||
actions: {
|
actions: {
|
||||||
sx: { width: 76 },
|
sx: { width: 76 },
|
||||||
content: (
|
content: (
|
||||||
@ -450,10 +408,6 @@ function getHeader(dateColumnTitle: string, isMobile: boolean): IHead[] {
|
|||||||
key: "date",
|
key: "date",
|
||||||
title: dateColumnTitle,
|
title: dateColumnTitle,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
key: "file",
|
|
||||||
title: "Fichier",
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
key: "actions",
|
key: "actions",
|
||||||
title: "Action",
|
title: "Action",
|
||||||
|
@ -16,7 +16,6 @@ import DocumentTables from "./DocumentTables";
|
|||||||
import EmailReminder from "./EmailReminder";
|
import EmailReminder from "./EmailReminder";
|
||||||
|
|
||||||
import FolderService from "src/common/Api/LeCoffreApi/sdk/FolderService";
|
import FolderService from "src/common/Api/LeCoffreApi/sdk/FolderService";
|
||||||
import LoaderService from "src/common/Api/LeCoffreApi/sdk/Loader/LoaderService";
|
|
||||||
|
|
||||||
type IProps = {
|
type IProps = {
|
||||||
folder: OfficeFolder;
|
folder: OfficeFolder;
|
||||||
@ -63,7 +62,7 @@ export default function ClientView(props: IProps) {
|
|||||||
const handleClientDelete = useCallback(
|
const handleClientDelete = useCallback(
|
||||||
(customerUid: string) => {
|
(customerUid: string) => {
|
||||||
if (!folder.uid) return;
|
if (!folder.uid) return;
|
||||||
LoaderService.getInstance().show();
|
|
||||||
FolderService.getFolderByUid(folder.uid, false, false).then((process: any) => {
|
FolderService.getFolderByUid(folder.uid, false, false).then((process: any) => {
|
||||||
if (process) {
|
if (process) {
|
||||||
const folder: any = process.processData;
|
const folder: any = process.processData;
|
||||||
@ -72,7 +71,6 @@ export default function ClientView(props: IProps) {
|
|||||||
const customers = folder.customers.filter((uid: string) => uid !== customerUid);
|
const customers = folder.customers.filter((uid: string) => uid !== customerUid);
|
||||||
|
|
||||||
FolderService.updateFolder(process, { customers: customers }).then(() => {
|
FolderService.updateFolder(process, { customers: customers }).then(() => {
|
||||||
setTimeout(() => LoaderService.getInstance().hide(), 2000);
|
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,6 @@ import { useRouter } from "next/router";
|
|||||||
import React, { useCallback } from "react";
|
import React, { useCallback } from "react";
|
||||||
|
|
||||||
import FolderService from "src/common/Api/LeCoffreApi/sdk/FolderService";
|
import FolderService from "src/common/Api/LeCoffreApi/sdk/FolderService";
|
||||||
import LoaderService from "src/common/Api/LeCoffreApi/sdk/Loader/LoaderService";
|
|
||||||
|
|
||||||
type IProps = {
|
type IProps = {
|
||||||
isOpen: boolean;
|
isOpen: boolean;
|
||||||
@ -25,13 +24,9 @@ export default function DeleteFolderModal(props: IProps) {
|
|||||||
|
|
||||||
return new Promise<void>(
|
return new Promise<void>(
|
||||||
(resolve: () => void) => {
|
(resolve: () => void) => {
|
||||||
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' }).then(() => resolve());
|
||||||
setTimeout(() => LoaderService.getInstance().hide(), 2000);
|
|
||||||
resolve();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
@ -24,7 +24,6 @@ import AnchoringProcessingInfo from "./elements/AnchoringProcessingInfo";
|
|||||||
import FolderService from "src/common/Api/LeCoffreApi/sdk/FolderService";
|
import FolderService from "src/common/Api/LeCoffreApi/sdk/FolderService";
|
||||||
import NoteService from "src/common/Api/LeCoffreApi/sdk/NoteService";
|
import NoteService from "src/common/Api/LeCoffreApi/sdk/NoteService";
|
||||||
import DocumentService from "src/common/Api/LeCoffreApi/sdk/DocumentService";
|
import DocumentService from "src/common/Api/LeCoffreApi/sdk/DocumentService";
|
||||||
import LoaderService from "src/common/Api/LeCoffreApi/sdk/Loader/LoaderService";
|
|
||||||
|
|
||||||
export enum AnchorStatus {
|
export enum AnchorStatus {
|
||||||
"VERIFIED_ON_CHAIN" = "VERIFIED_ON_CHAIN",
|
"VERIFIED_ON_CHAIN" = "VERIFIED_ON_CHAIN",
|
||||||
@ -109,7 +108,6 @@ export default function FolderInformation(props: IProps) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// TODO: review
|
// TODO: review
|
||||||
LoaderService.getInstance().show();
|
|
||||||
return FolderService.getFolderByUid(folderUid).then(async (process: any) => {
|
return FolderService.getFolderByUid(folderUid).then(async (process: any) => {
|
||||||
if (process) {
|
if (process) {
|
||||||
const folder: any = process.processData;
|
const folder: any = process.processData;
|
||||||
@ -135,7 +133,7 @@ export default function FolderInformation(props: IProps) {
|
|||||||
if (processes.length > 0) {
|
if (processes.length > 0) {
|
||||||
const documents: any[] = processes.map((process: any) => process.processData);
|
const documents: any[] = processes.map((process: any) => process.processData);
|
||||||
for (const customer of folder.customers) {
|
for (const customer of folder.customers) {
|
||||||
customer.documents = documents.filter((document: any) => document.depositor && document.depositor.uid === customer.uid);
|
customer.documents = documents.filter((document: any) => document.depositor.uid === customer.uid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
resolve();
|
resolve();
|
||||||
@ -143,7 +141,6 @@ export default function FolderInformation(props: IProps) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
setFolder(folder);
|
setFolder(folder);
|
||||||
setTimeout(() => LoaderService.getInstance().hide(), 2000);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}, [folderUid]);
|
}, [folderUid]);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import backgroundImage from "@Assets/images/background_refonte.svg";
|
import backgroundImage from "@Assets/images/background_refonte.svg";
|
||||||
import { EDocumentNotaryStatus } from "le-coffre-resources/dist/Notary/DocumentNotary";
|
import DocumentsNotary from "@Front/Api/LeCoffreApi/Notary/DocumentsNotary/DocumentsNotary";
|
||||||
|
import Folders from "@Front/Api/LeCoffreApi/Notary/Folders/Folders";
|
||||||
import Button, { EButtonstyletype, EButtonVariant } from "@Front/Components/DesignSystem/Button";
|
import Button, { EButtonstyletype, EButtonVariant } from "@Front/Components/DesignSystem/Button";
|
||||||
import DragAndDrop from "@Front/Components/DesignSystem/DragAndDrop";
|
import DragAndDrop from "@Front/Components/DesignSystem/DragAndDrop";
|
||||||
import Form from "@Front/Components/DesignSystem/Form";
|
import Form from "@Front/Components/DesignSystem/Form";
|
||||||
@ -18,11 +19,6 @@ import React, { useCallback, useEffect, useMemo, useState } from "react";
|
|||||||
|
|
||||||
import classes from "./classes.module.scss";
|
import classes from "./classes.module.scss";
|
||||||
|
|
||||||
import LoaderService from "src/common/Api/LeCoffreApi/sdk/Loader/LoaderService";
|
|
||||||
import FolderService from "src/common/Api/LeCoffreApi/sdk/FolderService";
|
|
||||||
import DocumentService from "src/common/Api/LeCoffreApi/sdk/DocumentService";
|
|
||||||
import FileService from "src/common/Api/LeCoffreApi/sdk/FileService";
|
|
||||||
|
|
||||||
enum EClientSelection {
|
enum EClientSelection {
|
||||||
ALL_CLIENTS = "all_clients",
|
ALL_CLIENTS = "all_clients",
|
||||||
SELECTED_CLIENTS = "selected_clients",
|
SELECTED_CLIENTS = "selected_clients",
|
||||||
@ -63,64 +59,6 @@ export default function SendDocuments() {
|
|||||||
throw new Error("No clients selected");
|
throw new Error("No clients selected");
|
||||||
}
|
}
|
||||||
|
|
||||||
LoaderService.getInstance().show();
|
|
||||||
for (const selectedClient of selectedClients) {
|
|
||||||
for (const file of files) {
|
|
||||||
await new Promise<void>((resolve: () => void) => {
|
|
||||||
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: any = {
|
|
||||||
type: file.type,
|
|
||||||
data: uint8Array
|
|
||||||
};
|
|
||||||
|
|
||||||
const fileData: any = {
|
|
||||||
file_blob: fileBlob,
|
|
||||||
file_name: file.name
|
|
||||||
};
|
|
||||||
const validatorId: string = '884cb36a346a79af8697559f16940141f068bdf1656f88fa0df0e9ecd7311fb8:0';
|
|
||||||
|
|
||||||
FileService.createFile(fileData, validatorId).then((processCreated: any) => {
|
|
||||||
const fileUid: string = processCreated.processData.uid;
|
|
||||||
|
|
||||||
const documentData: any = {
|
|
||||||
folder: {
|
|
||||||
uid: folderUid as string
|
|
||||||
},
|
|
||||||
customer: {
|
|
||||||
uid: selectedClient as string
|
|
||||||
},
|
|
||||||
files: [
|
|
||||||
{
|
|
||||||
uid: fileUid
|
|
||||||
}
|
|
||||||
],
|
|
||||||
document_status: EDocumentNotaryStatus.SENT
|
|
||||||
};
|
|
||||||
|
|
||||||
DocumentService.createDocument(documentData, validatorId).then(() => resolve());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
reader.readAsArrayBuffer(file);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
LoaderService.getInstance().hide();
|
|
||||||
|
|
||||||
router.push(
|
|
||||||
Module.getInstance()
|
|
||||||
.get()
|
|
||||||
.modules.pages.Folder.pages.FolderInformation.props.path.replace("[folderUid]", folderUid as string),
|
|
||||||
);
|
|
||||||
setIsSending(false);
|
|
||||||
ToasterService.getInstance().success({ title: "Succès !", description: "Votre document a été envoyée avec succès." });
|
|
||||||
|
|
||||||
/*
|
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
selectedClients.map(async (customer) => {
|
selectedClients.map(async (customer) => {
|
||||||
const promises = files.map(async (file) => {
|
const promises = files.map(async (file) => {
|
||||||
@ -145,7 +83,6 @@ export default function SendDocuments() {
|
|||||||
);
|
);
|
||||||
setIsSending(false);
|
setIsSending(false);
|
||||||
ToasterService.getInstance().success({ title: "Succès !", description: "Votre document a été envoyée avec succès." });
|
ToasterService.getInstance().success({ title: "Succès !", description: "Votre document a été envoyée avec succès." });
|
||||||
*/
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setIsSending(false);
|
setIsSending(false);
|
||||||
console.warn("Error while sending files: ", error);
|
console.warn("Error while sending files: ", error);
|
||||||
@ -155,14 +92,18 @@ export default function SendDocuments() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const fetchFolder = useCallback(async () => {
|
const fetchFolder = useCallback(async () => {
|
||||||
LoaderService.getInstance().show();
|
Folders.getInstance()
|
||||||
FolderService.getFolderByUid(folderUid as string).then((process: any) => {
|
.getByUid(folderUid as string, {
|
||||||
if (process) {
|
q: {
|
||||||
const folder: any = process.processData;
|
customers: {
|
||||||
setFolder(folder);
|
include: {
|
||||||
LoaderService.getInstance().hide();
|
contact: true,
|
||||||
}
|
},
|
||||||
});
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.then((folder) => setFolder(folder))
|
||||||
|
.catch((e) => console.warn(e));
|
||||||
}, [folderUid]);
|
}, [folderUid]);
|
||||||
|
|
||||||
const onClientSelectionChange = useCallback(
|
const onClientSelectionChange = useCallback(
|
||||||
|
@ -17,7 +17,6 @@ import { useCallback, useEffect, useState } from "react";
|
|||||||
import classes from "./classes.module.scss";
|
import classes from "./classes.module.scss";
|
||||||
|
|
||||||
import CustomerService from "src/common/Api/LeCoffreApi/sdk/CustomerService";
|
import CustomerService from "src/common/Api/LeCoffreApi/sdk/CustomerService";
|
||||||
import LoaderService from "src/common/Api/LeCoffreApi/sdk/Loader/LoaderService";
|
|
||||||
|
|
||||||
export default function UpdateClient() {
|
export default function UpdateClient() {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
@ -36,12 +35,12 @@ export default function UpdateClient() {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchCustomer = async () => {
|
const fetchCustomer = async () => {
|
||||||
try {
|
try {
|
||||||
LoaderService.getInstance().show();
|
|
||||||
CustomerService.getCustomerByUid(customerUid as string).then((process: any) => {
|
CustomerService.getCustomerByUid(customerUid as string).then((process: any) => {
|
||||||
if (process) {
|
if (process) {
|
||||||
const customer: any = process.processData;
|
const customer: any = process.processData;
|
||||||
|
if (customer) {
|
||||||
setCustomer(customer);
|
setCustomer(customer);
|
||||||
setTimeout(() => LoaderService.getInstance().hide(), 2000);
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -71,13 +70,10 @@ export default function UpdateClient() {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
await contact.validateOrReject?.({ groups: ["createCustomer"], forbidUnknownValues: false });
|
await contact.validateOrReject?.({ groups: ["createCustomer"], forbidUnknownValues: false });
|
||||||
|
|
||||||
LoaderService.getInstance().show();
|
|
||||||
CustomerService.getCustomerByUid(customerUid as string).then((process: any) => {
|
CustomerService.getCustomerByUid(customerUid as string).then((process: any) => {
|
||||||
if (process) {
|
if (process) {
|
||||||
// TODO: review - address
|
// TODO: review - address
|
||||||
CustomerService.updateCustomer(process, { contact: contact }).then(() => {
|
CustomerService.updateCustomer(process, { contact: contact }).then(() => {
|
||||||
setTimeout(() => LoaderService.getInstance().hide(), 2000);
|
|
||||||
router.push(backwardPath);
|
router.push(backwardPath);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,6 @@ import classes from "./classes.module.scss";
|
|||||||
import Note from "le-coffre-resources/dist/Customer/Note";
|
import Note from "le-coffre-resources/dist/Customer/Note";
|
||||||
|
|
||||||
import NoteService from "src/common/Api/LeCoffreApi/sdk/NoteService";
|
import NoteService from "src/common/Api/LeCoffreApi/sdk/NoteService";
|
||||||
import LoaderService from "src/common/Api/LeCoffreApi/sdk/Loader/LoaderService";
|
|
||||||
|
|
||||||
type IProps = {};
|
type IProps = {};
|
||||||
|
|
||||||
@ -68,7 +67,6 @@ class UpdateCustomerNoteClass extends BasePage<IPropsClass, IState> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override async componentDidMount() {
|
public override async componentDidMount() {
|
||||||
LoaderService.getInstance().show();
|
|
||||||
NoteService.getNoteByUid(this.props.noteUid).then((process: any) => {
|
NoteService.getNoteByUid(this.props.noteUid).then((process: any) => {
|
||||||
if (process) {
|
if (process) {
|
||||||
const note: any = process.processData;
|
const note: any = process.processData;
|
||||||
@ -82,17 +80,15 @@ class UpdateCustomerNoteClass extends BasePage<IPropsClass, IState> {
|
|||||||
.get()
|
.get()
|
||||||
.modules.pages.Folder.pages.FolderInformation.props.path.replace("[folderUid]", note.folder?.uid!),
|
.modules.pages.Folder.pages.FolderInformation.props.path.replace("[folderUid]", note.folder?.uid!),
|
||||||
});
|
});
|
||||||
|
|
||||||
LoaderService.getInstance().hide();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private async onFormSubmit(e: React.FormEvent<HTMLFormElement> | null, values: { [key: string]: string }) {
|
private async onFormSubmit(e: React.FormEvent<HTMLFormElement> | null, values: { [key: string]: string }) {
|
||||||
try {
|
try {
|
||||||
LoaderService.getInstance().show();
|
|
||||||
NoteService.getNoteByUid(this.props.noteUid).then((process: any) => {
|
NoteService.getNoteByUid(this.props.noteUid).then((process: any) => {
|
||||||
if (process) {
|
if (process) {
|
||||||
|
|
||||||
NoteService.updateNote(process, { content: values["content"] }).then(() => {
|
NoteService.updateNote(process, { content: values["content"] }).then(() => {
|
||||||
this.props.router.push(this.state.backwardPath);
|
this.props.router.push(this.state.backwardPath);
|
||||||
});
|
});
|
||||||
|
@ -19,7 +19,6 @@ import TextAreaField from "@Front/Components/DesignSystem/Form/TextareaField";
|
|||||||
import { isArray } from "class-validator";
|
import { isArray } from "class-validator";
|
||||||
|
|
||||||
import FolderService from "src/common/Api/LeCoffreApi/sdk/FolderService";
|
import FolderService from "src/common/Api/LeCoffreApi/sdk/FolderService";
|
||||||
import LoaderService from "src/common/Api/LeCoffreApi/sdk/Loader/LoaderService";
|
|
||||||
|
|
||||||
export default function UpdateFolderMetadata() {
|
export default function UpdateFolderMetadata() {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
@ -49,18 +48,14 @@ export default function UpdateFolderMetadata() {
|
|||||||
setValidationError(validationErrors as ValidationError[]);
|
setValidationError(validationErrors as ValidationError[]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
LoaderService.getInstance().show();
|
await Folders.getInstance().put(folderUid, newValues);
|
||||||
FolderService.getFolderByUid(folderUid).then((process: any) => {
|
const url = Module.getInstance()
|
||||||
if (process) {
|
|
||||||
FolderService.updateFolder(process, { ...values, deed: { uid: values["deed"] } }).then(() => {
|
|
||||||
setTimeout(() => LoaderService.getInstance().hide(), 2000);
|
|
||||||
router.push(Module.getInstance()
|
|
||||||
.get()
|
.get()
|
||||||
.modules.pages.Folder.pages.FolderInformation.props.path.replace("[folderUid]", folderUid));
|
.modules.pages.Folder.pages.FolderInformation.props.path.replace("[folderUid]", folderUid);
|
||||||
});
|
|
||||||
}
|
router.push(url);
|
||||||
});
|
|
||||||
} catch (backError) {
|
} catch (backError) {
|
||||||
if (!Array.isArray(backError)) return;
|
if (!Array.isArray(backError)) return;
|
||||||
setValidationError(backError);
|
setValidationError(backError);
|
||||||
@ -70,12 +65,24 @@ export default function UpdateFolderMetadata() {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!folderUid || isArray(folderUid)) return;
|
if (!folderUid || isArray(folderUid)) return;
|
||||||
LoaderService.getInstance().show();
|
|
||||||
|
/* TODO: review
|
||||||
|
const query = {
|
||||||
|
q: {
|
||||||
|
deed: { include: { deed_type: true } },
|
||||||
|
office: true,
|
||||||
|
customers: { include: { contact: true } },
|
||||||
|
},
|
||||||
|
};
|
||||||
|
Folders.getInstance()
|
||||||
|
.getByUid(folderUid, query)
|
||||||
|
.then((folder) => setSelectedFolder(folder));
|
||||||
|
*/
|
||||||
|
|
||||||
FolderService.getFolderByUid(folderUid).then((process: any) => {
|
FolderService.getFolderByUid(folderUid).then((process: any) => {
|
||||||
if (process) {
|
if (process) {
|
||||||
const folder: any = process.processData;
|
const folder: any = process.processData;
|
||||||
setSelectedFolder(folder);
|
setSelectedFolder(folder);
|
||||||
setTimeout(() => LoaderService.getInstance().hide(), 2000);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}, [folderUid]);
|
}, [folderUid]);
|
||||||
|
@ -6,7 +6,7 @@ import Confirm from "@Front/Components/DesignSystem/OldModal/Confirm";
|
|||||||
import Typography, { ETypo, ETypoColor } from "@Front/Components/DesignSystem/Typography";
|
import Typography, { ETypo, ETypoColor } from "@Front/Components/DesignSystem/Typography";
|
||||||
import DefaultNotaryDashboard from "@Front/Components/LayoutTemplates/DefaultNotaryDashboard";
|
import DefaultNotaryDashboard from "@Front/Components/LayoutTemplates/DefaultNotaryDashboard";
|
||||||
import Module from "@Front/Config/Module";
|
import Module from "@Front/Config/Module";
|
||||||
import { Document } from "le-coffre-resources/dist/Notary";
|
import { Document, File } from "le-coffre-resources/dist/Notary";
|
||||||
import { EDocumentStatus } from "le-coffre-resources/dist/Notary/Document";
|
import { EDocumentStatus } from "le-coffre-resources/dist/Notary/Document";
|
||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
import { NextRouter, useRouter } from "next/router";
|
import { NextRouter, useRouter } from "next/router";
|
||||||
|
@ -5,7 +5,6 @@ import TextField from "@Front/Components/DesignSystem/Form/TextField";
|
|||||||
import Confirm from "@Front/Components/DesignSystem/OldModal/Confirm";
|
import Confirm from "@Front/Components/DesignSystem/OldModal/Confirm";
|
||||||
import Typography, { ETypo } from "@Front/Components/DesignSystem/Typography";
|
import Typography, { ETypo } from "@Front/Components/DesignSystem/Typography";
|
||||||
import DefaultRolesDashboard from "@Front/Components/LayoutTemplates/DefaultRoleDashboard";
|
import DefaultRolesDashboard from "@Front/Components/LayoutTemplates/DefaultRoleDashboard";
|
||||||
import { ToasterService } from "@Front/Components/DesignSystem/Toaster";
|
|
||||||
import Module from "@Front/Config/Module";
|
import Module from "@Front/Config/Module";
|
||||||
import { Office, OfficeRole } from "le-coffre-resources/dist/Admin";
|
import { Office, OfficeRole } from "le-coffre-resources/dist/Admin";
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
@ -17,9 +16,6 @@ import Rules, { RulesMode } from "@Front/Components/Elements/Rules";
|
|||||||
import { AppRuleActions, AppRuleNames } from "@Front/Api/Entities/rule";
|
import { AppRuleActions, AppRuleNames } from "@Front/Api/Entities/rule";
|
||||||
import { ValidationError } from "class-validator";
|
import { ValidationError } from "class-validator";
|
||||||
|
|
||||||
import RoleService from "src/common/Api/LeCoffreApi/sdk/RoleService";
|
|
||||||
import LoaderService from "src/common/Api/LeCoffreApi/sdk/Loader/LoaderService";
|
|
||||||
|
|
||||||
type IProps = {};
|
type IProps = {};
|
||||||
export default function RolesCreate(props: IProps) {
|
export default function RolesCreate(props: IProps) {
|
||||||
const [hasChanged, setHasChanged] = useState<boolean>(false);
|
const [hasChanged, setHasChanged] = useState<boolean>(false);
|
||||||
@ -30,17 +26,12 @@ export default function RolesCreate(props: IProps) {
|
|||||||
const onSubmitHandler = useCallback(
|
const onSubmitHandler = useCallback(
|
||||||
async (e: React.FormEvent<HTMLFormElement> | null, values: { [key: string]: string }) => {
|
async (e: React.FormEvent<HTMLFormElement> | null, values: { [key: string]: string }) => {
|
||||||
const jwt = JwtService.getInstance().decodeJwt();
|
const jwt = JwtService.getInstance().decodeJwt();
|
||||||
|
|
||||||
// TODO: review
|
|
||||||
const officeId = 'demo_notary_office_id'; //jwt?.office_Id;
|
|
||||||
|
|
||||||
const officeRole = OfficeRole.hydrate<OfficeRole>({
|
const officeRole = OfficeRole.hydrate<OfficeRole>({
|
||||||
name: values["name"],
|
name: values["name"],
|
||||||
office: Office.hydrate<Office>({
|
office: Office.hydrate<Office>({
|
||||||
uid: officeId,
|
uid: jwt?.office_Id,
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await officeRole.validateOrReject?.({ groups: ["createOfficeRole"], forbidUnknownValues: true });
|
await officeRole.validateOrReject?.({ groups: ["createOfficeRole"], forbidUnknownValues: true });
|
||||||
} catch (validationErrors: Array<ValidationError> | any) {
|
} catch (validationErrors: Array<ValidationError> | any) {
|
||||||
@ -48,29 +39,6 @@ export default function RolesCreate(props: IProps) {
|
|||||||
setValidationError(validationErrors as ValidationError[]);
|
setValidationError(validationErrors as ValidationError[]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const roleData: any = {
|
|
||||||
name: values["name"],
|
|
||||||
office: {
|
|
||||||
uid: officeId,
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const validatorId: string = '884cb36a346a79af8697559f16940141f068bdf1656f88fa0df0e9ecd7311fb8:0';
|
|
||||||
|
|
||||||
LoaderService.getInstance().show();
|
|
||||||
RoleService.createRole(roleData, validatorId).then((processCreated: any) => {
|
|
||||||
if (processCreated) {
|
|
||||||
ToasterService.getInstance().success({
|
|
||||||
title: "Succès !",
|
|
||||||
description: "Rôle créé avec succès"
|
|
||||||
});
|
|
||||||
setTimeout(() => LoaderService.getInstance().hide(), 2000);
|
|
||||||
const role: any = processCreated.processData;
|
|
||||||
router.push(Module.getInstance().get().modules.pages.Roles.pages.RolesInformations.props.path.replace("[uid]", role.uid!));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
/*
|
|
||||||
try {
|
try {
|
||||||
const role = await OfficeRoles.getInstance().post(
|
const role = await OfficeRoles.getInstance().post(
|
||||||
OfficeRole.hydrate<OfficeRole>({
|
OfficeRole.hydrate<OfficeRole>({
|
||||||
@ -87,7 +55,6 @@ export default function RolesCreate(props: IProps) {
|
|||||||
setValidationError(validationErrors as ValidationError[]);
|
setValidationError(validationErrors as ValidationError[]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
},
|
},
|
||||||
[router],
|
[router],
|
||||||
);
|
);
|
||||||
|
@ -13,9 +13,6 @@ import React from "react";
|
|||||||
import classes from "./classes.module.scss";
|
import classes from "./classes.module.scss";
|
||||||
import RulesGroups from "@Front/Api/LeCoffreApi/Admin/RulesGroups/RulesGroups";
|
import RulesGroups from "@Front/Api/LeCoffreApi/Admin/RulesGroups/RulesGroups";
|
||||||
|
|
||||||
import RoleService from "src/common/Api/LeCoffreApi/sdk/RoleService";
|
|
||||||
import LoaderService from "src/common/Api/LeCoffreApi/sdk/Loader/LoaderService";
|
|
||||||
|
|
||||||
type RuleGroupsCheckbox = RulesGroup & {
|
type RuleGroupsCheckbox = RulesGroup & {
|
||||||
checked: boolean;
|
checked: boolean;
|
||||||
};
|
};
|
||||||
@ -42,60 +39,24 @@ export default function RolesInformations() {
|
|||||||
setSelectAll(false);
|
setSelectAll(false);
|
||||||
async function getUser() {
|
async function getUser() {
|
||||||
if (!roleUid) return;
|
if (!roleUid) return;
|
||||||
|
|
||||||
/*
|
|
||||||
const role = await OfficeRoles.getInstance().getByUid(roleUid as string, {
|
const role = await OfficeRoles.getInstance().getByUid(roleUid as string, {
|
||||||
q: {
|
q: {
|
||||||
rules: true,
|
rules: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
*/
|
|
||||||
|
|
||||||
LoaderService.getInstance().show();
|
|
||||||
const role: any = await new Promise<any>((resolve: (role: any) => void) => {
|
|
||||||
RoleService.getRoleByUid(roleUid as string).then((process: any) => {
|
|
||||||
if (process) {
|
|
||||||
const role: any = process.processData;
|
|
||||||
resolve(role);
|
|
||||||
setTimeout(() => LoaderService.getInstance().hide(), 2000);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
})
|
|
||||||
|
|
||||||
/* TODO: review
|
|
||||||
const rulesGroups = await RulesGroups.getInstance().get({
|
const rulesGroups = await RulesGroups.getInstance().get({
|
||||||
include: {
|
include: {
|
||||||
rules: true,
|
rules: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
*/
|
|
||||||
const rulesGroups: RulesGroup[] = [
|
|
||||||
{
|
|
||||||
uid: 'toto',
|
|
||||||
name: 'toto',
|
|
||||||
rules: [
|
|
||||||
{
|
|
||||||
uid: 'toto',
|
|
||||||
name: 'toto',
|
|
||||||
label: 'toto',
|
|
||||||
namespace: 'toto',
|
|
||||||
created_at: new Date(),
|
|
||||||
updated_at: new Date(),
|
|
||||||
}
|
|
||||||
],
|
|
||||||
created_at: new Date(),
|
|
||||||
updated_at: new Date(),
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
if (!role) return;
|
if (!role) return;
|
||||||
setRoleSelected(role);
|
setRoleSelected(role);
|
||||||
|
|
||||||
// TODO: review
|
|
||||||
if (!role.rules) return;
|
if (!role.rules) return;
|
||||||
const rulesCheckboxes = rulesGroups
|
const rulesCheckboxes = rulesGroups
|
||||||
.map((ruleGroup) => {
|
.map((ruleGroup) => {
|
||||||
if (ruleGroup.rules?.every((rule) => role.rules?.find((r: any) => r.uid === rule.uid))) {
|
if (ruleGroup.rules?.every((rule) => role.rules?.find((r) => r.uid === rule.uid))) {
|
||||||
return { ...ruleGroup, checked: true };
|
return { ...ruleGroup, checked: true };
|
||||||
}
|
}
|
||||||
return { ...ruleGroup, checked: false };
|
return { ...ruleGroup, checked: false };
|
||||||
|
@ -8,8 +8,6 @@ import getConfig from "next/config";
|
|||||||
import { GoogleTagManager } from "@next/third-parties/google";
|
import { GoogleTagManager } from "@next/third-parties/google";
|
||||||
import { hotjar } from "react-hotjar";
|
import { hotjar } from "react-hotjar";
|
||||||
|
|
||||||
import Loader from "src/common/Api/LeCoffreApi/sdk/Loader";
|
|
||||||
|
|
||||||
import IframeReference from "src/sdk/IframeReference";
|
import IframeReference from "src/sdk/IframeReference";
|
||||||
import Iframe from "src/sdk/Iframe";
|
import Iframe from "src/sdk/Iframe";
|
||||||
import MessageBus from "src/sdk/MessageBus";
|
import MessageBus from "src/sdk/MessageBus";
|
||||||
@ -117,7 +115,6 @@ const MyApp = (({
|
|||||||
</Component>
|
</Component>
|
||||||
}
|
}
|
||||||
{isConnected && <Iframe />}
|
{isConnected && <Iframe />}
|
||||||
<Loader />
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}) as AppType;
|
}) as AppType;
|
||||||
|
@ -153,10 +153,6 @@ export default class MessageBus {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const key of Object.keys(publicDataDecoded)) {
|
|
||||||
processData[key] = publicDataDecoded[key];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!file) {
|
if (!file) {
|
||||||
file = {
|
file = {
|
||||||
processId,
|
processId,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user