[Layouts/Folder] update FolderInformation ClientView
This commit is contained in:
parent
b22eda0399
commit
b70516bc86
@ -17,9 +17,10 @@ import EmailReminder from "./EmailReminder";
|
||||
|
||||
import FolderService from "src/common/Api/LeCoffreApi/sdk/FolderService";
|
||||
import LoaderService from "src/common/Api/LeCoffreApi/sdk/Loader/LoaderService";
|
||||
import MessageBus from "src/sdk/MessageBus";
|
||||
|
||||
type IProps = {
|
||||
folder: OfficeFolder;
|
||||
folder: { processId: string, FolderData: OfficeFolder};
|
||||
anchorStatus: AnchorStatus;
|
||||
};
|
||||
|
||||
@ -30,7 +31,7 @@ export default function ClientView(props: IProps) {
|
||||
|
||||
const customers: ICustomer[] = useMemo(
|
||||
() => {
|
||||
return folder?.customers
|
||||
return folder?.FolderData?.customers
|
||||
?.map((customer: any) => ({
|
||||
id: customer.uid ?? '',
|
||||
...customer,
|
||||
@ -62,16 +63,17 @@ export default function ClientView(props: IProps) {
|
||||
|
||||
const handleClientDelete = useCallback(
|
||||
(customerUid: string) => {
|
||||
if (!folder.uid) return;
|
||||
if (!folder.processId) return;
|
||||
LoaderService.getInstance().show();
|
||||
FolderService.getFolderByUid(folder.uid).then((process: any) => {
|
||||
MessageBus.getInstance().getProcessData(folder.processId).then((process: { [key: string]: any }) => {
|
||||
if (process) {
|
||||
const folder: any = process.processData;
|
||||
const processId = folder.processId;
|
||||
const folderData = process[processId];
|
||||
|
||||
// FilterBy customerUid
|
||||
const customers = folder.customers.filter((uid: string) => uid !== customerUid);
|
||||
const customers = folderData.customers.filter((uid: string) => uid !== customerUid);
|
||||
|
||||
FolderService.updateFolder(process, { customers: customers }).then(() => {
|
||||
FolderService.updateFolder(processId, { customers: customers }).then(() => {
|
||||
LoaderService.getInstance().hide();
|
||||
window.location.reload();
|
||||
});
|
||||
@ -90,7 +92,7 @@ export default function ClientView(props: IProps) {
|
||||
<Link
|
||||
href={Module.getInstance()
|
||||
.get()
|
||||
.modules.pages.Folder.pages.AddClient.props.path.replace("[folderUid]", folder.uid ?? "")}>
|
||||
.modules.pages.Folder.pages.AddClient.props.path.replace("[folderUid]", folder.processId ?? "")}>
|
||||
<Button
|
||||
size={EButtonSize.MD}
|
||||
rightIcon={<UserPlusIcon />}
|
||||
@ -106,17 +108,17 @@ export default function ClientView(props: IProps) {
|
||||
<ClientBox
|
||||
customer={customer}
|
||||
anchorStatus={anchorStatus}
|
||||
folderUid={folder.uid}
|
||||
folderUid={folder.processId}
|
||||
onDelete={handleClientDelete}
|
||||
customerNote={folder.notes!.find((value: any) => value.customer?.uid === customer.uid) ?? null}
|
||||
customerNote={folder.FolderData?.notes?.find((value: any) => value.customer?.uid === customer.uid) ?? null}
|
||||
/>
|
||||
<div className={classes["button-container"]}>
|
||||
{anchorStatus === AnchorStatus.NOT_ANCHORED && (
|
||||
<Link
|
||||
href={Module.getInstance()
|
||||
.get()
|
||||
.modules.pages.Folder.pages.AskDocument.props.path.replace("[folderUid]", folder.uid ?? "")
|
||||
.replace("[customerUid]", customer.uid ?? "")}>
|
||||
.modules.pages.Folder.pages.AskDocument.props.path.replace("[folderUid]", folder.processId ?? "")
|
||||
.replace("[customerUid]", customer?.uid ?? "")}>
|
||||
<Button rightIcon={<DocumentIcon />} variant={EButtonVariant.PRIMARY} fullwidth>
|
||||
Demander un document
|
||||
</Button>
|
||||
@ -126,7 +128,7 @@ export default function ClientView(props: IProps) {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{customer.uid && folder.uid && <DocumentTables customerUid={customer.uid} folderUid={folder.uid} />}
|
||||
{customer?.uid && folder.processId && <DocumentTables customerUid={customer.uid} folderUid={folder.processId} />}
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user