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