Fix some bugs - continue
This commit is contained in:
parent
5ad6465b74
commit
ccc0a1620c
@ -92,4 +92,17 @@ export default class CustomerService {
|
||||
}).catch(reject);
|
||||
});
|
||||
}
|
||||
|
||||
public static updateCustomer(process: any, newData: any): Promise<void> {
|
||||
return new Promise<void>((resolve: () => void, reject: (error: string) => void) => {
|
||||
this.messageBus.updateProcess(process.processId, newData, [], null).then((processUpdated: any) => {
|
||||
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);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,8 @@ import React, { useEffect, useState } from "react";
|
||||
|
||||
import DefaultDashboardWithList, { IPropsDashboardWithList } from "../DefaultDashboardWithList";
|
||||
|
||||
import FolderService from "src/common/Api/LeCoffreApi/sdk/FolderService";
|
||||
|
||||
type IProps = IPropsDashboardWithList & {};
|
||||
|
||||
export default function DefaultCustomerDashboard(props: IProps) {
|
||||
@ -19,6 +21,7 @@ export default function DefaultCustomerDashboard(props: IProps) {
|
||||
const jwt = JwtService.getInstance().decodeCustomerJwt();
|
||||
if (!jwt) return;
|
||||
|
||||
/*
|
||||
Folders.getInstance()
|
||||
.get({
|
||||
q: {
|
||||
@ -42,6 +45,14 @@ export default function DefaultCustomerDashboard(props: IProps) {
|
||||
},
|
||||
})
|
||||
.then((folders) => setFolders(folders));
|
||||
*/
|
||||
|
||||
FolderService.getFolders().then((processes: any[]) => {
|
||||
if (processes.length > 0) {
|
||||
const folders: any[] = processes.map((process: any) => process.processData);
|
||||
setFolders(folders);
|
||||
}
|
||||
});
|
||||
}, []);
|
||||
|
||||
const onSelectedBlock = (block: IBlock) => {
|
||||
|
@ -47,9 +47,11 @@ export default function ContactBox(props: IProps) {
|
||||
|
||||
useEffect(() => {
|
||||
if (!folder?.office?.uid) return;
|
||||
/* TODO: review
|
||||
OfficeRib.getInstance()
|
||||
.getRibStream(folder.office.uid)
|
||||
.then((blob) => setRibUrl(URL.createObjectURL(blob)));
|
||||
*/
|
||||
}, [folder]);
|
||||
|
||||
const downloadRib = useCallback(async () => {
|
||||
|
@ -27,11 +27,12 @@ import DepositOtherDocument from "@Front/Components/DesignSystem/DepositOtherDoc
|
||||
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
|
||||
import MessageBus from "src/sdk/MessageBus";
|
||||
|
||||
import MapUtils from "src/sdk/MapUtils";
|
||||
import AuthModal from "src/sdk/AuthModal";
|
||||
import FormModal from "./FormModal";
|
||||
//import FormModal from "./FormModal";
|
||||
|
||||
import FolderService from "src/common/Api/LeCoffreApi/sdk/FolderService";
|
||||
import DocumentService from "src/common/Api/LeCoffreApi/sdk/DocumentService";
|
||||
import DocumentTypeService from "src/common/Api/LeCoffreApi/sdk/DocumentTypeService";
|
||||
|
||||
type IProps = {};
|
||||
|
||||
@ -48,13 +49,26 @@ export default function ClientDashboard(props: IProps) {
|
||||
const [isAddDocumentModalVisible, setIsAddDocumentModalVisible] = useState<boolean>(false);
|
||||
|
||||
const [isAuthModalOpen, setIsAuthModalOpen] = useState(false);
|
||||
const [isFormModalOpen, setIsFormModalOpen] = useState(false);
|
||||
//const [isFormModalOpen, setIsFormModalOpen] = useState(false);
|
||||
|
||||
const fetchFolderAndCustomer = useCallback(async () => {
|
||||
// TODO: review
|
||||
const { folder, customer, file } = await new Promise<any>((resolve) => {
|
||||
MessageBus.getInstance().isReady().then(() => {
|
||||
setTimeout(() => {
|
||||
FolderService.getFolderByUid(folderUid as string).then((process: any) => {
|
||||
if (process) {
|
||||
const folder: any = process.processData;
|
||||
|
||||
const customers: any[] = folder.customers;
|
||||
const customer: any = customers.find((customer: any) => customer.uid === profileUid as string);
|
||||
if (customer) {
|
||||
|
||||
|
||||
resolve({ folder: folder, customer, file: null });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/*
|
||||
MessageBus.getInstance().getFolders().then(async (folders) => {
|
||||
const folder: any = folders.find((folder: any) => folder.processData.uid === folderUid as string);
|
||||
if (folder) {
|
||||
@ -80,8 +94,7 @@ export default function ClientDashboard(props: IProps) {
|
||||
resolve({ folder: folder.processData, customer, file: file ? file.processData : null });
|
||||
}
|
||||
});
|
||||
}, 2500);
|
||||
});
|
||||
*/
|
||||
});
|
||||
|
||||
setCustomer(customer);
|
||||
@ -135,6 +148,7 @@ export default function ClientDashboard(props: IProps) {
|
||||
|
||||
const fetchDocuments = useCallback(
|
||||
(customerUid: string | undefined) => {
|
||||
/*
|
||||
const query: IGetDocumentsparams = {
|
||||
where: { depositor: { uid: customerUid }, folder_uid: folderUid as string },
|
||||
include: {
|
||||
@ -157,6 +171,20 @@ export default function ClientDashboard(props: IProps) {
|
||||
return Documents.getInstance()
|
||||
.get(query)
|
||||
.then((documents) => setDocuments(documents));
|
||||
*/
|
||||
|
||||
return DocumentService.getDocuments().then(async (processes: any[]) => {
|
||||
if (processes.length > 0) {
|
||||
const documents: any[] = processes.map((process: any) => process.processData);
|
||||
|
||||
for (const document of documents) {
|
||||
const p: any = await DocumentTypeService.getDocumentTypeByUid(document.document_type.uid);
|
||||
document.document_type = p.processData;
|
||||
}
|
||||
|
||||
setDocuments(documents);
|
||||
}
|
||||
});
|
||||
},
|
||||
[folderUid],
|
||||
);
|
||||
@ -336,12 +364,15 @@ export default function ClientDashboard(props: IProps) {
|
||||
isOpen={isAuthModalOpen}
|
||||
onClose={() => {
|
||||
setIsAuthModalOpen(false);
|
||||
/*
|
||||
setTimeout(() => {
|
||||
setIsFormModalOpen(true);
|
||||
}, 500);
|
||||
*/
|
||||
}}
|
||||
/>}
|
||||
|
||||
{/*
|
||||
<FormModal
|
||||
isOpen={isFormModalOpen}
|
||||
onClose={() => setIsFormModalOpen(false)}
|
||||
@ -366,6 +397,7 @@ export default function ClientDashboard(props: IProps) {
|
||||
file: fileBlob
|
||||
}
|
||||
|
||||
/ *
|
||||
MessageBus.getInstance().isReady().then(() => {
|
||||
MessageBus.getInstance().createFile(fileData, [], []).then((processCreated: any) => {
|
||||
MessageBus.getInstance().notifyUpdate(processCreated.processId, processCreated.process.states[0].state_id).then(() => {
|
||||
@ -375,12 +407,14 @@ export default function ClientDashboard(props: IProps) {
|
||||
});
|
||||
});
|
||||
});
|
||||
* /
|
||||
}
|
||||
};
|
||||
reader.readAsArrayBuffer(file);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
*/}
|
||||
</div>
|
||||
</DefaultCustomerDashboard>
|
||||
);
|
||||
|
@ -13,9 +13,10 @@ import BasePage from "../../Base";
|
||||
import classes from "./classes.module.scss";
|
||||
import Customer from "le-coffre-resources/dist/Customer";
|
||||
import Note from "le-coffre-resources/dist/Customer/Note";
|
||||
import Folders from "@Front/Api/LeCoffreApi/Customer/Folders/Folders";
|
||||
import Notes from "@Front/Api/LeCoffreApi/Customer/Notes/Notes";
|
||||
import Customers from "@Front/Api/LeCoffreApi/Notary/Customers/Customers";
|
||||
|
||||
import FolderService from "src/common/Api/LeCoffreApi/sdk/FolderService";
|
||||
import CustomerService from "src/common/Api/LeCoffreApi/sdk/CustomerService";
|
||||
|
||||
type IProps = {};
|
||||
|
||||
@ -76,9 +77,25 @@ class CreateCustomerNoteClass extends BasePage<IPropsClass, IState> {
|
||||
}
|
||||
|
||||
public override async componentDidMount() {
|
||||
/* TODO: review
|
||||
// const note = await Notes.getInstance().getByUid(this.props.noteUid, query);
|
||||
const folder = await Folders.getInstance().getByUid(this.props.folderUid, { note: true });
|
||||
const customer = await Customers.getInstance().getByUid(this.props.customerUid);
|
||||
*/
|
||||
|
||||
const folder: any = await FolderService.getFolderByUid(this.props.folderUid).then((process: any) => {
|
||||
if (process) {
|
||||
const folder: any = process.processData;
|
||||
return folder;
|
||||
}
|
||||
});
|
||||
|
||||
const customer: any = await CustomerService.getCustomerByUid(this.props.customerUid).then((process: any) => {
|
||||
if (process) {
|
||||
const customer: any = process.processData;
|
||||
return customer;
|
||||
}
|
||||
});
|
||||
|
||||
//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);
|
||||
|
@ -6,7 +6,8 @@ import Image from "next/image";
|
||||
import React, { useCallback, useState } from "react";
|
||||
|
||||
import classes from "./classes.module.scss";
|
||||
import MessageBus from "src/sdk/MessageBus";
|
||||
|
||||
import FolderService from "src/common/Api/LeCoffreApi/sdk/FolderService";
|
||||
|
||||
type IProps = {
|
||||
isOpen: boolean;
|
||||
@ -23,14 +24,9 @@ export default function AnchoringModal(props: IProps) {
|
||||
setIsAnchoring(true);
|
||||
|
||||
// TODO: review
|
||||
MessageBus.getInstance().isReady().then(() => {
|
||||
MessageBus.getInstance().getFolders().then((folders: any) => {
|
||||
const folder = folders.find((folder: any) => folder.processData.uid === folderUid);
|
||||
if (folder) {
|
||||
MessageBus.getInstance().updateProcess(folder.processId, { isArchived: 'true' }, [], null).then((processUpdated: any) => {
|
||||
const newStateId: string = processUpdated.diffs[0]?.state_id;
|
||||
MessageBus.getInstance().notifyUpdate(folder.processId, newStateId).then(() => {
|
||||
MessageBus.getInstance().validateState(folder.processId, newStateId).then((_updatedProcess) => {
|
||||
FolderService.getFolderByUid(folderUid as string).then((process: any) => {
|
||||
if (process) {
|
||||
FolderService.updateFolder(process, { status: '' }).then(() => {
|
||||
setIsAnchoring(false);
|
||||
|
||||
onAnchorSuccess();
|
||||
@ -38,11 +34,8 @@ export default function AnchoringModal(props: IProps) {
|
||||
onClose();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
/*
|
||||
const timeoutDelay = 9800;
|
||||
|
@ -1,5 +1,4 @@
|
||||
import backgroundImage from "@Assets/images/background_refonte.svg";
|
||||
import Customers from "@Front/Api/LeCoffreApi/Notary/Customers/Customers";
|
||||
import Button, { EButtonstyletype, EButtonVariant } from "@Front/Components/DesignSystem/Button";
|
||||
import Form, { IBaseField } from "@Front/Components/DesignSystem/Form";
|
||||
import TextField from "@Front/Components/DesignSystem/Form/TextField";
|
||||
@ -17,8 +16,7 @@ import { useRouter } from "next/router";
|
||||
import { useCallback, useEffect, useState } from "react";
|
||||
import classes from "./classes.module.scss";
|
||||
|
||||
import MessageBus from "src/sdk/MessageBus";
|
||||
import MapUtils from "src/sdk/MapUtils";
|
||||
import CustomerService from "src/common/Api/LeCoffreApi/sdk/CustomerService";
|
||||
|
||||
export default function UpdateClient() {
|
||||
const router = useRouter();
|
||||
@ -37,32 +35,14 @@ export default function UpdateClient() {
|
||||
useEffect(() => {
|
||||
const fetchCustomer = async () => {
|
||||
try {
|
||||
// TODO: review
|
||||
MessageBus.getInstance().isReady().then(() => {
|
||||
MessageBus.getInstance().getFolders().then((folders: any) => {
|
||||
const folder = folders.find((folder: any) => folder.processData.uid === folderUid as string);
|
||||
if (folder) {
|
||||
const customers: any[] = folder.processData.customers.map((customer: any) => MapUtils.toJson(customer));
|
||||
const customer: any = customers.find((customer: any) => customer.uid === customerUid as string);
|
||||
CustomerService.getCustomerByUid(customerUid as string).then((process: any) => {
|
||||
if (process) {
|
||||
const customer: any = process.processData;
|
||||
if (customer) {
|
||||
setCustomer(customer);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
/*
|
||||
const customerData = await Customers.getInstance().getByUid(customerUid as string, {
|
||||
contact: {
|
||||
include: {
|
||||
address: true,
|
||||
},
|
||||
},
|
||||
});
|
||||
if (customerData) {
|
||||
setCustomer(customerData);
|
||||
}
|
||||
*/
|
||||
} catch (error) {
|
||||
console.error("Failed to fetch customer", error);
|
||||
}
|
||||
@ -89,34 +69,15 @@ export default function UpdateClient() {
|
||||
});
|
||||
|
||||
try {
|
||||
// TODO: review
|
||||
MessageBus.getInstance().isReady().then(() => {
|
||||
MessageBus.getInstance().getFolders().then((folders: any) => {
|
||||
const folder = folders.find((folder: any) => folder.processData.uid === folderUid as string);
|
||||
if (folder) {
|
||||
const customers: any[] = folder.processData.customers.map((customer: any) => MapUtils.toJson(customer));
|
||||
const customer: any = customers.find((customer: any) => customer.uid === customerUid as string);
|
||||
if (customer) {
|
||||
customer.contact = contact; // Update the contact
|
||||
|
||||
MessageBus.getInstance().updateProcess(folder.processId, { customers: customers }, [], null).then((processUpdated: any) => {
|
||||
const newStateId: string = processUpdated.diffs[0]?.state_id;
|
||||
MessageBus.getInstance().notifyUpdate(folder.processId, newStateId).then(() => {
|
||||
MessageBus.getInstance().validateState(folder.processId, newStateId).then((_stateValidated) => {
|
||||
router.push(backwardPath);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
/*
|
||||
await contact.validateOrReject?.({ groups: ["createCustomer"], forbidUnknownValues: false });
|
||||
await Customers.getInstance().put(customerUid as string, { contact });
|
||||
CustomerService.getCustomerByUid(customerUid as string).then((process: any) => {
|
||||
if (process) {
|
||||
// TODO: review - address
|
||||
CustomerService.updateCustomer(process, { contact: contact }).then(() => {
|
||||
router.push(backwardPath);
|
||||
*/
|
||||
});
|
||||
}
|
||||
});
|
||||
} catch (validationErrors) {
|
||||
if (Array.isArray(validationErrors)) {
|
||||
setValidationError(validationErrors as ValidationError[]);
|
||||
|
@ -18,6 +18,8 @@ import DefaultDoubleSidePage from "@Front/Components/LayoutTemplates/DefaultDoub
|
||||
import TextAreaField from "@Front/Components/DesignSystem/Form/TextareaField";
|
||||
import { isArray } from "class-validator";
|
||||
|
||||
import FolderService from "src/common/Api/LeCoffreApi/sdk/FolderService";
|
||||
|
||||
export default function UpdateFolderMetadata() {
|
||||
const router = useRouter();
|
||||
|
||||
@ -63,6 +65,8 @@ export default function UpdateFolderMetadata() {
|
||||
|
||||
useEffect(() => {
|
||||
if (!folderUid || isArray(folderUid)) return;
|
||||
|
||||
/* TODO: review
|
||||
const query = {
|
||||
q: {
|
||||
deed: { include: { deed_type: true } },
|
||||
@ -73,6 +77,14 @@ export default function UpdateFolderMetadata() {
|
||||
Folders.getInstance()
|
||||
.getByUid(folderUid, query)
|
||||
.then((folder) => setSelectedFolder(folder));
|
||||
*/
|
||||
|
||||
FolderService.getFolderByUid(folderUid).then((process: any) => {
|
||||
if (process) {
|
||||
const folder: any = process.processData;
|
||||
setSelectedFolder(folder);
|
||||
}
|
||||
});
|
||||
}, [folderUid]);
|
||||
|
||||
const backwardPath = Module.getInstance()
|
||||
|
Loading…
x
Reference in New Issue
Block a user