Merge branch 'ajanin' into cicd
All checks were successful
Build and Push to Registry / build-and-push (push) Successful in 2m23s
All checks were successful
Build and Push to Registry / build-and-push (push) Successful in 2m23s
This commit is contained in:
commit
a351c1814c
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
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,4 +1,3 @@
|
|||||||
|
|
||||||
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,4 +1,3 @@
|
|||||||
|
|
||||||
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,4 +1,3 @@
|
|||||||
|
|
||||||
import { v4 as uuidv4 } from 'uuid';
|
import { v4 as uuidv4 } from 'uuid';
|
||||||
|
|
||||||
import MessageBus from 'src/sdk/MessageBus';
|
import MessageBus from 'src/sdk/MessageBus';
|
||||||
@ -10,7 +9,7 @@ export default class DocumentTypeService {
|
|||||||
|
|
||||||
private constructor() { }
|
private constructor() { }
|
||||||
|
|
||||||
public static createDocumentType(documentData: any, validatorId: string): Promise<any> {
|
public static createDocumentType(documentTypeData: any, validatorId: string): Promise<any> {
|
||||||
const ownerId = User.getInstance().getPairingId()!;
|
const ownerId = User.getInstance().getPairingId()!;
|
||||||
|
|
||||||
const processData: any = {
|
const processData: any = {
|
||||||
@ -19,7 +18,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(),
|
||||||
...documentData,
|
...documentTypeData,
|
||||||
};
|
};
|
||||||
|
|
||||||
const privateFields: string[] = Object.keys(processData);
|
const privateFields: string[] = Object.keys(processData);
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
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,4 +1,3 @@
|
|||||||
|
|
||||||
import { v4 as uuidv4 } from 'uuid';
|
import { v4 as uuidv4 } from 'uuid';
|
||||||
|
|
||||||
import MessageBus from 'src/sdk/MessageBus';
|
import MessageBus from 'src/sdk/MessageBus';
|
||||||
|
45
src/common/Api/LeCoffreApi/sdk/Loader/LoaderService.ts
Normal file
45
src/common/Api/LeCoffreApi/sdk/Loader/LoaderService.ts
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
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;
|
38
src/common/Api/LeCoffreApi/sdk/Loader/classes.module.scss
Normal file
38
src/common/Api/LeCoffreApi/sdk/Loader/classes.module.scss
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
@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;
|
||||||
|
}
|
37
src/common/Api/LeCoffreApi/sdk/Loader/index.tsx
Normal file
37
src/common/Api/LeCoffreApi/sdk/Loader/index.tsx
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
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,4 +1,3 @@
|
|||||||
|
|
||||||
import { v4 as uuidv4 } from 'uuid';
|
import { v4 as uuidv4 } from 'uuid';
|
||||||
|
|
||||||
import MessageBus from 'src/sdk/MessageBus';
|
import MessageBus from 'src/sdk/MessageBus';
|
||||||
|
109
src/common/Api/LeCoffreApi/sdk/RoleService.ts
Normal file
109
src/common/Api/LeCoffreApi/sdk/RoleService.ts
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
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,10 +14,12 @@ 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;
|
||||||
@ -196,7 +198,7 @@ export default class DepositOtherDocument extends React.Component<IProps, IState
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override componentDidMount(): void {}
|
public override componentDidMount(): void { }
|
||||||
|
|
||||||
private onCloseAlertUpload() {
|
private onCloseAlertUpload() {
|
||||||
this.setState({ showFailedUploaded: null });
|
this.setState({ showFailedUploaded: null });
|
||||||
@ -206,18 +208,30 @@ 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;
|
if (!filesArray) return;
|
||||||
let documentCreated: Document = {} as Document;
|
|
||||||
|
LoaderService.getInstance().show();
|
||||||
|
let documentCreated: any;
|
||||||
try {
|
try {
|
||||||
documentCreated = await Documents.getInstance().post({
|
documentCreated = await new Promise<any>((resolve: (document: any) => void) => {
|
||||||
folder: {
|
const documentTypeData: any = {
|
||||||
uid: this.props.folder_uid,
|
folder: {
|
||||||
},
|
uid: this.props.folder_uid,
|
||||||
depositor: {
|
},
|
||||||
uid: this.props.customer_uid,
|
depositor: {
|
||||||
},
|
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 });
|
||||||
@ -225,16 +239,46 @@ 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 formData = new FormData();
|
const file = filesArray[i]!.file;
|
||||||
formData.append("file", filesArray[i]!.file, filesArray[i]!.fileName);
|
await new Promise<void>((resolve: () => void) => {
|
||||||
const query = JSON.stringify({ document: { uid: documentCreated.uid } });
|
const reader = new FileReader();
|
||||||
formData.append("q", query);
|
reader.onload = (event) => {
|
||||||
try {
|
if (event.target?.result) {
|
||||||
await Files.getInstance().post(formData);
|
const arrayBuffer = event.target.result as ArrayBuffer;
|
||||||
} catch (e) {
|
const uint8Array = new Uint8Array(arrayBuffer);
|
||||||
this.setState({ showFailedUploaded: "Le fichier ne correspond pas aux critères demandés", isLoading: false });
|
|
||||||
return;
|
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;
|
||||||
|
|
||||||
|
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,6 +31,7 @@ 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);
|
||||||
@ -38,6 +39,7 @@ export default function Navigation() {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const getNotifications = useCallback(async () => {
|
const getNotifications = useCallback(async () => {
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
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";
|
||||||
@ -14,7 +13,7 @@ type IProps = IPropsDashboardWithList & {};
|
|||||||
|
|
||||||
export default function DefaultCustomerDashboard(props: IProps) {
|
export default function DefaultCustomerDashboard(props: IProps) {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { folderUid } = router.query;
|
const { folderUid, profileUid } = router.query;
|
||||||
const [folders, setFolders] = useState<OfficeFolder[]>([]);
|
const [folders, setFolders] = useState<OfficeFolder[]>([]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -61,7 +60,9 @@ export default function DefaultCustomerDashboard(props: IProps) {
|
|||||||
router.push(
|
router.push(
|
||||||
Module.getInstance()
|
Module.getInstance()
|
||||||
.get()
|
.get()
|
||||||
.modules.pages.ClientDashboard.props.path.replace("[folderUid]", folder.uid ?? ""),
|
.modules.pages.ClientDashboard.props.path
|
||||||
|
.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,6 +7,8 @@ import DefaultDashboardWithList, { IPropsDashboardWithList } from "../DefaultDas
|
|||||||
import { OfficeRole } from "le-coffre-resources/dist/Notary";
|
import { OfficeRole } from "le-coffre-resources/dist/Notary";
|
||||||
import OfficeRoles, { IGetRolesParams } from "@Front/Api/LeCoffreApi/Admin/OfficeRoles/OfficeRoles";
|
import OfficeRoles, { IGetRolesParams } from "@Front/Api/LeCoffreApi/Admin/OfficeRoles/OfficeRoles";
|
||||||
|
|
||||||
|
import 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) {
|
||||||
@ -23,7 +25,13 @@ 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) => {
|
||||||
@ -37,10 +45,10 @@ export default function DefaultRoleDashboard(props: IProps) {
|
|||||||
blocks={
|
blocks={
|
||||||
roles
|
roles
|
||||||
? roles.map((role) => ({
|
? roles.map((role) => ({
|
||||||
id: role.uid!,
|
id: role.uid!,
|
||||||
primaryText: role.name,
|
primaryText: role.name,
|
||||||
isActive: role.uid === roleUid,
|
isActive: role.uid === roleUid,
|
||||||
}))
|
}))
|
||||||
: []
|
: []
|
||||||
}
|
}
|
||||||
bottomButton={{
|
bottomButton={{
|
||||||
|
@ -110,7 +110,8 @@ export default function DepositDocumentComponent(props: IProps) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const onOpenModal = useCallback(async () => {
|
const onOpenModal = useCallback(async () => {
|
||||||
const refused_reason = document.document_history?.find((history: any) => history.document_status === "REFUSED")?.refused_reason;
|
if (document.document_status !== "REFUSED") return;
|
||||||
|
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,5 +1,3 @@
|
|||||||
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";
|
||||||
@ -16,10 +14,14 @@ 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",
|
||||||
@ -47,6 +49,26 @@ 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,
|
||||||
@ -76,32 +98,58 @@ 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]);
|
|
||||||
|
|
||||||
const onDownload = useCallback((doc: DocumentNotary) => {
|
DocumentService.getDocuments().then(async (processes: any[]) => {
|
||||||
|
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 || !file?.uid || !doc.uid) return;
|
if (!file) return;
|
||||||
|
|
||||||
return FilesNotary.getInstance()
|
return new Promise<void>((resolve: () => void) => {
|
||||||
.download(file.uid, doc.uid)
|
const blob = new Blob([file.file_blob.data], { type: file.file_blob.type });
|
||||||
.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();
|
||||||
URL.revokeObjectURL(url);
|
document.body.removeChild(a);
|
||||||
})
|
URL.revokeObjectURL(url);
|
||||||
.catch((e) => console.warn(e));
|
|
||||||
|
resolve();
|
||||||
|
}).catch((e) => console.warn(e));
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const onDownloadAll = useCallback(async () => {
|
const onDownloadAll = useCallback(async () => {
|
||||||
@ -110,16 +158,14 @@ export default function ReceivedDocuments() {
|
|||||||
const zip = new JSZip();
|
const zip = new JSZip();
|
||||||
const folder = zip.folder("documents") || zip;
|
const folder = zip.folder("documents") || zip;
|
||||||
|
|
||||||
const downloadPromises = documentsNotary.map(async (doc) => {
|
documentsNotary.map((doc: any) => {
|
||||||
const file = doc.files?.[0];
|
const file = doc.files?.[0];
|
||||||
if (file && file.uid && doc.uid) {
|
if (file) {
|
||||||
const blob = await FilesNotary.getInstance().download(file.uid, doc.uid);
|
const blob = new Blob([file.file_blob.data], { type: file.file_blob.type });
|
||||||
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,9 +10,12 @@ 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 = {
|
||||||
@ -123,11 +126,26 @@ class ViewDocumentsNotaryClass extends BasePage<IPropsClass, IState> {
|
|||||||
|
|
||||||
override async componentDidMount() {
|
override async componentDidMount() {
|
||||||
try {
|
try {
|
||||||
const documentNotary = await DocumentsNotary.getInstance().getByUid(this.props.documentUid, {
|
LoaderService.getInstance().show();
|
||||||
files: true,
|
const documentNotary: any = await new Promise<any>((resolve: (document: any) => void) => {
|
||||||
folder: true,
|
DocumentService.getDocumentByUid(this.props.documentUid).then(async (process: any) => {
|
||||||
depositor: true,
|
if (process) {
|
||||||
|
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,
|
||||||
@ -149,8 +167,7 @@ class ViewDocumentsNotaryClass extends BasePage<IPropsClass, IState> {
|
|||||||
|
|
||||||
private async getFilePreview(): Promise<void> {
|
private async getFilePreview(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
const fileBlob: Blob = await FilesNotary.getInstance().download(this.state.selectedFile?.uid as string, this.props.documentUid);
|
const fileBlob: Blob = new Blob([this.state.selectedFile.file_blob.data], { type: this.state.selectedFile.file_blob.type });
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
fileBlob,
|
fileBlob,
|
||||||
});
|
});
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
"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";
|
||||||
|
|
||||||
@ -10,7 +9,6 @@ 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";
|
||||||
@ -21,16 +19,19 @@ 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 = {};
|
||||||
|
|
||||||
@ -46,6 +47,30 @@ 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;
|
||||||
@ -54,6 +79,7 @@ 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) {
|
||||||
@ -72,6 +98,7 @@ export default function ClientDashboard(props: IProps) {
|
|||||||
setFolder(folder);
|
setFolder(folder);
|
||||||
|
|
||||||
setIsAuthModalOpen(true);
|
setIsAuthModalOpen(true);
|
||||||
|
LoaderService.getInstance().hide();
|
||||||
|
|
||||||
return { folder, customer };
|
return { folder, customer };
|
||||||
|
|
||||||
@ -111,52 +138,34 @@ export default function ClientDashboard(props: IProps) {
|
|||||||
|
|
||||||
const fetchDocuments = useCallback(
|
const fetchDocuments = useCallback(
|
||||||
async (customerUid: string | undefined) => {
|
async (customerUid: string | undefined) => {
|
||||||
/* TODO: review
|
LoaderService.getInstance().show();
|
||||||
const query: IGetDocumentsparams = {
|
return new Promise<void>((resolve: () => void) => {
|
||||||
where: { depositor: { uid: customerUid }, folder_uid: folderUid as string },
|
DocumentService.getDocuments().then(async (processes: any[]) => {
|
||||||
include: {
|
if (processes.length > 0) {
|
||||||
files: true,
|
let documents: any[] = processes.map((process: any) => process.processData);
|
||||||
document_history: true,
|
|
||||||
document_type: true,
|
|
||||||
depositor: true,
|
|
||||||
folder: {
|
|
||||||
include: {
|
|
||||||
customers: {
|
|
||||||
include: {
|
|
||||||
contact: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
return Documents.getInstance()
|
// FilterBy folder.uid & depositor.uid
|
||||||
.get(query)
|
documents = documents.filter((document: any) => document.folder.uid === folderUid && document.depositor && document.depositor.uid === customerUid);
|
||||||
.then((documents) => setDocuments(documents));
|
|
||||||
*/
|
|
||||||
|
|
||||||
return DocumentService.getDocuments().then(async (processes: any[]) => {
|
for (const document of documents) {
|
||||||
if (processes.length > 0) {
|
if (document.document_type) {
|
||||||
let documents: any[] = processes.map((process: any) => process.processData);
|
document.document_type = (await DocumentTypeService.getDocumentTypeByUid(document.document_type.uid)).processData;
|
||||||
|
|
||||||
// FilterBy folder_uid
|
|
||||||
documents = documents.filter((document: any) => document.folder.uid === folderUid);
|
|
||||||
|
|
||||||
for (const document of documents) {
|
|
||||||
document.document_type = (await DocumentTypeService.getDocumentTypeByUid(document.document_type.uid)).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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
setDocuments(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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setDocuments(documents);
|
||||||
|
}
|
||||||
|
LoaderService.getInstance().hide();
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
[folderUid],
|
[folderUid],
|
||||||
@ -170,12 +179,28 @@ export default function ClientDashboard(props: IProps) {
|
|||||||
const customerUid = customer?.uid;
|
const customerUid = customer?.uid;
|
||||||
if (!folderUid || !customerUid) return;
|
if (!folderUid || !customerUid) return;
|
||||||
|
|
||||||
/* TODO: review
|
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((documentsNotary) => setDocumentsNotary(documentsNotary));
|
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?.uid]);
|
}, [folderUid, customer?.uid]);
|
||||||
|
|
||||||
const documentsNotaryNotRead = useMemo(
|
const documentsNotaryNotRead = useMemo(
|
||||||
@ -312,8 +337,52 @@ 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,6 +5,7 @@ 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";
|
||||||
@ -15,6 +16,7 @@ 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) {
|
||||||
@ -52,7 +54,13 @@ 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,6 +14,9 @@ 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;
|
||||||
@ -27,12 +30,14 @@ export default function DeedTypesEdit() {
|
|||||||
setHasChanged(false);
|
setHasChanged(false);
|
||||||
async function getDeedType() {
|
async function getDeedType() {
|
||||||
if (!deedTypeUid) return;
|
if (!deedTypeUid) return;
|
||||||
const deedType = await DeedTypes.getInstance().getByUid(deedTypeUid as string, {
|
LoaderService.getInstance().show();
|
||||||
q: {
|
DeedTypeService.getDeedTypeByUid(deedTypeUid as string).then((process: any) => {
|
||||||
document_types: true,
|
if (process) {
|
||||||
},
|
const deedType: any = process.processData;
|
||||||
|
setDeedTypeSelected(deedType);
|
||||||
|
}
|
||||||
|
setTimeout(() => LoaderService.getInstance().hide(), 2000);
|
||||||
});
|
});
|
||||||
setDeedTypeSelected(deedType);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getDeedType();
|
getDeedType();
|
||||||
@ -57,19 +62,19 @@ export default function DeedTypesEdit() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
await DeedTypes.getInstance().put(
|
LoaderService.getInstance().show();
|
||||||
deedTypeUid as string,
|
DeedTypeService.getDeedTypeByUid(deedTypeUid as string).then((process: any) => {
|
||||||
DeedType.hydrate<DeedType>({
|
if (process) {
|
||||||
uid: deedTypeUid as string,
|
DeedTypeService.updateDeedType(process, { name: values["name"], description: values["description"] }).then(() => {
|
||||||
name: values["name"],
|
setTimeout(() => LoaderService.getInstance().hide(), 2000);
|
||||||
description: values["description"],
|
router.push(
|
||||||
}),
|
Module.getInstance()
|
||||||
);
|
.get()
|
||||||
router.push(
|
.modules.pages.DeedTypes.pages.DeedTypesInformations.props.path.replace("[uid]", deedTypeUid as string),
|
||||||
Module.getInstance()
|
);
|
||||||
.get()
|
});
|
||||||
.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,6 +20,7 @@ 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) {
|
||||||
@ -50,9 +51,11 @@ 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);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -103,6 +106,7 @@ 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;
|
||||||
@ -115,6 +119,7 @@ export default function DeedTypesInformations(props: IProps) {
|
|||||||
.forEach((selectedDocument: any) => document_types.push(selectedDocument));
|
.forEach((selectedDocument: any) => document_types.push(selectedDocument));
|
||||||
|
|
||||||
DeedTypeService.updateDeedType(process, { document_types: document_types }).then(() => {
|
DeedTypeService.updateDeedType(process, { document_types: document_types }).then(() => {
|
||||||
|
setTimeout(() => LoaderService.getInstance().hide(), 2000);
|
||||||
closeSaveModal();
|
closeSaveModal();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ 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";
|
||||||
@ -14,6 +15,7 @@ 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) {
|
||||||
@ -37,7 +39,7 @@ export default function DocumentTypesCreate(props: IProps) {
|
|||||||
});
|
});
|
||||||
await validateOrReject(documentFormModel, { groups: ["createDocumentType"] });
|
await validateOrReject(documentFormModel, { groups: ["createDocumentType"] });
|
||||||
|
|
||||||
const documentData: any = {
|
const documentTypeData: any = {
|
||||||
...values,
|
...values,
|
||||||
office: {
|
office: {
|
||||||
uid: officeId,
|
uid: officeId,
|
||||||
@ -45,7 +47,13 @@ export default function DocumentTypesCreate(props: IProps) {
|
|||||||
};
|
};
|
||||||
const validatorId: string = '884cb36a346a79af8697559f16940141f068bdf1656f88fa0df0e9ecd7311fb8:0';
|
const validatorId: string = '884cb36a346a79af8697559f16940141f068bdf1656f88fa0df0e9ecd7311fb8:0';
|
||||||
|
|
||||||
DocumentTypeService.createDocumentType(documentData, validatorId).then((processCreated: any) => {
|
LoaderService.getInstance().show();
|
||||||
|
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,4 +1,3 @@
|
|||||||
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";
|
||||||
@ -13,6 +12,9 @@ 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;
|
||||||
@ -23,10 +25,14 @@ export default function DocumentTypesEdit() {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
async function getDocumentType() {
|
async function getDocumentType() {
|
||||||
if (!documentTypeUid) return;
|
if (!documentTypeUid) return;
|
||||||
const documentType = await DocumentTypes.getInstance().getByUid(documentTypeUid as string, {
|
LoaderService.getInstance().show();
|
||||||
_count: true,
|
DocumentTypeService.getDocumentTypeByUid(documentTypeUid as string).then((process: any) => {
|
||||||
|
if (process) {
|
||||||
|
const documentType: any = process.processData;
|
||||||
|
setDocumentTypeSelected(documentType);
|
||||||
|
}
|
||||||
|
setTimeout(() => LoaderService.getInstance().hide(), 2000);
|
||||||
});
|
});
|
||||||
setDocumentTypeSelected(documentType);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getDocumentType();
|
getDocumentType();
|
||||||
@ -46,16 +52,22 @@ export default function DocumentTypesEdit() {
|
|||||||
setValidationError(validationErrors as ValidationError[]);
|
setValidationError(validationErrors as ValidationError[]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
LoaderService.getInstance().show();
|
||||||
const documentTypeUpdated = await DocumentTypes.getInstance().put(documentTypeUid as string, documentToUpdate);
|
DocumentTypeService.getDocumentTypeByUid(documentTypeUid as string).then((process: any) => {
|
||||||
router.push(
|
if (process) {
|
||||||
Module.getInstance()
|
DocumentTypeService.updateDocumentType(process, values).then(() => {
|
||||||
.get()
|
setTimeout(() => LoaderService.getInstance().hide(), 2000);
|
||||||
.modules.pages.DocumentTypes.pages.DocumentTypesInformations.props.path.replace(
|
router.push(
|
||||||
"[uid]",
|
Module.getInstance()
|
||||||
documentTypeUpdated.uid ?? "",
|
.get()
|
||||||
),
|
.modules.pages.DocumentTypes.pages.DocumentTypesInformations.props.path.replace(
|
||||||
);
|
"[uid]",
|
||||||
|
documentTypeUid as string ?? "",
|
||||||
|
)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
} 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,6 +7,7 @@ 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";
|
||||||
@ -17,6 +18,7 @@ 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";
|
||||||
|
|
||||||
@ -78,6 +80,7 @@ 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) {
|
||||||
@ -88,6 +91,11 @@ 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}`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -99,11 +107,17 @@ 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}`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -142,6 +156,7 @@ 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);
|
||||||
|
|
||||||
@ -162,6 +177,8 @@ 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,5 +1,3 @@
|
|||||||
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";
|
||||||
@ -7,12 +5,14 @@ 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 { DocumentType, OfficeFolder } from "le-coffre-resources/dist/Notary";
|
import { 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,18 +75,38 @@ export default function ParameterDocuments(props: IProps) {
|
|||||||
const addDocument = useCallback(async () => {
|
const addDocument = useCallback(async () => {
|
||||||
if (addOrEditDocument === "add") {
|
if (addOrEditDocument === "add") {
|
||||||
try {
|
try {
|
||||||
const documentType = await DocumentTypes.getInstance().post({
|
LoaderService.getInstance().show();
|
||||||
|
|
||||||
|
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!, {
|
|
||||||
document_types: [...oldDocumentsType, documentType],
|
await new Promise<void>((resolve: () => void) => {
|
||||||
|
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
|
||||||
@ -100,28 +120,44 @@ 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 Deeds.getInstance().put(props.folder.deed?.uid!, {
|
await new Promise<void>((resolve: () => void) => {
|
||||||
document_types: [
|
DeedTypeService.getDeedTypeByUid(props.folder.deed?.deed_type?.uid!).then((process: any) => {
|
||||||
...oldDocumentsType,
|
if (process) {
|
||||||
...selectedDocuments.map((document) => DocumentType.hydrate<DocumentType>({ uid: document.id as string })),
|
DeedTypeService.updateDeedType(process, {
|
||||||
],
|
document_types: [
|
||||||
|
...oldDocumentsType.map((document: any) => ({ uid: document.uid })),
|
||||||
|
...selectedDocuments.map((document: any) => ({ 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 fullDoc = await DocumentTypes.getInstance().getByUid(doc.id as string);
|
const documentType: any = await new Promise<any>((resolve: (documentType: any) => void) => {
|
||||||
|
DocumentTypeService.getDocumentTypeByUid(doc.id as string).then((process: any) => {
|
||||||
|
if (process) {
|
||||||
|
const documentType: any = process.processData;
|
||||||
|
resolve(documentType);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
return {
|
return {
|
||||||
label: fullDoc.name!,
|
label: documentType.name!,
|
||||||
value: fullDoc.uid!,
|
value: documentType.uid!,
|
||||||
description: fullDoc.private_description!,
|
description: documentType.private_description!,
|
||||||
} as IFormOption;
|
} as IFormOption;
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
@ -130,6 +166,7 @@ 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,6 +17,7 @@ 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();
|
||||||
@ -58,8 +59,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: {
|
||||||
@ -77,7 +78,6 @@ 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,11 +127,13 @@ 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,6 +17,7 @@ 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 = {};
|
||||||
|
|
||||||
@ -83,6 +84,8 @@ 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;
|
||||||
@ -97,6 +100,8 @@ 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 });
|
||||||
@ -121,6 +126,7 @@ 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,6 +8,7 @@ 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";
|
||||||
@ -22,6 +23,7 @@ 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 {
|
||||||
/**
|
/**
|
||||||
@ -95,7 +97,13 @@ 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,6 +14,7 @@ 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;
|
||||||
@ -37,12 +38,13 @@ 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 depositor_uid & folder_uid
|
// FilterBy folder.uid & depositor.uid
|
||||||
documents = documents.filter((document: any) => document.depositor.uid === customerUid && document.folder.uid === folderUid);
|
documents = documents.filter((document: any) => document.folder.uid === folderUid && document.depositor && document.depositor.uid === customerUid);
|
||||||
|
|
||||||
if (documents && documents.length > 0) {
|
if (documents && documents.length > 0) {
|
||||||
closeDeleteModal();
|
closeDeleteModal();
|
||||||
|
@ -4,6 +4,7 @@ import Typography, { ETypo } from "@Front/Components/DesignSystem/Typography";
|
|||||||
import React, { useCallback } from "react";
|
import React, { useCallback } from "react";
|
||||||
|
|
||||||
import DocumentService from "src/common/Api/LeCoffreApi/sdk/DocumentService";
|
import DocumentService from "src/common/Api/LeCoffreApi/sdk/DocumentService";
|
||||||
|
import LoaderService from "src/common/Api/LeCoffreApi/sdk/Loader/LoaderService";
|
||||||
|
|
||||||
type IProps = {
|
type IProps = {
|
||||||
documentUid: string;
|
documentUid: string;
|
||||||
@ -16,7 +17,8 @@ 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) => {
|
||||||
@ -27,8 +29,10 @@ 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,9 +1,11 @@
|
|||||||
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;
|
||||||
@ -15,13 +17,18 @@ export default function DeleteSentDocumentModal(props: IProps) {
|
|||||||
const { isOpen, onClose, documentUid, onDeleteSuccess } = props;
|
const { isOpen, onClose, documentUid, onDeleteSuccess } = props;
|
||||||
|
|
||||||
const onDelete = useCallback(
|
const onDelete = useCallback(
|
||||||
() =>
|
() => {
|
||||||
DocumentsNotary.getInstance()
|
LoaderService.getInstance().show();
|
||||||
.delete(documentUid)
|
DocumentService.getDocumentByUid(documentUid).then((process: any) => {
|
||||||
.then(() => onDeleteSuccess(documentUid))
|
if (process) {
|
||||||
.then(() => ToasterService.getInstance().success({ title: "Succès !", description: "Le document a été supprimé avec succès." }))
|
DocumentService.updateDocument(process, { isDeleted: 'true' })
|
||||||
.then(onClose)
|
.then(() => onDeleteSuccess(documentUid))
|
||||||
.catch((error) => console.warn(error)),
|
.then(() => ToasterService.getInstance().success({ title: "Succès !", description: "Le document a été supprimé avec succès." }))
|
||||||
|
.then(() => LoaderService.getInstance().hide())
|
||||||
|
.then(onClose);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
[documentUid, onClose, onDeleteSuccess],
|
[documentUid, onClose, onDeleteSuccess],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
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";
|
||||||
@ -10,7 +8,6 @@ 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";
|
||||||
@ -24,6 +21,7 @@ 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;
|
||||||
@ -44,7 +42,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<Document[]>([]);
|
const [documents, setDocuments] = useState<any[]>([]);
|
||||||
const [documentsNotary, setDocumentsNotary] = useState<DocumentNotary[]>([]);
|
const [documentsNotary, setDocumentsNotary] = useState<DocumentNotary[]>([]);
|
||||||
const [focusedDocumentUid, setFocusedDocumentUid] = useState<string | null>(null);
|
const [focusedDocumentUid, setFocusedDocumentUid] = useState<string | null>(null);
|
||||||
|
|
||||||
@ -55,17 +53,18 @@ export default function DocumentTables(props: IProps) {
|
|||||||
|
|
||||||
const fetchDocuments = useCallback(
|
const fetchDocuments = useCallback(
|
||||||
() => {
|
() => {
|
||||||
setDocuments([]);
|
LoaderService.getInstance().show();
|
||||||
|
|
||||||
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.uid === customerUid);
|
documents = documents.filter((document: any) => document.folder.uid === folderUid && document.depositor && document.depositor.uid === customerUid);
|
||||||
|
|
||||||
for (const document of documents) {
|
for (const document of documents) {
|
||||||
document.document_type = (await DocumentTypeService.getDocumentTypeByUid(document.document_type.uid)).processData;
|
if (document.document_type) {
|
||||||
|
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[] = [];
|
||||||
@ -80,24 +79,45 @@ export default function DocumentTables(props: IProps) {
|
|||||||
} else {
|
} else {
|
||||||
setDocuments([]);
|
setDocuments([]);
|
||||||
}
|
}
|
||||||
})
|
LoaderService.getInstance().hide();
|
||||||
|
});
|
||||||
},
|
},
|
||||||
[customerUid, folderUid],
|
[customerUid, folderUid],
|
||||||
);
|
);
|
||||||
|
|
||||||
const fetchDocumentsNotary = useCallback(
|
const fetchDocumentsNotary = useCallback(
|
||||||
() =>
|
() => {
|
||||||
DocumentsNotary.getInstance()
|
LoaderService.getInstance().show();
|
||||||
.get({ where: { folder: { uid: folderUid }, customer: { uid: customerUid } }, include: { files: true } })
|
DocumentService.getDocuments().then(async (processes: any[]) => {
|
||||||
.then(setDocumentsNotary)
|
if (processes.length > 0) {
|
||||||
.catch(console.warn),
|
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);
|
||||||
|
} 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(
|
||||||
@ -137,21 +157,23 @@ export default function DocumentTables(props: IProps) {
|
|||||||
}).catch((e) => console.warn(e));
|
}).catch((e) => console.warn(e));
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const onDownloadFileNotary = useCallback((doc: DocumentNotary) => {
|
const onDownloadFileNotary = useCallback((doc: any) => {
|
||||||
const file = doc.files?.[0];
|
const file = doc.files?.[0];
|
||||||
if (!file || !file?.uid) return;
|
if (!file) return;
|
||||||
|
|
||||||
return FilesNotary.getInstance()
|
return new Promise<void>((resolve: () => void) => {
|
||||||
.download(file.uid)
|
const blob = new Blob([file.file_blob.data], { type: file.file_blob.type });
|
||||||
.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();
|
||||||
URL.revokeObjectURL(url);
|
document.body.removeChild(a);
|
||||||
})
|
URL.revokeObjectURL(url);
|
||||||
.catch((e) => console.warn(e));
|
|
||||||
|
resolve();
|
||||||
|
}).catch((e) => console.warn(e));
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const askedDocuments: IRowProps[] = useMemo(
|
const askedDocuments: IRowProps[] = useMemo(
|
||||||
@ -161,21 +183,25 @@ 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: 400 }, content: document.document_type?.name ?? "_" },
|
document_type: { sx: { width: 300 }, 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].toUpperCase()}
|
label={tradDocumentStatus[document.document_status as EDocumentStatus].toUpperCase()}
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
date: {
|
date: {
|
||||||
sx: { width: 107 },
|
sx: { width: 120 },
|
||||||
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: (
|
||||||
@ -197,21 +223,25 @@ 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: 400 }, content: document.document_type?.name ?? "_" },
|
document_type: { sx: { width: 300 }, 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].toUpperCase()}
|
label={tradDocumentStatus[document.document_status as EDocumentStatus].toUpperCase()}
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
date: {
|
date: {
|
||||||
sx: { width: 107 },
|
sx: { width: 120 },
|
||||||
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: (
|
||||||
@ -239,21 +269,25 @@ 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: 400 }, content: document.document_type?.name ?? "_" },
|
document_type: { sx: { width: 300 }, 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].toUpperCase()}
|
label={tradDocumentStatus[document.document_status as EDocumentStatus].toUpperCase()}
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
date: {
|
date: {
|
||||||
sx: { width: 107 },
|
sx: { width: 120 },
|
||||||
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: (
|
||||||
@ -282,21 +316,25 @@ 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: 400 }, content: document.document_type?.name ?? "_" },
|
document_type: { sx: { width: 300 }, 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].toUpperCase()}
|
label={tradDocumentStatus[document.document_status as EDocumentStatus].toUpperCase()}
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
date: {
|
date: {
|
||||||
sx: { width: 107 },
|
sx: { width: 120 },
|
||||||
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: "" },
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
@ -311,7 +349,7 @@ export default function DocumentTables(props: IProps) {
|
|||||||
return {
|
return {
|
||||||
key: document.uid,
|
key: document.uid,
|
||||||
document_type: {
|
document_type: {
|
||||||
sx: { width: 400 },
|
sx: { width: 300 },
|
||||||
content: formatName(document.files?.[0]?.file_name?.split(".")?.[0] ?? "") || "_",
|
content: formatName(document.files?.[0]?.file_name?.split(".")?.[0] ?? "") || "_",
|
||||||
},
|
},
|
||||||
document_status: {
|
document_status: {
|
||||||
@ -319,9 +357,13 @@ export default function DocumentTables(props: IProps) {
|
|||||||
content: getTagForSentDocument(document.document_status as EDocumentNotaryStatus),
|
content: getTagForSentDocument(document.document_status as EDocumentNotaryStatus),
|
||||||
},
|
},
|
||||||
date: {
|
date: {
|
||||||
sx: { width: 107 },
|
sx: { width: 120 },
|
||||||
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: (
|
||||||
@ -408,6 +450,10 @@ 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,6 +16,7 @@ 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;
|
||||||
@ -62,7 +63,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;
|
||||||
@ -71,6 +72,7 @@ export default function ClientView(props: IProps) {
|
|||||||
const customers = folder.customers.filter((uid: string) => uid !== customerUid);
|
const customers = folder.customers.filter((uid: string) => uid !== customerUid);
|
||||||
|
|
||||||
FolderService.updateFolder(process, { customers: customers }).then(() => {
|
FolderService.updateFolder(process, { customers: customers }).then(() => {
|
||||||
|
setTimeout(() => LoaderService.getInstance().hide(), 2000);
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ 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;
|
||||||
@ -24,9 +25,13 @@ 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(() => resolve());
|
FolderService.updateFolder(process, { isDeleted: 'true' }).then(() => {
|
||||||
|
setTimeout(() => LoaderService.getInstance().hide(), 2000);
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
@ -24,6 +24,7 @@ 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",
|
||||||
@ -108,6 +109,7 @@ 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;
|
||||||
@ -133,7 +135,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.uid === customer.uid);
|
customer.documents = documents.filter((document: any) => document.depositor && document.depositor.uid === customer.uid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
resolve();
|
resolve();
|
||||||
@ -141,6 +143,7 @@ export default function FolderInformation(props: IProps) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
setFolder(folder);
|
setFolder(folder);
|
||||||
|
setTimeout(() => LoaderService.getInstance().hide(), 2000);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}, [folderUid]);
|
}, [folderUid]);
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import backgroundImage from "@Assets/images/background_refonte.svg";
|
import backgroundImage from "@Assets/images/background_refonte.svg";
|
||||||
import DocumentsNotary from "@Front/Api/LeCoffreApi/Notary/DocumentsNotary/DocumentsNotary";
|
import { EDocumentNotaryStatus } from "le-coffre-resources/dist/Notary/DocumentNotary";
|
||||||
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";
|
||||||
@ -19,6 +18,11 @@ 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",
|
||||||
@ -59,6 +63,64 @@ 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) => {
|
||||||
@ -83,6 +145,7 @@ 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);
|
||||||
@ -92,18 +155,14 @@ export default function SendDocuments() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const fetchFolder = useCallback(async () => {
|
const fetchFolder = useCallback(async () => {
|
||||||
Folders.getInstance()
|
LoaderService.getInstance().show();
|
||||||
.getByUid(folderUid as string, {
|
FolderService.getFolderByUid(folderUid as string).then((process: any) => {
|
||||||
q: {
|
if (process) {
|
||||||
customers: {
|
const folder: any = process.processData;
|
||||||
include: {
|
setFolder(folder);
|
||||||
contact: true,
|
LoaderService.getInstance().hide();
|
||||||
},
|
}
|
||||||
},
|
});
|
||||||
},
|
|
||||||
})
|
|
||||||
.then((folder) => setFolder(folder))
|
|
||||||
.catch((e) => console.warn(e));
|
|
||||||
}, [folderUid]);
|
}, [folderUid]);
|
||||||
|
|
||||||
const onClientSelectionChange = useCallback(
|
const onClientSelectionChange = useCallback(
|
||||||
|
@ -17,6 +17,7 @@ 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();
|
||||||
@ -35,12 +36,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) {
|
||||||
@ -70,10 +71,13 @@ 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,6 +13,7 @@ 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 = {};
|
||||||
|
|
||||||
@ -67,6 +68,7 @@ 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;
|
||||||
@ -80,15 +82,17 @@ 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,6 +19,7 @@ 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();
|
||||||
@ -48,14 +49,18 @@ export default function UpdateFolderMetadata() {
|
|||||||
setValidationError(validationErrors as ValidationError[]);
|
setValidationError(validationErrors as ValidationError[]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await Folders.getInstance().put(folderUid, newValues);
|
LoaderService.getInstance().show();
|
||||||
const url = Module.getInstance()
|
FolderService.getFolderByUid(folderUid).then((process: any) => {
|
||||||
.get()
|
if (process) {
|
||||||
.modules.pages.Folder.pages.FolderInformation.props.path.replace("[folderUid]", folderUid);
|
FolderService.updateFolder(process, { ...values, deed: { uid: values["deed"] } }).then(() => {
|
||||||
|
setTimeout(() => LoaderService.getInstance().hide(), 2000);
|
||||||
router.push(url);
|
router.push(Module.getInstance()
|
||||||
|
.get()
|
||||||
|
.modules.pages.Folder.pages.FolderInformation.props.path.replace("[folderUid]", folderUid));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
} catch (backError) {
|
} catch (backError) {
|
||||||
if (!Array.isArray(backError)) return;
|
if (!Array.isArray(backError)) return;
|
||||||
setValidationError(backError);
|
setValidationError(backError);
|
||||||
@ -65,24 +70,12 @@ 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, File } from "le-coffre-resources/dist/Notary";
|
import { Document } 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,6 +5,7 @@ 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";
|
||||||
@ -16,6 +17,9 @@ 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);
|
||||||
@ -26,12 +30,17 @@ 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: jwt?.office_Id,
|
uid: officeId,
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
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) {
|
||||||
@ -39,6 +48,29 @@ 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>({
|
||||||
@ -55,6 +87,7 @@ export default function RolesCreate(props: IProps) {
|
|||||||
setValidationError(validationErrors as ValidationError[]);
|
setValidationError(validationErrors as ValidationError[]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
},
|
},
|
||||||
[router],
|
[router],
|
||||||
);
|
);
|
||||||
|
@ -13,6 +13,9 @@ 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;
|
||||||
};
|
};
|
||||||
@ -39,24 +42,60 @@ 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) => r.uid === rule.uid))) {
|
if (ruleGroup.rules?.every((rule) => role.rules?.find((r: any) => r.uid === rule.uid))) {
|
||||||
return { ...ruleGroup, checked: true };
|
return { ...ruleGroup, checked: true };
|
||||||
}
|
}
|
||||||
return { ...ruleGroup, checked: false };
|
return { ...ruleGroup, checked: false };
|
||||||
|
@ -8,6 +8,8 @@ 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";
|
||||||
@ -115,6 +117,7 @@ const MyApp = (({
|
|||||||
</Component>
|
</Component>
|
||||||
}
|
}
|
||||||
{isConnected && <Iframe />}
|
{isConnected && <Iframe />}
|
||||||
|
<Loader />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}) as AppType;
|
}) as AppType;
|
||||||
|
@ -153,6 +153,10 @@ 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